qrap: Fix qemu name-guessing loop, add /usr/libexec/qemu-kvm as full path too

The name-guessing loop should iterate over names, not single
characters. Also add /usr/libexec/qemu-kvm as full path for
execvp(): execvp() won't find it if it's not in $PATH, which
is the reason why it shouldn't be under /usr/libexec/, but this
seems to be the case for some current version of Fedora.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2021-05-10 14:00:30 +02:00
parent 0328e2a1f7
commit f98e3589b4

9
qrap.c
View file

@ -33,6 +33,7 @@ static char *qemu_names[] = {
#ifdef ARCH #ifdef ARCH
"qemu-system-" ARCH, "qemu-system-" ARCH,
#endif #endif
"/usr/libexec/qemu-kvm",
NULL, NULL,
}; };
@ -135,11 +136,11 @@ valid_args:
close(s); close(s);
if (qemu_argc) { if (qemu_argc) {
char *name; char **name;
for (name = qemu_names[0]; name; name++) { for (name = qemu_names; *name; name++) {
qemu_argv[0] = name; qemu_argv[0] = *name;
execvp(name, qemu_argv); execvp(*name, qemu_argv);
if (errno != ENOENT) { if (errno != ENOENT) {
perror("execvp"); perror("execvp");
usage(argv[0]); usage(argv[0]);