Move the PM validation being done by qemuBuildPMCommandLine() to
to a new qemuDomainDefValidatePM() function. This new function
is called by qemuDomainDefValidate(), promoting PM validation in
domain define time.
Tests were adapted to consider the new caps being needed in
this earlier stage.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_command.c | 14 ++------------
src/qemu/qemu_domain.c | 35 +++++++++++++++++++++++++++++++++++
tests/qemuhotplugtest.c | 2 ++
tests/qemuxml2argvtest.c | 2 +-
tests/qemuxml2xmltest.c | 20 ++++++++++++++------
5 files changed, 54 insertions(+), 19 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 13abee9a42..5c29ec897b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6253,13 +6253,8 @@ qemuBuildPMCommandLine(virCommandPtr cmd,
const char *pm_object = "PIIX4_PM";
if (qemuDomainIsQ35(def) &&
- virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_DISABLE_S3)) {
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_DISABLE_S3))
pm_object = "ICH9-LPC";
- } else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX_DISABLE_S3)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- "%s", _("setting ACPI S3 not
supported"));
- return -1;
- }
virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "%s.disable_s3=%d",
@@ -6270,13 +6265,8 @@ qemuBuildPMCommandLine(virCommandPtr cmd,
const char *pm_object = "PIIX4_PM";
if (qemuDomainIsQ35(def) &&
- virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_DISABLE_S4)) {
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_DISABLE_S4))
pm_object = "ICH9-LPC";
- } else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX_DISABLE_S4)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- "%s", _("setting ACPI S4 not
supported"));
- return -1;
- }
virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "%s.disable_s4=%d",
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 4715976b1b..a87f283f19 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5417,6 +5417,38 @@ qemuDomainDefValidateClockTimers(const virDomainDef *def,
}
+static int
+qemuDomainDefValidatePM(const virDomainDef *def,
+ virQEMUCapsPtr qemuCaps)
+{
+ bool q35Dom = qemuDomainIsQ35(def);
+
+ if (def->pm.s3) {
+ bool q35ICH9_S3 = q35Dom &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_DISABLE_S3);
+
+ if (!q35ICH9_S3 && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX_DISABLE_S3))
{
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s", _("setting ACPI S3 not
supported"));
+ return -1;
+ }
+ }
+
+ if (def->pm.s4) {
+ bool q35ICH9_S4 = q35Dom &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_DISABLE_S4);
+
+ if (!q35ICH9_S4 && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX_DISABLE_S4))
{
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s", _("setting ACPI S4 not
supported"));
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
static int
qemuDomainDefValidate(const virDomainDef *def,
void *opaque)
@@ -5512,6 +5544,9 @@ qemuDomainDefValidate(const virDomainDef *def,
if (qemuDomainDefValidateClockTimers(def, qemuCaps) < 0)
goto cleanup;
+ if (qemuDomainDefValidatePM(def, qemuCaps) < 0)
+ 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 */
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 8e7273b673..0645b936d0 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -82,6 +82,8 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_QXL);
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_VGA);
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA);
+ virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_PIIX_DISABLE_S3);
+ virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_PIIX_DISABLE_S4);
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, priv->qemuCaps) < 0)
return -1;
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 8a5524c3fb..6f6585ba71 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1279,7 +1279,7 @@ mymain(void)
DO_TEST("misc-disable-s3", QEMU_CAPS_PIIX_DISABLE_S3);
DO_TEST("misc-disable-suspends", QEMU_CAPS_PIIX_DISABLE_S3,
QEMU_CAPS_PIIX_DISABLE_S4);
DO_TEST("misc-enable-s4", QEMU_CAPS_PIIX_DISABLE_S4);
- DO_TEST_FAILURE("misc-enable-s4", NONE);
+ DO_TEST_PARSE_ERROR("misc-enable-s4", NONE);
DO_TEST("misc-no-reboot", NONE);
DO_TEST("misc-uuid", NONE);
DO_TEST_PARSE_ERROR("vhost_queues-invalid", NONE);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 0fa8582dd5..29d3a31e9f 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -386,9 +386,11 @@ mymain(void)
DO_TEST("input-usbmouse", NONE);
DO_TEST("input-usbtablet", NONE);
DO_TEST("misc-acpi", NONE);
- DO_TEST("misc-disable-s3", NONE);
- DO_TEST("misc-disable-suspends", NONE);
- DO_TEST("misc-enable-s4", NONE);
+ DO_TEST("misc-disable-s3", QEMU_CAPS_PIIX_DISABLE_S3);
+ DO_TEST("misc-disable-suspends",
+ QEMU_CAPS_PIIX_DISABLE_S3,
+ QEMU_CAPS_PIIX_DISABLE_S4);
+ DO_TEST("misc-enable-s4", QEMU_CAPS_PIIX_DISABLE_S4);
DO_TEST("misc-no-reboot", NONE);
DO_TEST("misc-uuid", NONE);
DO_TEST("net-vhostuser", NONE);
@@ -499,7 +501,9 @@ mymain(void)
DO_TEST("vhost_queues", NONE);
DO_TEST("interface-driver", NONE);
DO_TEST("interface-server", QEMU_CAPS_DEVICE_CIRRUS_VGA,
- QEMU_CAPS_OBJECT_MEMORY_FILE);
+ QEMU_CAPS_OBJECT_MEMORY_FILE,
+ QEMU_CAPS_PIIX_DISABLE_S3,
+ QEMU_CAPS_PIIX_DISABLE_S4);
DO_TEST("virtio-lun", NONE);
DO_TEST("usb-none", NONE);
@@ -530,7 +534,9 @@ mymain(void)
DO_TEST("blkdeviotune-max", NONE);
DO_TEST("blkdeviotune-group-num", NONE);
DO_TEST("blkdeviotune-max-length", NONE);
- DO_TEST("controller-usb-order", NONE);
+ DO_TEST("controller-usb-order",
+ QEMU_CAPS_PIIX_DISABLE_S3,
+ QEMU_CAPS_PIIX_DISABLE_S4);
DO_TEST_FULL("seclabel-dynamic-baselabel", WHEN_INACTIVE,
ARG_QEMU_CAPS, NONE);
@@ -1279,7 +1285,9 @@ mymain(void)
DO_TEST("user-aliases",
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_QCOW2_LUKS,
- QEMU_CAPS_OBJECT_MEMORY_FILE);
+ QEMU_CAPS_OBJECT_MEMORY_FILE,
+ QEMU_CAPS_PIIX_DISABLE_S3,
+ QEMU_CAPS_PIIX_DISABLE_S4);
DO_TEST("input-virtio-ccw",
QEMU_CAPS_CCW,
QEMU_CAPS_VIRTIO_KEYBOARD,
--
2.23.0