]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: be quiet when pm-is-supported is unavailable
authorJán Tomko <jtomko@redhat.com>
Tue, 13 Aug 2019 15:21:53 +0000 (17:21 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 14 Aug 2019 09:27:38 +0000 (11:27 +0200)
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@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
src/util/virnodesuspend.c

index b5e253147ab290594b9b0a69fce1cc95dba3105b..93b0685ca6b0fd4de151f2dd1cc01174be335046 100644 (file)
@@ -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);