Fix issue with large virtio disks getting corrupted. bug #321005
authorDoug Goldstein <cardoe@gentoo.org>
Tue, 15 Jun 2010 18:41:41 +0000 (18:41 +0000)
committerDoug Goldstein <cardoe@gentoo.org>
Tue, 15 Jun 2010 18:41:41 +0000 (18:41 +0000)
Package-Manager: portage-2.1.8.3/cvs/Linux x86_64

app-emulation/qemu-kvm/ChangeLog
app-emulation/qemu-kvm/Manifest
app-emulation/qemu-kvm/files/qemu-kvm-0.12.4-large-virtio-corruption.patch [new file with mode: 0644]
app-emulation/qemu-kvm/qemu-kvm-0.12.4-r1.ebuild [new file with mode: 0644]

index 8b1cc429db0203d1e32f31e3f67c4a712964f793..7368cdf00116b68d04b52ae68d2cce0844277b01 100644 (file)
@@ -1,6 +1,13 @@
 # ChangeLog for app-emulation/qemu-kvm
 # Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-emulation/qemu-kvm/ChangeLog,v 1.29 2010/06/12 05:20:47 jmbsvicetto Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/qemu-kvm/ChangeLog,v 1.30 2010/06/15 18:41:40 cardoe Exp $
+
+*qemu-kvm-0.12.4-r1 (15 Jun 2010)
+
+  15 Jun 2010; Doug Goldstein <cardoe@gentoo.org>
+  +qemu-kvm-0.12.4-r1.ebuild,
+  +files/qemu-kvm-0.12.4-large-virtio-corruption.patch:
+  Fix issue with large virtio disks getting corrupted. bug #321005
 
   12 Jun 2010; Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
   qemu-kvm-9999.ebuild:
index 98fe60208b44dcf1e9bf5faff2dadb48bd41f86e..edd099f7cd53d03395c73506c1eecf936c16ac84 100644 (file)
@@ -4,6 +4,7 @@ AUX qemu-kvm-0.12.1-kvm_save_mpstate-workaround.patch 622 RMD160 d3add3022d9eba3
 AUX qemu-kvm-0.12.2-virtio-large-iovecs.patch 987 RMD160 b16ae8ffd7a4b2d32c32d0ae56c707958344b3eb SHA1 65cd9b99929e5057d636d9676f5a3435db24695f SHA256 e4ca83f65c4deb16e2c22d728e547012aa6110a00ced92a9590990307ab9f7df
 AUX qemu-kvm-0.12.3-fix-crash-with-sdl.patch 4003 RMD160 1e8965e94537e24d0903a7a096c91e35f7013118 SHA1 a6a36da9613d90d45148aa133392bd342b83d1cd SHA256 aeca9f133c021726c0e3ce2a58843ee12d592669143d0b75e46b8e301b5cf102
 AUX qemu-kvm-0.12.3-include-madvise-defines.patch 274 RMD160 2b2b454fabc3b5362c0479d581e5fb038e02aa97 SHA1 c34b51b9c0b5a69ab2ab7a8a64c804f7cbbbebf5 SHA256 0d33d22a853e9b1d19786c9ac53a515587a9753ff69a2f53e61c4764590e7821
+AUX qemu-kvm-0.12.4-large-virtio-corruption.patch 1291 RMD160 66ae04ddfbb6d2e6ce55d109917b231cf354dcbf SHA1 2dc977ce2de3a9b129688d62b04dde079070b97f SHA256 ee279695557224a0f1d1eddf7739932f93abfd781724ac7768a7d1b6a6d61a14
 DIST qemu-kvm-0.11.1.tar.gz 4384334 RMD160 0f945f1812b3a42a5642698d2f15bd8f456612f8 SHA1 291d0b771feb4c67bce71d393868a6d1a1db345b SHA256 7df5b589fabb1f0f35a06abce7e34c81574e09ade538ba883ef5b43ccbd8458b
 DIST qemu-kvm-0.12.3.tar.gz 4718791 RMD160 fe88117e6e32188e097a86f95bffc4b74422a5e6 SHA1 235a790056a1b751791e64dd499129b2dbf55be8 SHA256 77cccdc8938b33f3ed74763d01deaad58918c85f04a06afd10f00857b504c2b2
 DIST qemu-kvm-0.12.4.tar.gz 4720232 RMD160 63a18ff3b95de2b4d0dfac130cf850c1cd7caec0 SHA1 955c8dad1f65df0eb5403f40a6c92d93a0a252be SHA256 1489fe5a0def7b857256817a998768bb21662167d10e7c372312c5939e64181e
