]> xenbits.xensource.com Git - libvirt.git/commitdiff
libxl: fix net device detach
authorJim Fehlig <jfehlig@suse.com>
Wed, 30 Mar 2016 21:12:35 +0000 (15:12 -0600)
committerJim Fehlig <jfehlig@suse.com>
Thu, 31 Mar 2016 16:17:28 +0000 (10:17 -0600)
Chunyan sent a nice cleanup patch for libxlDomainDetachNetDevice

https://www.redhat.com/archives/libvir-list/2016-March/msg00926.html

which I incorrectly modified before pushing as commit b5534e53. My
modification caused network devices of type hostdev to no longer
be removed. This patch changes b5534e53 to resemble Chunyan's
original, correct patch.

src/libxl/libxl_driver.c

index 9955cc7bbbee7fe5acbbd65a7ff449c1a73d233d..bf97c9c1160796bf5c9aaf327abcef87fa3f130f 100644 (file)
@@ -3449,12 +3449,14 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver,
         goto cleanup;
     }
 
-    networkReleaseActualDevice(vm->def, detach);
-    virDomainNetRemove(vm->def, detachidx);
     ret = 0;
 
  cleanup:
     libxl_device_nic_dispose(&nic);
+    if (!ret) {
+        networkReleaseActualDevice(vm->def, detach);
+        virDomainNetRemove(vm->def, detachidx);
+    }
     virObjectUnref(cfg);
     return ret;
 }