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 921398

Summary: virsh update-device with option "--config" should not be affect before boot
Product: Red Hat Enterprise Linux 7 Reporter: Xuesong Zhang <xuzhang>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: acathrow, cwei, dyuan, gsun, jmiao, lsu, mzhan, pkrempa
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.0.5-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 921407 1049529 (view as bug list) Environment:
Last Closed: 2014-06-13 12:32:01 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:
Bug Depends On:    
Bug Blocks: 921407, 1049529, 1125194    

Description Xuesong Zhang 2013-03-14 06:41:29 UTC
Description of problem:
virsh update-device with option "--config" should not be affect before next boot

Version-Release number of selected component (if applicable):
libvirt-1.0.3-1.el7.x86_64
qemu-kvm-1.4.0-1.el7.x86_64
kernel-3.8.0-0.40.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
 1. prepare one running health guest, make sure it contains the CDROM device:
 #virsh list --all
 Id    Name                           State
 ----------------------------------------------------
 3     mig2                           running

 #virsh dumpxml mig2
 ......
    <disk type='file' device='cdrom'
      <driver name='qemu' type='raw'/
      <source file='/var/lib/libvirt/images/temp1.iso'/
      <target dev='hdc' bus='ide'/
      <readonly/
      <alias name='ide0-1-0'/
      <address type='drive' controller='0' bus='1' target='0' unit='0'/
    </disk

 ......

 2. prepare one xml file like the following one, which the source file is changed:
 #cat cdrom2.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/
      <alias name='ide0-1-0'/
    </disk
 3.virsh update-device mig2 cdrom2.xml --config
 Device updated successfully

 4. check the dumpxml before boot, the source file is changed before boot.
 #virsh dumpxml mig2
 ......
    <disk type='file' device='cdrom'
      <driver name='qemu' type='raw'/
      <source file='/var/lib/libvirt/images/temp2.iso'/
      <target dev='hdc' bus='ide'/
      <readonly/
      <alias name='ide0-1-0'/
      <address type='drive' controller='0' bus='1' target='0' unit='0'/
    </disk

 ......

 5. check the help of update-device command, it said the domain should be affect next boot if run command with option "--config".
 #virsh help update-device
  NAME
    update-device - update device from an XML file

  SYNOPSIS
    update-device <domain <file [--config] [--force]

  DESCRIPTION
    Update device from an XML <file.

  OPTIONS
    [--domain] <stringdomain name, id or uuid
    [--file] <stringXML file
    --config         affect next boot
    --force          force device update
  
Actual results:
domain is affected before boot

Expected results:
domain should be affected after boot

Additional info:

Comment 2 Peter Krempa 2013-04-02 14:34:09 UTC
Fixed upstream with:

commit 69ce3ffa8d431e9810607c6e00b7cfcc481b491d
Author: Peter Krempa <pkrempa>
Date:   Fri Mar 15 17:11:28 2013 +0100

    virsh: Fix semantics of --config for "update-device" command
    
    The man page states that with --config the next boot is affected. This
    can be understood as if _only_ the next boot was affected. This isn't
    true if the machine is running.
    
    This patch adds the full --live, --config, --current infrastructure and
    tweaks stuff to correctly support the obsolete --persistent flag.
    
    Note that this patch changes the the behavior of the --config flag to match the
    use of this flag in rest of libvirt. This flag was mistakenly renamed from
    --persistent that originaly had different semantics.

and a few cleanup commits before.

v1.0.4-16-gb685a73

Comment 3 Xuesong Zhang 2013-05-07 05:59:54 UTC
Verify this bug with libvirt-1.0.5-1.el7.x86_64, this bug is fixed, change the status to verify.
Add more scenario to test this command, since add new option "live", "current" and "persistent" to this command.

OPTIONS
    [--domain] <string>  domain name, id or uuid
    [--file] <string>  XML file
    --persistent     make live change persistent
    --config         affect next boot
    --live           affect running domain
    --current        affect current domain
    --force          force device update

