[PATCH 09/14] Fix check for whether a suspend target is supported

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

hostPMFeatures is a bitmask, but the VIR_NODE_SUSPEND_TARGET
constants are from an enum. Thus the code was checking the
wrong bit values

* src/util/virnodesuspend.c: Fix suspend target checks
---
 src/util/virnodesuspend.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index 4ac0d45..4eb5439 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -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();
-- 
1.7.6.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]