]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Don't use legacy API if --current is used on device hot(un)plug
authorPeter Krempa <pkrempa@redhat.com>
Tue, 7 Jan 2014 15:44:02 +0000 (16:44 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 8 Jan 2014 08:47:44 +0000 (09:47 +0100)
https://bugzilla.redhat.com/show_bug.cgi?id=1049529

The legacy virDomainAttachDevice and virDomainDetachDevice operate only
on active domains. When a user specified --current flag with an inactive
domain the old API was used and reported an error. Fix it by calling the
new API if --current is specified explicitly.

tools/virsh-domain.c

index 3aabd26af1d3348a06ea659a79c109a6c7782283..5468365c45d463e6864d6a57abbe615dc3e63afd 100644 (file)
@@ -230,7 +230,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    if (flags)
+    if (flags || current)
         rv = virDomainAttachDeviceFlags(dom, buffer, flags);
     else
         rv = virDomainAttachDevice(dom, buffer);
@@ -669,7 +669,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
         virDomainIsActive(dom) == 1)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (flags)
+    if (flags || current)
         ret = virDomainAttachDeviceFlags(dom, xml, flags);
     else
         ret = virDomainAttachDevice(dom, xml);
@@ -923,7 +923,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
 
     xml = virBufferContentAndReset(&buf);
 
-    if (flags)
+    if (flags || current)
         ret = virDomainAttachDeviceFlags(dom, xml, flags);
     else
         ret = virDomainAttachDevice(dom, xml);
@@ -9609,7 +9609,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    if (flags != 0)
+    if (flags != 0 || current)
         ret = virDomainDetachDeviceFlags(dom, buffer, flags);
     else
         ret = virDomainDetachDevice(dom, buffer);
@@ -9884,7 +9884,7 @@ hit:
         goto cleanup;
     }
 
-    if (flags != 0)
+    if (flags != 0 || current)
         ret = virDomainDetachDeviceFlags(dom, detach_xml, flags);
     else
         ret = virDomainDetachDevice(dom, detach_xml);
@@ -10189,7 +10189,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
                                        VSH_PREPARE_DISK_XML_NONE)))
         goto cleanup;
 
-    if (flags != 0)
+    if (flags != 0 || current)
         ret = virDomainDetachDeviceFlags(dom, disk_xml, flags);
     else
         ret = virDomainDetachDevice(dom, disk_xml);