<html><body><p><font size="2">Hi Martin, thanks for the explanation. Now I understand why libvirt doesn't revert the file permissions back to the original. I am running these VMs on an isolated test machine, so I'll disable dynamic file ownership and make sure libvirt has access to image files.</font><br><br><font size="2">Sorry about the message formatting. I modified settings on my client, hopefully it sends plaintext now. (I'll switch to personal email going forward, as the choice of email clients at work is limited.)</font><br><br><font size="2">-Joe </font><br><br><img width="16" height="16" src="cid:1__=0ABB0FA7DFC342F48f9e8a93df938690918c0AB@" border="0" alt="Inactive hide details for Martin Kletzander ---03/20/2020 04:01:43 PM---On Fri, Mar 20, 2020 at 03:38:36PM +0000, Joe Muro wrot"><font size="2" color="#424282">Martin Kletzander ---03/20/2020 04:01:43 PM---On Fri, Mar 20, 2020 at 03:38:36PM +0000, Joe Muro wrote: >Hi,</font><br><br><font size="2" color="#5F5F5F">From:        </font><font size="2">Martin Kletzander <mkletzan@redhat.com></font><br><font size="2" color="#5F5F5F">To:        </font><font size="2">Joe Muro <joemuro@us.ibm.com></font><br><font size="2" color="#5F5F5F">Cc:        </font><font size="2">libvirt-users@redhat.com</font><br><font size="2" color="#5F5F5F">Date:        </font><font size="2">03/20/2020 04:01 PM</font><br><font size="2" color="#5F5F5F">Subject:        </font><font size="2">[EXTERNAL] Re: libvirt dynamic file ownership</font><br><hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br><br><br><tt><font size="2">On Fri, Mar 20, 2020 at 03:38:36PM +0000, Joe Muro wrote:<br>>Hi,<br>> <br><br>Hi, could you please configure your client to send plaintext version as well?<br>We mainly prefer plaintext on this list ;-)<br><br>>I am trying to understand libvirt dynamic ownership behavior. I have a VM that<br>>uses a qcow2 image with the following permissions:<br>> <br>>$ ll t257kvxg-10-20-101-40.qcow2<br>>-rw-r--r-- 1 jmuro libvirt 2279079936 Mar 20 11:10 t257kvxg-10-20-101-40.qcow2<br>><br>>When I start the domain the permissions are changed:<br>><br>>$ virsh start t257kvxg-10-20-101-40<br>>Domain t257kvxg-10-20-101-40 started<br>>$ ll t257kvxg-10-20-101-40.qcow2<br>>-rw-r--r-- 1 libvirt-qemu libvirt 2279079936 Mar 20 11:18<br>>t257kvxg-10-20-101-40.qcow2<br>><br>>This is expected behavior based on the settings in /etc/libvirt/qemu.conf:<br>><br>>user = "libvirt-qemu"<br>>group = "libvirt"<br>># Whether libvirt should dynamically change file ownership<br>># to match the configured user/group above. Defaults to 1.<br>># Set to 0 to disable file ownership changes.<br>>#dynamic_ownership = 1<br>><br>>However, when I shutdown the domain, the file permissions revert to root.<br>><br>>$ ll t257kvxg-10-20-101-40.qcow2<br>>-rw-r--r-- 1 root root 2282749952 Mar 20 11:20 t257kvxg-10-20-101-40.qcow2<br>><br>>I expect libvirt to revert the file permissions back to the original.<br>>Otherwise, a regular user would lose ownership of the image file. FWIW: I am<br>>starting the domain as a non-root user under qemu:///system<br>><br><br>This has always been the case because the original information is lost (which is<br>actually not that easy to store properly, race-free, etc.) and the safest way to<br>make sure nobody accesses the disks (e.g. another domain running under<br>libvirt-qemu:libvirt, that would get exploited) is to just change it to<br>root:root.  Michal finally managed to make this work, in limited cases, but I<br>think it landed in 6.1.0, I'm not sure.<br><br>Anyway, there are some workarounds you can do:<br><br>  a) set relabel=no for the disk in the XML (and make sure the VM will be able to<br>     access it),<br><br>  b) set relabel=no for the whole domain (and make sure the VM will be able to<br>     access everything), or<br><br>  c) if worse comes to worse, just disable the whole dynamic ownership and handle<br>     it yourself<br><br>If possible, try upgrading libvirt and checking if that helps.<br><br>>I am running on Ubuntu 20.04 LTS (Focal Fossa) with the following libvirt<br>>level:<br>><br>>libvirt-clients/focal,now 6.0.0-0ubuntu5 s390x [installed]<br>>libvirt-daemon-driver-qemu/focal,now 6.0.0-0ubuntu5 s390x [installed,automatic]<br>>libvirt-daemon-driver-storage-rbd/focal,now 6.0.0-0ubuntu5 s390x<br>>[installed,automatic]<br>>libvirt-daemon-system-systemd/focal,now 6.0.0-0ubuntu5 s390x<br>>[installed,automatic]<br>>libvirt-daemon-system/focal,now 6.0.0-0ubuntu5 s390x [installed]<br>>libvirt-daemon/focal,now 6.0.0-0ubuntu5 s390x [installed]<br>>libvirt-glib-1.0-0/focal,now 2.0.0-2 s390x [installed,automatic]<br>>libvirt0/focal,now 6.0.0-0ubuntu5 s390x [installed,automatic]<br>>python3-libvirt/focal,now 6.0.0-0ubuntu3 s390x [installed]<br>><br>>Thanks<br>><br>>-Joe<br>><br>[attachment "signature.asc" deleted by Joe Muro/Poughkeepsie/IBM] </font></tt><br><br><BR>
</body></html>