]> xenbits.xensource.com Git - libvirt.git/commitdiff
update domain status forcibly even if attach a device failed
authorWen Congyang <wency@cn.fujitsu.com>
Thu, 17 Feb 2011 03:32:13 +0000 (11:32 +0800)
committerWen Congyang <wency@cn.fujitsu.com>
Thu, 24 Mar 2011 07:26:28 +0000 (15:26 +0800)
Steps to reproduce this bug:
1. virsh attach-disk domain --source diskimage --target sdb --sourcetype file --driver qemu --subdriver qcow2
   error: Failed to attach disk
   error: operation failed: adding scsi-disk,bus=scsi0.0,scsi-id=1,drive=drive-scsi0-0-1,id=scsi0-0-1 device failed: Property 'scsi-disk.drive' can't find value 'drive-scsi0-0-1'
2. service libvirtd restart
   Stopping libvirtd daemon:                                  [  OK  ]
   Starting libvirtd daemon:                                  [  OK  ]
3. virsh attach-disk domain --source diskimage --target sdb --sourcetype file --driver qemu --subdriver raw
   error: Failed to attach disk
   error: operation failed: adding lsi,id=scsi0,bus=pci.0,addr=0x6 device failed: Duplicate ID 'scsi0' for device

The reason is that we create a new scsi controller but we do not update
/var/run/libvirt/qemu/domain.xml.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
src/qemu/qemu_driver.c

index 6f296c9bfd339a8db1b88beb77123ea3a1e7183a..af897addba50319a651122db50d98e0970774719 100644 (file)
@@ -4121,7 +4121,11 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
         goto endjob;
     }
 
-    if (!ret && virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
+    /* update domain status forcibly because the domain status may be changed
+     * even if we attach the device failed. For example, a new controller may
+     * be created.
+     */
+    if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
         ret = -1;
 
 endjob: