Import KVM headers including Makefile and import script
Subsystems (2)
PATCH 1/1 Import KVM headers including Makefile and import script
These are the headers from Linux 2.6.29 that have been modified to work under QEMU. This includes the necessary scripts to generate the headers from the original Linux source tree.
--- configure | 7 +- include/HEAD | 1 + include/Makefile | 26 ++ include/README | 6 + include/asm-powerpc/kvm.h | 55 ++++ include/asm-powerpc/kvm_para.h | 37 +++ include/asm-x86/kvm.h | 218 ++++++++++++++++ include/asm-x86/kvm_para.h | 147 +++++++++++ include/fixup.sed | 11 + include/linux/kvm.h | 533 ++++++++++++++++++++++++++++++++++++++++ include/linux/kvm_para.h | 44 ++++ 11 files changed, 1084 insertions(+), 1 deletions(-) create mode 100644 include/HEAD create mode 100644 include/Makefile create mode 100644 include/README create mode 100644 include/asm-powerpc/kvm.h create mode 100644 include/asm-powerpc/kvm_para.h create mode 100644 include/asm-x86/kvm.h create mode 100644 include/asm-x86/kvm_para.h create mode 100644 include/fixup.sed create mode 100644 include/linux/kvm.h create mode 100644 include/linux/kvm_para.h
configure +6 -1
@@ -188,7 +188,7 @@ nptl="yes" mixemu="no" bluez="yes" kvm="yes" -kerneldir="" +kerneldir="." aix="no" blobs="yes" fdt="yes"
@@ -1081,6 +1081,11 @@ EOF fi fi +# Make kerneldir relative to source path +if test `echo $kerneldir | cut -c1-2` != '/' -a "$source_path" ; then + kerneldir="$source_path/$kerneldir" +fi + ########################################## # kvm probe if test "$kvm" = "yes" ; then
include/HEAD new file +1 -0
@@ -0,0 +1 @@ +8e0ee43bc2c3e19db56a4adaa9a9b04ce885cd84
include/Makefile new file +26 -0
@@ -0,0 +1,26 @@ +KERNELDIR ?= /lib/modules/$(shell uname -r)/build +LINUX_HEADERS=kvm.h kvm_para.h +ASM_X86_HEADERS=kvm.h kvm_para.h +ASM_POWERPC_HEADERS=kvm.h kvm_para.h + +sync: clean + @for file in $(LINUX_HEADERS); do \ + echo " IMPORT linux/$${file}"; \ + sed -f fixup.sed $(KERNELDIR)/include/linux/$${file} > \ + linux/$${file}; \ + done + @for file in $(ASM_X86_HEADERS); do \ + echo " IMPORT asm-x86/$${file}"; \ + sed -f fixup.sed $(KERNELDIR)/arch/x86/include/asm/$${file} > \ + asm-x86/$${file}; \ + done + @for file in $(ASM_POWERPC_HEADERS); do \ + echo " IMPORT asm-powerpc/$${file}"; \ + sed -f fixup.sed $(KERNELDIR)/arch/powerpc/include/asm/$${file} > \ + asm-powerpc/$${file}; \ + done + +clean: + @$(RM) linux/*.h asm-x86/*.h asm-powerpc/*.h + +.PHONY: sync clean
include/README new file +6 -0
@@ -0,0 +1,6 @@ +This are the Linux KVM headers. HEAD refers to the linux-2.6 git commit from +which these headers are derived. + +To regenerate headers from a newer kernel version, use make sync. It takes +KERNELDIR as the path to the root of the Linux source tree. HEAD must be +created manually.
include/asm-powerpc/kvm.h new file +55 -0
55 lines not on this page · raw message
include/asm-powerpc/kvm_para.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License, version 2, as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +* Copyright IBM Corp. 2008 +* +* Authors: Hollis Blanchard <[email protected]> +*/ + +#ifndef __POWERPC_KVM_PARA_H__ +#define __POWERPC_KVM_PARA_H__ + +#ifdef __KERNEL__ + +static inline int kvm_para_available (void ) +{ +return 0 ; +} + +static inline unsigned int kvm_arch_para_features (void ) +{ +return 0 ; +} + +#endif /* __KERNEL__ */ + +#endif /* __POWERPC_KVM_PARA_H__ */
include/asm-x86/kvm.h new file +218 -0
218 lines not on this page · raw message
include/asm-x86/kvm_para.h new file +147 -0
147 lines not on this page · raw message
include/fixup.sed new file +11 -0
@@ -0,0 +1,11 @@ +# Header file fix ups. This is tailored for importing the kvm linux headers + +# Expand asm/ includes to avoid having to do symlink trickery +s:^#include <asm/kvm\(.*\)>$:#if defined(__x86_64__) || defined(__i386__)\n#include <asm-x86/kvm\1>\n#elif defined(__powerpc__)\n#include <asm-powerpc/kvm\1>\n#endif:g + +# Kill linux/compiler.h which is used for sparse annotations. This is not +# always part of glibc kernel headers +s:^\(#include <linux/compiler.h>\)$:#if defined(__KERNEL__)\n\1\n#endif:g + +# Kill sparse annotations +s:__user::g
include/linux/kvm.h new file +533 -0
533 lines not on this page · raw message
include/linux/kvm_para.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
1.6.0.6
Quoted 6 lines · Anthony Liguori
These are the headers from Linux 2.6.29 that have been modified to work under QEMU. This includes the necessary scripts to generate the headers from the original Linux source tree.
Signed-off-by Anthony Liguori <[email protected]>
Hollis: can you verify this actually works for PPC?
In theory, you should be able to omit --kerneldir and still have working KVM support.
Signature · 3 lines
Regards, Anthony Liguori
Quoted 5 lines · Anthony Liguori
These are the headers from Linux 2.6.29 that have been modified to work under QEMU. This includes the necessary scripts to generate the headers from the original Linux source tree.
Signed-off-by Anthony Liguori <[email protected]>
Quoted 13 lines
--- configure | 7 +- include/HEAD | 1 + include/Makefile | 26 ++ include/README | 6 + include/asm-powerpc/kvm.h | 55 ++++ include/asm-powerpc/kvm_para.h | 37 +++ include/asm-x86/kvm.h | 218 ++++++++++++++++ include/asm-x86/kvm_para.h | 147 +++++++++++ include/fixup.sed | 11 + include/linux/kvm.h | 533 ++++++++++++++++++++++++++++++++++++++++ include/linux/kvm_para.h | 44 ++++
Can we put them under kvm/, as include/ looks like a generic include directory, which this isn't. Also, this generates a gratuitous conflict with qemu-kvm.git, and we have enough of those already.
I also suggest using arch/*/include/asm as a way of avoiding the symlink, instead of the extra hack in fixup.sed.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Re: [Qemu-devel] [PATCH] Import KVM headers including Makefile andimport script
Quoted 21 lines · Avi Kivity
Quoted 5 lines · Anthony Liguori
These are the headers from Linux 2.6.29 that have been modified to work under QEMU. This includes the necessary scripts to generate the headers from the original Linux source tree.
Signed-off-by Anthony Liguori <[email protected]>Quoted 14 lines
--- configure | 7 +- include/HEAD | 1 + include/Makefile | 26 ++ include/README | 6 + include/asm-powerpc/kvm.h | 55 ++++ include/asm-powerpc/kvm_para.h | 37 +++ include/asm-x86/kvm.h | 218 ++++++++++++++++ include/asm-x86/kvm_para.h | 147 +++++++++++ include/fixup.sed | 11 + include/linux/kvm.h | 533 ++++++++++++++++++++++++++++++++++++++++ include/linux/kvm_para.h | 44 ++++
Quoted 1 line
Can we put them under kvm/, as
include/looks like a generic include directory, which this isn't. Also, this generates a gratuitous conflict with qemu-kvm.git, and we have enough of those already.
I'd rather put them under linux/ because right now, we depend on a number of Linux headers (for USB pass through, for instance).
The qemu-kvm.git layout is kvm/kernel/include. That doesn't seem to make a lot of sense for QEMU.
Quoted 2 lines
I also suggest using
arch/*/include/asmas a way of avoiding the symlink, instead of the extra hack in fixup.sed.
I did it the current way to avoid deep directory layouts. We would end up with an extra level of directories via linux/arch-x86/asm/foo.h as opposed to linux/asm-x86/foo.h.
Did you have a reason for wanting to avoid the sed hacks verses a layout like this other than to avoid the hack?
The fixup certainly can be made more readable. For instance:
# Expand asm/ includes to avoid having to do symlink trickery s:^#include <asm/kvm\(.*\)>$:\
#if defined(__x86_64__) || defined(__i386__) \ #include <asm-x86/kvm\1> \ #elif defined(__powerpc__) \ #include <asm-powerpc/kvm\1> \
#endif\
:g
Signature · 3 lines
Regards, Anthony Liguori
Re: [Qemu-devel] [PATCH] Import KVM headers including Makefile andimport script
Quoted 5 lines · Anthony Liguori
Quoted 1 line
Can we put them under kvm/, as
include/looks like a generic include directory, which this isn't. Also, this generates a gratuitous conflict with qemu-kvm.git, and we have enough of those already.I'd rather put them under linux/ because right now, we depend on a number of Linux headers (for USB pass through, for instance).
The qemu-kvm.git layout is kvm/kernel/include. That doesn't seem to make a lot of sense for QEMU.
linux/ makes sense. But let's coordinate the change.
Quoted 7 lines
Quoted 3 lines
I also suggest using
arch/*/include/asmas a way of avoiding the symlink, instead of the extra hack in fixup.sed.I did it the current way to avoid deep directory layouts. We would end up with an extra level of directories via
linux/arch-x86/asm/foo.has opposed tolinux/asm-x86/foo.h.Did you have a reason for wanting to avoid the sed hacks verses a layout like this other than to avoid the hack?
Hacks are not good. I'd avoid them whenever possible. Just as an example, we'll need to hack the hack whenever we add an architecture (ia64, s390, arm...).
I don't see a problem with the extra directory level, especially as tab completion expands it immediately.
Quoted 12 lines
The fixup certainly can be made more readable. For instance:
# Expand asm/ includes to avoid having to do symlink trickery s:^#include <asm/kvm\(.*\)>$:\
#if defined(__x86_64__) || defined(__i386__) \ #include <asm-x86/kvm\1> \ #elif defined(__powerpc__) \ #include <asm-powerpc/kvm\1> \#endif\
:g
Let's avoid it altogether (we can avoid the compiler.h hack by adding a dummy <linux/compiler.h>).
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH] Import KVM headers including Makefile andimportscript
Quoted 8 lines · Avi Kivity
Quoted 5 lines · Anthony Liguori
Quoted 1 line
Can we put them under kvm/, as
include/looks like a generic include directory, which this isn't. Also, this generates a gratuitous conflict with qemu-kvm.git, and we have enough of those already.I'd rather put them under linux/ because right now, we depend on a number of Linux headers (for USB pass through, for instance).
The qemu-kvm.git layout is kvm/kernel/include. That doesn't seem to make a lot of sense for QEMU.
linux/ makes sense. But let's coordinate the change.
BTW, the next logic step for qemu-kvm.git is to move /libkvm/libkvm.c to /libkvm-all.c, then move /libkvm/libkvm-<arch>.c to /target-<arch>/libkvm.c. Then make each target that supports kvm depend on libkvm-all.o and libkvm.o. kvmctl can be moved to the top-level too and treated like another qemu tool. The trick is to build a kvmctl-libkvm.o or something like that but it should be too difficult.
Quoted 1 line
Hacks are not good. I'd avoid them whenever possible. Just as an example, we'll need to hack the hack whenever we add an architecture (ia64, s390, arm...).
It's purely aesthetic for me and I don't mind changing it.
Quoted 12 lines
Quoted 12 lines
The fixup certainly can be made more readable. For instance:
# Expand asm/ includes to avoid having to do symlink trickery s:^#include <asm/kvm\(.*\)>$:\
#if defined(__x86_64__) || defined(__i386__) \ #include <asm-x86/kvm\1> \ #elif defined(__powerpc__) \ #include <asm-powerpc/kvm\1> \#endif\
:g
Quoted 1 line
Let's avoid it altogether (we can avoid the
compiler.hhack by adding a dummy <linux/compiler.h>).
I still think a fixup is needed because once concern I have is that it's far too brittle in its current state. It's too easy to not pull in a header and end up using /usr/include/linux/foo.h. This could lead to very subtle build errors that would be host OS dependent.
So I'm thinking that a common prefix to avoid confusion is warranted. So the fixup would become:
s:^#include <linux/\(.*\)>:#include "host/linux/\1":g s:^#include <asm/\(.*\)>:#include "host/asm/\1":g
And we'd change all the existing #includes to use "host/foo". I think that would make it much more robust.
Signature · 3 lines
Regards, Anthony Liguori
Re: [Qemu-devel] [PATCH] Import KVM headers including Makefile andimportscript
Quoted 11 lines · Anthony Liguori
Quoted 8 lines · Avi Kivity
Quoted 5 lines · Anthony Liguori
Quoted 1 line
Can we put them under kvm/, as
include/looks like a generic include directory, which this isn't. Also, this generates a gratuitous conflict with qemu-kvm.git, and we have enough of those already.I'd rather put them under linux/ because right now, we depend on a number of Linux headers (for USB pass through, for instance).
The qemu-kvm.git layout is kvm/kernel/include. That doesn't seem to make a lot of sense for QEMU.
linux/ makes sense. But let's coordinate the change.
BTW, the next logic step for qemu-kvm.git is to move /libkvm/libkvm.c to /libkvm-all.c, then move /libkvm/libkvm-<arch>.c to /target-<arch>/libkvm.c. Then make each target that supports kvm depend on libkvm-all.o and libkvm.o. kvmctl can be moved to the top-level too and treated like another qemu tool. The trick is to build a kvmctl-libkvm.o or something like that but it should be too difficult.
My plan for kvmctl is to port the tests to 'qemu -kernel' and retire it. We can use standard serial or virtio-console for logging. We'll need some fake devices for the testing, but they'd all be very simple.
Given that, we can start porting things from libkvm to kvm-all.c and eventually remove it.
Quoted 3 lines
Quoted 1 line
Let's avoid it altogether (we can avoid the
compiler.hhack by adding a dummy <linux/compiler.h>).I still think a fixup is needed because once concern I have is that it's far too brittle in its current state. It's too easy to not pull in a header and end up using
/usr/include/linux/foo.h. This could lead to very subtle build errors that would be host OS dependent.
Not to mention, libc would see a mix of the newer kernel headers and the system kernel headers.
Quoted 7 lines
So I'm thinking that a common prefix to avoid confusion is warranted. So the fixup would become:
s:^#include <linux/\(.*\)>:#include "host/linux/\1":g s:^#include <asm/\(.*\)>:#include "host/asm/\1":g
And we'd change all the existing #includes to use "host/foo". I think that would make it much more robust.
But pretty ugly :(; maybe we can find a cleaner solution.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Quoted 5 lines · Anthony Liguori
These are the headers from Linux 2.6.29 that have been modified to work under QEMU. This includes the necessary scripts to generate the headers from the original Linux source tree.
Signed-off-by Anthony Liguori <[email protected]>
Quoted 13 lines
--- configure | 7 +- include/HEAD | 1 + include/Makefile | 26 ++ include/README | 6 + include/asm-powerpc/kvm.h | 55 ++++ include/asm-powerpc/kvm_para.h | 37 +++ include/asm-x86/kvm.h | 218 ++++++++++++++++ include/asm-x86/kvm_para.h | 147 +++++++++++ include/fixup.sed | 11 + include/linux/kvm.h | 533 ++++++++++++++++++++++++++++++++++++++++ include/linux/kvm_para.h | 44 ++++
Another comment: let's add this as two separate commits, one for the configure/Makefile and one for the actual headers. The headers are generated files, after all, so we should follow the procedures we use for other generated files like the bios.
It also makes the first commit easy to cherry-pick across branches and repositories.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH] Import KVM headers including Makefile andimport script
Quoted 21 lines · Avi Kivity
Quoted 5 lines · Anthony Liguori
These are the headers from Linux 2.6.29 that have been modified to work under QEMU. This includes the necessary scripts to generate the headers from the original Linux source tree.
Signed-off-by Anthony Liguori <[email protected]>Quoted 14 lines
--- configure | 7 +- include/HEAD | 1 + include/Makefile | 26 ++ include/README | 6 + include/asm-powerpc/kvm.h | 55 ++++ include/asm-powerpc/kvm_para.h | 37 +++ include/asm-x86/kvm.h | 218 ++++++++++++++++ include/asm-x86/kvm_para.h | 147 +++++++++++ include/fixup.sed | 11 + include/linux/kvm.h | 533 ++++++++++++++++++++++++++++++++++++++++ include/linux/kvm_para.h | 44 ++++
Quoted 3 lines
Another comment: let's add this as two separate commits, one for the configure/Makefile and one for the actual headers. The headers are generated files, after all, so we should follow the procedures we use for other generated files like the bios.
It also makes the first commit easy to cherry-pick across branches and repositories.
Sure. As I mention in the newer README, I expect that we can track the kernel more closely as long as we're in a development branch (x.y.50). We just need to make sure that we use kernel releases for QEMU releases. I think this should work out well for qemu-kvm.git too, right?
This new patch also implements the need for -D__user in CFLAGS FWIW.
Signature · 3 lines
Regards, Anthony Liguori