]> xenbits.xensource.com Git - libvirt.git/commitdiff
Move reboot/shutdown flags combination check into QEMU driver
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 30 Nov 2012 13:51:39 +0000 (13:51 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 30 Nov 2012 19:18:27 +0000 (19:18 +0000)
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
src/qemu/qemu_driver.c

index 955e761ff2c829b100666560f7acbe6622e2d8f0..3e654f0eb72f915b15e5b9c3bbf22f53e348c6b4 100644 (file)
@@ -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 <channel> 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) {
index ae98dbfbe5f74dcbf28adc6c72e37e7faae38872..8e838cd21c0bdd7036f71168004abce24984de92 100644 (file)
@@ -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);