From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Ehrhardt Date: Wed, 10 Dec 2008 12:50:58 +0000 Subject: kvm-userspace requires kvm capable kernel headers in default search Message-Id: <493FBB32.8000507@linux.vnet.ibm.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------000406020101010904030507" List-Id: To: kvm , kvm-ppc , Hollis Blanchard , Avi Kivity This is a multi-part message in MIME format. --------------000406020101010904030507 Content-Type: text/plain; charset="iso-8859-1"; format="flowed" Content-Transfer-Encoding: quoted-printable Hi everyone, while running a test when updating kvm-userspace for powerpc I found=20 that the current kvm userspace requires kvm kernel headers in the=20 default search path of the used compilers. I used to update and build in the same kvm-userspace directory for a=20 while and this one had an old stale kernel/include directory which=20 fulfilled all the requirements. While testing my current patch series on a new git clone of=20 kvm-userspace I wondered why this doesn't work anymore (it worked in my=20 old directory which also had the updated current source). I switched to x86 to verify that issue there and I found that eventually=20 the issue is in the kvm detection "KVM Probe" part of the qemu=20 configuration in kvm-userspace. It failed not finding kvm headers. gcc -m32 -o /tmp/qemu-conf--21885- =20 -I/home/paelzer/Desktop/kvm-userspace/kernel/include=20 /tmp/qemu-conf--21885-.c /tmp/qemu-conf--21885-.c:1:23: error: linux/kvm.h: No such file or=20 directory /tmp/qemu-conf--21885-.c:3:2: error: #error Invalid KVM version Looking at the include paths it is worth to note that a current git=20 clone of kvm-userspace has no kernel/include directory anymore. A few=20 questions later to some other kvm developers I found that there headers=20 can be found, but in the default search path of the compiler e.g.=20 /usr/include. In my environment with an older gcc cross compiler for=20 powerpc and no up to date linux headers installed for x86 both=20 architectures failed. The Solution to that can be done in several ways: a) we decide that kvm-userspace needs up-to-date kernel headers=20 installed. And modify the KVM Probe at least to tell the user about this=20 possible reason when failing instead of silently switching to "KVM=20 support no". b) if the user already provide a --kerneldir option to specify where the=20 right includes can be found we should give those configure checks a=20 chance to really reach that. Atm it adds the kernel/include path of the=20 kvm-userspace tree which doesn't exist anymore (except as stale old dir=20 in a lot of source trees out there). c) I overlooked something and there is an even better or trivial=20 approach :-) Since this could be solved several very different ways I think its worth=20 a discussion. As I prefer b) I attached a simple patch example how this could look=20 like :-). --=20 Gr=FCsse / regards,=20 Christian Ehrhardt IBM Linux Technology Center, Open Virtualization --------------000406020101010904030507 Content-Type: text/x-diff; name="fix-qemu-kerneldir-include.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fix-qemu-kerneldir-include.diff" diff --git a/configure b/configure index 63f956c..f772bae 100755 --- a/configure +++ b/configure @@ -3,6 +3,7 @@ prefix=/usr/local kernelsourcedir= kerneldir=/lib/modules/$(uname -r)/build +qemu_kerneldir= cc=gcc ld=ld objcopy=objcopy @@ -56,6 +57,7 @@ while [[ "$1" = -* ]]; do ;; --kerneldir) kerneldir="$arg" + qemu_kerneldir="$arg" ;; --with-patched-kernel) want_module= @@ -84,9 +86,12 @@ while [[ "$1" = -* ]]; do esac done - -#set kenel directory +#set libkvm kernel directory libkvm_kerneldir=$(readlink -f kernel) +# use libkvm_kerneldir for qemu if no kerneldir option was set +if test "$qemu_kerneldir" = "" ; then + qemu_kerneldir=$libkvm_kerneldir +fi case $arch in i?86*|x86_64*) @@ -123,7 +128,7 @@ fi --disable-gcc-check \ --extra-cflags="-I $PWD/../libkvm $qemu_cflags" \ --extra-ldflags="-L $PWD/../libkvm $qemu_ldflags" \ - --kerneldir="$libkvm_kerneldir" \ + --kerneldir="$qemu_kerneldir" \ --prefix="$prefix" \ ${cross_prefix:+"--cross-prefix=$cross_prefix"} \ ${cross_prefix:+"--cpu=$arch"} "${qemu_opts[@]}" --------------000406020101010904030507--