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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux