提交 dff4a753 编写于 作者: D Daniel P. Berrange

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: NDaniel P. Berrange <berrange@redhat.com>
上级 c4ef575c
...@@ -3237,7 +3237,9 @@ error: ...@@ -3237,7 +3237,9 @@ error:
* *
* If @flags is set to zero, then the hypervisor will choose the * If @flags is set to zero, then the hypervisor will choose the
* method of shutdown it considers best. To have greater control * 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. * Returns 0 in case of success and -1 in case of failure.
*/ */
...@@ -3260,14 +3262,6 @@ virDomainShutdownFlags(virDomainPtr domain, unsigned int flags) ...@@ -3260,14 +3262,6 @@ virDomainShutdownFlags(virDomainPtr domain, unsigned int flags)
goto error; 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; conn = domain->conn;
if (conn->driver->domainShutdownFlags) { if (conn->driver->domainShutdownFlags) {
...@@ -3296,7 +3290,9 @@ error: ...@@ -3296,7 +3290,9 @@ error:
* *
* If @flags is set to zero, then the hypervisor will choose the * If @flags is set to zero, then the hypervisor will choose the
* method of shutdown it considers best. To have greater control * 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 * To use guest agent (VIR_DOMAIN_REBOOT_GUEST_AGENT) the domain XML
* must have <channel> configured. * must have <channel> configured.
...@@ -3322,14 +3318,6 @@ virDomainReboot(virDomainPtr domain, unsigned int flags) ...@@ -3322,14 +3318,6 @@ virDomainReboot(virDomainPtr domain, unsigned int flags)
goto error; 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; conn = domain->conn;
if (conn->driver->domainReboot) { if (conn->driver->domainReboot) {
......
...@@ -1814,6 +1814,14 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags) { ...@@ -1814,6 +1814,14 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags) {
virCheckFlags(VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN | virCheckFlags(VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN |
VIR_DOMAIN_SHUTDOWN_GUEST_AGENT, -1); 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); qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid); vm = virDomainFindByUUID(&driver->domains, dom->uuid);
qemuDriverUnlock(driver); qemuDriverUnlock(driver);
...@@ -1896,6 +1904,14 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags) ...@@ -1896,6 +1904,14 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags)
virCheckFlags(VIR_DOMAIN_REBOOT_ACPI_POWER_BTN | virCheckFlags(VIR_DOMAIN_REBOOT_ACPI_POWER_BTN |
VIR_DOMAIN_REBOOT_GUEST_AGENT , -1); 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); qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid); vm = virDomainFindByUUID(&driver->domains, dom->uuid);
qemuDriverUnlock(driver); qemuDriverUnlock(driver);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册