[PATCH v2 03/17] qemu: Move error reporting out of qemuDomainDefaultSCSIControllerModel()

Andrea Bolognani posted 17 patches 11 months ago
[PATCH v2 03/17] qemu: Move error reporting out of qemuDomainDefaultSCSIControllerModel()
Posted by Andrea Bolognani 11 months ago
We want this helper to work more like other similar ones, where
error reporting is performed by the caller. This introduces a
small amount of code duplication but makes for a cleaner API.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 src/qemu/qemu_domain.c  | 9 +++++----
 src/qemu/qemu_hotplug.c | 3 +++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 01f4ed6917..22e6b9fd3e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4125,9 +4125,6 @@ qemuDomainDefaultSCSIControllerModel(const virDomainDef *def,
     if (qemuDomainHasBuiltinESP(def))
         return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_NCR53C90;
 
-    virReportError(VIR_ERR_INTERNAL_ERROR,
-                   _("Unable to determine model for SCSI controller idx=%1$d"),
-                   cont->idx);
     return -1;
 }
 
@@ -5616,8 +5613,12 @@ qemuDomainControllerDefPostParse(virDomainControllerDef *cont,
         /* Set the default SCSI controller model if not already set */
         cont->model = qemuDomainDefaultSCSIControllerModel(def, cont, qemuCaps);
 
-        if (cont->model < 0)
+        if (cont->model < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("Unable to determine model for SCSI controller idx=%1$d"),
+                           cont->idx);
             return -1;
+        }
         break;
 
     case VIR_DOMAIN_CONTROLLER_TYPE_USB:
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index a2498e793a..a9dbc37915 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -883,6 +883,9 @@ qemuDomainFindOrCreateSCSIDiskController(virDomainObj *vm,
         cont->model = model;
 
     if (cont->model < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Unable to determine model for SCSI controller idx=%1$d"),
+                       cont->idx);
         VIR_FREE(cont);
         return NULL;
     }
-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH v2 03/17] qemu: Move error reporting out of qemuDomainDefaultSCSIControllerModel()
Posted by Peter Krempa 11 months ago
On Wed, Feb 14, 2024 at 18:11:10 +0100, Andrea Bolognani wrote:
> We want this helper to work more like other similar ones, where
> error reporting is performed by the caller. This introduces a
> small amount of code duplication but makes for a cleaner API.
> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  src/qemu/qemu_domain.c  | 9 +++++----
>  src/qemu/qemu_hotplug.c | 3 +++
>  2 files changed, 8 insertions(+), 4 deletions(-)

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