<div dir="ltr"><div>Hi,</div><div>Currently virt-aa-helper has no support for pools, so if you use a volume from a pool like:</div><div>    <disk type='volume' device='disk'></div><div>      <driver name='qemu' type='raw' cache='none'/></div><div>      <source pool='internal' volume='foo'/></div><div>      <target dev='vdc' bus='virtio'/></div><div>    </disk></div><div>Then there is no matching apparmor rule generated to allow qemu to access the related devices.</div><div><br></div><div>That goes along a simple pool like:</div><div># create a zpool to use</div><div> $ for i in $(seq 1 3); do dd if=/dev/zero of=/tmp/fdisk${i} bs=1M count=1024; done</div><div> $ sudo zpool create internal /tmp/fdisk*</div><div># make pool in libvirt and guest disk foo</div><div> $ virsh pool-define-as internal zfs</div><div> $ virsh pool-start internal</div><div> $ virsh vol-create-as internal foo 2G</div><div><br></div><div>When libvirt actually builds up the command for qemu what to use based on the pools information it uses the function "virStorageTranslateDiskSourcePool" to learn about the actual path of the disk.</div><div><br></div><div>Usually virt-aa-helper tries to stay close to what libvirt does to spawn the guest, because only then the generated rules match what will be used. But in this case this isn't as easy.</div><div>The lookup by "virStorageTranslateDiskSourcePool" is done on a virConnectPtr via:</div><div>  conn->storageDriver->storagePoolLookupByName</div><div>That is fine from the code that sets up the guest, but virt-aa-helper has no virConnectPtr context.</div><div><br></div><div>Surely virt-aa-helper could connect via e.g. "virConnectOpenReadOnly" but the lifecycle of virt-aa-helper doesn't match that. It is invoked as external program by libvirtd local to the execution of the guest e.g. the qemu. So adding a connection via a socket makes not much sense. Also in this environment the connect URI is not set and also not passed to virt-aa-helper so we can't be sure we have "the same".</div><div><br></div><div>I found that while trying to implement that, but I don't like the preliminary change [1] for the reasons I identified and outlined above. It initializes the storage drivers correctly, but then fails to look up [2] and since I doubt it is the right way for the environment and lifecycle of virt-aa-helper I don't want to go down that way before having a discussion about it.</div><div><br></div><div>Therefore I wanted to ask for some guidance:</div><div>1. is there a reasonable way to be able to call virStorageTranslateDiskSourcePool from virt-aa-helper</div><div>2. maybe I overlook a path to get to a valid virConnectPtr from the virDomainDefPtr or any other in [3] that virt-aa-helper aready has.</div><div>3. what would be an alternative to be able to translate pool/volume info to real paths from virt-aa-helper</div><div><br></div><div><br></div><div>[1]: <a href="http://paste.ubuntu.com/25570670/">http://paste.ubuntu.com/25570670/</a></div><div>[2]: <a href="http://paste.ubuntu.com/25570673/">http://paste.ubuntu.com/25570673/</a></div>[3]: <a href="http://paste.ubuntu.com/25570720/">http://paste.ubuntu.com/25570720/</a><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><span style="color:rgb(136,136,136);font-size:12.8px">Christian Ehrhardt</span><div style="color:rgb(136,136,136);font-size:12.8px">Software Engineer, Ubuntu Server</div><div style="color:rgb(136,136,136);font-size:12.8px">Canonical Ltd</div></div></div></div></div>
</div>