Move error handling of IDE controller from qemuBuildControllerDevStr to
qemuDomainDeviceDefValidate for reminding users eariler.
Signed-off-by: Lin Ma <lma(a)suse.com>
---
src/qemu/qemu_command.c | 17 -----------------
src/qemu/qemu_domain.c | 26 ++++++++++++++++++++++++++
2 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b1cfafa79..463952d9b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3106,23 +3106,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 ece8ee7dd..d0be2afaf 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3539,6 +3539,29 @@ qemuDomainWatchdogDefValidate(const virDomainWatchdogDef *dev,
}
+static int
+qemuDomainControllerDefValidate(const virDomainControllerDefPtr controller,
+ const virDomainDef *def)
+{
+ if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE) {
+ if (qemuDomainHasBuiltinIDE(def) && controller->idx != 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Only a single IDE controller is supported "
+ "for this machine type"));
+ return -1;
+ }
+ if (qemuDomainIsQ35(def)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("IDE controllers are unsupported for q35 "
+ "machine type"));
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
static int
qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
const virDomainDef *def,
@@ -3650,6 +3673,9 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
} else if (dev->type == VIR_DOMAIN_DEVICE_WATCHDOG) {
if (qemuDomainWatchdogDefValidate(dev->data.watchdog, def) < 0)
goto cleanup;
+ } else if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER) {
+ if (qemuDomainControllerDefValidate(dev->data.controller, def) < 0)
+ goto cleanup;
}
/* forbid capabilities mode hostdev in this kind of hypervisor */
--
2.14.0