[libvirt] [PATCH 3/3] util: be quiet when pm-is-supported is unavailable

Ján Tomko jtomko at redhat.com
Tue Aug 13 15:24:26 UTC 2019


Look up the binary name upfront to avoid the error:
Cannot find 'pm-is-supported' in path: No such file or directory

In that case, we just assume nodesuspend is not available.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/util/virnodesuspend.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index 62e62bb171..fea2ebcd76 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -29,6 +29,7 @@
 #include "datatypes.h"
 
 #include "viralloc.h"
+#include "virfile.h"
 #include "virlog.h"
 #include "virerror.h"
 
@@ -239,11 +240,15 @@ static int
 virNodeSuspendSupportsTargetPMUtils(unsigned int target, bool *supported)
 {
     VIR_AUTOPTR(virCommand) cmd = NULL;
-    const char *binary = "pm-is-supported";
+    VIR_AUTOFREE(char *) binary = NULL;
     int status;
 
     *supported = false;
 
+    binary = virFindFileInPath("pm-is-supported");
+    if (!binary)
+        return -2;
+
     switch (target) {
     case VIR_NODE_SUSPEND_TARGET_MEM:
         cmd = virCommandNewArgList(binary, "--suspend", NULL);
-- 
2.19.2




More information about the libvir-list mailing list