[qemu] Build KVM for all targets

Cole Robinson crobinso at fedoraproject.org
Tue Aug 14 12:54:56 UTC 2012


commit c5cd364aca2df4c1ced0849d0da81fd555f876b3
Author: Cole Robinson <crobinso at redhat.com>
Date:   Tue Aug 14 08:54:17 2012 -0400

    Build KVM for all targets

 0002-configure-Add-disable-kvm-options.patch |   72 ++++++++++++++++++++++++++
 qemu.spec                                    |   29 ++++++++---
 2 files changed, 93 insertions(+), 8 deletions(-)
---
diff --git a/0002-configure-Add-disable-kvm-options.patch b/0002-configure-Add-disable-kvm-options.patch
new file mode 100644
index 0000000..9a0e5f1
--- /dev/null
+++ b/0002-configure-Add-disable-kvm-options.patch
@@ -0,0 +1,72 @@
+From b652c0572859e594fe8d1fc9fd2289126a4c3a1b Mon Sep 17 00:00:00 2001
+From: Cole Robinson <crobinso at redhat.com>
+Date: Mon, 13 Aug 2012 18:39:54 -0400
+Subject: [PATCH] configure: Add --disable-kvm-options
+
+In Fedora, our qemu package is based on qemu-kvm, and we go to convoluted
+lengths to provide a qemu-kvm binary with KVM on by default, but all
+qemu-system-* with KVM off by default (using ./configure --disable-kvm)
+
+For qemu-system*, what we really want is upstream qemu symantics of TCG
+by default, but the opt in option for KVM. CONFIG_KVM_OPTIONS fits the
+bill, so let's expose it through ./configure. This will also simplify
+our packaging for non-x86 KVM.
+
+Signed-off-by: Cole Robinson <crobinso at redhat.com>
+---
+ configure | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/configure b/configure
+index 6b66d34..8f4d9e3 100755
+--- a/configure
++++ b/configure
+@@ -189,6 +189,7 @@ guest_base=""
+ uname_release=""
+ mixemu="no"
+ kvm_cap_device_assignment="yes"
++kvmoptions="yes"
+ aix="no"
+ blobs="yes"
+ pkgversion=" ($(kvm_version))"
+@@ -707,6 +708,8 @@ for opt do
+   ;;
+   --enable-kvm) kvm="yes"
+   ;;
++  --disable-kvm-options) kvmoptions="no"
++  ;;
+   --disable-tcg-interpreter) tcg_interpreter="no"
+   ;;
+   --enable-tcg-interpreter) tcg_interpreter="yes"
+@@ -1071,6 +1074,8 @@ echo "  --enable-bluez           enable bluez stack connectivity"
+ echo "  --disable-slirp          disable SLIRP userspace network connectivity"
+ echo "  --disable-kvm            disable KVM acceleration support"
+ echo "  --enable-kvm             enable KVM acceleration support"
++echo "  --disable-kvm-options    if KVM is enabled, default to KVM=off, and"
++echo "                           remove non-upstream cli options"
+ echo "  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
+ echo "  --disable-kvm-device-assignment  disable KVM device assignment support"
+ echo "  --enable-kvm-device-assignment   enable KVM device assignment support"
+@@ -3101,6 +3106,7 @@ echo "Install blobs     $blobs"
+ echo "KVM support       $kvm"
+ echo "TCG interpreter   $tcg_interpreter"
+ echo "KVM device assig. $kvm_cap_device_assignment"
++echo "KVM CLI options   $kvmoptions"
+ echo "fdt support       $fdt"
+ echo "preadv support    $preadv"
+ echo "fdatasync         $fdatasync"
+@@ -3818,7 +3824,10 @@ case "$target_arch2" in
+       \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
+       \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
+       echo "CONFIG_KVM=y" >> $config_target_mak
+-      echo "CONFIG_KVM_OPTIONS=y" >> $config_host_mak
++
++      if test "$kvmoptions" = "yes" ; then
++        echo "CONFIG_KVM_OPTIONS=y" >> $config_host_mak
++      fi
+       if test "$vhost_net" = "yes" ; then
+         echo "CONFIG_VHOST_NET=y" >> $config_target_mak
+       fi
+-- 
+1.7.11.2
+
diff --git a/qemu.spec b/qemu.spec
index 400a941..3697f94 100644
--- a/qemu.spec
+++ b/qemu.spec
@@ -87,6 +87,10 @@ Source11: 99-qemu-guest-agent.rules
 # Non upstream build fix
 Patch1: 0001-mips-Fix-link-error-with-piix4_pm_init.patch
 