scenario 1: update device with option persistent on shutoff domain
[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
   ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
   ......
[root@xuzhangtest2 home]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     rhel7                          shut off

[root@xuzhangtest2 home]# virsh update-device rhel7 cdrom1.xml --persistent
Device updated successfully

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
......    
<disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
......
[root@xuzhangtest2 home]# virsh start rhel7
Domain rhel7 started

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
   ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
......

scenario 2: update device with option persistent on running domain
[root@xuzhangtest2 home]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     rhel7                          running
[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
   ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
......

# virsh update-device rhel7 cdrom2.xml --persistent
Device updated successfully

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk 
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
   ......
[root@xuzhangtest2 home]# virsh destroy rhel7
Domain rhel7 destroyed

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk 
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>


scenario 3: update device with option config running domain
[root@xuzhangtest2 home]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     rhel7                          running
[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
   ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
......
[root@xuzhangtest2 home]# virsh update-device rhel7 cdrom2.xml --config
Device updated successfully

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
 ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide' tray='open'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
[root@xuzhangtest2 home]# virsh destroy rhel7
Domain rhel7 destroyed

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
......
[root@xuzhangtest2 home]# virsh start rhel7
Domain rhel7 started

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
  ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
......

scenario 4: update device with option config shutoff domain
[root@xuzhangtest2 home]# virsh destroy rhel7
Domain rhel7 destroyed

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
   ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
   ......
[root@xuzhangtest2 home]# virsh update-device rhel7 cdrom1.xml --config
Device updated successfully

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
   ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    ......
[root@xuzhangtest2 home]# virsh start rhel7
Domain rhel7 started

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
   ......

scenario 5: update device with option live on running domain
[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
    ......
[root@xuzhangtest2 home]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 8     rhel7                          running

[root@xuzhangtest2 home]# virsh update-device rhel7 cdrom2.xml --live
Device updated successfully

[root@intel-3323-24-2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
    ......
[root@intel-3323-24-2 home]# virsh destroy rhel7
Domain rhel7 destroyed

[root@intel-3323-24-2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    ......
[root@intel-3323-24-2 home]# virsh start rhel7
Domain rhel7 started

[root@intel-3323-24-2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>


scenario 6: update device with option live on shutoff domain
[root@xuzhangtest2 home]# virsh destroy rhel7
Domain rhel7 destroyed

[root@xuzhangtest2 home]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     rhel7                          shut off
 -     rhel7-2                        shut off

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
   ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    ......
[root@xuzhangtest2 home]# virsh update-device rhel7 cdrom2.xml --live
error: Failed to update device from cdrom2.xml
error: Requested operation is not valid: cannot do live update a device on inactive domain

scenario 7: update device with option current on shutoff domain

#virsh update-device rhel7 cdrom2.xml --current
Device updated successfully

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    ......
[root@xuzhangtest2 home]# virsh start rhel7
Domain rhel7 started

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
    ......
[root@xuzhangtest2 home]# virsh destroy rhel7
Domain rhel7 destroyed

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
   ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    ......

scenario 8: update device with option current on running domain

[root@xuzhangtest2 home]# virsh start rhel7
Domain rhel7 started

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
   ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
    ......
[root@xuzhangtest2 home]# virsh update-device rhel7 cdrom1.xml --current  
Device updated successfully

[root@intel-3323-24-2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
    ......
[root@intel-3323-24-2 home]# virsh destroy rhel7
Domain rhel7 destroyed

[root@intel-3323-24-2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    ......
[root@intel-3323-24-2 home]# virsh start rhel7
Domain rhel7 started

[root@intel-3323-24-2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
    


scenario 8: update device with option force on running domain 
[root@xuzhangtest2 home]# virsh start rhel7
Domain rhel7 started

login guest, mount the cdrom to /mnt.

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
   ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
   ......

[root@xuzhangtest2 home]# virsh update-device rhel7 cdrom1.xml 
error: Failed to update device from cdrom1.xml
error: operation failed: Unable to eject media before changing it

[root@xuzhangtest2 home]# virsh update-device rhel7 cdrom1.xml --force
Device updated successfully

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
    ......

scenario 9: update device with option "live" and "config" on running domain
[root@xuzhangtest2 home]# virsh start rhel7
Domain rhel7 started

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp1.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
    ......

[root@xuzhangtest2 home]# virsh update-device rhel7 cdrom2.xml --live --config
Device updated successfully

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
    </disk>
    ......
[root@xuzhangtest2 home]# virsh destroy rhel7
Domain rhel7 destroyed

[root@xuzhangtest2 home]# virsh dumpxml rhel7|grep -A 5 disk
    ......
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/temp2.img'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    ......

scenario 9: update device with option "live" and "config" on shutoff domain
[root@xuzhangtest2 home]# virsh update-device rhel7 cdrom1.xml --live --config
error: Failed to update device from cdrom1.xml
error: Requested operation is not valid: cannot do live update a device on inactive domain

scenario 10: nagetive testing. option "current" is exclusive with "config" and "live".
[root@xuzhangtest2 home]# virsh update-device rhel7 cdrom1.xml --live --current
error: Options --current and --live are mutually exclusive

[root@xuzhangtest2 home]# virsh update-device rhel7 cdrom1.xml --current --config
error: Options --current and --config are mutually exclusive

Comment 4 Wayne Sun 2013-12-26 02:59:28 UTC
pkgs:
libvirt-1.1.1-16.el7.x86_64

Problem 1:
Attach/detach with --config
steps:
1. attach-disk with --config when domain is running
# virsh list
 Id    Name                           State
----------------------------------------------------
 15    virt-tests-vm1                 running

# virsh attach-disk virt-tests-vm1 /tmp/aa.img vdd --config
Disk attached successfully

2. detach with --config
# virsh detach-disk --domain virt-tests-vm1 --target vdd --config
error: No found disk whose source path or target is vdd 

The attach/detach with --config here is little confusing, since the semantic of --config is updated in this bug. With running domain, if the user want use this work, need do it as follow ways:

1. attach-disk with --config --live, then detach will success
# virsh attach-disk virt-tests-vm1 /tmp/test.img vdd --config --live
Disk attached successfully

# virsh detach-disk virt-tests-vm1 vdd --config
Disk detached successfully

Problem 2:
--current when domain shut off
steps:
# virsh destroy virt-tests-vm1
Domain virt-tests-vm1 destroyed

# virsh attach-disk virt-tests-vm1 /tmp/test.img vdd
error: Failed to attach disk
error: Requested operation is not valid: cannot do live update a device on inactive domain

# virsh attach-disk virt-tests-vm1 /tmp/test.img vdd --current
error: Failed to attach disk
error: Requested operation is not valid: cannot do live update a device on inactive domain

--current should be equal to --config when domain is shut off, and by default is --current. It should not fail here and no need to specify --config when domain is shut off.

Peter, can you help check the two problems here?

Comment 5 Peter Krempa 2014-01-07 17:13:12 UTC
Yes, those two are problems, but they are not entirely relevant to this bug.

I cloned this as https://bugzilla.redhat.com/show_bug.cgi?id=1049529 to track the problems.

Comment 6 Ludek Smid 2014-06-13 12:32:01 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.