]> xenbits.xensource.com Git - libvirt.git/commitdiff
libxlDomainDetachDeviceLive: handle hostdev parent is network device
authorChunyan Liu <cyliu@suse.com>
Mon, 21 Mar 2016 08:11:38 +0000 (16:11 +0800)
committerJim Fehlig <jfehlig@suse.com>
Fri, 25 Mar 2016 22:57:34 +0000 (16:57 -0600)
When hostdev parent is network device, should call
libxlDomainDetachNetDevice to detach the device from a higher level.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
src/libxl/libxl_driver.c

index b2e23c0a895394d2c4187919b6e05d30d437d90d..cc7f2246355b98607c8e70617ffc5208e7913dae 100644 (file)
@@ -3438,6 +3438,7 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver,
         goto cleanup;
     }
 
+    networkReleaseActualDevice(vm->def, detach);
     virDomainNetRemove(vm->def, detachidx);
     ret = 0;
 
@@ -3452,6 +3453,7 @@ libxlDomainDetachDeviceLive(libxlDriverPrivatePtr driver,
                             virDomainObjPtr vm,
                             virDomainDeviceDefPtr dev)
 {
+    virDomainHostdevDefPtr hostdev;
     int ret = -1;
 
     switch (dev->type) {
@@ -3465,8 +3467,16 @@ libxlDomainDetachDeviceLive(libxlDriverPrivatePtr driver,
             break;
 
         case VIR_DOMAIN_DEVICE_HOSTDEV:
-            ret = libxlDomainDetachHostDevice(driver, vm,
-                                              dev->data.hostdev);
+            hostdev = dev->data.hostdev;
+
+            /* If this is a network hostdev, we need to use the higher-level
+             * detach function so that mac address / virtualport are reset
+             */
+            if (hostdev->parent.type == VIR_DOMAIN_DEVICE_NET)
+                ret = libxlDomainDetachNetDevice(driver, vm,
+                                                 hostdev->parent.data.net);
+            else
+                ret = libxlDomainDetachHostDevice(driver, vm, hostdev);
             break;
 
         default: