]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: use cleanup label consistently in virHostdevNetConfigReplace()
authorLaine Stump <laine@laine.org>
Sun, 26 Feb 2017 18:27:48 +0000 (13:27 -0500)
committerLaine Stump <laine@laine.org>
Fri, 24 Mar 2017 04:36:22 +0000 (00:36 -0400)
This will make an upcoming functional change more straightforward.

src/util/virhostdev.c

index a75d108f7351b4d7085555c88387824a8dd2f5b2..e84a6d608239a01cb38c8d7ff73de54fb6689bf5 100644 (file)
@@ -411,15 +411,14 @@ virHostdevNetConfigReplace(virDomainHostdevDefPtr hostdev,
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("Interface type hostdev is currently supported on"
                          " SR-IOV Virtual Functions only"));
-        return ret;
+        goto cleanup;
     }
 
     if (virHostdevNetDevice(hostdev, &linkdev, &vf) < 0)
-        return ret;
+        goto cleanup;
 
     vlan = virDomainNetGetActualVlan(hostdev->parent.data.net);
-    virtPort = virDomainNetGetActualVirtPortProfile(
-                                 hostdev->parent.data.net);
+    virtPort = virDomainNetGetActualVirtPortProfile(hostdev->parent.data.net);
     if (virtPort) {
         if (vlan) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -428,15 +427,21 @@ virHostdevNetConfigReplace(virDomainHostdevDefPtr hostdev,
                            virNetDevVPortTypeToString(virtPort->virtPortType));
             goto cleanup;
         }
-        ret = virHostdevNetConfigVirtPortProfile(linkdev, vf,
-                            virtPort, &hostdev->parent.data.net->mac, uuid,
-                            port_profile_associate);
+        if (virHostdevNetConfigVirtPortProfile(linkdev, vf, virtPort,
+                                               &hostdev->parent.data.net->mac,
+                                               uuid, port_profile_associate) < 0) {
+            goto cleanup;
+        }
     } else {
         /* Set only mac and vlan */
-        ret = virNetDevReplaceNetConfig(linkdev, vf,
-                                        &hostdev->parent.data.net->mac,
-                                        vlan, stateDir);
+        if (virNetDevReplaceNetConfig(linkdev, vf,
+                                      &hostdev->parent.data.net->mac,
+                                      vlan, stateDir) < 0) {
+            goto cleanup;
+        }
     }
+
+    ret = 0;
  cleanup:
     VIR_FREE(linkdev);
     return ret;