[PATCH 14/33] qemu: Add missing error handling

Andrea Bolognani posted 33 patches 8 months, 2 weeks ago
There is a newer version of this series
[PATCH 14/33] qemu: Add missing error handling
Posted by Andrea Bolognani 8 months, 2 weeks ago
qemuDomainGetSCSIControllerModel() can return -1 on failure,
but qemuDomainFindOrCreateSCSIDiskController() didn't implement
any handling for this scenario.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 src/qemu/qemu_hotplug.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 0e45bd53e1..afb720fc0b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -881,6 +881,11 @@ qemuDomainFindOrCreateSCSIDiskController(virDomainObj *vm,
     else
         cont->model = model;
 
+    if (cont->model < 0) {
+        VIR_FREE(cont);
+        return NULL;
+    }
+
     VIR_INFO("No SCSI controller present, hotplugging one model=%s",
              virDomainControllerModelSCSITypeToString(cont->model));
     if (qemuDomainAttachControllerDevice(vm, cont) < 0) {
-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH 14/33] qemu: Add missing error handling
Posted by Peter Krempa 8 months, 2 weeks ago
On Wed, Jan 24, 2024 at 20:37:34 +0100, Andrea Bolognani wrote:
> qemuDomainGetSCSIControllerModel() can return -1 on failure,
> but qemuDomainFindOrCreateSCSIDiskController() didn't implement
> any handling for this scenario.
> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  src/qemu/qemu_hotplug.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 0e45bd53e1..afb720fc0b 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -881,6 +881,11 @@ qemuDomainFindOrCreateSCSIDiskController(virDomainObj *vm,
>      else
>          cont->model = model;
>  
> +    if (cont->model < 0) {
> +        VIR_FREE(cont);
> +        return NULL;
> +    }
> +
>      VIR_INFO("No SCSI controller present, hotplugging one model=%s",
>               virDomainControllerModelSCSITypeToString(cont->model));

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org