[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH V4 2/6] libxlDomainDetachNetDevice: cleanup codes



Adjust codes to make it cleaner.

Signed-off-by: Chunyan Liu <cyliu suse com>
---
 src/libxl/libxl_driver.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 05ebe29..74ebea4 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -3413,8 +3413,10 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver,
     char mac[VIR_MAC_STRING_BUFLEN];
     int ret = -1;
 
+    libxl_device_nic_init(&nic);
+
     if ((detachidx = virDomainNetFindIdx(vm->def, net)) < 0)
-        goto out;
+        goto cleanup;
 
     detach = vm->def->nets[detachidx];
 
@@ -3424,10 +3426,9 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver,
          */
         ret = libxlDomainDetachHostDevice(driver, vm,
                                           virDomainNetGetActualHostdev(detach));
-        goto out;
+        goto cleanup;
     }
 
-    libxl_device_nic_init(&nic);
     if (libxl_mac_to_device_nic(cfg->ctx, vm->def->id,
                                 virMacAddrFormat(&detach->mac, mac), &nic))
         goto cleanup;
@@ -3442,7 +3443,6 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driver,
 
  cleanup:
     libxl_device_nic_dispose(&nic);
- out:
     if (!ret)
         virDomainNetRemove(vm->def, detachidx);
     virObjectUnref(cfg);
-- 
2.1.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]