提交 cb182eb1 编写于 作者: L Laine Stump

qemu: don't kill qemu process on restart if networkNotify fails

Nothing that could happen during networkNotifyActualDevice() could
justify unceremoniously killing the qemu process, but that's what we
were doing.

In particular, new code added in commit 85bcc022 (first appearred in
libvirt-3.2.0) attempts to reattach tap devices to their assigned
bridge devices when libvirtd restarts (to make it easier to recover
from a restart of a libvirt network). But if the network has been
stopped and *not* restarted, the bridge device won't exist and
networkNotifyActualDevice() will fail.

This patch changes networkNotifyActualDevice() and
qemuProcessNotifyNets() to return void, so that qemuProcessReconnect()
will soldier on regardless of what happens (any errors will still be
logged though).

Partially resolves: https://bugzilla.redhat.com/1442700
上级 2b7d5164
...@@ -4649,9 +4649,9 @@ networkAllocateActualDevice(virDomainDefPtr dom, ...@@ -4649,9 +4649,9 @@ networkAllocateActualDevice(virDomainDefPtr dom,
* order, or re-attach the interface's tap device to the network's * order, or re-attach the interface's tap device to the network's
* bridge. * bridge.
* *
* Returns 0 on success, -1 on failure. * No return value (but does log any failures)
*/ */
int void
networkNotifyActualDevice(virDomainDefPtr dom, networkNotifyActualDevice(virDomainDefPtr dom,
virDomainNetDefPtr iface) virDomainNetDefPtr iface)
{ {
...@@ -4661,11 +4661,10 @@ networkNotifyActualDevice(virDomainDefPtr dom, ...@@ -4661,11 +4661,10 @@ networkNotifyActualDevice(virDomainDefPtr dom,
virNetworkDefPtr netdef; virNetworkDefPtr netdef;
virNetworkForwardIfDefPtr dev = NULL; virNetworkForwardIfDefPtr dev = NULL;
size_t i; size_t i;
int ret = -1;
char *master = NULL; char *master = NULL;
if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK) if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK)
return 0; return;
network = virNetworkObjFindByName(driver->networks, iface->data.network.name); network = virNetworkObjFindByName(driver->networks, iface->data.network.name);
if (!network) { if (!network) {
...@@ -4841,11 +4840,10 @@ networkNotifyActualDevice(virDomainDefPtr dom, ...@@ -4841,11 +4840,10 @@ networkNotifyActualDevice(virDomainDefPtr dom,
} }
networkLogAllocation(netdef, actualType, dev, iface, true); networkLogAllocation(netdef, actualType, dev, iface, true);
ret = 0;
cleanup: cleanup:
virNetworkObjEndAPI(&network); virNetworkObjEndAPI(&network);
VIR_FREE(master); VIR_FREE(master);
return ret; return;
error: error:
goto cleanup; goto cleanup;
......
...@@ -37,8 +37,8 @@ int networkRegister(void); ...@@ -37,8 +37,8 @@ int networkRegister(void);
int networkAllocateActualDevice(virDomainDefPtr dom, int networkAllocateActualDevice(virDomainDefPtr dom,
virDomainNetDefPtr iface) virDomainNetDefPtr iface)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int networkNotifyActualDevice(virDomainDefPtr dom, void networkNotifyActualDevice(virDomainDefPtr dom,
virDomainNetDefPtr iface) virDomainNetDefPtr iface)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int networkReleaseActualDevice(virDomainDefPtr dom, int networkReleaseActualDevice(virDomainDefPtr dom,
virDomainNetDefPtr iface) virDomainNetDefPtr iface)
...@@ -72,11 +72,10 @@ int networkBandwidthUpdate(virDomainNetDefPtr iface, ...@@ -72,11 +72,10 @@ int networkBandwidthUpdate(virDomainNetDefPtr iface,
# define networkDnsmasqConfContents(network, pidfile, configstr, \ # define networkDnsmasqConfContents(network, pidfile, configstr, \
dctx, caps) 0 dctx, caps) 0
static inline int static inline void
networkNotifyActualDevice(virDomainDefPtr dom ATTRIBUTE_UNUSED, networkNotifyActualDevice(virDomainDefPtr dom ATTRIBUTE_UNUSED,
virDomainNetDefPtr iface ATTRIBUTE_UNUSED) virDomainNetDefPtr iface ATTRIBUTE_UNUSED)
{ {
return 0;
} }
static inline int static inline int
......
...@@ -2825,7 +2825,7 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver, ...@@ -2825,7 +2825,7 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver,
static int static void
qemuProcessNotifyNets(virDomainDefPtr def) qemuProcessNotifyNets(virDomainDefPtr def)
{ {
size_t i; size_t i;
...@@ -2840,10 +2840,8 @@ qemuProcessNotifyNets(virDomainDefPtr def) ...@@ -2840,10 +2840,8 @@ qemuProcessNotifyNets(virDomainDefPtr def)
if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT)
ignore_value(virNetDevMacVLanReserveName(net->ifname, false)); ignore_value(virNetDevMacVLanReserveName(net->ifname, false));
if (networkNotifyActualDevice(def, net) < 0) networkNotifyActualDevice(def, net);
return -1;
} }
return 0;
} }
static int static int
...@@ -3480,8 +3478,7 @@ qemuProcessReconnect(void *opaque) ...@@ -3480,8 +3478,7 @@ qemuProcessReconnect(void *opaque)
if (qemuSecurityReserveLabel(driver->securityManager, obj->def, obj->pid) < 0) if (qemuSecurityReserveLabel(driver->securityManager, obj->def, obj->pid) < 0)
goto error; goto error;
if (qemuProcessNotifyNets(obj->def) < 0) qemuProcessNotifyNets(obj->def);
goto error;
if (qemuProcessFiltersInstantiate(obj->def)) if (qemuProcessFiltersInstantiate(obj->def))
goto error; goto error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册