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
This commit is contained in:
Daniel P. Berrange 2011-02-02 12:35:31 +00:00
parent 2222bd2459
commit bf6a3825b5

View File

@ -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);