Bug 658713

Summary: virsh attach-disk --persistent unsupported on kvm
Product: Red Hat Enterprise Linux 6 Reporter: Eric Blake <eblake>
Component: libvirtAssignee: Eric Blake <eblake>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 6.0CC: ajia, dallan, dyuan, eblake, mzhan, rwu, weizhan, whuang, xen-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.9.2-1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 10:52:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Eric Blake 2010-12-01 03:36:24 UTC
Description of problem:
The only way to persistently add a disk to a qemu-kvm guest is to manually edit the xml, since qemudDomainAttachDeviceFlags rejects VIR_DOMAIN_DEVICE_MODIFY_CONFIG.

Version-Release number of selected component (if applicable):
libvirt-0.8.1-27.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
[root@ntc164 utils]# qemu-img create /var/lib/libvirt/images/KVM-Guest-2.img 8G
Formatting '/var/lib/libvirt/images/KVM-Guest-2.img', fmt=raw, size=8388608 kB
[root@ntc164 utils]# virsh attach-disk KVM-Guest-1 /var/lib/libvirt/images/KVM-Guest-2.img hdb
error: Failed to attach disk
error: this function is not supported by the connection driver: disk bus 'ide' cannot be hotplugged.

[root@ntc164 utils]# virsh destroy KVM-Guest-1
Domain KVM-Guest-1 destroyed

[root@ntc164 utils]# virsh attach-disk KVM-Guest-1 /var/lib/libvirt/images/KVM-Guest-2.img hdb
error: Failed to attach disk
error: Requested operation is not valid: cannot attach device on inactive domain

[root@ntc164 utils]# virsh attach-disk KVM-Guest-1 /var/lib/libvirt/images/KVM-Guest-2.img hdb --type disk --driver qemu --subdriver raw  --mode readonly
error: No support for qemu in command 'attach-disk'

  
Actual results:
All attempts to use virsh shorthand fail; the only way to add the device is through 'virsh edit' or other full xml editing.

Expected results:
virsh attach-disk --persistent should avoid the need for a manual xml edit

Additional info:

Comment 2 Suzanne Logcher 2011-03-28 21:14:59 UTC
Since RHEL 6.1 External Beta has begun, and this bug remains 
unresolved, it has been rejected as it is not proposed as an 
exception or blocker.

Red Hat invites you to ask your support representative to 
propose this request, if appropriate and relevant, in the 
next release of Red Hat Enterprise Linux.

Comment 4 Eric Blake 2011-06-20 16:43:36 UTC
Fixed upstream (and therefore will be picked up by rebase); upstream patch series includes:

commit f37c29c8aa32390c68eb79614d69c2bc7f6d5e8f
Author: KAMEZAWA Hiroyuki <kamezawa.hiroyu.com>
Date:   Fri Apr 22 12:10:28 2011 +0900

    libvirt/qemu - support persistent update of disks
    
    Support update of disks by MODIFY_CONFIG
    
    This patch includes changes for qemu's disk to support
    virDomainUpdateDeviceFlags() with VIR_DOMAIN_DEVICE_MODIFY_CONFIG.
    
    This patch adds support for CDROM/foppy disk types.
    
    Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu.com>

Comment 5 Daniel Veillard 2011-06-23 02:41:09 UTC
This should be fixed by the libvirt-0.9.2-1.el6 rebase

Comment 8 Huang Wenlong 2011-06-23 06:12:14 UTC
Version-Release number of selected component:

libvirt-0.9.2-1.el6.x86_64
qemu-kvm-0.12.1.2-2.165.el6.x86_64
kernel-2.6.32-156.el6.x86_64

Test steps : 
1)qemu-img create /var/lib/libvirt/images/test-disk.img 8G

2)When the guest is active ,run the command 

#virsh attach-disk fedora14 /var/lib/libvirt/images/test-disk.img vdb --persistent
error: Failed to attach disk
error: operation failed: drive hotplug is not supported

3)destroy the guest 
# virsh destroy fedora14

3)When the guest is inactive ,run the command 
# virsh attach-disk fedora14 /var/lib/libvirt/images/test-disk.img vdb 
error: Failed to attach disk
error: Requested operation is not valid: cannot do live update a device on inactive domain

4)add --persistent option 
# virsh attach-disk fedora14 /var/lib/libvirt/images/test-disk.img vdb --persistent 
Disk attached successfully

So the --persistent is effective

Comment 10 Rita Wu 2011-07-06 10:28:39 UTC
Set it as VERIFIED per comment8

Comment 11 errata-xmlrpc 2011-12-06 10:52:53 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-2011-1513.html