|
|
5c27b6 |
From 2dca449de05381494f6d7a0d126ae3a06b8d7120 Mon Sep 17 00:00:00 2001
|
|
|
5c27b6 |
Message-Id: <2dca449de05381494f6d7a0d126ae3a06b8d7120@dist-git>
|
|
|
5c27b6 |
From: Laine Stump <laine@laine.org>
|
|
|
5c27b6 |
Date: Thu, 13 Apr 2017 14:29:31 -0400
|
|
|
5c27b6 |
Subject: [PATCH] util: use new virNetDev*NetConfig() functions for hostdev
|
|
|
5c27b6 |
setup/teardown
|
|
|
5c27b6 |
|
|
|
5c27b6 |
virHostdevNetConfigReplace() and virHostdevNetConfigRestore() are
|
|
|
5c27b6 |
modified to use the new virNetDev*NetConfig() functions.
|
|
|
5c27b6 |
|
|
|
5c27b6 |
Note that due to the VF's original MAC addresses being saved after it
|
|
|
5c27b6 |
has already been un-bound from the host net driver, the actual current
|
|
|
5c27b6 |
VF MAC address won't be saved (because it no longer exists) - only the
|
|
|
5c27b6 |
"admin MAC" will be saved. This reflects existing behavior that will
|
|
|
5c27b6 |
be fixed in an upcoming patch.
|
|
|
5c27b6 |
|
|
|
5c27b6 |
Resolves: https://bugzilla.redhat.com/1442040 (RHEL 7.3.z)
|
|
|
5c27b6 |
Resolves: https://bugzilla.redhat.com/1415609 (RHEL 7.4)
|
|
|
5c27b6 |
|
|
|
5c27b6 |
(cherry picked from commit 9c004d55d02422b8eaa6db857372bdd4af3e26ed)
|
|
|
5c27b6 |
---
|
|
|
5c27b6 |
src/util/virhostdev.c | 31 ++++++++++++++++++++++++-------
|
|
|
5c27b6 |
1 file changed, 24 insertions(+), 7 deletions(-)
|
|
|
5c27b6 |
|
|
|
5c27b6 |
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
|
|
|
5c27b6 |
index 93b69501c..a715aae12 100644
|
|
|
5c27b6 |
--- a/src/util/virhostdev.c
|
|
|
5c27b6 |
+++ b/src/util/virhostdev.c
|
|
|
5c27b6 |
@@ -428,10 +428,13 @@ virHostdevNetConfigReplace(virDomainHostdevDefPtr hostdev,
|
|
|
5c27b6 |
goto cleanup;
|
|
|
5c27b6 |
}
|
|
|
5c27b6 |
} else {
|
|
|
5c27b6 |
- /* Set only mac and vlan */
|
|
|
5c27b6 |
- if (virNetDevReplaceNetConfig(linkdev, vf,
|
|
|
5c27b6 |
- &hostdev->parent.data.net->mac,
|
|
|
5c27b6 |
- vlan, stateDir) < 0) {
|
|
|
5c27b6 |
+ /* Save/Set only mac and vlan */
|
|
|
5c27b6 |
+
|
|
|
5c27b6 |
+ if (virNetDevSaveNetConfig(linkdev, vf, stateDir, true) < 0)
|
|
|
5c27b6 |
+ goto cleanup;
|
|
|
5c27b6 |
+
|
|
|
5c27b6 |
+ if (virNetDevSetNetConfig(linkdev, vf, &hostdev->parent.data.net->mac,
|
|
|
5c27b6 |
+ vlan, NULL, true) < 0) {
|
|
|
5c27b6 |
goto cleanup;
|
|
|
5c27b6 |
}
|
|
|
5c27b6 |
}
|
|
|
5c27b6 |
@@ -484,9 +487,23 @@ virHostdevNetConfigRestore(virDomainHostdevDefPtr hostdev,
|
|
|
5c27b6 |
NULL,
|
|
|
5c27b6 |
port_profile_associate);
|
|
|
5c27b6 |
} else {
|
|
|
5c27b6 |
- ret = virNetDevRestoreNetConfig(linkdev, vf, stateDir);
|
|
|
5c27b6 |
- if (ret < 0 && oldStateDir != NULL)
|
|
|
5c27b6 |
- ret = virNetDevRestoreNetConfig(linkdev, vf, oldStateDir);
|
|
|
5c27b6 |
+ virMacAddrPtr MAC = NULL;
|
|
|
5c27b6 |
+ virMacAddrPtr adminMAC = NULL;
|
|
|
5c27b6 |
+ virNetDevVlanPtr vlan = NULL;
|
|
|
5c27b6 |
+
|
|
|
5c27b6 |
+ ret = virNetDevReadNetConfig(linkdev, vf, stateDir, &adminMAC, &vlan, &MAC);
|
|
|
5c27b6 |
+ if (ret < 0 && oldStateDir)
|
|
|
5c27b6 |
+ ret = virNetDevReadNetConfig(linkdev, vf, oldStateDir,
|
|
|
5c27b6 |
+ &adminMAC, &vlan, &MAC);
|
|
|
5c27b6 |
+
|
|
|
5c27b6 |
+ if (ret == 0) {
|
|
|
5c27b6 |
+ ignore_value(virNetDevSetNetConfig(linkdev, vf,
|
|
|
5c27b6 |
+ adminMAC, vlan, MAC, true));
|
|
|
5c27b6 |
+ }
|
|
|
5c27b6 |
+
|
|
|
5c27b6 |
+ VIR_FREE(MAC);
|
|
|
5c27b6 |
+ VIR_FREE(adminMAC);
|
|
|
5c27b6 |
+ virNetDevVlanFree(vlan);
|
|
|
5c27b6 |
}
|
|
|
5c27b6 |
|
|
|
5c27b6 |
VIR_FREE(linkdev);
|
|
|
5c27b6 |
--
|
|
|
5c27b6 |
2.12.2
|
|
|
5c27b6 |
|