From: Lin Ma <lma(a)suse.com>
Move the IDE controller check from command line building to
controller def validation.
Cause the IDE case for command line building to generate a
failure if called to add an IDE since that shouldn't happen
if the Validate code did the right thing.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/qemu/qemu_command.c | 16 ----------------
src/qemu/qemu_domain.c | 27 ++++++++++++++++++++++++++-
2 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 15d9209c6..8af30a8ca 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3120,22 +3120,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;
-
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 1fc360af9..d2412154a 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3959,10 +3959,32 @@ qemuDomainDeviceDefSkipController(const virDomainControllerDef
*controller,
static int
+qemuDomainDeviceDefValidateControllerIDE(const virDomainDef *def)
+{
+ /* 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, "%s",
+ _("IDE controllers are unsupported for "
+ "this QEMU binary or machine type"));
+ return -1;
+}
+
+
+static int
qemuDomainDeviceDefValidateController(const virDomainControllerDef *controller,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
{
+ int ret = 0;
unsigned int flags = 0;
if (qemuDomainDeviceDefSkipController(controller, def, &flags))
@@ -3977,6 +3999,9 @@ qemuDomainDeviceDefValidateController(const virDomainControllerDef
*controller,
switch ((virDomainControllerType) controller->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
+ ret = qemuDomainDeviceDefValidateControllerIDE(def);
+ break;
+
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
case VIR_DOMAIN_CONTROLLER_TYPE_SATA:
@@ -3988,7 +4013,7 @@ qemuDomainDeviceDefValidateController(const virDomainControllerDef
*controller,
break;
}
- return 0;
+ return ret;
}
--
2.13.6