kvm-userspace requires kvm capable kernel headers in default search path of the compiler
Hi everyone,
while running a test when updating kvm-userspace for powerpc I found that the current kvm userspace requires kvm kernel headers in the default search path of the used compilers. I used to update and build in the same kvm-userspace directory for a while and this one had an old stale kernel/include directory which fulfilled all the requirements. While testing my current patch series on a new git clone of kvm-userspace I wondered why this doesn't work anymore (it worked in my old directory which also had the updated current source).
I switched to x86 to verify that issue there and I found that eventually the issue is in the kvm detection "KVM Probe" part of the qemu configuration in kvm-userspace. It failed not finding kvm headers.
gcc -m32 -o /tmp/qemu-conf--21885-
-I/home/paelzer/Desktop/kvm-userspace/kernel/include /tmp/qemu-conf--21885-.c
/tmp/qemu-conf--21885-.c:1:23: error: linux/kvm.h: No such file or
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 clone of kvm-userspace has no kernel/include directory anymore. A few questions later to some other kvm developers I found that there headers can be found, but in the default search path of the compiler e.g. /usr/include. In my environment with an older gcc cross compiler for powerpc and no up to date linux headers installed for x86 both architectures failed.
The Solution to that can be done in several ways:
a) we decide that kvm-userspace needs up-to-date kernel headers installed. And modify the KVM Probe at least to tell the user about this possible reason when failing instead of silently switching to "KVM support no".
b) if the user already provide a --kerneldir option to specify where the right includes can be found we should give those configure checks a chance to really reach that. Atm it adds the kernel/include path of the kvm-userspace tree which doesn't exist anymore (except as stale old dir in a lot of source trees out there).
c) I overlooked something and there is an even better or trivial approach :-)
Since this could be solved several very different ways I think its worth a discussion. As I prefer b) I attached a simple patch example how this could look like :-).
Signature · 2 lines
Grüsse / regards, Christian Ehrhardt IBM Linux Technology Center, Open Virtualization
configure +8 -3
@@ -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[@]}"
Quoted 4 lines · Christian Ehrhardt
Hi everyone,
while running a test when updating kvm-userspace for powerpc I found that the current kvm userspace requires kvm kernel headers in the default search path of the used compilers.
You lost me with this mail, but after hitting the problem myself, I think I can summarize:
% ./configure
KVM support no
% cd kernel; make sync LINUX=/home/hollisb/source/kvm.git; cd .. % ./configure
KVM support yes
This is building x86 kvm-userspace.git on an x86 host; no cross-compiling or PowerPC involved.
This seems wrong to me, and also contradicts the "building an external module with older kernels" directions at
http://kvm.qumranet.com/kvmwiki/Code .
Avi, did something in the build procedure break recently?
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 9 lines · Hollis Blanchard
You lost me with this mail, but after hitting the problem myself, I think I can summarize:
% ./configure
KVM support no
% cd kernel; make sync LINUX=/home/hollisb/source/kvm.git; cd .. % ./configure
KVM support yes
Quoted 9 lines
This is building x86 kvm-userspace.git on an x86 host; no cross-compiling or PowerPC involved.
This seems wrong to me, and also contradicts the "building an external module with older kernels" directions at
http://kvm.qumranet.com/kvmwiki/Code .Avi, did something in the build procedure break recently?
I guess kvm detection changed, or perhaps on your host there are no kvm headers in /usr/include.
I don't see a way to work around this; before a 'make sync', one cannot detect kvm support reliably.
Signature · 1 line
error compiling committee.c: too many arguments to function