]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Fix values of PM target type constants
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 29 Nov 2011 13:58:32 +0000 (13:58 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 30 Nov 2011 10:12:29 +0000 (10:12 +0000)
The VIR_NODE_SUSPEND_TARGET constants are not flags, so they
should just be assigned straightforward incrementing values.

* include/libvirt/libvirt.h.in: Change VIR_NODE_SUSPEND_TARGET
  values
* src/util/virnodesuspend.c: Fix suspend target checks

include/libvirt/libvirt.h.in
src/util/virnodesuspend.c

index 1b10dc79017237a05822e4e0949a5fdfb7d98519..d01d1bc5fa8d5d879772784185447d176b2d04bc 100644 (file)
@@ -257,9 +257,12 @@ typedef enum {
  * transitioned to.
  */
 typedef enum {
-    VIR_NODE_SUSPEND_TARGET_MEM     = (1 << 0),
-    VIR_NODE_SUSPEND_TARGET_DISK    = (1 << 1),
-    VIR_NODE_SUSPEND_TARGET_HYBRID  = (1 << 2),
+    VIR_NODE_SUSPEND_TARGET_MEM     = 0,
+    VIR_NODE_SUSPEND_TARGET_DISK    = 1,
+    VIR_NODE_SUSPEND_TARGET_HYBRID  = 2,
+
+    /* This constant is subject to change */
+    VIR_NODE_SUSPEND_TARGET_LAST,
 } virNodeSuspendTarget;
 
 /**
index 01feaa2b883ad89e0de8a702bda0523e642d0994..8a5a2c7d68148dea6353ec9fd6df56c351eee130 100644 (file)
@@ -213,7 +213,7 @@ int nodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED,
     /* Check if the host supports the requested suspend target */
     switch (target) {
     case VIR_NODE_SUSPEND_TARGET_MEM:
-        if (hostPMFeatures & VIR_NODE_SUSPEND_TARGET_MEM) {
+        if (hostPMFeatures & (1 << VIR_NODE_SUSPEND_TARGET_MEM)) {
             cmdString = strdup("pm-suspend");
             if (cmdString == NULL) {
                 virReportOOMError();
@@ -225,7 +225,7 @@ int nodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED,
         goto cleanup;
 
     case VIR_NODE_SUSPEND_TARGET_DISK:
-        if (hostPMFeatures & VIR_NODE_SUSPEND_TARGET_DISK) {
+        if (hostPMFeatures & (1 << VIR_NODE_SUSPEND_TARGET_DISK)) {
             cmdString = strdup("pm-hibernate");
             if (cmdString == NULL) {
                 virReportOOMError();
@@ -237,7 +237,7 @@ int nodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED,
         goto cleanup;
 
     case VIR_NODE_SUSPEND_TARGET_HYBRID:
-        if (hostPMFeatures & VIR_NODE_SUSPEND_TARGET_HYBRID) {
+        if (hostPMFeatures & (1 << VIR_NODE_SUSPEND_TARGET_HYBRID)) {
             cmdString = strdup("pm-suspend-hybrid");
             if (cmdString == NULL) {
                 virReportOOMError();