From: Daniel P. Berrange Date: Fri, 30 Nov 2012 13:51:39 +0000 (+0000) Subject: Move reboot/shutdown flags combination check into QEMU driver X-Git-Tag: v1.0.1-rc1~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dff4a753c474b4028e458006d47ca0142fd66000;p=thirdparty%2Flibvirt.git Move reboot/shutdown flags combination check into QEMU driver The fact that only the guest agent, or ACPI flag can be used when requesting reboot/shutdown is merely a limitation of the QEMU driver impl at this time. Thus it should not be in libvirt.c code Signed-off-by: Daniel P. Berrange --- diff --git a/src/libvirt.c b/src/libvirt.c index 955e761ff2..3e654f0eb7 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -3237,7 +3237,9 @@ error: * * If @flags is set to zero, then the hypervisor will choose the * method of shutdown it considers best. To have greater control - * pass exactly one of the virDomainShutdownFlagValues. + * pass one or more of the virDomainShutdownFlagValues. The order + * in which the hypervisor tries each shutdown method is undefined, + * and a hypervisor is not required to support all methods. * * Returns 0 in case of success and -1 in case of failure. */ @@ -3260,14 +3262,6 @@ virDomainShutdownFlags(virDomainPtr domain, unsigned int flags) goto error; } - /* At most one of these two flags should be set. */ - if ((flags & VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN) && - (flags & VIR_DOMAIN_SHUTDOWN_GUEST_AGENT)) { - virReportInvalidArg(flags, "%s", - _("flags for acpi power button and guest agent are mutually exclusive")); - goto error; - } - conn = domain->conn; if (conn->driver->domainShutdownFlags) { @@ -3296,7 +3290,9 @@ error: * * If @flags is set to zero, then the hypervisor will choose the * method of shutdown it considers best. To have greater control - * pass exactly one of the virDomainRebootFlagValues. + * pass one or more of the virDomainShutdownFlagValues. The order + * in which the hypervisor tries each shutdown method is undefined, + * and a hypervisor is not required to support all methods. * * To use guest agent (VIR_DOMAIN_REBOOT_GUEST_AGENT) the domain XML * must have configured. @@ -3322,14 +3318,6 @@ virDomainReboot(virDomainPtr domain, unsigned int flags) goto error; } - /* At most one of these two flags should be set. */ - if ((flags & VIR_DOMAIN_REBOOT_ACPI_POWER_BTN) && - (flags & VIR_DOMAIN_REBOOT_GUEST_AGENT)) { - virReportInvalidArg(flags, "%s", - _("flags for acpi power button and guest agent are mutually exclusive")); - goto error; - } - conn = domain->conn; if (conn->driver->domainReboot) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ae98dbfbe5..8e838cd21c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1814,6 +1814,14 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags) { virCheckFlags(VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN | VIR_DOMAIN_SHUTDOWN_GUEST_AGENT, -1); + /* At most one of these two flags should be set. */ + if ((flags & VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN) && + (flags & VIR_DOMAIN_SHUTDOWN_GUEST_AGENT)) { + virReportInvalidArg(flags, "%s", + _("flags for acpi power button and guest agent are mutually exclusive")); + return -1; + } + qemuDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); qemuDriverUnlock(driver); @@ -1896,6 +1904,14 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags) virCheckFlags(VIR_DOMAIN_REBOOT_ACPI_POWER_BTN | VIR_DOMAIN_REBOOT_GUEST_AGENT , -1); + /* At most one of these two flags should be set. */ + if ((flags & VIR_DOMAIN_REBOOT_ACPI_POWER_BTN) && + (flags & VIR_DOMAIN_REBOOT_GUEST_AGENT)) { + virReportInvalidArg(flags, "%s", + _("flags for acpi power button and guest agent are mutually exclusive")); + return -1; + } + qemuDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); qemuDriverUnlock(driver);