render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From 01c309a7d81daa85e7212e37c8b4b9dd2c08f898 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <01c309a7d81daa85e7212e37c8b4b9dd2c08f898@dist-git>
3e5111
From: Laine Stump <laine@laine.org>
3e5111
Date: Tue, 2 May 2017 12:31:51 -0400
3e5111
Subject: [PATCH] qemu: don't kill qemu process on restart if networkNotify
3e5111
 fails
3e5111
3e5111
Nothing that could happen during networkNotifyActualDevice() could
3e5111
justify unceremoniously killing the qemu process, but that's what we
3e5111
were doing.
3e5111
3e5111
In particular, new code added in commit 85bcc022 (first appearred in
3e5111
libvirt-3.2.0) attempts to reattach tap devices to their assigned
3e5111
bridge devices when libvirtd restarts (to make it easier to recover
3e5111
from a restart of a libvirt network). But if the network has been
3e5111
stopped and *not* restarted, the bridge device won't exist and
3e5111
networkNotifyActualDevice() will fail.
3e5111
3e5111
This patch changes networkNotifyActualDevice() and
3e5111
qemuProcessNotifyNets() to return void, so that qemuProcessReconnect()
3e5111
will soldier on regardless of what happens (any errors will still be
3e5111
logged though).
3e5111
3e5111
Partially resolves: https://bugzilla.redhat.com/1442700
3e5111
3e5111
(cherry picked from commit cb182eb11d3a99adb06e188989899dcd488c43fc)
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/network/bridge_driver.c | 10 ++++------
3e5111
 src/network/bridge_driver.h |  7 +++----
3e5111
 src/qemu/qemu_process.c     |  9 +++------
3e5111
 3 files changed, 10 insertions(+), 16 deletions(-)
3e5111
3e5111
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
3e5111
index ef982363b..cb91a2c90 100644
3e5111
--- a/src/network/bridge_driver.c
3e5111
+++ b/src/network/bridge_driver.c
3e5111
@@ -4656,9 +4656,9 @@ networkAllocateActualDevice(virDomainDefPtr dom,
3e5111
  * order, or re-attach the interface's tap device to the network's
3e5111
  * bridge.
3e5111
  *
3e5111
- * Returns 0 on success, -1 on failure.
3e5111
+ * No return value (but does log any failures)
3e5111
  */
3e5111
-int
3e5111
+void
3e5111
 networkNotifyActualDevice(virDomainDefPtr dom,
3e5111
                           virDomainNetDefPtr iface)
3e5111
 {
3e5111
@@ -4668,11 +4668,10 @@ networkNotifyActualDevice(virDomainDefPtr dom,
3e5111
     virNetworkDefPtr netdef;
3e5111
     virNetworkForwardIfDefPtr dev = NULL;
3e5111
     size_t i;
3e5111
-    int ret = -1;
3e5111
     char *master = NULL;
3e5111
 
3e5111
     if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK)
3e5111
-        return 0;
3e5111
+        return;
3e5111
 
3e5111
     network = virNetworkObjFindByName(driver->networks, iface->data.network.name);
3e5111
     if (!network) {
3e5111
@@ -4848,11 +4847,10 @@ networkNotifyActualDevice(virDomainDefPtr dom,
3e5111
     }
3e5111
     networkLogAllocation(netdef, actualType, dev, iface, true);
3e5111
 
3e5111
-    ret = 0;
3e5111
  cleanup:
3e5111
     virNetworkObjEndAPI(&network);
3e5111
     VIR_FREE(master);
3e5111
-    return ret;
3e5111
+    return;
3e5111
 
3e5111
  error:
3e5111
     goto cleanup;
3e5111
diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h
3e5111
index c696f0301..aaedd67a1 100644
3e5111
--- a/src/network/bridge_driver.h
3e5111
+++ b/src/network/bridge_driver.h
3e5111
@@ -37,8 +37,8 @@ int networkRegister(void);
3e5111
 int networkAllocateActualDevice(virDomainDefPtr dom,
3e5111
                                 virDomainNetDefPtr iface)
3e5111
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3e5111
-int networkNotifyActualDevice(virDomainDefPtr dom,
3e5111
-                              virDomainNetDefPtr iface)
3e5111
+void networkNotifyActualDevice(virDomainDefPtr dom,
3e5111
+                               virDomainNetDefPtr iface)
3e5111
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
3e5111
 int networkReleaseActualDevice(virDomainDefPtr dom,
3e5111
                                virDomainNetDefPtr iface)
3e5111
@@ -72,11 +72,10 @@ int networkBandwidthUpdate(virDomainNetDefPtr iface,
3e5111
 #  define networkDnsmasqConfContents(network, pidfile, configstr, \
3e5111
                     dctx, caps) 0
3e5111
 
3e5111
-static inline int
3e5111
+static inline void
3e5111
 networkNotifyActualDevice(virDomainDefPtr dom ATTRIBUTE_UNUSED,
3e5111
                           virDomainNetDefPtr iface ATTRIBUTE_UNUSED)
3e5111
 {
3e5111
-    return 0;
3e5111
 }
3e5111
 
3e5111
 static inline int
3e5111
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
3e5111
index a33ec87e6..df5ba575a 100644
3e5111
--- a/src/qemu/qemu_process.c
3e5111
+++ b/src/qemu/qemu_process.c
3e5111
@@ -2825,7 +2825,7 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver,
3e5111
 
3e5111
 
3e5111
 
3e5111
-static int
3e5111
+static void
3e5111
 qemuProcessNotifyNets(virDomainDefPtr def)
3e5111
 {
3e5111
     size_t i;
3e5111
@@ -2840,10 +2840,8 @@ qemuProcessNotifyNets(virDomainDefPtr def)
3e5111
         if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT)
3e5111
            ignore_value(virNetDevMacVLanReserveName(net->ifname, false));
3e5111
 
3e5111
-        if (networkNotifyActualDevice(def, net) < 0)
3e5111
-            return -1;
3e5111
+        networkNotifyActualDevice(def, net);
3e5111
     }
3e5111
-    return 0;
3e5111
 }
3e5111
 
3e5111
 static int
3e5111
@@ -3480,8 +3478,7 @@ qemuProcessReconnect(void *opaque)
3e5111
     if (qemuSecurityReserveLabel(driver->securityManager, obj->def, obj->pid) < 0)
3e5111
         goto error;
3e5111
 
3e5111
-    if (qemuProcessNotifyNets(obj->def) < 0)
3e5111
-        goto error;
3e5111
+    qemuProcessNotifyNets(obj->def);
3e5111
 
3e5111
     if (qemuProcessFiltersInstantiate(obj->def))
3e5111
         goto error;
3e5111
-- 
3e5111
2.12.2
3e5111