From 5f8a09506e65628954bd6ac1f67d99c0fe8cf757 Mon Sep 17 00:00:00 2001
Message-Id: <5f8a09506e65628954bd6ac1f67d99c0fe8cf757@dist-git>
From: Laine Stump <laine@laine.org>
Date: Thu, 13 Apr 2017 14:29:21 -0400
Subject: [PATCH] util: use cleanup label consistently in
virHostdevNetConfigReplace()
This will make an upcoming functional change more straightforward.
Resolves: https://bugzilla.redhat.com/1442040 (RHEL 7.3.z)
Resolves: https://bugzilla.redhat.com/1415609 (RHEL 7.4)
(cherry picked from commit 19c5db749cdc3ddf53c2b23d5803a0f17cc5077a)
---
src/util/virhostdev.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 9b5ca6f41..1e4bb1e7d 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -393,15 +393,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,
@@ -410,15 +409,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;
--
2.12.2