From: Peter Krempa Date: Tue, 14 Apr 2015 13:26:36 +0000 (+0200) Subject: qemu: monitor: Ensure that qemuMonitorSetLink is called with non-null name X-Git-Tag: v1.2.15-rc1~162 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee591240c2074ab905a4f9bf0db2bb40fc10bc85;p=thirdparty%2Flibvirt.git qemu: monitor: Ensure that qemuMonitorSetLink is called with non-null name --- diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 6a6ccf932c..b49ed3da26 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1672,11 +1672,11 @@ qemuMonitorSetLink(qemuMonitorPtr mon, virDomainNetInterfaceLinkState state) { int ret; - VIR_DEBUG("mon=%p, name=%p:%s, state=%u", mon, name, name, state); + VIR_DEBUG("mon=%p, name=%s, state=%u", mon, name, state); - if (!mon || !name) { + if (!mon) { virReportError(VIR_ERR_INVALID_ARG, "%s", - _("monitor || name must not be NULL")); + _("monitor must not be NULL")); return -1; } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index d673154f82..999af10d5e 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -233,7 +233,8 @@ int qemuMonitorSetCapabilities(qemuMonitorPtr mon); int qemuMonitorSetLink(qemuMonitorPtr mon, const char *name, - virDomainNetInterfaceLinkState state); + virDomainNetInterfaceLinkState state) + ATTRIBUTE_NONNULL(2); /* These APIs are for use by the internal Text/JSON monitor impl code only */ char *qemuMonitorNextCommandID(qemuMonitorPtr mon); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d9611c9ac7..276837e505 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2355,6 +2355,12 @@ qemuProcessSetLinkStates(virDomainObjPtr vm) for (i = 0; i < def->nnets; i++) { if (def->nets[i]->linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) { + if (!def->nets[i]->info.alias) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing alias for network device")); + return -1; + } + VIR_DEBUG("Setting link state: %s", def->nets[i]->info.alias); if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {