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 658147 - [vdsm] [libvirt] RFE - libvirt should allow user to ask for force eject
Summary: [vdsm] [libvirt] RFE - libvirt should allow user to ask for force eject
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.1
Hardware: All
OS: Linux
urgent
high
Target Milestone: rc
: ---
Assignee: Daniel Veillard
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 626305
Blocks: 602685
TreeView+ depends on / blocked
 
Reported: 2010-11-29 14:17 UTC by RHEL Program Management
Modified: 2013-01-11 03:37 UTC (History)
16 users (show)

Fixed In Version: libvirt-0.8.1-27.el6_0.1
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-01-28 16:15:58 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description RHEL Program Management 2010-11-29 14:17:51 UTC
This bug has been copied from bug #626305 and has been proposed
to be backported to 6.0 z-stream (EUS).

Comment 3 Jiri Denemark 2010-11-29 23:52:05 UTC
Patches built into libvirt-0.8.1-27.el6_0.1

Comment 4 zhanghaiyan 2010-12-21 09:31:12 UTC
I tested in plain libvirt without vdsm as we don't have vdsm env. Test result shows virsh command doesn't provide such option and the error still shows up. I wonder do you design expose such flag in virsh command or not ? Thanks.

- libvirt-0.8.1-27.el6_0.2.x86_64
- kernel-2.6.32-71.13.1.el6.x86_64
- qemu-kvm-0.12.1.2-2.113.el6_0.5.x86_64

1. Download an iso file
2. Add the following xml in guest xml config file and then start guest
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/RHEL6.0-20100922.1-Server-x86_64-DVD1.iso'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>
3. In guest, #mount /dev/sr0 /mnt
4. Prepare another cdrom-update.xml as below
    <disk type='file' device='cdrom'>
          <driver name='qemu' type='raw'/>
          <target dev='hdc' bus='ide'/>
    </disk>
5. Force eject the cdrom in mouting failed
# virsh update-device rhel6-1 cdrom-update.xml 
error: Failed to update device from cdrom-update.xml
error: internal error unable to execute QEMU command 'eject': Device 'drive-ide0-1-0' is locked

Comment 5 Dan Kenigsberg 2010-12-21 16:30:59 UTC
The new flag name is not the same in RHEL 6.0.z and RHEL 6.1. I do not care which version gives in, but the difference is too ugly to keep.

# rpm -q libvirt ; pydoc libvirt |grep FORCE
libvirt-0.8.1-28.el6.x86_64         VIR_DOMAIN_DEVICE_EJECT_FORCE = 4
libvirt-0.8.1-27.el6_0.2.x86_64     VIR_DOMAIN_DEVICE_MODIFY_FORCE = 4

Comment 6 Jiri Denemark 2010-12-21 17:40:49 UTC
The z-stream package is correct.

Comment 8 Jiri Denemark 2010-12-22 06:44:40 UTC
Hmm, right, the patch doesn't contain virsh support for this flag. It's not required for vdsm but it would be nice to have. To verify this, you either need vdsm environment with support for this or call the API from a python script.

Comment 9 Dan Kenigsberg 2010-12-22 07:07:25 UTC
zhanghaiyan, you can use the following python script to force-eject a mounted cdrom:

import libvirt

empty = """<disk device='cdrom'>
      <target dev='hdc' bus='ide'/>
      <alias name='ide0-1-0'/>
</disk>
"""
c = libvirt.open('qemu:///system')
d = c.lookupByName('your domain name')
d.updateDeviceFlags(empty, libvirt.VIR_DOMAIN_DEVICE_MODIFY_FORCE)

Comment 10 zhanghaiyan 2010-12-23 03:04:11 UTC
Thanks for Jiri and Dan's guide.
I verified this bug PASS calling the API from python script.
- libvirt-0.8.1-27.el6_0.2.x86_64
- kernel-2.6.32-71.13.1.el6.x86_64
- qemu-kvm-0.12.1.2-2.113.el6_0.5.x86_64

Test steps:
1. Download an iso file
2. Add the following xml in guest xml config file and then start guest
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source
file='/var/lib/libvirt/images/RHEL6.0-20100922.1-Server-x86_64-DVD1.iso'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>
3. In guest, #mount /dev/sr0 /mnt
4. # python
Python 2.6.5 (r265:79063, Jul 14 2010, 11:36:05) 
[GCC 4.4.4 20100630 (Red Hat 4.4.4-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> empty="""<disk device='cdrom'>
... <target dev='hdc' bus='ide'/>
... <alias name='ide0-1-0'/>
... </disk>
... """
>>> c = libvirt.open('qemu:///system')
>>> d = c.lookupByName('rhel6-11')
>>> d.updateDeviceFlags(empty,libvirt.VIR_DOMAIN_DEVICE_MODIFY_FORCE)
0
5. cdrom device is replaced with empty
# virsh dumpxml rhel6-11
.....
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' unit='0'/>
    </disk>
.....


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