From: Ján Tomko Date: Tue, 13 Aug 2019 15:21:53 +0000 (+0200) Subject: util: be quiet when pm-is-supported is unavailable X-Git-Tag: v5.7.0-rc1~238 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff9aa7a862b8ba204bf0c0a7268640303b6bf46d;p=thirdparty%2Flibvirt.git util: be quiet when pm-is-supported is unavailable 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 Reviewed-by: Andrea Bolognani --- diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c index b5e253147a..93b0685ca6 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);