Comment 13 for bug 1767997

Revision history for this message
Christian Ehrhardt  (paelzer) wrote : Re: virt-manager destroys all volumes in libvirt zfs pool

I was collecting a summary to report upstream, but then I wondered are there other scenarios where this should not be stripped to the base?
Or is there another common use case were the pool is created differently so it works?

I followed some other guides and ended up with a non-external created pool:

<pool type="zfs">
  <name>myzfspool</name>
  <source>
    <name>zpoolname</name>
    <device path="/tmp/Nzfs1"/>
    <device path="/tmp/Nzfs2"/>
  </source>
</pool>

$ virsh pool-create --build Nzfs.xml

Now I have a pool (with the odd name zpoolname)
$ sudo zpool list; sudo zfs list
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
Xzfs 80M 146K 79,9M - 1% 0% 1.00x ONLINE -
Yzfs 80M 117K 79,9M - 1% 0% 1.00x ONLINE -
zfs 80M 130K 79,9M - 1% 0% 1.00x ONLINE -
zfs2 80M 94,5K 79,9M - 1% 0% 1.00x ONLINE -
zpoolname 160M 646K 159M - 1% 0% 1.00x ONLINE -
NAME USED AVAIL REFER MOUNTPOINT
Xzfs 12,6M 27,4M 24K /Xzfs
Xzfs/images 12,5M 27,4M 24K /Xzfs/images
Xzfs/images/vol1 12,5M 39,9M 12K -
Yzfs 108K 39,9M 24K /Yzfs
Yzfs/images 24K 39,9M 24K /Yzfs/images
zfs 35,3M 4,67M 24K /zfs
zfs/vol1 12,5M 17,2M 12K -
zfs/vol2 22,8M 27,4M 12K -
zfs2 78K 39,9M 24K /zfs2
zpoolname 84K 79,9M 24K /zpoolname

From this libvirt can create volumes.

$ virsh vol-create-as --pool myzfspool --name vol1 --capacity 10M
Gets me in zfs tools:
...
zpoolname/vol1 12,5M 79,9M 12K -

And with that libvirt can refresh just fine:
$ virsh vol-list --pool myzfspool
 Name Path
 vol1 /dev/zvol/zpoolname/vol1
$ virsh pool-refresh myzfspool
Pool myzfspool refreshed
$ virsh vol-list --pool myzfspool
 Name Path
 vol1 /dev/zvol/zpoolname/vol1

So I wonder is this "just" a conflict between how libvirt expects pools to be set up (and as it does by itself) vs the manual set up one?

After I learned the above I tried this:
$ fallocate -l 100M /tmp/Mzfs
$ sudo zpool create Mzfs /tmp/Mzfs
$ virsh pool-define-as --name zfs --source-name Mzfs --type zfs
$ virsh pool-start zfs
$ virsh vol-create-as --pool zfs --name vol1 --capacity 10M
$ virsh vol-list --pool zfs
 Name Path
 vol1 /dev/zvol/Mzfs/vol1
$ virsh pool-refresh zfs
Pool zfs refreshed
$ virsh vol-list --pool zfs
 Name Path
 vol1 /dev/zvol/Mzfs/vol1

This confirms that if you skip the "zfs create zfs/images" step and define the libvirt pool from the zpool directly then all things seem to work.

I'd appreciate a report upstream still, but I think the issue is no more that severe atm.