]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: monitor: Ensure that qemuMonitorSetLink is called with non-null name
authorPeter Krempa <pkrempa@redhat.com>
Tue, 14 Apr 2015 13:26:36 +0000 (15:26 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 15 Apr 2015 11:58:26 +0000 (13:58 +0200)
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_process.c

index 6a6ccf932cacf34cee81c792dc4e3fe1bedc5210..b49ed3da266a92b218ebbb5ef22c9f026ef8d390 100644 (file)
@@ -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;
     }
 
index d673154f82dc067f73c4e02924d0ed450d2d07dc..999af10d5e0ad4396c95bb1ceb5ec1a9c341e8df 100644 (file)
@@ -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);
index d9611c9ac7549bde25e455ce78164d39d16c3463..276837e505eef974a06b01a5e1c8318a3d804293 100644 (file)
@@ -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)) {