> This one is the "unknown" for me. What happens if you
create
> Xzfs/images/vol1 (or your command below) without first
creating Xzfs/images?
Answer: it fails, unless you give the '-p' flag.
-p
Creates all the non-existing parent
datasets. Datasets created in this manner
are automatically mounted according to
the mountpoint property inherited from
their parent. Any property specified on
the command line using the -o option
is ignored. If the target filesystem
already exists, the operation completes
successfully.
Example: given an existing zfs pool called "zfs":
# zfs create zfs/foo/bar
cannot create 'zfs/foo/bar': parent does not exist
# zfs create -p zfs/foo/bar
# zfs list zfs/foo
NAME USED AVAIL REFER MOUNTPOINT
zfs/foo 192K 23.5G 96K /zfs/foo
# zfs list -r zfs/foo
NAME USED AVAIL REFER MOUNTPOINT
zfs/foo 192K 23.5G 96K /zfs/foo
zfs/foo/bar 96K 23.5G 96K /zfs/foo/bar
> If one digs into the virStorageBackendZFSBuildPool they will see libvirt > pool create/build processing would "zpool create $name $path[0...n]" > where $name is the "source.name" (in your case Xzfs/images) and > $path[0...n] would be the various paths (in your case tmp/Xzfs)
Just to be clear, creating a zpool ("zpool create") is different
to creating a zfs dataset ("zfs create").
By analogy to LVM: a zpool is like a volume group, and a zfs dataset/zvol is like a logical volume.
A zpool (or VG) is created from a collection of block devices -
or something which looks like a block device, e.g. a partition or
a loopback-mounted file. Those are $path[0...n] in the above, and
would be called "physical volumes" in LVM.
And actually, this almost works. It's just the pool refresh which fails, because it tries to treat "zfs/images" as if it were a zpool. Stripping off everything up to the first slash for "zpool get" would fix this.
Arguably this uncovers a couple of other related issues to do with error handling:
- to the end user, "virsh pool-refresh" silently appears to work (unless you dig down deep into logs), even though the underlying "zpool get" returns with an error- by this stage, pool-refresh has already destroyed all existing libvirt volumes which were previously in the pool
Regards,
Brian.