RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1105428 - readonly=on has no effect for drive with no media
Summary: readonly=on has no effect for drive with no media
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm
Version: 6.6
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-06 06:19 UTC by Xuesong Zhang
Modified: 2014-10-14 07:01 UTC (History)
16 users (show)

Fixed In Version: qemu-kvm-0.12.1.2-2.429.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-10-14 07:01:29 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1025235 0 medium CLOSED the readonly permission of floppy will be changed after eject/change 2021-02-22 00:41:40 UTC
Red Hat Product Errata RHBA-2014:1490 0 normal SHIPPED_LIVE qemu-kvm bug fix and enhancement update 2014-10-14 01:28:27 UTC

Internal Links: 1025235

Description Xuesong Zhang 2014-06-06 06:19:27 UTC
Description of problem:
Start one guest with empty cdrom, after the guest finish booting, insert one cdrom will meet error.

Version-Release number of selected component (if applicable):
libvirt-0.10.2-37.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.427.el6.x86_64
kernel-2.6.32-474.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. start one guest with empty cdrom
# virsh dumpxml rhel6.6
......
   <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
......

2. prepare the following cdrom xml, note only add the source file section, other content are same with the one in guest dumpxml.
# cat cdrom.xml 
<disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.iso'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>

3. insert the iso to the empty cdrom.
# virsh update-device rhel6.6 cdrom.xml 
error: Failed to update device from cdrom.xml
error: internal error unable to execute QEMU command 'change': Could not open '/var/lib/libvirt/images/temp2.iso': Permission denied

# virsh attach-device rhel6.6 cdrom.xml 
error: Failed to attach device from cdrom.xml
error: internal error unable to execute QEMU command 'change': Could not open '/var/lib/libvirt/images/temp2.iso': Permission denied

4. prepare another xml, the source file is one physical cdrom.
# cat cdrom1.xml 
<disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/dev/sr1'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>

5. insert the physical cdrom to the guest
# virsh attach-device rhel6.6 cdrom1.xml 
error: Failed to attach device from cdrom1.xml
error: internal error unable to execute QEMU command 'change': Could not open '/dev/sr1': Operation not permitted

# virsh update-device rhel6.6 cdrom.xml 
error: Failed to update device from cdrom.xml
error: internal error unable to execute QEMU command 'change': Could not open '/dev/sr1': Operation not permitted


Actual results:
As step 3, while insert the virtual iso to the guest empty cdrom, will meet error whether via "attach-device" or "update-device" command.
As step 5, while insert the physical CD to the guest empty cdrom, will meet another error message.
Expected results:

Additional info:
1. Do not meet this issue in rhel6.5 release version and latest rhel6.5.z version.
2. If download the libvirt version to the libvirt rhel6.5 release version, then will also meet this issue.
3. If download the qemu-kvm version to the qemu-kvm rhel6.5 release version, will NOT meet this issue.
   But contact with the qemu guy, they will not meet this issue while using pure qemu command.
4. If starting the guest with one cdrom which contains the content, then update the cdrom content to others, will NOT meet this error message.
5. If disable the selinux, will NOT meet this error message.

Comment 1 Jiri Denemark 2014-06-06 10:54:04 UTC
Looks like a labeling issue, however, it does not seem to be a regression, since I can reproduce it even with libvirt-0.10.2-29.el6.x86_64 (6.5):

virsh change-media rhel6 hdc /var/lib/libvirt/images/cdrom.iso 
error: Failed to complete action update on media
error: internal error unable to execute QEMU command 'change': Could not open '/var/lib/libvirt/images/cdrom.iso': Permission denied

I can confirm that it works in permissive mode, although I did not see anything in audit.log.

Comment 2 Ján Tomko 2014-06-06 12:59:14 UTC
Fails with:
qemu-kvm-rhev-0.12.1.2-2.420.el6
Works with:
qemu-kvm-rhev-0.12.1.2-2.419.el6

