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-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=ee591240c2074ab905a4f9bf0db2bb40fc10bc85;p=people%2Fliuw%2Flibxenctrl-split%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 6a6ccf932..b49ed3da2 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 d673154f8..999af10d5 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 d9611c9ac..276837e50 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)) {