virsh attach-device can't attach a new device to a kvm guest OS

Solution Verified - Updated -

Issue

  • virsh attach-device can't attach a new device to a kvm guest OS.
  • We ran virsh attach-device while a kvm guest OS is not running.  The command failed with the following error messages.

    # virsh attach-device RHEL60beta1_kvm disk1.xml
    error: Failed to attach device from disk1.xml
    error: Requested operation is not valid: cannot attach device on inactive domain
    
  • Additionally, we ran "virsh attach-device" while the kvm guest OS is running.  The command failed with the following error messages.

    # virsh attach-device RHEL60beta1_kvm disk1.xml
    error: Failed to attach device from disk1.xml
    error: internal error unable to execute QEMU command 'drive_add': The command drive_add has not been found
    
  • Step to Reproduce:

      0. Define a new device in an XML file.

# cat disk1.xml
<disk type='block' device='disk'>
  <driver name='qemu'/>
  <source dev='/dev/sdc1'/>
  <target dev='vdd' bus='virtio'/>
  <alias name='virtio-disk0'/>
</disk>

      [Case 1: A kvm guest OS is not running.]
      1-1. Run the following command to shut down a kvm guest OS.

# virsh shutdown <kvm-guestOS-name>

      1-2. Run the following command to check that the kvm guest OS is not running.

# virsh list --all
 Id Name                 State
 ----------------------------------
  - RHEL60beta1_kvm      shut off

     1-3. Run the following command to attach the new device to the kvm guest OS.

# virsh attach-device RHEL60beta1_kvm disk1.xml

     [Case 2: A kvm guest OS is running.]
     2-1. Run the following command to start a kvm guest OS.

# virsh start <kvm-guestOS-name>

      2-2. Run the following command to check that the kvm guest OS is running.

# virsh list --all
 Id Name                 State
 ----------------------------------
 30 RHEL60beta1_kvm      running

      2-3. Run the following command to attach the new device to the kvm guest OS.

# virsh attach-device RHEL60beta1_kvm disk1.xml

We know this problem is related to BZ573946 and BZ581963.
BZ573946: QMP: broken drive hotplug due to missing 'blockdev_add' /
           'drive_add' commands in QEMU
           (https://bugzilla.redhat.com/show_bug.cgi?id=573946)
BZ581963: QMP: missing drive_add command in JSON mode
           (https://bugzilla.redhat.com/show_bug.cgi?id=581963)

Environment

  • Red Hat Enterprise Linux 6.0
  • x86_64

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content