Currently KVM/QEMU will designate a disk read only, if it fails to open the underlying disk device/file with write permissions. This may be a result of the filesystem being read only, or the file/device being readonly. What is needed though is some mechanism is request that the virtual disk is read only even if the underlying file/device is writable. This would allow libvirt to honour the <readonly/> flag for disks, resulting in safe sharing of disks between guests without having to resort to cluster filesystems.
We'll address it on the next release. We also shouldn't allow the opposite case where there are no write permissions and an image is open with write mode. It should quit qemu.
Moving back to assigned state since it found upstream resistance. Postponed to 5.6
bcao---->nsprei, can you please to see the following problem? the read-only disk cannot be open in windows guest os. #uname -r 2.6.18-194.el5 #rpm -q kvm kvm-83-171.el5 guest :window 7 ultimate 64bit windows 2008 r2 64bit. steps: 1. create a new image 2. start win2008r2 guest with the new created image in non_readonly mode #/usr/libexec/qemu-kvm -rtc-td-hack -no-hpet -usbdevice tablet -drive file=/root/win,if=virtio,format=qcow2,boot=on -drive file=/root/mike.qcow2,if=virtio,format=qcow2 -net nic,macaddr=20:20:20:34:23:12,model=virtio,vlan=0 -net tap,script=/etc/qemu-ifup,vlan=0 -uuid `uuidgen` -vnc :10 -cpu qemu64,+sse2 -smp 2 -m 2G -monitor stdio 3. Formatted the new added disk and then create a new file in it. 4. shutdown the guest. 5. start the vm with the new image in readonly mode #/usr/libexec/qemu-kvm -rtc-td-hack -no-hpet -usbdevice tablet -drive file=/root/win,if=virtio,format=qcow2,boot=on -drive file=/root/mike.qcow2,if=virtio,readonly=on,format=qcow2 -net nic,macaddr=20:20:20:34:23:12,model=virtio,vlan=0 -net tap,script=/etc/qemu-ifup,vlan=0 -uuid `uuidgen` -vnc :10 -cpu qemu64,+sse2 -smp 2 -m 2G -monitor stdio actual results: windows starting Process is very slow,it will take about 10 minutes. It shows "the disk is not accessible" after double-clicking the read-only disk icon. Guests always in "not responding" state when do some operations in it.
Pls try with full cmdline of werror=stop. Naphtali, is the readonly flag visible to the guest? I'm sure we do not have this in windows drivers.
(In reply to comment #11) > Pls try with full cmdline of werror=stop. > Naphtali, is the readonly flag visible to the guest? > I'm sure we do not have this in windows drivers. Start the Windows Guest with the following cmd: # /usr/libexec/qemu-kvm -rtc-td-hack -no-hpet -usbdevice tablet -drive file=/root/win2008r2-64-virtio.qcow2,if=virtio,format=qcow2,werror=stop,boot=on -drive file=/root/mike.qcow2,if=virtio,format=qcow2,readonly=on,werror=stop -net nic,macaddr=10:10:20:34:23:12,model=virtio,vlan=0 -net tap,script=/etc/qemu-ifup,vlan=0 -uuid `uuidgen` -vnc :20 -cpu qemu64,+sse2 -smp 2 -m 2G -monitor stdio -drive file=/dev/cdrom,if=ide,media=cdrom,index=3 actual results: Guest paused during booting up. (qemu) info status VM status: paused (qemu) info stop-reason VM is stopped due to disk write error: virtio1: Input/output error
The read-only attribute is visible to the guest (if it looks for it).
Windows guests does not have this capability while Linux guests do have it. Please re-test w/ linux guests. I opened 'Bug 584689 - Make the virtio-blk aware of read only disks' for windows.
Test this with linux guest # uname -r 2.6.18-194.el5 # rpm -q kvm kvm-83-171.el5 steps: 1. start linux guest with on read-only disk: # /usr/libexec/qemu-kvm -no-hpet -usbdevice tablet -rtc-td-hack -drive file=rhel5.5-64-virtio.qcow2,media=disk,if=virtio,boot=on,cache=off,index=0,werror=stop -smp 1 -m 1G -cpu qemu64,+sse2 -vnc :31 -monitor stdio -net nic,vlan=0,macaddr=20:20:28:90:68:80,model=e1000 -net tap,vlan=0,script=/etc/qemu-ifup -boot c -drive file=test_read.qcow2,if=virtio,media=disk,werror=stop,readonly=on actual result: 1. in monitor: (qemu) info block virtio1: type=hd removable=0 file=test_read.qcow2 ro=1 drv=qcow2 2. in guest: # dd if=/dev/zero of=/dev/vdb dd: writing to `/dev/vdb': Operation not permitted 1+0 records in 0+0 records out 0 bytes (0 B) copied, 0.002813 seconds, 0.0 kB/s
when change cd in qemu monitor, monitor always use read-write, so reopen this bug. start guest: # /usr/libexec/qemu-kvm -no-hpet -usbdevice tablet -rtc-td-hack -drive file=rhel5.5-64-virtio.qcow2,media=disk,if=virtio,boot=on,cache=off,index=0,werror=stop -smp 1 -m 1G -cpu qemu64,+sse2 -vnc :31 -monitor stdio -net nic,vlan=0,macaddr=20:20:28:90:68:80,model=e1000 -net tap,vlan=0,script=/etc/qemu-ifup -boot c -drive file=test_read.qcow2,if=virtio,media=disk,werror=stop,readonly=on (qemu) eject ide1-cd0 (qemu) change ide1-cd0 gpxe.iso (qemu) info block ide1-cd0: type=cdrom removable=1 locked=0 file=gpxe.iso ro=0 drv=raw
Re-visiting the recommendation for re-opening the bug, I think that the bug has to move on the path to QA and on, and another bug should be opened for the issue with the implementation. The required functionality, the bug reporter asked for, exists now, while the issue with the implementation doesn't affects, directly, the reporter needs, as stated in the bug subject.
Based on comment#15 and comment#17, the required functionality of the original bug exists, so move this bug from assigned to modified, new issue with the implementation in comment#16 has been reported as new bug: https://bugzilla.redhat.com/show_bug.cgi?id=586173
Verified on # uname -r 2.6.18-229.el5 # rpm -q kvm kvm-83-207.el5 Test both windows guest and linux guest with a extra image with -drive readonly=on . the disk will be write-protected as expected. Above all ,this issue has already been fixed.
(In reply to comment #21) Verified on # uname -r 2.6.18-233.el5 #rpm -q kvm kvm-83-213.el5 Test success with Linux guest. But for Windows2008 guest, I met the same situation as comment #10 : Windows starting process is very slow and the readonly disk cannot get opened when I double click the disk icon.
(In reply to comment #23) > (In reply to comment #21) > > Verified on > # uname -r > 2.6.18-233.el5 > #rpm -q kvm > kvm-83-213.el5 > > Test success with Linux guest. > > But for Windows2008 guest, I met the same situation as comment #10 : Windows > starting process is very slow and the readonly disk cannot get opened when I > double click the disk icon. Hi May I know Which version of windows virtio-driver are you using for testing?
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHSA-2011-0028.html