[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]