Blame SOURCES/libvirt-util-save-hostdev-network-device-config-before-unbinding-from-host-driver.patch

5c27b6
From bf59aaa70ce909af0fffb99575173730bae05e4e Mon Sep 17 00:00:00 2001
5c27b6
Message-Id: <bf59aaa70ce909af0fffb99575173730bae05e4e@dist-git>
5c27b6
From: Laine Stump <laine@laine.org>
5c27b6
Date: Thu, 13 Apr 2017 14:29:33 -0400
5c27b6
Subject: [PATCH] util: save hostdev network device config before unbinding
5c27b6
 from host driver
5c27b6
5c27b6
In order to properly restore the original state of an SRIOV VF when
5c27b6
we're finished with it, we need to save the MAC address of the VF
5c27b6
itself (not just the admin MAC address for the VF that is stored in
5c27b6
the PF). But that can only be done when the VF is still bound to the
5c27b6
host's netdev driver, and we have always done the saving of device
5c27b6
config after the VF is already bound to vfio-pci. This patch prepares
5c27b6
us for adding a save of the VF's MAC by calling the function that
5c27b6
saves netconfig earlier in the device preparation, before we've
5c27b6
unbound it from the host netdev driver.
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 cceada574e7b057c82927f7939c7491488e67463)
5c27b6
---
5c27b6
 src/util/virhostdev.c | 11 ++++++++---
5c27b6
 1 file changed, 8 insertions(+), 3 deletions(-)
5c27b6
5c27b6
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
5c27b6
index b869ebc0c..f07e50d2c 100644
5c27b6
--- a/src/util/virhostdev.c
5c27b6
+++ b/src/util/virhostdev.c
5c27b6
@@ -620,6 +620,14 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
5c27b6
         }
5c27b6
     }
5c27b6
 
5c27b6
+    /* Step 1.5: For non-802.11Qbh SRIOV network devices, save the
5c27b6
+     * current device config
5c27b6
+     */
5c27b6
+    for (i = 0; i < nhostdevs; i++) {
5c27b6
+        if (virHostdevSaveNetConfig(hostdevs[i], mgr->stateDir) < 0)
5c27b6
+            goto cleanup;
5c27b6
+    }
5c27b6
+
5c27b6
     /* Step 2: detach managed devices and make sure unmanaged devices
5c27b6
      *         have already been taken care of */
5c27b6
     for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
5c27b6
@@ -710,9 +718,6 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
5c27b6
      * the network device, set the new netdev config */
5c27b6
     for (i = 0; i < nhostdevs; i++) {
5c27b6
 
5c27b6
-        if (virHostdevSaveNetConfig(hostdevs[i], mgr->stateDir) < 0)
5c27b6
-            goto resetvfnetconfig;
5c27b6
-
5c27b6
         if (virHostdevSetNetConfig(hostdevs[i], uuid) < 0)
5c27b6
             goto resetvfnetconfig;
5c27b6
 
5c27b6
-- 
5c27b6
2.12.2
5c27b6