qemu: command: move qemuBuildPMCommandLine validation to qemu_domain.c

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.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Daniel Henrique Barboza 2019-12-09 20:15:22 -03:00 committed by Cole Robinson
parent e8b2fc077d
commit 3b32de2297
5 changed files with 54 additions and 19 deletions

View File

@ -6296,13 +6296,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",
@ -6313,13 +6308,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",

View File

@ -5463,6 +5463,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)
@ -5579,6 +5611,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 */

View File

@ -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;

View File

@ -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);

View File

@ -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);
@ -494,7 +496,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);
@ -525,7 +529,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);
@ -1274,7 +1280,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,