[PATCH v4 3/3] qemu_domain: Error out earlier when configuring IDE controller incorrectly

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

 



Validate IDE controllers in qemuDomainDeviceDefValidate for reminding
users earlier.

Signed-off-by: Lin Ma <lma@xxxxxxxx>
---
 src/qemu/qemu_command.c | 17 -----------------
 src/qemu/qemu_domain.c  | 35 ++++++++++++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6a8da1d58..96e4b8b9e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3123,23 +3123,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
         }
         break;
 
-    case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
-        /* Since we currently only support the integrated IDE
-         * controller on various boards, if we ever get to here, it's
-         * because some other machinetype had an IDE controller
-         * specified, or one with a single IDE contraller had multiple
-         * ide controllers specified.
-         */
-        if (qemuDomainHasBuiltinIDE(domainDef))
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("Only a single IDE controller is supported "
-                             "for this machine type"));
-        else
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("IDE controllers are unsupported for "
-                             "this QEMU binary or machine type"));
-        goto error;
-
     default:
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("Unsupported controller type: %s"),
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e8e03134f..f14cb1720 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3884,6 +3884,36 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk)
 }
 
 
+static int
+qemuDomainControllerDefValidate(const virDomainControllerDef *controller,
+                                const virDomainDef *def)
+{
+    if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE) {
+        /* No need to check implicit/builtin IDE controller */
+        if (controller->idx == 0 && qemuDomainHasBuiltinIDE(def))
+            return 0;
+
+        /* Since we currently only support the integrated IDE
+         * controller on various boards, if we ever get to here, it's
+         * because some other machinetype had an IDE controller
+         * specified, or one with a single IDE controller had multiple
+         * ide controllers specified.
+         */
+        if (qemuDomainHasBuiltinIDE(def))
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("Only a single IDE controller is supported "
+                             "for this machine type"));
+        else
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("IDE controllers are unsupported for "
+                             "this QEMU binary or machine type: %s"),
+                             def->os.machine);
+        return -1;
+    }
+    return 0;
+}
+
+
 static int
 qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
                             const virDomainDef *def,
@@ -3928,11 +3958,14 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
         ret = qemuDomainDeviceDefValidateDisk(dev->data.disk);
         break;
 
+    case VIR_DOMAIN_DEVICE_CONTROLLER:
+        ret = qemuDomainControllerDefValidate(dev->data.controller, def);
+        break;
+
     case VIR_DOMAIN_DEVICE_LEASE:
     case VIR_DOMAIN_DEVICE_FS:
     case VIR_DOMAIN_DEVICE_INPUT:
     case VIR_DOMAIN_DEVICE_SOUND:
-    case VIR_DOMAIN_DEVICE_CONTROLLER:
     case VIR_DOMAIN_DEVICE_GRAPHICS:
     case VIR_DOMAIN_DEVICE_HUB:
     case VIR_DOMAIN_DEVICE_MEMBALLOON:
-- 
2.14.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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