Move QEMU caps validation of qemuBuildSgaCommandLine() to
qemuDomainDefValidate(), allowing validation at domain define
time.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_command.c | 18 +++---------------
src/qemu/qemu_domain.c | 14 ++++++++++++++
2 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1bbd69b891..fe5333efdf 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6025,23 +6025,11 @@ qemuBuildVMGenIDCommandLine(virCommandPtr cmd,
static int
qemuBuildSgaCommandLine(virCommandPtr cmd,
- const virDomainDef *def,
- virQEMUCapsPtr qemuCaps)
+ const virDomainDef *def)
{
/* Serial graphics adapter */
- if (def->os.bios.useserial == VIR_TRISTATE_BOOL_YES) {
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SGA)) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("qemu does not support SGA"));
- return -1;
- }
- if (!def->nserials) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("need at least one serial port to use SGA"));
- return -1;
- }
+ if (def->os.bios.useserial == VIR_TRISTATE_BOOL_YES)
virCommandAddArgList(cmd, "-device", "sga", NULL);
- }
return 0;
}
@@ -10039,7 +10027,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
virCommandAddArg(cmd, "-no-user-config");
virCommandAddArg(cmd, "-nodefaults");
- if (qemuBuildSgaCommandLine(cmd, def, qemuCaps) < 0)
+ if (qemuBuildSgaCommandLine(cmd, def) < 0)
return NULL;
if (qemuBuildMonitorCommandLine(logManager, secManager, cmd, cfg, def, priv) < 0)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e3ffa4978b..94bb4e4fca 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5398,6 +5398,20 @@ qemuDomainDefValidate(const virDomainDef *def,
goto cleanup;
}
+ /* Serial graphics adapter */
+ if (def->os.bios.useserial == VIR_TRISTATE_BOOL_YES) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SGA)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("qemu does not support SGA"));
+ goto cleanup;
+ }
+ if (!def->nserials) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("need at least one serial port to use SGA"));
+ goto cleanup;
+ }
+ }
+
/* QEMU 2.7 (detected via the availability of query-hotpluggable-cpus)
* enforces stricter rules than previous versions when it comes to guest
* CPU topology. Verify known constraints are respected */
--
2.23.0