From: Lin Ma <lma(a)suse.com>
Move the IDE controller check from command line building to
controller def validation. Also explicitly include the avoidance
check for the implicit IDE controller from qemuBuildSkipController.
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 | 33 ++++++++++++++++++++++++++++++++-
2 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 894c3f323..2dd50a214 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 8d966156d..076c68c9f 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3893,16 +3893,47 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk)
static int
+qemuDomainDeviceDefValidateControllerIDE(const virDomainControllerDef *controller,
+ const virDomainDef *def)
+{
+ /* first IDE controller is implicit on various machines */
+ 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, "%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;
+
if (!qemuDomainCheckCCWS390AddressSupport(def, controller->info, qemuCaps,
"controller"))
return -1;
switch ((virDomainControllerType) controller->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
+ ret = qemuDomainDeviceDefValidateControllerIDE(controller, def);
+ break;
+
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
case VIR_DOMAIN_CONTROLLER_TYPE_SATA:
@@ -3914,7 +3945,7 @@ qemuDomainDeviceDefValidateController(const virDomainControllerDef
*controller,
break;
}
- return 0;
+ return ret;
}
--
2.13.6