From 9f6a5f50aee13575331f79f5d93635f701646eb7 Mon Sep 17 00:00:00 2001 From: Daniel P. Berrange Date: Mon, 11 May 2009 15:14:24 +0000 Subject: [PATCH] Fix QEMU ARGV detection with kvm >= 85 (cherry picked from commit 426f9772b84752b4901b72fd382ff6e28e258efd) Fedora-patch: libvirt-0.6.2-fix-qemu-argv-detection-with-kvm-85.patch --- src/qemu_conf.c | 18 ++++++++++++++---- src/qemu_driver.c | 12 ++---------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/qemu_conf.c b/src/qemu_conf.c index 929fe00..3e7e32d 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -431,18 +431,28 @@ int qemudExtractVersionInfo(const char *qemu, return -1; char *help = NULL; - enum { MAX_HELP_OUTPUT_SIZE = 8192 }; + enum { MAX_HELP_OUTPUT_SIZE = 1024*64 }; int len = virFileReadLimFD(newstdout, MAX_HELP_OUTPUT_SIZE, &help); - if (len < 0) + if (len < 0) { + virReportSystemError(NULL, errno, "%s", + _("Unable to read QEMU help output")); goto cleanup2; + } if (sscanf(help, "QEMU PC emulator version %u.%u.%u (kvm-%u)", &major, &minor, µ, &kvm_version) != 4) kvm_version = 0; - if (!kvm_version && sscanf(help, "QEMU PC emulator version %u.%u.%u", - &major, &minor, µ) != 3) + if (!kvm_version && + sscanf(help, "QEMU PC emulator version %u.%u.%u", + &major, &minor, µ) != 3) { + char *eol = strchr(help, '\n'); + if (eol) *eol = '\0'; + qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _("cannot parse QEMU version number in '%s'"), + help); goto cleanup2; + } version = (major * 1000 * 1000) + (minor * 1000) + micro; diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 4752a64..5ca3d20 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -1379,12 +1379,8 @@ static int qemudStartVMDaemon(virConnectPtr conn, if (qemudExtractVersionInfo(emulator, NULL, - &qemuCmdFlags) < 0) { - qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, - _("Cannot determine QEMU argv syntax %s"), - emulator); + &qemuCmdFlags) < 0) goto cleanup; - } if (qemuPrepareHostDevices(conn, vm->def) < 0) goto cleanup; @@ -3606,12 +3602,8 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn, if (qemudExtractVersionInfo(vm->def->emulator, NULL, - &qemuCmdFlags) < 0) { - qemudReportError(conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, - _("Cannot determine QEMU argv syntax %s"), - vm->def->emulator); + &qemuCmdFlags) < 0) return -1; - } if (qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE) { if (!(devname = qemudDiskDeviceName(conn, newdisk))) -- 1.6.2.5