[libvirt] [PATCH 0/3] qemu: Fix few issues from the -blockdev series

All three should appease coverity. Peter Krempa (3): qemu: hotplug: Don't generate alias when detaching controllers qemu: hotplug: Don't leak 'nodename' in qemuDomainChangeMediaBlockdev qemu: monitor: Fix device matching in qemuMonitorJSONBlockIoThrottleInfo src/qemu/qemu_hotplug.c | 6 +----- src/qemu/qemu_monitor_json.c | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) -- 2.16.2

qemuDomainDetachControllerDevice contained code which implied that alias might be NULL when detaching the disk and tried to generate it. This is no longer possible so we can remove the code. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_hotplug.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index bd1942efe7..1a9a9e1a32 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5281,11 +5281,6 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver, goto cleanup; } - if (!detach->info.alias) { - if (qemuAssignDeviceControllerAlias(vm->def, priv->qemuCaps, detach) < 0) - goto cleanup; - } - if (!async) qemuDomainMarkDeviceForRemoval(vm, &detach->info); -- 2.16.2

qemuDomainDiskGetBackendAlias allocates a copy of the nodename string so we need to free it at the end. Found by Coverity. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_hotplug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1a9a9e1a32..0b84a503bb 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -700,6 +700,7 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver, cleanup: qemuHotplugDiskSourceDataFree(newbackend); qemuHotplugDiskSourceDataFree(oldbackend); + VIR_FREE(nodename); /* caller handles correct exchange of sources */ disk->src = oldsrc; return ret; -- 2.16.2

We should compare the alias/qdev id only when it was provided by the caller and when it was found in the reply. Otherwise we could dereference a NULL pointer. STRNEQ_NULLABLE is not appropriate since it would return 'true' if the string was not present in the JSON output. Found by Coverity. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_monitor_json.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 5cd38710e5..ddfa261743 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5001,8 +5001,8 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr io_throttle, goto cleanup; } - if ((drivealias && STRNEQ(current_drive, drivealias)) || - (qdevid && STRNEQ(current_qdev, qdevid))) + if ((drivealias && current_drive && STRNEQ(current_drive, drivealias)) || + (qdevid && current_qdev && STRNEQ(current_qdev, qdevid))) continue; found = true; -- 2.16.2

On 08/22/2018 07:27 AM, Peter Krempa wrote:
All three should appease coverity.
That they do...
Peter Krempa (3): qemu: hotplug: Don't generate alias when detaching controllers qemu: hotplug: Don't leak 'nodename' in qemuDomainChangeMediaBlockdev qemu: monitor: Fix device matching in qemuMonitorJSONBlockIoThrottleInfo
src/qemu/qemu_hotplug.c | 6 +----- src/qemu/qemu_monitor_json.c | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-)
Reviewed-by: John Ferlan <jferlan@redhat.com> John
participants (2)
-
John Ferlan
-
Peter Krempa