Comment 3 Ján Tomko 2014-06-06 13:53:39 UTC
With qemu-kvm version 420, the device is not read only after changing the media:
# /usr/libexec/qemu-kvm -M pc -enable-kvm -m 1024 -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -monitor stdio
VNC server running on `::1:5900'
QEMU 0.12.1 monitor - type 'help' for more information
(qemu) info block
drive-ide0-1-0: removable=1 locked=0 tray-open=0 io-status=ok [not inserted]
floppy0: removable=1 locked=0 tray-open=0 [not inserted]
sd0: removable=1 locked=0 tray-open=0 [not inserted]
(qemu) change drive-ide0-1-0 /var/lib/libvirt/images/f14-kde.iso raw
(qemu) info block
drive-ide0-1-0: removable=1 locked=0 tray-open=0 io-status=ok file=/var/lib/libvirt/images/f14-kde.iso ro=0 drv=raw encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0
floppy0: removable=1 locked=0 tray-open=0 [not inserted]
sd0: removable=1 locked=0 tray-open=0 [not inserted]

With version 419 and the current upstream, the device stays read-only even if it originally had no media.

Possible fix in upstream git:
commit 80dd1aae3657a902d262f5d20a7a3c655b23705e
Author:     Kevin Shanahan <kmshanah>
AuthorDate: 2012-09-21 08:50:22 +0930
Commit:     Kevin Wolf <kwolf>
CommitDate: 2012-09-24 15:15:11 +0200

    blockdev: preserve readonly and snapshot states across media changes
    
    If readonly=on is given at device creation time, the ->readonly flag
    needs to be set in the block driver state for this device so that
    readonly-ness is preserved across media changes (qmp change command).
    Similarly, to preserve the snapshot property requires ->open_flags to
    be correct.
    
    Signed-off-by: Kevin Shanahan <kmshanah>
    Signed-off-by: Kevin Wolf <kwolf>

Comment 6 Miroslav Rezanina 2014-07-04 07:10:25 UTC
Fix included in qemu-kvm-0.12.1.2-2.429.el6

Comment 8 Shaolong Hu 2014-07-21 05:43:36 UTC
Reproduced on qemu-kvm-0.12.1.2-2.429.el6.x86_64:

[root@localhost ~]# /usr/libexec/qemu-kvm -M pc -enable-kvm -m 1024 -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -monitor stdio
VNC server running on `::1:5900'
QEMU 0.12.1 monitor - type 'help' for more information
(qemu) info block
drive-ide0-1-0: removable=1 locked=0 tray-open=0 io-status=ok [not inserted]
floppy0: removable=1 locked=0 tray-open=0 [not inserted]
sd0: removable=1 locked=0 tray-open=0 [not inserted]
(qemu) change drive-ide0-1-0 sn1
(qemu) info block
drive-ide0-1-0: removable=1 locked=0 tray-open=0 io-status=ok file=sn1 ro=0 drv=qcow2 encrypted=0
floppy0: removable=1 locked=0 tray-open=0 [not inserted]
sd0: removable=1 locked=0 tray-open=0 [not inserted]



Verified on qemu-kvm-0.12.1.2-2.429.el6.x86_64:

[root@localhost ~]# /usr/libexec/qemu-kvm -M pc -enable-kvm -m 1024 -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -monitor stdio
VNC server running on `::1:5900'
QEMU 0.12.1 monitor - type 'help' for more information
(qemu) info block
drive-ide0-1-0: removable=1 locked=0 tray-open=0 io-status=ok [not inserted]
floppy0: removable=1 locked=0 tray-open=0 [not inserted]
sd0: removable=1 locked=0 tray-open=0 [not inserted]
(qemu) change drive-ide0-1-0 sn1
(qemu) info block
drive-ide0-1-0: removable=1 locked=0 tray-open=0 io-status=ok file=sn1 ro=1 drv=qcow2 encrypted=0
floppy0: removable=1 locked=0 tray-open=0 [not inserted]
sd0: removable=1 locked=0 tray-open=0 [not inserted]

Comment 9 Shaolong Hu 2014-07-21 05:49:24 UTC
Reproduce version should be 427.

Comment 10 errata-xmlrpc 2014-10-14 07:01:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1490.html


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