Bug 619190 - virsh attach-device fails to attach a new device to a KVM guest
virsh attach-device fails to attach a new device to a KVM guest
Status: CLOSED DUPLICATE of bug 589662
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
6.0
All Linux
medium Severity medium
: rc
: ---
Assigned To: Daniel Veillard
Virtualization Bugs
: RHELNAK
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-07-28 16:02 EDT by Nandini Chandra
Modified: 2010-08-18 04:27 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-08-18 04:27:37 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Nandini Chandra 2010-07-28 16:02:47 EDT
Description of problem:
'virsh attach-device' fails to attach a new device to an active KVM guest.It fails with the following error message:

# virsh attach-device RHEL60beta2_kvm disk1.xml
error: Failed to attach device from disk1.xml
error: internal error unable to execute QEMU command '__com.redhat_drive_add': Device 'drive-virtio-disk1' could not be initialized

Version-Release number of selected component (if applicable):
libvirt-0.8.1-15.el6.x86_64
qemu-kvm-0.12.1.2-2.96.el6.x86_64
qemu-img-0.12.1.2-2.96.el6.x86_64

[root@ibm-hs21-1 ~]# uname -r
2.6.32-52.el6.x86_64
 

How reproducible:
Consistently

Steps to Reproduce:
1.[root@ibm-hs21-1 ~]# cat disk-block.xml
> <disk type='block' device='disk'>
> <source dev='/dev/sda3'/>
> <target dev='vdb' bus='virtio'/>
> </disk>

[root@ibm-hs21-1 ~]# ll /dev/sda3
brw-rw----. 1 root root 8, 3 Jul 26 21:54 /dev/sda3

2.[root@ibm-hs21-1 ~]# virsh attach-device rhel6beta2 disk-block.xml
 error: Failed to attach device from disk-block.xml
 error: internal error unable to execute QEMU command 
 '__com.redhat_drive_add': Device 'drive-virtio-disk1' could not be initialized

It doesn't work for disk type='block' as shown in the above example.

  
Actual results:
virsh attach-device fails to attach a device to an active domain.


Expected results:
virsh attach-device should attach a device to an active domain.

Additional info:
It works for disk type='file'.

[root@ibm-hs21-1 ~]# cat disk-file.xml
<disk type="file" device="disk">
 <source file="/root/dd.img"/>
 <target dev="vdc" bus="virtio"/>
</disk>

[root@ibm-hs21-1 ~]# ll /root/dd.img
-rw-r--r--. 1 root root 10485760 Jul 26 22:07 /root/dd.img

[root@ibm-hs21-1 ~]# virsh attach-device rhel6beta2 disk-file.xml
Device attached successfully
Comment 1 RHEL Product and Program Management 2010-07-28 16:17:50 EDT
This issue has been proposed when we are only considering blocker
issues in the current Red Hat Enterprise Linux release.

** If you would still like this issue considered for the current
release, ask your support representative to file as a blocker on
your behalf. Otherwise ask that it be considered for the next
Red Hat Enterprise Linux release. **
Comment 2 Daniel Veillard 2010-07-30 13:35:03 EDT
Well, that works for me fine, I can't reproduce it with the
current stack:

[root@test tmp]# virsh attach-device test6.1 disk-block.xml
Device attached successfully

[root@test tmp]# getenforce
Enforcing
[root@test tmp]# rpm -q libvirt qemu-kvm qemu-img
libvirt-0.8.1-20.el6.x86_64
qemu-kvm-0.12.1.2-2.104.el6.x86_64
qemu-img-0.12.1.2-2.104.el6.x86_64
[root@test tmp]# ls -l /dev/sdb1
brw-rw----. 1 qemu qemu 8, 17 Jul 31 02:45 /dev/sdb1
[root@test tmp]# virsh detach-device test6.1 disk-block.xml
Device detached successfully

[root@test tmp]# ls -l /dev/sdb1
brw-rw----. 1 root disk 8, 17 Jul 31 03:28 /dev/sdb1
[root@test tmp]# cat disk-block.xml
<disk type='block' device='disk'>
  <source dev='/dev/sdb1'/>
  <target dev='vdb' bus='virtio'/>
</disk>


[root@test tmp]# 


In the guest I saw in dmesg the virtio-pci logs ending up with
 vbb: unknown partition table.

I also tried with an /dev/sr0 device read-only that worked fine too
and the attachemnt of a file based device also worked fine.

Could you double check with the recent stack as this seems to work
fine for me with current packages.
Also what kind of guest are you using ?
And did you get any error on the qemu logs ?

Daniel
Comment 7 Daniel Veillard 2010-08-12 05:06:32 EDT
I logged in the box yesterday and could reproduce the issue
it's very strange indeed, nothing seems to be wrong ... except that
specific command doesn't work, I will try to debug the issue further if you can keep the access to that machine and setup for me.
One question though, the guest is running for a week now, did you update any
of the libvirt or kvm packages on that box since then ?

Daniel
Comment 10 Daniel Berrange 2010-08-17 06:12:30 EDT
> > And did you get any error on the qemu logs ?
> 
> /var/log/libvirt/qemu/rhel6beta2.log
> ----------
> qemu: could not open disk image /dev/sda3: Operation not permitted

What kernel version do you have, and are any of the 'cgroup' filesystems shown in /proc/mounts ?

I expect this is a duplicate of this kernel bug.

https://bugzilla.redhat.com/show_bug.cgi?id=589662
Comment 11 Daniel Veillard 2010-08-17 16:30:30 EDT
I logged on the test machine, stopped cgconfig, 
[root@ibm-hs21-1 tmp]# /etc/init.d/cgconfig stop
Stopping cgconfig service:                                 [  OK  ]
[root@ibm-hs21-1 tmp]# /etc/init.d/libvirtd restart
Stopping libvirtd daemon:                                  [  OK  ]
Starting libvirtd daemon:                                  [  OK  ]
[root@ibm-hs21-1 tmp]# 
[root@ibm-hs21-1 tmp]# virsh attach-device rhel6beta2 disk-block.xml
Device attached successfully

[root@ibm-hs21-1 tmp]# 


so that could be the problem, yes

[root@ibm-hs21-1 tmp]# ls /cgroup/
[root@ibm-hs21-1 tmp]# 

Daniel
Comment 12 Daniel Berrange 2010-08-18 04:27:37 EDT

*** This bug has been marked as a duplicate of bug 589662 ***

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