]> xenbits.xensource.com Git - libvirt.git/commitdiff
hotplug: fix char device detach
authorPavel Hrdina <phrdina@redhat.com>
Fri, 31 Oct 2014 13:59:55 +0000 (14:59 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Sat, 1 Nov 2014 15:18:34 +0000 (16:18 +0100)
Hotplugging and hotunplugging char devices is only supported through
'-device' and the check for device capability should be independently.

Coverity also complains about 'tmpChr->info.alias' could be NULL and we
are dereferencing it but it somehow only in this case don't recognize
that the value is set by 'qemuAssignDeviceChrAlias' so it's clearly
false positive. Add sa_assert to make coverity happy.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_hotplug.c

index d3bf392387a0f834146392e787f10e28a1ee807b..13bcd8898f5334607c01e695e50aedae9a80dd6a 100644 (file)
@@ -3713,12 +3713,17 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
         return ret;
     }
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
-        !tmpChr->info.alias) {
-        if (qemuAssignDeviceChrAlias(vmdef, tmpChr, -1) < 0)
-            return ret;
+    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("qemu does not support -device"));
+        return ret;
     }
 
+    if (!tmpChr->info.alias && qemuAssignDeviceChrAlias(vmdef, tmpChr, -1) < 0)
+        return ret;
+
+    sa_assert(tmpChr->info.alias);
+
     if (qemuBuildChrDeviceStr(&devstr, vm->def, chr, priv->qemuCaps) < 0)
         return ret;