[libvirt] [PATCH] Move reboot/shutdown flags combination check into QEMU driver

From: "Daniel P. Berrange" <berrange@redhat.com> 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 <berrange@redhat.com> --- src/libvirt.c | 16 ---------------- src/qemu/qemu_driver.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 757bfa8..d5310ed 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -3260,14 +3260,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) { @@ -3322,14 +3314,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 c37bdb9..6a8a333 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); -- 1.7.11.7

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 <berrange@redhat.com> --- src/libvirt.c | 16 ---------------- src/qemu/qemu_driver.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-)
ACK.

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 <berrange@redhat.com> --- src/libvirt.c | 16 ---------------- src/qemu/qemu_driver.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-)
ACK.
Problem. Now our virsh command doesn't have full expression of the possible API usage. You need to modify 'virsh shutdown --mode=...' so that --mode can now take a comma-separated list of modes to combine, rather than only being able to select a single mode, if you want to be able to stress-test the full power of the API.

On Fri, Nov 30, 2012 at 09:12:44AM -0500, Eric Blake wrote:
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 <berrange@redhat.com> --- src/libvirt.c | 16 ---------------- src/qemu/qemu_driver.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-)
ACK.
Problem. Now our virsh command doesn't have full expression of the possible API usage. You need to modify 'virsh shutdown --mode=...' so that --mode can now take a comma-separated list of modes to combine, rather than only being able to select a single mode, if you want to be able to stress-test the full power of the API.
Ok, will send another patch todo that too Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (2)
-
Daniel P. Berrange
-
Eric Blake