Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1229592

Summary: change-media with option update cannot eject cdrom as it always requires new source when device has source
Product: Red Hat Enterprise Linux 7 Reporter: Yang Yang <yanyang>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: dyuan, mzhan, pkrempa, pzhang, rbalakri, shyu, xuzhang
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.17-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:40:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Yang Yang 2015-06-09 08:10:40 UTC
Description of problem:
change-media with option update cannot eject cdrom as it always requires new source when device has source

Version-Release number of selected component (if applicable):
libvirt-1.2.16-1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.prepare a running guest with following xml
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/vm1.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <boot order='1'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw' cache='none'/>
      <source file='/var/lib/libvirt/images/bbb.iso'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

2.eject cdrom by issuing following cli
# virsh change-media simple hda --update
error: New disk media source was not specified

3.

Actual results:
Cannot eject cdrom by change-media --update

Expected results:
cdrom should be ejected

Additional info:
regression

Comment 2 Peter Krempa 2015-06-09 12:17:05 UTC
Fixed upstream:

commit 23e913671d20a9b6cc233f72cc8ac2fe996443a1
Author: Peter Krempa <pkrempa>
Date:   Tue Jun 9 13:27:42 2015 +0200

    virsh: change-media: Fix behavior with --update without a source
    
    Docs state that it should behave like eject. Currently the code does not
    do that. This is a regression since f4b5f53027da4fed2250628e11bac4019.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1229592

v1.2.16-112-g23e9136

Comment 5 Pei Zhang 2015-08-04 09:39:21 UTC
I can reproduce it . verify it like following 

verify version:
libvirt-1.2.17-3.el7.x86_64

steps:

1>change-media via --update for a running domian 
1.define and start a guest like following 
# virsh dumpxml r7-vm1 | grep disk -A 9
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/a.iso' startupPolicy='optional'/>
      <backingStore/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
2.Using change-media with --update to eject the cdrom 

# virsh change-media r7-vm1 hdc --update
Successfully ejected media.

3.check domain xml, the media is ejected.
# virsh dumpxml r7-vm1 | grep disk -A 9
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source startupPolicy='optional'/>
      <backingStore/>
      <target dev='hdc' bus='ide' tray='open'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

2>change-media via --update with --config

1.define and start a guest like following 
# virsh dumpxml r7-vm1 --inactive | grep disk -A 9
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/b.iso' startupPolicy='optional'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

# virsh change-media r7-vm1 hdc --update --config
Successfully ejected media.

2. reboot guest to check 

# virsh destroy r7-vm1;virsh start r7-vm1
Domain r7-vm1 destroyed

Domain r7-vm1 started

3.dumpxml to check, the media was ejected.

# virsh dumpxml r7-vm1 | grep disk -A 9
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source startupPolicy='optional'/>
      <backingStore/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
3>change-media via --update with --live --config; pass 
# virsh change-media r7-vm1 hdc --update --live --config
Successfully ejected media.

4>change-media via --update with --current ; pass 
# virsh change-media r7-vm1 hdc --update --current
Successfully ejected media.

5>change-media with source , the media can be changed 

3. change-media via --update with a source .the media can be changed .
# virsh dumpxml r7-vm1 | grep disk -A 9
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/b.iso' startupPolicy='optional'/>
      <backingStore/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

# virsh change-media r7-vm1 hdc --update /var/lib/libvirt/images/a.iso 
Successfully updated media.

# virsh dumpxml r7-vm1 | grep disk -A 9
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/a.iso' startupPolicy='optional'/>
      <backingStore/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

As above, move this bug to verified.

Comment 7 errata-xmlrpc 2015-11-19 06:40:26 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.

https://rhn.redhat.com/errata/RHBA-2015-2202.html