@@ -11,7 +12,8 @@ EBUILD qemu-kvm-0.11.1-r1.ebuild 5797 RMD160 a3f4f239cd7a6cc9a7debfe6d347e0d9e1f
 EBUILD qemu-kvm-0.11.1.ebuild 5725 RMD160 87f907a96b5b7cc6387de9b738c6261c57605877 SHA1 5cb4172354f07be1c0b9199b1aa2d880d5b1ef54 SHA256 7bd18bfac7eaa453b5edacc4111426ceab8a8652b311ad97cb6310a42392f5ed
 EBUILD qemu-kvm-0.12.3-r1.ebuild 7452 RMD160 e4b2b3bf62be0147db6d03d34f033e87de4975f2 SHA1 a3b00b0646ce25c29439170f424328cde28ca98a SHA256 34373fec4dca921c1d1e9c19fa1335d70491283a5fc03544f735c7d9db9f3a60
 EBUILD qemu-kvm-0.12.3.ebuild 7291 RMD160 6a23cf04d27e8cb4a41586f64ef20ba96a1edd02 SHA1 aa72ec725c4facdcbf6b19880fdfc9114a9ea7c1 SHA256 6b27f2365f1114df96f45e3f5501aa5788a007db3619f55d9d678af69d5a2ed1
+EBUILD qemu-kvm-0.12.4-r1.ebuild 7465 RMD160 c32fe0dcce892c434ec4b31b3df75cf05d6081b0 SHA1 d070f01e143193ffce49c0f7da8acc1c4113a11e SHA256 b03ce84894aaeba4be70b4f18f0b45df00aef6e73677bd02ee2ebae10d7e91e4
 EBUILD qemu-kvm-0.12.4.ebuild 7408 RMD160 8227b225228a4050331405da9a88522d3bd56f64 SHA1 f860cb9c27db03208f5bfc75f6f5605b62173d57 SHA256 c64e9a8f7e56ce55e81b98f7089406be18c5d63341414a66422d7dcd6e28c6aa
 EBUILD qemu-kvm-9999.ebuild 7578 RMD160 7308cf5d755cc0120b42cc32934122ea8a517836 SHA1 c475e51846ada54a25820f7de9dfbd8a4f1dd32f SHA256 3996be11e01042d2df9565ecc6ae0bb1df27cd4450732e7031a18f7309557d47
-MISC ChangeLog 6452 RMD160 c382faed2a223f2b7f13ce9a20826f2349865ef3 SHA1 7976ba6a5638b7ddc42418c524c8c12fa7a3664e SHA256 99e8ccb6c98b41f7c94029098a06f282eacfc86a8b53945b3409f89ad92c7871
+MISC ChangeLog 6686 RMD160 4d85a7e761f69461945f605212c4a26c3c539ffd SHA1 44317a796654fe3a5fd55eb7ad7a96c432d4a94f SHA256 cbc6fcdfc05a007fa82a996c16a3115d0d462327d6cce7f3945a0206da4e2d0e
 MISC metadata.xml 978 RMD160 2e120b8332c7fc1d6b4baa4149b0f13a73c74fb2 SHA1 5fe37c22d64ca52ef6d26debc46b23b415e04a7a SHA256 76676f1a327e743dd3579109250ace6012ac93ffea5d1daab0a24b194b55164f
