Bug 16316 - VM's started through libvirt can't write to disk image files unless the file is owned by root
Summary: VM's started through libvirt can't write to disk image files unless the file ...
Status: RESOLVED INVALID
Alias: None
Product: Virtualization
Classification: Unclassified
Component: kvm (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Avi Kivity
URL: http://kernel.ubuntu.com/~kernel-ppa/...
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-29 21:37 UTC by Jamin W. Collins
Modified: 2010-07-11 07:25 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.34-020634-generic
Subsystem:
Regression: No
Bisected commit-id:


Attachments
strace of unwritable VM startup (805.87 KB, application/x-gzip)
2010-07-08 19:18 UTC, Jamin W. Collins
Details

Description Jamin W. Collins 2010-06-29 21:37:19 UTC
With Ubuntu's 10.04 stock kernel (2.6.32-22-generic), libvirt functions normally.  However, after changing only the kernel version to 2.6.34-020634-generic from Ubuntu's mainline PPA (http://kernel.ubuntu.com/~kernel-ppa/mainline/) all VM's started through libvirt fail to write to their disk images unless the image is owned by root.  Rebooting to the older kernel resolves the issue, as does making root the owner of the disk images.

I would have set the severity on this to Low, as there is a workaround.  However, the workaround creates more of a problem as making root the owner of the disk images creates more problems for anything else needing access to the disk images.
Comment 1 Marcelo Tosatti 2010-06-30 15:39:38 UTC
Jamin,

Please file this report in Ubuntu's bug tracker, as it is not an upstream kernel issue.
Comment 2 Jamin W. Collins 2010-07-01 03:02:23 UTC
I'd already asked on the Ubuntu kernel team's IRC channel where the bug report should be filed.  They indicated that the mainline PPA kernels are only packaged versions of the kernel.org source and that the report should be filed here.

From http://irclogs.ubuntu.com/2010/06/29/%23ubuntu-kernel.txt:

[22:22] <jaminc> is there a place to report bugs found in kernels from the mainline-ppa?
[22:24] <jjohansen> jaminc: https://bugzilla.kernel.org/
[22:26] <jaminc> guess I'm a bit confused, are the mainline builds essentially just the kernel.org versions?
[22:27] <jjohansen> yes
[22:27] <jjohansen> just built into a deb for testing
Comment 3 Avi Kivity 2010-07-08 06:46:38 UTC
Please strace qemu and show how the writes are failing.

Note, this is unlikely to be a kvm problem.  kvm doesn't read or write files.
Comment 4 Jamin W. Collins 2010-07-08 13:22:49 UTC
The problem only happens when the VM is started via libvirt with a newer (mainline) kernel.  The log entry provided is simply "Write failed".  If I call kvm directly (without libvirt) and specify the same VM disk image, both newer (mainline) and older kernel versions work fine regardless of which user owns the disk image files.

I'm open to suggestions on how to get the trace you're after when starting the VM from libvirt.
Comment 5 Avi Kivity 2010-07-08 17:25:59 UTC
Move qemu somewhere else, replace by a script that straces it into some file.
Comment 6 Jamin W. Collins 2010-07-08 19:18:27 UTC
Created attachment 27047 [details]
strace of unwritable VM startup

I believe I've managed to get the trace you wanted.  Changing the ownership on the winxp.qcow2 file to root fixes the problem.
Comment 7 Avi Kivity 2010-07-09 08:43:30 UTC
open("/opt/vms/winxp.qcow2", O_RDWR|O_SYNC|O_CLOEXEC) = -1 EACCES (Permission denied)
open("/opt/vms/winxp.qcow2", O_RDONLY|O_SYNC|O_CLOEXEC) = 8

Obviously, qemu can't open the file due to permissions problems.

Please report this as a libvirt bug (but check first for user error).
Comment 8 Jamin W. Collins 2010-07-09 12:58:41 UTC
I'm more than a bit lost as to how this is a libvirt issue when it's caused and fixed by changing only the kernel version.  Additionally, the process attempting to access the file is running as root, I've verified this by gathering additional information in the tracing shell script replacement for qemu-system-x86_64 that gathered the provided trace.  

In short, the very same libvirt binaries and libraries work fine with Ubuntu's 2.6.32-23-generic kernel, but not with 2.6.34-020634-generic unless the disk images are owned by root.
Comment 9 Avi Kivity 2010-07-11 07:25:39 UTC
Please ask the libvirt people for help.  It may be a security module/libvirt interaction issue.

It is NOT a kvm issue.  Do NOT reopen this bug, at least not under the kvm component.  Thanks.

Note You need to log in before you can comment on or make changes to this bug.