+# Add ./configure --disable-kvm-options
+# Sent upstream on August 13 2012
+Patch2: 0002-configure-Add-disable-kvm-options.patch
+
 # The infamous chardev flow control patches
 Patch101: 0101-char-Split-out-tcp-socket-close-code-in-a-separate-f.patch
 Patch102: 0102-char-Add-a-QemuChrHandlers-struct-to-initialise-char.patch
@@ -378,6 +382,7 @@ such as kvm_stat.
 %setup -q -n qemu-kvm-%{version}
 
 %patch1 -p1
+%patch2 -p1
 
 %patch101 -p1
 %patch102 -p1
@@ -393,7 +398,6 @@ such as kvm_stat.
 %patch112 -p1
 %patch113 -p1
 
-
 %build
 buildarch="i386-softmmu x86_64-softmmu arm-softmmu cris-softmmu \
     m68k-softmmu mips-softmmu mipsel-softmmu mips64-softmmu \
@@ -405,7 +409,7 @@ buildarch="i386-softmmu x86_64-softmmu arm-softmmu cris-softmmu \
     ppc64abi32-linux-user sh4-linux-user sh4eb-linux-user \
     sparc-linux-user sparc64-linux-user sparc32plus-linux-user"
 %if %{with x86only}
-    buildarch="i386-softmmu x86_64-softmmu i386-linux-user x86_64-linux-user"
+    buildarch="i386-linux-user x86_64-linux-user"
 %endif
 
 # Targets we don't build as of qemu 1.1.50
@@ -430,6 +434,7 @@ dobuild() {
     ./configure \
         --prefix=%{_prefix} \
         --sysconfdir=%{_sysconfdir} \
+        --interp-prefix=%{_prefix}/qemu-%%M \
         --audio-drv-list=pa,sdl,alsa,oss \
         --disable-strip \
         --extra-ldflags="$extraldflags -pie -Wl,-z,relro -Wl,-z,now" \
@@ -447,6 +452,7 @@ dobuild() {
         --enable-trace-backend=dtrace \
         --disable-werror \
         --disable-xen \
+        --enable-kvm \
         "$@"
 
     echo "config-host.mak contents:"
@@ -457,11 +463,21 @@ dobuild() {
     make V=1 %{?_smp_mflags} $buildldflags
 }
 
+# This is kind of confusing. We run ./configure + make twice here to
+# preserve some back compat: if on x86, we want to provide a qemu-kvm
+# binary that defaults to KVM=on. All other qemu-system* should be
+# able to use KVM, but default to KVM=off (upstream qemu semantics).
+#
+# Once qemu-kvm and qemu fully merge, and we base off qemu releases,
+# all qemu-system-* will default to KVM=off, so we hopefully won't need
+# to do these double builds. But then I'm not sure how we are going to
+# generate a back compat qemu-kvm binary...
 
-# KVM enabled builds
 %ifarch %{ix86} x86_64
+# Build qemu-kvm back compat binary
 dobuild --target-list=x86_64-softmmu
 
+# Setup back compat qemu-kvm binary which defaults to KVM=on
 ./scripts/tracetool.py --backend dtrace --format stap \
   --binary %{_bindir}/qemu-kvm --target-arch x86_64 --target-type system \
   --probe-prefix qemu.kvm < ./trace-events > qemu-kvm.stp
@@ -469,11 +485,8 @@ cp -a x86_64-softmmu/qemu-system-x86_64 qemu-kvm
 make clean
 %endif
 
-# KVM disabled builds
-dobuild --target-list="$buildarch" \
-    --interp-prefix=%{_prefix}/qemu-%%M \
-    --disable-kvm
-
+# Build qemu-system-* with consistent default of kvm=off
+dobuild --target-list="$buildarch" --disable-kvm-options
 gcc %{SOURCE6} -O2 -g -o ksmctl
 
 


More information about the scm-commits mailing list