Bug #2766
closedzoneadm install fails with root of zpool not mounted
100%
Description
zoneadm install fails with:
ERROR: the zonepath must be a ZFS dataset. The parent directory of the zonepath must be a ZFS dataset so that the zonepath ZFS dataset can be created properly.
Instructions to reproduce:
openindiana# zfs list -r tank NAME USED AVAIL REFER MOUNTPOINT tank 580K 3.91G 31K none tank/zones 31K 3.91G 31K /export/zones openindiana# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / ipkg shared - testzone configured /export/zones/testzone ipkg shared openindiana# zoneadm -z testzone install ERROR: the zonepath must be a ZFS dataset. The parent directory of the zonepath must be a ZFS dataset so that the zonepath ZFS dataset can be created properly. openindiana# zfs set mountpoint=/tank tank openindiana# zoneadm -z testzone install A ZFS file system has been created for this zone. Publisher: Using openindiana.org (http://pkg.openindiana.org/dev/ ). Image: Preparing at /export/zones/testzone/root. Refreshing catalog 1/1 openindiana.org^C
Checking the source I think it's this part that is wrong:
https://github.com/illumos/illumos-gate/blob/master/usr/src/cmd/zoneadm/zfs.c#L501
or around there somewhere.
Might be wrong though.
Updated by Lauri Tirkkonen over 8 years ago
Actually it's mount2zhandle that is failing (returning NULL)
- dtrace -n 'pid$target::mount2zhandle:return { ustack(); trace(arg1); }' -c 'zoneadm -z stat install'
dtrace: description 'pid$target::mount2zhandle:return ' matched 1 probe
CPU ID FUNCTION:NAME
3 77414 mount2zhandle:return
zoneadm`mount2zhandle+0x2e
zoneadm`create_zfs_zonepath+0x2b
zoneadm`install_func+0x484
zoneadm`parse_and_run+0x3c
zoneadm`main+0x3c1
zoneadm`_start+0x83
0
ERROR: the zonepath must be a ZFS dataset.
The parent directory of the zonepath must be a ZFS dataset so that the
zonepath ZFS dataset can be created properly.
dtrace: pid 28482 has exited
and thus path2name and create_zfs_zonepath fail. This comment is interesting: http://src.illumos.org/source/xref/illumos-gate/usr/src/cmd/zoneadm/zoneadm.c#3504
However the ipkg brand common.ksh (which admittedly is not part of gate) assumes that zoneadm creates the dataset successfully, which is why the error happens.
mount2zhandle just calls zfs_iter_root with http://src.illumos.org/source/xref/illumos-gate/usr/src/cmd/zoneadm/zfs.c#match_mountpoint - I'm not familiar with libzfs but perhaps this needs further investigation: I don't see why the pool's root would need to be mounted here.
Updated by Andy Fiddaman about 2 years ago
- Category set to cmd - userland programs
- Status changed from New to In Progress
- Assignee set to Andy Fiddaman
- Tags deleted (
needs-triage)
Updated by Andy Fiddaman about 2 years ago
zoneadm
creates a ZFS dataset for the zone based on the zone's zonepath
attribute.
Since a zonepath
is a pathname, it has to first work out if there is a suitable parent dataset and it does this by iterating datasets from the root.
However, if it finds an unmounted dataset, it stops iterating, which is wrong.
It doesn't have to be the root of the pool that is not mounted, any dataset above the zone root parent directory is enough.
bloody# zfs list -r rpool/xxx rpool/xxx 61.6M 43.2G 192K none rpool/xxx/zones 61.4M 43.2G 192K /z bloody# zadm show sparse zonepath "/z/sparse" bloody# zoneadm -z sparse install ERROR: the zonepath must be a ZFS dataset. The parent directory of the zonepath must be a ZFS dataset so that the zonepath ZFS dataset can be created properly.
With the proposed patch:
bloody# /tmp/zoneadm -z sparse install A ZFS file system has been created for this zone. Image: Preparing at /z/sparse/root.
With this patch I've installed a number of zones with different zonepath
attributes under mounted and non-mounted datasets. All now work successfully.
Updated by Electric Monk about 2 years ago
- Status changed from In Progress to Closed
- % Done changed from 0 to 100
git commit cd12acafe1f95ec0f3308baba673d2653990a014
commit cd12acafe1f95ec0f3308baba673d2653990a014 Author: Andy Fiddaman <omnios@citrus-it.co.uk> Date: 2021-03-04T13:43:36.000Z 2766 zoneadm install fails with root of zpool not mounted Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Robert French <robert@robertdfrench.me> Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>