<div dir="ltr">Hi,<br>by discussing on bug [1] we found an issue in the ZFS storage backend.<br>When one defines a zfs pool through XML (virsh pool-create --build) a top level ZFS pool will be created and works fine. The virsh pool-define-as counterpart to this is:<br><br>$ fallocate -l 100M /tmp/Mzfs<br>$ sudo zpool create Mzfs /tmp/Mzfs<br>$ virsh pool-define-as --name zfs --source-name Mzfs --type zfs<br>$ virsh pool-start zfs<br>$ virsh vol-create-as --pool zfs --name vol1 --capacity 10M<br>$ virsh vol-list --pool zfs<br> vol1 /dev/zvol/Mzfs/vol1<br>$ virsh pool-refresh zfs<br> Pool zfs refreshed<br>$ virsh vol-list --pool zfs<br> vol1 /dev/zvol/Mzfs/vol1<br><br>Ok, all fine so far.<br>But if one wants to use a zfs-FS as sub-pool things work a while but fail as soon as pool info is refreshed.<br><br>$ fallocate -l 100M /tmp/Xzfs<br>$ sudo zpool create Xzfs /tmp/Xzfs<br>$ sudo zfs create Xzfs/images<br>$ virsh pool-define-as --name Xzfs --source-name Xzfs/images --type zfs<br>I ended with the pool not being started (expected after pool-define-as), but then<br>$ virsh pool-start Xzfs<br>$ virsh vol-create-as --pool Xzfs --name vol1 --capacity 10M<br>$ virsh vol-list --pool Xzfs<br>  vol1 /dev/zvol/Xzfs/images/vol1<br>$ virsh pool-refresh zfs<br>   Pool zfs refreshed<br><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">$ virsh vol-list --pool Xzfs</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">  # no output anymore</span><br style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><br><div><span style="color:rgb(51,51,51);font-family:monospace;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">We happened to find this in the libvirt log:</span><br style="color:rgb(51,51,51);font-family:monospace;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(51,51,51);font-family:monospace;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"> error : virCommandWait:2601 : internal error: Child process (/sbin/zpool get -Hp health,</span><span style="color:rgb(51,51,51);font-family:monospace;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">size,free,</span><span style="color:rgb(51,51,51);font-family:monospace;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">allocated Xzfs/images) unexpected exit status 1: cannot open 'Xzfs/images': invalid character '/' in pool name</span><br><div><br></div><div>So it seems the data refresh would need to become aware of filesytems and strip this to the basename before doing the call.</div><div>This comes from <span style="color:rgb(51,51,51);font-family:monospace;font-size:12px">src/storage/</span><span style="color:rgb(51,51,51);font-family:monospace;font-size:12px">storage_</span><span style="color:rgb(51,51,51);font-family:monospace;font-size:12px">backe<wbr>nd_</span><span style="color:rgb(51,51,51);font-family:monospace;font-size:12px">zfs.c</span><p style="margin:0px 0px 0.8em;padding:0px;width:auto;max-width:45em;color:rgb(51,51,51);font-family:monospace;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">    cmd = virCommandNewArgList(ZPOOL,<br>                              <wbr> "get", "-Hp",<br>                              <wbr> "health,size,free,allocated",<br>                              <wbr> def-><a href="http://source.name">source.name</a>,<br>                              <wbr> NULL);</p></div><div># fails<br></div><div>zfs list -Hp -t volume -r -o name,volsize,refreservation Xzfs/images<br></div><div># would work</div><div>zfs list -Hp -t volume -r -o name,volsize,refreservation Xzfs<br></div><div><br></div><div>But there might be more to it than what I see, either more changes needed to fully work with subpools or intentionally not working with them.</div><div>For the latter we should still consider improving the error handling, like refusing right away with a reasonable message on "virsh pool-define-as".</div><div><br></div><div>I wondered if one with more experience in that area of libvirt would be willing to pick this up or has an opinion why it would not need to be changed that I might be missing?<br><br>[1]: <a href="https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1767997" target="_blank">https://bugs.launchpad.net/<wbr>ubuntu/+source/libvirt/+bug/<wbr>1767997</a><br><br>--<br>Christian Ehrhardt<br>Software Engineer, Ubuntu Server<br>Canonical Ltd<br><div>
</div></div></div></div>