Bug 510630 - -drive arg has no way to request a read only disk
Summary: -drive arg has no way to request a read only disk
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: kvm
Version: 5.4
Hardware: All
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Tim Burke
QA Contact: Lawrence Lim
URL:
Whiteboard:
Depends On:
Blocks: 510612 537164 Rhel5KvmTier2
TreeView+ depends on / blocked
 
Reported: 2009-07-09 22:17 UTC by Daniel Berrangé
Modified: 2014-03-26 00:58 UTC (History)
21 users (show)

Fixed In Version: kvm-83-171.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 537164 (view as bug list)
Environment:
Last Closed: 2011-01-13 23:11:11 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:0028 0 normal SHIPPED_LIVE Low: kvm security and bug fix update 2011-01-13 11:03:39 UTC

Comment 1 Daniel Berrangé 2009-07-09 22:20:55 UTC
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.

Comment 2 Dor Laor 2009-07-14 14:53:11 UTC
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.

Comment 5 Dor Laor 2010-02-17 13:16:02 UTC
Moving back to assigned state since it found upstream resistance.
Postponed to 5.6

Comment 10 Mike Cao 2010-04-22 03:09:55 UTC
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.

Comment 11 Dor Laor 2010-04-22 06:36:40 UTC
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.

Comment 12 Mike Cao 2010-04-22 07:42:44 UTC
(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

Comment 13 Naphtali Sprei 2010-04-22 07:57:40 UTC
The read-only attribute is visible to the guest (if it looks for it).

Comment 14 Dor Laor 2010-04-22 08:17:02 UTC
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.

Comment 15 Miya Chen 2010-04-22 09:38:16 UTC
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

Comment 16 Miya Chen 2010-04-22 10:40:30 UTC
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

Comment 17 Naphtali Sprei 2010-04-25 08:29:12 UTC
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.

Comment 18 Miya Chen 2010-04-27 02:33:37 UTC
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

Comment 21 Mike Cao 2010-11-03 09:29:17 UTC
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.

Comment 23 yusonghai 2010-12-06 06:51:11 UTC
(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.

Comment 24 Mike Cao 2010-12-06 06:57:03 UTC
(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?

Comment 26 errata-xmlrpc 2011-01-13 23:11:11 UTC
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


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