diff options
author | Pavel Hrdina <phrdina@redhat.com> | 2014-10-31 14:59:55 +0100 |
---|---|---|
committer | Pavel Hrdina <phrdina@redhat.com> | 2014-11-01 16:18:34 +0100 |
commit | e7e05801e5e81bd80ea7dd9f0e0ae37f43ec49ad (patch) | |
tree | e4492083d77a00ed26ab55489f3c1ca4c089233a | |
parent | bddf8561d26e9d3741ec70c431771e4747f87f70 (diff) | |
download | libvirt-e7e05801e5e81bd80ea7dd9f0e0ae37f43ec49ad.tar.gz |
hotplug: fix char device detach
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>
-rw-r--r-- | src/qemu/qemu_hotplug.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d3bf392387..13bcd8898f 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -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; |