From: Jan Kiszka <jan.kiszka@siemens.com>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Avi Kivity <avi@redhat.com>, kvm <kvm@vger.kernel.org>,
Alexander Graf <agraf@suse.de>
Subject: [Qemu-devel] [RFC][PATCH] Import Linux headers for KVM and vhost
Date: Tue, 03 May 2011 16:05:37 +0200 [thread overview]
Message-ID: <4DC00BB1.7000008@siemens.com> (raw)
This helps reducing our build-time checks for feature support in the
available Linux kernel headers. And it helps users that do not have
sufficiently recent headers installed on their build machine.
Header upstate is triggered via 'make update-linux-headers', optionally
specifying a kernel directory as source via 'LINUX='.
---
I'm sure this is not yet perfect from technical POV (e.g. the patch to
Makefile.target looks like a hack to me, better ideas welcome),
therefore RFC and no SOB. But it should demonstrate the plan. The
workflow for adding a new KVM feature support would be first a 'make
update-linux-header LINUX=/my/local/linux' + git commit, and then the
commit of the kvm, vhost, whatever changes.
A patch to actually add the result of the header update would be posted
separately. Same for the now possible massive cleanups of kvm sources.
Makefile | 17 +++++++
Makefile.target | 2 +-
configure | 127 ++++++++-----------------------------------------------
3 files changed, 36 insertions(+), 110 deletions(-)
diff --git a/Makefile b/Makefile
index 67c0268..6ca065b 100644
--- a/Makefile
+++ b/Makefile
@@ -341,3 +341,20 @@ tarbin:
# Include automatically generated dependency files
-include $(wildcard *.d audio/*.d slirp/*.d block/*.d net/*.d ui/*.d)
+
+update-linux-headers:
+ for arch in x86 powerpc s390; do \
+ $(MAKE) -C $(LINUX) INSTALL_HDR_PATH=`pwd`/.tmp-hdrs SRCARCH="$$arch" headers_install; \
+ rm -rf $(SRC_PATH)/include/asm-"$$arch"/*; \
+ for header in kvm.h kvm_para.h; do \
+ cp .tmp-hdrs/include/asm/$$header $(SRC_PATH)/include/asm-"$$arch"; \
+ done; \
+ if test $$arch == x86; then \
+ cp .tmp-hdrs/include/asm/hyperv.h $(SRC_PATH)/include/asm-x86; \
+ fi \
+ done
+ rm -rf $(SRC_PATH)/include/linux/*
+ for header in kvm.h kvm_para.h vhost.h virtio_config.h virtio_ring.h; do \
+ cp .tmp-hdrs/include/linux/$$header $(SRC_PATH)/include/linux; \
+ done
+ rm -rf .tmp-hdrs
diff --git a/Makefile.target b/Makefile.target
index 89280c6..b0fe021 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -14,7 +14,7 @@ endif
TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
$(call set-vpath, $(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw)
-QEMU_CFLAGS+= -I.. -I$(TARGET_PATH) -DNEED_CPU_H
+QEMU_CFLAGS+= -I.. -I../include -I$(TARGET_PATH) -DNEED_CPU_H
include $(SRC_PATH)/Makefile.objs
diff --git a/configure b/configure
index 3239fbb..792e4c2 100755
--- a/configure
+++ b/configure
@@ -113,8 +113,7 @@ curl=""
curses=""
docs=""
fdt=""
-kvm=""
-kvm_para=""
+kvm="yes"
nptl=""
sdl=""
vnc="yes"
@@ -129,7 +128,7 @@ vnc_thread="no"
xen=""
linux_aio=""
attr=""
-vhost_net=""
+vhost_net="yes"
xfs=""
gprof="no"
@@ -1695,109 +1694,6 @@ EOF
fi
##########################################
-# kvm probe
-if test "$kvm" != "no" ; then
- cat > $TMPC <<EOF
-#include <linux/kvm.h>
-#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
-#error Invalid KVM version
-#endif
-EOF
- must_have_caps="KVM_CAP_USER_MEMORY \
- KVM_CAP_DESTROY_MEMORY_REGION_WORKS \
- KVM_CAP_COALESCED_MMIO \
- KVM_CAP_SYNC_MMU \
- "
- if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) ; then
- must_have_caps="$caps \
- KVM_CAP_SET_TSS_ADDR \
- KVM_CAP_EXT_CPUID \
- KVM_CAP_CLOCKSOURCE \
- KVM_CAP_NOP_IO_DELAY \
- KVM_CAP_PV_MMU \
- KVM_CAP_MP_STATE \
- KVM_CAP_USER_NMI \
- "
- fi
- for c in $must_have_caps ; do
- cat >> $TMPC <<EOF
-#if !defined($c)
-#error Missing KVM capability $c
-#endif
-EOF
- done
- cat >> $TMPC <<EOF
-int main(void) { return 0; }
-EOF
- if test "$kerneldir" != "" ; then
- kvm_cflags=-I"$kerneldir"/include
- if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
- -a -d "$kerneldir/arch/x86/include" ; then
- kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
- elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
- kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
- elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
- kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
- elif test -d "$kerneldir/arch/$cpu/include" ; then
- kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
- fi
- else
- kvm_cflags=`$pkg_config --cflags kvm-kmod 2>/dev/null`
- fi
- if compile_prog "$kvm_cflags" "" ; then
- kvm=yes
- cat > $TMPC <<EOF
-#include <linux/kvm_para.h>
-int main(void) { return 0; }
-EOF
- if compile_prog "$kvm_cflags" "" ; then
- kvm_para=yes
- fi
- else
- if test "$kvm" = "yes" ; then
- if has awk && has grep; then
- kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
- | grep "error: " \
- | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
- if test "$kvmerr" != "" ; then
- echo -e "${kvmerr}\n\
-NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
-recent kvm-kmod from http://sourceforge.net/projects/kvm."
- fi
- fi
- feature_not_found "kvm"
- fi
- kvm=no
- fi
-fi
-
-##########################################
-# test for vhost net
-
-if test "$vhost_net" != "no"; then
- if test "$kvm" != "no"; then
- cat > $TMPC <<EOF
- #include <linux/vhost.h>
- int main(void) { return 0; }
-EOF
- if compile_prog "$kvm_cflags" "" ; then
- vhost_net=yes
- else
- if test "$vhost_net" = "yes" ; then
- feature_not_found "vhost-net"
- fi
- vhost_net=no
- fi
- else
- if test "$vhost_net" = "yes" ; then
- echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
- feature_not_found "vhost-net"
- fi
- vhost_net=no
- fi
-fi
-
-##########################################
# pthread probe
PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
@@ -3251,9 +3147,7 @@ case "$target_arch2" in
\( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then
echo "CONFIG_KVM=y" >> $config_target_mak
echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
- if test "$kvm_para" = "yes"; then
- echo "CONFIG_KVM_PARA=y" >> $config_target_mak
- fi
+ echo "CONFIG_KVM_PARA=y" >> $config_target_mak
if test $vhost_net = "yes" ; then
echo "CONFIG_VHOST_NET=y" >> $config_target_mak
fi
@@ -3449,6 +3343,21 @@ if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
esac
fi
+# use included Linux headers
+includes="-I\$(SRC_PATH)/include $includes"
+mkdir -p include
+case "$cpu" in
+i386|x86_64)
+ symlink $source_path/include/asm-x86 include/asm
+ ;;
+ppcemb|ppc|ppc64)
+ symlink $source_path/include/asm-x86 include/asm
+ ;;
+s390x)
+ symlink $source_path/include/asm-s390 include/asm
+ ;;
+esac
+
echo "LDFLAGS+=$ldflags" >> $config_target_mak
echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
echo "QEMU_INCLUDES+=$includes" >> $config_target_mak
--
1.7.1
next reply other threads:[~2011-05-03 14:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-03 14:05 Jan Kiszka [this message]
2011-05-03 15:12 ` [Qemu-devel] [RFC][PATCH] Import Linux headers for KVM and vhost Christoph Hellwig
2011-05-03 15:32 ` Jan Kiszka
2011-05-03 15:41 ` Arnd Bergmann
2011-05-03 16:48 ` [Qemu-devel] [PATCH v2] " Jan Kiszka
2011-05-03 16:55 ` Avi Kivity
2011-05-03 17:09 ` Jan Kiszka
2011-05-03 17:13 ` Avi Kivity
2011-05-03 17:32 ` Edgar E. Iglesias
2011-05-03 17:39 ` Jan Kiszka
2011-05-03 17:57 ` Scott Wood
2011-05-03 19:26 ` Arnd Bergmann
2011-05-03 17:30 ` Peter Maydell
2011-05-03 17:42 ` Jan Kiszka
2011-05-03 17:45 ` Anthony Liguori
2011-05-03 17:55 ` Jan Kiszka
2011-05-03 17:59 ` Anthony Liguori
2011-05-03 21:37 ` Michael S. Tsirkin
2011-05-04 8:55 ` Jan Kiszka
2011-05-09 3:24 ` Rusty Russell
2011-05-03 20:22 ` Peter Maydell
2011-05-04 10:28 ` Jan Kiszka
2011-05-04 17:58 ` Andreas Färber
2011-05-04 18:01 ` Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DC00BB1.7000008@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=agraf@suse.de \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).