diff --git a/app-emulation/qemu-kvm/files/qemu-kvm-0.12.4-large-virtio-corruption.patch b/app-emulation/qemu-kvm/files/qemu-kvm-0.12.4-large-virtio-corruption.patch
new file mode 100644 (file)
index 0000000..81a44cb
--- /dev/null
@@ -0,0 +1,43 @@
+From: Christoph Hellwig <hch@lst.de>
+
+The difference between the start sectors of two requests can be larger
+than the size of the "int" type, which can lead to a not correctly
+sorted multiwrite array and thus spurious I/O errors and filesystem
+corruption due to incorrect request merges.
+
+So instead of doing the cute sector arithmetics trick spell out the
+exact comparisms.
+
+Spotted by Kevin Wolf based on a testcase from Michael Tokarev.
+
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Kevin Wolf <kwolf@redhat.com>
+---
+ block.c |   14 +++++++++++++-
+ 1 files changed, 13 insertions(+), 1 deletions(-)
+
+diff --git a/block.c b/block.c
+index bfe46e3..89eece7 100644
+--- a/block.c
++++ b/block.c
+@@ -1929,7 +1929,19 @@ static void multiwrite_cb(void *opaque, int ret)
+ 
+ static int multiwrite_req_compare(const void *a, const void *b)
+ {
+-    return (((BlockRequest*) a)->sector - ((BlockRequest*) b)->sector);
++    const BlockRequest *req1 = a, *req2 = b;
++
++    /*
++     * Note that we can't simply subtract req2->sector from req1->sector
++     * here as that could overflow the return value.
++     */
++    if (req1->sector > req2->sector) {
++        return 1;
++    } else if (req1->sector < req2->sector) {
++        return -1;
++    } else {
++        return 0;
++    }
+ }
+ 
+ /*
diff --git a/app-emulation/qemu-kvm/qemu-kvm-0.12.4-r1.ebuild b/app-emulation/qemu-kvm/qemu-kvm-0.12.4-r1.ebuild
new file mode 100644 (file)
index 0000000..7a61f2a
--- /dev/null
@@ -0,0 +1,236 @@
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-emulation/qemu-kvm/qemu-kvm-0.12.4-r1.ebuild,v 1.1 2010/06/15 18:41:40 cardoe Exp $
+
+EAPI="2"
+
+if [[ ${PV} = *9999* ]]; then
+       EGIT_REPO_URI="git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git"
+       GIT_ECLASS="git"
+fi
+
+inherit eutils flag-o-matic ${GIT_ECLASS} linux-info toolchain-funcs
+
+if [[ ${PV} = *9999* ]]; then
+       SRC_URI=""
+       KEYWORDS=""
+else
+       SRC_URI="mirror://sourceforge/kvm/${PN}/${P}.tar.gz"
+       KEYWORDS="~amd64 ~ppc ~ppc64 ~x86"
+fi
+
+DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
+HOMEPAGE="http://www.linux-kvm.org"
+
+LICENSE="GPL-2"
+SLOT="0"
+# xen is disabled until the deps are fixed
+IUSE="+aio alsa bluetooth curl esd gnutls fdt hardened kvm-trace ncurses \
+pulseaudio qemu-ifup sasl sdl static vde"
+
+COMMON_TARGETS="i386 x86_64 arm cris m68k microblaze mips mipsel ppc ppc64 sh4 sh4eb sparc sparc64"
+IUSE_SOFTMMU_TARGETS="${COMMON_TARGETS} mips64 mips64el ppcemb"
+IUSE_USER_TARGETS="${COMMON_TARGETS} alpha armeb ppc64abi32 sparc32plus"
+
+for target in ${IUSE_SOFTMMU_TARGETS}; do
+       IUSE="${IUSE} +qemu_softmmu_targets_${target}"
+done
+
+for target in ${IUSE_USER_TARGETS}; do
+       IUSE="${IUSE} +qemu_user_targets_${target}"
+done
+
+RESTRICT="test"
+
+RDEPEND="
+       !app-emulation/kqemu
+       !app-emulation/qemu
+       !app-emulation/qemu-softmmu
+       !app-emulation/qemu-user
+       sys-apps/pciutils
+       >=sys-apps/util-linux-2.16.0
+       sys-libs/zlib
+       aio? ( dev-libs/libaio )
+       alsa? ( >=media-libs/alsa-lib-1.0.13 )
+       bluetooth? ( net-wireless/bluez )
+       curl? ( net-misc/curl )
+       esd? ( media-sound/esound )
+       fdt? ( sys-apps/dtc )
+       gnutls? ( net-libs/gnutls )
+       ncurses? ( sys-libs/ncurses )
+       pulseaudio? ( media-sound/pulseaudio )
+       qemu-ifup? ( sys-apps/iproute2 net-misc/bridge-utils )
+       sasl? ( dev-libs/cyrus-sasl )
+       sdl? ( >=media-libs/libsdl-1.2.11[X] )
+       vde? ( net-misc/vde )
+"
+
+DEPEND="${RDEPEND}
+       app-text/texi2html
+       >=sys-kernel/linux-headers-2.6.29
+       gnutls? ( dev-util/pkgconfig )"
+
+kvm_kern_warn() {
+       eerror "Please enable KVM support in your kernel, found at:"
+       eerror
+       eerror "  Virtualization"
+       eerror "    Kernel-based Virtual Machine (KVM) support"
+       eerror
+}
+
+pkg_setup() {
+
+       local counter="0" check
+       use qemu_softmmu_targets_x86_64 || ewarn "You disabled default target QEMU_SOFTMMU_TARGETS=x86_64"
+       for check in ${IUSE_SOFTMMU_TARGETS} ; do
+               use "qemu_softmmu_targets_${check}" && counter="1"
+       done
+       [[ ${counter} == 0 ]] && die "You need to set at least 1 target in QEMU_SOFTMMU_TARGETS"
+
+       if kernel_is lt 2 6 25; then
+               eerror "This version of KVM requres a host kernel of 2.6.25 or higher."
+               eerror "Either upgrade your kernel"
+       else
+               if ! linux_config_exists; then
+                       eerror "Unable to check your kernel for KVM support"
+                       kvm_kern_warn
+               elif ! linux_chkconfig_present KVM; then
+                       kvm_kern_warn
+               fi
+       fi
+
+       enewgroup kvm
+}
+
+src_prepare() {
+       # prevent docs to get automatically installed
+       sed -i '/$(DESTDIR)$(docdir)/d' Makefile || die
+       # Alter target makefiles to accept CFLAGS set via flag-o
+       sed -i 's/^\(C\|OP_C\|HELPER_C\)FLAGS=/\1FLAGS+=/' \
+               Makefile Makefile.target || die
+       # append CFLAGS while linking
+       sed -i 's/$(LDFLAGS)/$(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS)/' rules.mak || die
+
+       # remove part to make udev happy
+       sed -e 's~NAME="%k", ~~' -i kvm/scripts/65-kvm.rules || die
+
+       epatch "${FILESDIR}"/qemu-0.11.0-mips64-user-fix.patch \
+               "${FILESDIR}"/${PN}-0.12.3-fix-crash-with-sdl.patch \
+               "${FILESDIR}"/${PN}-0.12.3-include-madvise-defines.patch \
+               "${FILESDIR}"/${P}-large-virtio-corruption.patch
+}
+
+src_configure() {
+       local conf_opts audio_opts softmmu_targets user_targets
+
+       for target in ${IUSE_SOFTMMU_TARGETS} ; do
+               use "qemu_softmmu_targets_${target}" && \
+               softmmu_targets="${softmmu_targets} ${target}-softmmu"
+       done
+
+       for target in ${IUSE_USER_TARGETS} ; do
+               use "qemu_user_targets_${target}" && \
+               user_targets="${user_targets} ${target}-linux-user"
+       done
+
+       if [ ! -z "${softmmu_targets}" ]; then
+               einfo "Building the following softmmu targets: ${softmmu_targets}"
+       fi
+
+       if [ ! -z "${user_targets}" ]; then
+               einfo "Building the following user targets: ${user_targets}"
+               conf_opts="${conf_opts} --enable-linux-user"
+       else
+               conf_opts="${conf_opts} --disable-linux-user"
+       fi
+
+       # Fix QA issues. QEMU needs executable heaps and we need to mark it as such
+       conf_opts="${conf_opts} --extra-ldflags=-Wl,-z,execheap"
+
+       # Add support for static builds
+       use static && conf_opts="${conf_opts} --static"
+
+       #config options
+       conf_opts="${conf_opts} $(use_enable aio linux-aio)"
+       use bluetooth || conf_opts="${conf_opts} --disable-bluez"
+       conf_opts="${conf_opts} $(use_enable curl)"
+       use gnutls || conf_opts="${conf_opts} --disable-vnc-tls"
+       conf_opts="${conf_opts} $(use_enable fdt)"
+       use hardened && conf_opts="${conf_opts} --enable-user-pie"
+       use kvm-trace && conf_opts="${conf_opts} --with-kvm-trace"
+       use ncurses || conf_opts="${conf_opts} --disable-curses"
+       use sasl || conf_opts="${conf_opts} --disable-vnc-sasl"
+       use sdl || conf_opts="${conf_opts} --disable-sdl"
+       use vde || conf_opts="${conf_opts} --disable-vde"
+#      conf_opts="${conf_opts} $(use_enable xen)"
+       conf_opts="${conf_opts} --disable-xen"
+       conf_opts="${conf_opts} --disable-darwin-user --disable-bsd-user"
+
+       # audio options
+       audio_opts="oss"
+       use alsa && audio_opts="alsa ${audio_opts}"
+       use esd && audio_opts="esd ${audio_opts}"
+       use pulseaudio && audio_opts="pa ${audio_opts}"
+       use sdl && audio_opts="sdl ${audio_opts}"
+       ./configure --prefix=/usr \
+               --disable-strip \
+               --enable-kvm \
+               --enable-nptl \
+               --enable-uuid \
+               ${conf_opts} \
+               --audio-drv-list="${audio_opts}" \
+               --target-list="${softmmu_targets} ${user_targets}" \
+               --cc=$(tc-getCC) \
+               --host-cc=$(tc-getBUILD_CC) \
+               || die "configure failed"
+
+               # this is for qemu upstream's threaded support which is
+               # in development and broken
+               # the kvm project has its own support for threaded IO
+               # which is always on and works
+#              --enable-io-thread \
+}
+
+src_install() {
+       emake DESTDIR="${D}" install || die "make install failed"
+
+       insinto /etc/udev/rules.d/
+       doins kvm/scripts/65-kvm.rules || die
+
+       if use qemu-ifup; then
+               insinto /etc/qemu/
+               insopts -m0755
+               doins kvm/scripts/qemu-ifup || die
+       fi
+
+       dodoc Changelog MAINTAINERS TODO pci-ids.txt || die
+       newdoc pc-bios/README README.pc-bios || die
+       dohtml qemu-doc.html qemu-tech.html || die
+
+       if use qemu_softmmu_targets_x86_64 ; then
+               dobin "${FILESDIR}"/qemu-kvm
+               dosym /usr/bin/qemu-kvm /usr/bin/kvm
+       else
+               elog "You disabled QEMU_SOFTMMU_TARGETS=x86_64, this disables install"
+               elog "of /usr/bin/qemu-kvm and /usr/bin/kvm"
+       fi
+}
+
+pkg_postinst() {
+       elog "If you don't have kvm compiled into the kernel, make sure you have"
+       elog "the kernel module loaded before running kvm. The easiest way to"
+       elog "ensure that the kernel module is loaded is to load it on boot."
+       elog "For AMD CPUs the module is called 'kvm-amd'"
+       elog "For Intel CPUs the module is called 'kvm-intel'"
+       elog "Please review /etc/conf.d/modules for how to load these"
+       elog
+       elog "Make sure your user is in the 'kvm' group"
+       elog "Just run 'gpasswd -a <USER> kvm', then have <USER> re-login."
+       elog
+       elog "You will need the Universal TUN/TAP driver compiled into your"
+       elog "kernel or loaded as a module to use the virtual network device"
+       elog "if using -net tap.  You will also need support for 802.1d"
+       elog "Ethernet Bridging and a configured bridge if using the provided"
+       elog "kvm-ifup script from /etc/kvm."
+       echo
+}