From bf6a3825b5c4feb198881fbc3413a1e34ea298a4 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 2 Feb 2011 12:35:31 +0000 Subject: [PATCH] Add check for binary existing in machine type probe When probing machine types if the QEMU binary does not exist we get a hard to diagnose error, due to the execve() in the child failing error: internal error Child process exited with status 1. Add an explicit check so that we get error: Cannot find QEMU binary /usr/libexec/qem3u-kvm: No such file or directory * src/qemu/qemu_capabilities.c: Check for QEMU binary --- src/qemu/qemu_capabilities.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 0e1f79cd20..4504b7e9f1 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -172,6 +172,15 @@ qemuCapsProbeMachineTypes(const char *binary, int ret = -1; virCommandPtr cmd; + /* Make sure the binary we are about to try exec'ing exists. + * Technically we could catch the exec() failure, but that's + * in a sub-process so it's hard to feed back a useful error. + */ + if (access(binary, X_OK) < 0) { + virReportSystemError(errno, _("Cannot find QEMU binary %s"), binary); + return -1; + } + cmd = virCommandNewArgList(binary, "-M", "?", NULL); virCommandAddEnvPassCommon(cmd); virCommandSetOutputBuffer(cmd, &output);