From e8eadea9cdc9a12a0199f9895ffffc2b00d12d8e Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Sep 30 2009 14:20:16 +0000 Subject: * Wed Sep 30 2009 Mark McLoughlin - 0.6.2-18 - Fix qemu-kvm version detection so GSO is enabled for virtio_net (#526472) --- diff --git a/libvirt-0.6.2-detect-newer-qemu-kvm-versions.patch b/libvirt-0.6.2-detect-newer-qemu-kvm-versions.patch new file mode 100644 index 0000000..561ae86 --- /dev/null +++ b/libvirt-0.6.2-detect-newer-qemu-kvm-versions.patch @@ -0,0 +1,170 @@ +From fe3cb2edefceacc76d0dc9c98b8d3b677a495c32 Mon Sep 17 00:00:00 2001 +From: Mark McLoughlin +Date: Thu, 11 Jun 2009 14:15:49 +0000 +Subject: [PATCH] Detect newer qemu-kvm versions + +The KVM version string can be one of the following: + + - qemu-kvm-x.y.z in stable releases + - kvm-XX for kvm versions up to kvm-85 + - qemu-kvm-devel-XX for kvm version kvm-86 and later + +There are only a few of places where we need to detect +differences between KVM versions based on 0.9.1: + + 1) VNET_HDR introduced in kvm-74 + + 2) -incoming tcp introduced in kvm-79 + + 3) -incoming exec introduced in kvm-80 + + 4) -incoming stdio in all earlier kvm versions + +With qemu-kvm-0.10.x, we can now assume that (1) is available +if it's a KVM release, (2) and (3) is always available and +(4) is never available. + +So, from now on we should only need to check the qemu version +number and the "is_kvm" flag for detecting feature availability. +We only need the KVM version number for older releases. + +(cherry picked from commit 04cbe687974b3b46c96fa20180bbb07ffeff69da) + +Signed-off-by: Mark McLoughlin +Fedora-patch: libvirt-0.6.2-detect-newer-qemu-kvm-versions.patch +--- + src/qemu_conf.c | 44 +++++++++++++++++++++++++++++++------------- + 1 files changed, 31 insertions(+), 13 deletions(-) + +diff --git a/src/qemu_conf.c b/src/qemu_conf.c +index e488d74..d76b2b6 100644 +--- a/src/qemu_conf.c ++++ b/src/qemu_conf.c +@@ -416,6 +416,7 @@ virCapsPtr qemudCapsInit(void) { + + static unsigned int qemudComputeCmdFlags(const char *help, + unsigned int version, ++ unsigned int is_kvm, + unsigned int kvm_version) + { + unsigned int flags = 0; +@@ -441,7 +442,8 @@ static unsigned int qemudComputeCmdFlags(const char *help, + flags |= QEMUD_CMD_FLAG_DRIVE_BOOT; + if (version >= 9000) + flags |= QEMUD_CMD_FLAG_VNC_COLON; +- if (kvm_version >= 74) ++ ++ if (is_kvm && (version >= 10000 || kvm_version >= 74)) + flags |= QEMUD_CMD_FLAG_VNET_HDR; + + /* +@@ -454,15 +456,15 @@ static unsigned int qemudComputeCmdFlags(const char *help, + * was broken, because it blocked the monitor console + * while waiting for data, so pretend it doesn't exist + */ +- if (kvm_version >= 79) { ++ if (version >= 10000) { ++ flags |= QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP; ++ flags |= QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC; ++ } else if (kvm_version >= 79) { + flags |= QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP; + if (kvm_version >= 80) + flags |= QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC; + } else if (kvm_version > 0) { + flags |= QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO; +- } else if (version >= 10000) { +- flags |= QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP; +- flags |= QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC; + } + + return flags; +@@ -472,10 +474,19 @@ static unsigned int qemudComputeCmdFlags(const char *help, + * version number. The first bit is easy, just parse + * 'QEMU PC emulator version x.y.z'. + * +- * With qemu-kvm, however, that is followed by a kvm-XX +- * string in parenthesis. ++ * With qemu-kvm, however, that is followed by a string ++ * in parenthesis as follows: ++ * - qemu-kvm-x.y.z in stable releases ++ * - kvm-XX for kvm versions up to kvm-85 ++ * - qemu-kvm-devel-XX for kvm version kvm-86 and later ++ * ++ * For qemu-kvm versions before 0.10.z, we need to detect ++ * the KVM version number for some features. With 0.10.z ++ * and later, we just need the QEMU version number and ++ * whether it is KVM QEMU or mainline QEMU. + */ + #define QEMU_VERSION_STR "QEMU PC emulator version" ++#define QEMU_KVM_VER_PREFIX "(qemu-kvm-" + #define KVM_VER_PREFIX "(kvm-" + + #define SKIP_BLANKS(p) do { while ((*(p) == ' ') || (*(p) == '\t')) (p)++; } while (0) +@@ -483,12 +494,13 @@ static unsigned int qemudComputeCmdFlags(const char *help, + static int qemudParseHelpStr(const char *help, + unsigned int *flags, + unsigned int *version, ++ unsigned int *is_kvm, + unsigned int *kvm_version) + { + unsigned major, minor, micro; + const char *p = help; + +- *flags = *version = *kvm_version = 0; ++ *flags = *version = *is_kvm = *kvm_version = 0; + + if (!STRPREFIX(p, QEMU_VERSION_STR)) + goto fail; +@@ -515,9 +527,13 @@ static int qemudParseHelpStr(const char *help, + + SKIP_BLANKS(p); + +- if (STRPREFIX(p, KVM_VER_PREFIX)) { ++ if (STRPREFIX(p, QEMU_KVM_VER_PREFIX)) { ++ *is_kvm = 1; ++ p += strlen(QEMU_KVM_VER_PREFIX); ++ } else if (STRPREFIX(p, KVM_VER_PREFIX)) { + int ret; + ++ *is_kvm = 1; + p += strlen(KVM_VER_PREFIX); + + ret = virParseNumber(&p); +@@ -529,12 +545,14 @@ static int qemudParseHelpStr(const char *help, + + *version = (major * 1000 * 1000) + (minor * 1000) + micro; + +- *flags = qemudComputeCmdFlags(help, *version, *kvm_version); ++ *flags = qemudComputeCmdFlags(help, *version, *is_kvm, *kvm_version); + + qemudDebug("Version %u.%u.%u, cooked version %u, flags %u", + major, minor, micro, *version, *flags); + if (*kvm_version) +- qemudDebug("KVM version %u detected", *kvm_version); ++ qemudDebug("KVM version %d detected", *kvm_version); ++ else if (*is_kvm) ++ qemudDebug("qemu-kvm version %u.%u.%u detected", major, minor, micro); + + return 0; + +@@ -560,7 +578,7 @@ int qemudExtractVersionInfo(const char *qemu, + pid_t child; + int newstdout = -1; + int ret = -1, status; +- unsigned int version, kvm_version; ++ unsigned int version, is_kvm, kvm_version; + unsigned int flags = 0; + + if (retflags) +@@ -581,7 +599,7 @@ int qemudExtractVersionInfo(const char *qemu, + goto cleanup2; + } + +- if (qemudParseHelpStr(help, &flags, &version, &kvm_version) == -1) ++ if (qemudParseHelpStr(help, &flags, &version, &is_kvm, &kvm_version) == -1) + goto cleanup2; + + if (retversion) +-- +1.6.2.5 + diff --git a/libvirt-0.6.2-refactor-qemu-version-parsing.patch b/libvirt-0.6.2-refactor-qemu-version-parsing.patch new file mode 100644 index 0000000..f1706d4 --- /dev/null +++ b/libvirt-0.6.2-refactor-qemu-version-parsing.patch @@ -0,0 +1,224 @@ +From 266df161bfd87220bac68918613a2ce9323c8238 Mon Sep 17 00:00:00 2001 +From: Mark McLoughlin +Date: Thu, 11 Jun 2009 14:12:30 +0000 +Subject: [PATCH] Re-factor qemu version parsing + +This patch is purely re-factoring without any functional changes +to make way for the next patch. + +The main thing achieved by the refactoring is that we now have +easier access to the parenthesised string that KVM folks seem +to delight in changing. + +(cherry picked from commit 56ecebf22dd5a235503028e20bf936229037664b) + +Signed-off-by: Mark McLoughlin +Fedora-patch: libvirt-0.6.2-refactor-qemu-version-parsing.patch +--- + src/qemu_conf.c | 174 +++++++++++++++++++++++++++++++++++++++---------------- + 1 files changed, 123 insertions(+), 51 deletions(-) + +diff --git a/src/qemu_conf.c b/src/qemu_conf.c +index 1194e36..e488d74 100644 +--- a/src/qemu_conf.c ++++ b/src/qemu_conf.c +@@ -414,54 +414,12 @@ virCapsPtr qemudCapsInit(void) { + return NULL; + } + +- +-int qemudExtractVersionInfo(const char *qemu, +- unsigned int *retversion, +- unsigned int *retflags) { +- const char *const qemuarg[] = { qemu, "-help", NULL }; +- const char *const qemuenv[] = { "LC_ALL=C", NULL }; +- pid_t child; +- int newstdout = -1; +- int ret = -1, status; +- unsigned int major, minor, micro; +- unsigned int version, kvm_version; ++static unsigned int qemudComputeCmdFlags(const char *help, ++ unsigned int version, ++ unsigned int kvm_version) ++{ + unsigned int flags = 0; + +- if (retflags) +- *retflags = 0; +- if (retversion) +- *retversion = 0; +- +- if (virExec(NULL, qemuarg, qemuenv, NULL, +- &child, -1, &newstdout, NULL, VIR_EXEC_NONE) < 0) +- return -1; +- +- char *help = NULL; +- enum { MAX_HELP_OUTPUT_SIZE = 1024*64 }; +- int len = virFileReadLimFD(newstdout, MAX_HELP_OUTPUT_SIZE, &help); +- 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) { +- 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; +- + if (strstr(help, "-no-kqemu")) + flags |= QEMUD_CMD_FLAG_KQEMU; + if (strstr(help, "-no-kvm")) +@@ -507,6 +465,125 @@ int qemudExtractVersionInfo(const char *qemu, + flags |= QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC; + } + ++ return flags; ++} ++ ++/* We parse the output of 'qemu -help' to get the QEMU ++ * version number. The first bit is easy, just parse ++ * 'QEMU PC emulator version x.y.z'. ++ * ++ * With qemu-kvm, however, that is followed by a kvm-XX ++ * string in parenthesis. ++ */ ++#define QEMU_VERSION_STR "QEMU PC emulator version" ++#define KVM_VER_PREFIX "(kvm-" ++ ++#define SKIP_BLANKS(p) do { while ((*(p) == ' ') || (*(p) == '\t')) (p)++; } while (0) ++ ++static int qemudParseHelpStr(const char *help, ++ unsigned int *flags, ++ unsigned int *version, ++ unsigned int *kvm_version) ++{ ++ unsigned major, minor, micro; ++ const char *p = help; ++ ++ *flags = *version = *kvm_version = 0; ++ ++ if (!STRPREFIX(p, QEMU_VERSION_STR)) ++ goto fail; ++ ++ p += strlen(QEMU_VERSION_STR); ++ ++ SKIP_BLANKS(p); ++ ++ major = virParseNumber(&p); ++ if (major == -1 || *p != '.') ++ goto fail; ++ ++ ++p; ++ ++ minor = virParseNumber(&p); ++ if (major == -1 || *p != '.') ++ goto fail; ++ ++ ++p; ++ ++ micro = virParseNumber(&p); ++ if (major == -1) ++ goto fail; ++ ++ SKIP_BLANKS(p); ++ ++ if (STRPREFIX(p, KVM_VER_PREFIX)) { ++ int ret; ++ ++ p += strlen(KVM_VER_PREFIX); ++ ++ ret = virParseNumber(&p); ++ if (ret == -1) ++ goto fail; ++ ++ *kvm_version = ret; ++ } ++ ++ *version = (major * 1000 * 1000) + (minor * 1000) + micro; ++ ++ *flags = qemudComputeCmdFlags(help, *version, *kvm_version); ++ ++ qemudDebug("Version %u.%u.%u, cooked version %u, flags %u", ++ major, minor, micro, *version, *flags); ++ if (*kvm_version) ++ qemudDebug("KVM version %u detected", *kvm_version); ++ ++ return 0; ++ ++fail: ++ p = strchr(help, '\n'); ++ if (p) ++ p = strndup(help, p - help); ++ ++ qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, ++ _("cannot parse QEMU version number in '%s'"), ++ p ? p : help); ++ ++ VIR_FREE(p); ++ ++ return -1; ++} ++ ++int qemudExtractVersionInfo(const char *qemu, ++ unsigned int *retversion, ++ unsigned int *retflags) { ++ const char *const qemuarg[] = { qemu, "-help", NULL }; ++ const char *const qemuenv[] = { "LC_ALL=C", NULL }; ++ pid_t child; ++ int newstdout = -1; ++ int ret = -1, status; ++ unsigned int version, kvm_version; ++ unsigned int flags = 0; ++ ++ if (retflags) ++ *retflags = 0; ++ if (retversion) ++ *retversion = 0; ++ ++ if (virExec(NULL, qemuarg, qemuenv, NULL, ++ &child, -1, &newstdout, NULL, VIR_EXEC_NONE) < 0) ++ return -1; ++ ++ char *help = NULL; ++ enum { MAX_HELP_OUTPUT_SIZE = 1024*64 }; ++ int len = virFileReadLimFD(newstdout, MAX_HELP_OUTPUT_SIZE, &help); ++ if (len < 0) { ++ virReportSystemError(NULL, errno, "%s", ++ _("Unable to read QEMU help output")); ++ goto cleanup2; ++ } ++ ++ if (qemudParseHelpStr(help, &flags, &version, &kvm_version) == -1) ++ goto cleanup2; ++ + if (retversion) + *retversion = version; + if (retflags) +@@ -514,11 +591,6 @@ int qemudExtractVersionInfo(const char *qemu, + + ret = 0; + +- qemudDebug("Version %d %d %d Cooked version: %d, with flags ? %d", +- major, minor, micro, version, flags); +- if (kvm_version) +- qemudDebug("KVM version %d detected", kvm_version); +- + cleanup2: + VIR_FREE(help); + if (close(newstdout) < 0) +-- +1.6.2.5 + diff --git a/libvirt-0.6.2-svirt-sound.patch b/libvirt-0.6.2-svirt-sound.patch index fdb9431..7c31d03 100644 --- a/libvirt-0.6.2-svirt-sound.patch +++ b/libvirt-0.6.2-svirt-sound.patch @@ -1,4 +1,4 @@ -From 0d72b6fb7d4aa5e55294eb3222e7156d3d75a9e7 Mon Sep 17 00:00:00 2001 +From 6096cb19d6b05707ca32f52b905c53818ecfc84b Mon Sep 17 00:00:00 2001 From: Daniel P. Berrange Date: Mon, 17 Aug 2009 08:52:30 +0100 Subject: [PATCH] Disable sound cards when running sVirt @@ -12,10 +12,10 @@ Fedora-patch: libvirt-0.6.2-svirt-sound.patch 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/src/qemu_conf.c b/src/qemu_conf.c -index 1194e36..f42aeaa 100644 +index d76b2b6..22c5363 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c -@@ -795,6 +795,20 @@ int qemudBuildCommandLine(virConnectPtr conn, +@@ -885,6 +885,20 @@ int qemudBuildCommandLine(virConnectPtr conn, char domid[50]; char *pidfile; const char *cpu = NULL; @@ -36,7 +36,7 @@ index 1194e36..f42aeaa 100644 uname_normalize(&ut); -@@ -1441,7 +1455,8 @@ int qemudBuildCommandLine(virConnectPtr conn, +@@ -1531,7 +1545,8 @@ int qemudBuildCommandLine(virConnectPtr conn, } /* Add sound hardware */ diff --git a/libvirt.spec b/libvirt.spec index ff67fe0..dc3253d 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -66,7 +66,7 @@ Summary: Library providing a simple API virtualization Name: libvirt Version: 0.6.2 -Release: 17%{?dist}%{?extra_release} +Release: 18%{?dist}%{?extra_release} License: LGPLv2+ Group: Development/Libraries Source: http://libvirt.org/sources/libvirt-%{version}.tar.gz @@ -134,6 +134,9 @@ Patch29: libvirt-allow-pci-hostdev-reset-to-reset-other-devices.patch Patch30: libvirt-fix-migration-completion-with-newer-qemu.patch # Fix dumpxml segfault with newer versions of Xen (#518091) Patch31: libvirt-fix-xen-driver-segfault-with-newer-xen.patch +# Fix qemu-kvm version detection so GSO is enabled +Patch32: libvirt-0.6.2-refactor-qemu-version-parsing.patch +Patch33: libvirt-0.6.2-detect-newer-qemu-kvm-versions.patch # Not for upstream. Temporary hack till PulseAudio autostart # problems are sorted out when SELinux enforcing @@ -317,6 +320,8 @@ of recent versions of Linux (and other OSes). %patch29 -p1 %patch30 -p1 %patch31 -p1 +%patch32 -p1 +%patch33 -p1 %patch200 -p1 @@ -640,6 +645,9 @@ fi %endif %changelog +* Wed Sep 30 2009 Mark McLoughlin - 0.6.2-18 +- Fix qemu-kvm version detection so GSO is enabled for virtio_net (#526472) + * Wed Aug 19 2009 Mark McLoughlin - 0.6.2-17 - Fix migration completion with newer versions of qemu (#516187) - Fix dumpxml segfault with newer versions of Xen (#518091)