render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From bf59aaa70ce909af0fffb99575173730bae05e4e Mon Sep 17 00:00:00 2001
Message-Id: <bf59aaa70ce909af0fffb99575173730bae05e4e@dist-git>
From: Laine Stump <laine@laine.org>
Date: Thu, 13 Apr 2017 14:29:33 -0400
Subject: [PATCH] util: save hostdev network device config before unbinding
 from host driver

In order to properly restore the original state of an SRIOV VF when
we're finished with it, we need to save the MAC address of the VF
itself (not just the admin MAC address for the VF that is stored in
the PF). But that can only be done when the VF is still bound to the
host's netdev driver, and we have always done the saving of device
config after the VF is already bound to vfio-pci. This patch prepares
us for adding a save of the VF's MAC by calling the function that
saves netconfig earlier in the device preparation, before we've
unbound it from the host netdev driver.

Resolves: https://bugzilla.redhat.com/1442040 (RHEL 7.3.z)
Resolves: https://bugzilla.redhat.com/1415609 (RHEL 7.4)

(cherry picked from commit cceada574e7b057c82927f7939c7491488e67463)
---
 src/util/virhostdev.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index b869ebc0c..f07e50d2c 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -620,6 +620,14 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
         }
     }
 
+    /* Step 1.5: For non-802.11Qbh SRIOV network devices, save the
+     * current device config
+     */
+    for (i = 0; i < nhostdevs; i++) {
+        if (virHostdevSaveNetConfig(hostdevs[i], mgr->stateDir) < 0)
+            goto cleanup;
+    }
+
     /* Step 2: detach managed devices and make sure unmanaged devices
      *         have already been taken care of */
     for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
@@ -710,9 +718,6 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
      * the network device, set the new netdev config */
     for (i = 0; i < nhostdevs; i++) {
 
-        if (virHostdevSaveNetConfig(hostdevs[i], mgr->stateDir) < 0)
-            goto resetvfnetconfig;
-
         if (virHostdevSetNetConfig(hostdevs[i], uuid) < 0)
             goto resetvfnetconfig;
 
-- 
2.12.2