Skip to contentSkip to conversation

Move libkvm (v2)

PATCH RESEND Applied Hollis Blanchard 3 participants 6 messages Oct 30, 2007 – Oct 31, 2007 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 Move libkvm (v2)

Move libkvm into its own directory. No functional changes.

---
I've build-tested this pretty thoroughly on x86(32).

Changes from v1: update libkvm.h #include guard macro.

Makefile +8 -6
@@ -5,16 +5,17 @@ DESTDIR=
 
 rpmrelease = devel
 
-.PHONY: kernel user qemu bios clean
+.PHONY: kernel user libkvm qemu bios clean
 
-all: $(if $(WANT_MODULE), kernel) user qemu
+all: $(if $(WANT_MODULE), kernel) user libkvm qemu
 
 kcmd = $(if $(WANT_MODULE),,@\#)
 
-qemu kernel user:
+qemu kernel user libkvm:
 	$(MAKE) -C $@
 
-qemu: user
+qemu: libkvm
+user: libkvm
 
 bios:
 	$(MAKE) -C $@
@@ -41,7 +42,7 @@ install-rpm:
 
 install:
 	$(kcmd)make -C kernel DESTDIR="$(DESTDIR)" install
-	make -C user DESTDIR="$(DESTDIR)" install
+	make -C libkvm DESTDIR="$(DESTDIR)" install
 	make -C qemu DESTDIR="$(DESTDIR)" install
 
 tmpspec = .tmp.kvm.spec
@@ -59,6 +60,7 @@ srpm:
 	sed 's/^Release:.*/Release: $(rpmrelease)/' kvm.spec > $(tmpspec)
 	tar czf SOURCES/kvm.tar.gz qemu
 	tar czf SOURCES/user.tar.gz user
+	tar czf SOURCES/libkvm.tar.gz libkvm
 	tar czf SOURCES/kernel.tar.gz kernel
 	tar czf SOURCES/scripts.tar.gz scripts
 	cp Makefile configure kvm_stat SOURCES
@@ -66,7 +68,7 @@ srpm:
 	$(RM) $(tmpspec)
 
 clean:
-	for i in $(if $(WANT_MODULE), kernel) user qemu; do \
+	for i in $(if $(WANT_MODULE), kernel) user libkvm qemu; do \
 		make -C $$i clean; \
 	done
 	rm -f config.mak user/config.mak
configure +2 -2
@@ -108,8 +108,8 @@ fi
 
 #configure qemu
 (cd qemu; ./configure --target-list=$target_exec \
-    --disable-kqemu --extra-cflags="-I $PWD/../user $qemu_cflags" \
-    --extra-ldflags="-L $PWD/../user $qemu_ldflags" \
+    --disable-kqemu --extra-cflags="-I $PWD/../libkvm $qemu_cflags" \
+    --extra-ldflags="-L $PWD/../libkvm $qemu_ldflags" \
     --enable-kvm --kernel-path="$libkvm_kerneldir" \
     ${enable_alsa:+"--enable-alsa"} \
     ${disable_vnc_tls:+"--disable-vnc-tls"} \
libkvm/Makefile new file +37 -0
new file mode 100644
@@ -0,0 +1,37 @@
+include ../config.mak
+include config-$(ARCH).mak
+
+# cc-option
+# Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
+cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \
+              > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
+
+CFLAGS += $(autodepend-flags) -g -fomit-frame-pointer -Wall
+CFLAGS += $(call cc-option, -fno-stack-protector, "")
+CFLAGS += $(call cc-option, -fno-stack-protector-all, "")
+CFLAGS += -I $(KERNELDIR)/include
+
+LDFLAGS += $(CFLAGS)
+
+CXXFLAGS = $(autodepend-flags)
+
+autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
+
+
+all: libkvm.a
+
+libkvm.a: libkvm.o
+	$(AR) rcs $@ $^
+
+install:
+	install -D libkvm.h $(DESTDIR)/$(PREFIX)/include/libkvm.h
+	install -D $(KERNELDIR)/include/linux/kvm.h \
+		$(DESTDIR)/$(PREFIX)/include/linux/kvm.h
+	install -D $(KERNELDIR)/include/linux/kvm_para.h \
+		$(DESTDIR)/$(PREFIX)/include/linux/kvm_para.h
+	install -D libkvm.a $(DESTDIR)/$(PREFIX)/$(LIBDIR)/libkvm.a
+
+-include .*.d
+
+clean:
+	$(RM) *.o *.a .*.d
libkvm/config-i386.mak new file +2 -0
new file mode 100644
@@ -0,0 +1,2 @@
+
+LIBDIR := /lib
libkvm/config-x86_64.mak new file +2 -0
new file mode 100644
@@ -0,0 +1,2 @@
+
+LIBDIR := /lib64
libkvm/kvm-abi-10.h renamed from user/kvm-abi-10.h +0 -0
rename from user/kvm-abi-10.h
rename to libkvm/kvm-abi-10.h
libkvm/libkvm.c +1 -1
rename from user/kvmctl.c
rename to libkvm/libkvm.c
@@ -34,7 +34,7 @@
 #include <string.h>
 #include <errno.h>
 #include <sys/ioctl.h>
-#include "kvmctl.h"
+#include "libkvm.h"
 #include "kvm-abi-10.h"
 
 static int kvm_abi = EXPECTED_KVM_API_VERSION;
libkvm/libkvm.h +2 -2
rename from user/kvmctl.h
rename to libkvm/libkvm.h
@@ -2,8 +2,8 @@
  * libkvm API
  */
 
-#ifndef KVMCTL_H
-#define KVMCTL_H
+#ifndef LIBKVM_H
+#define LIBKVM_H
 
 #include <stdint.h>
 
qemu/Makefile.target +1 -1
@@ -419,7 +419,7 @@ ifdef CONFIG_KVM_KERNEL_INC
 ifdef CONFIG_KVM_KERNEL_INC
 CFLAGS += -I $(CONFIG_KVM_KERNEL_INC)
 LIBS += -lkvm
-DEPLIBS += ../user/libkvm.a
+DEPLIBS += ../libkvm/libkvm.a
 endif
 
 ifdef CONFIG_VNC_TLS
qemu/hw/vga.c +1 -1
@@ -1413,7 +1413,7 @@ void vga_invalidate_scanlines(VGAState *
 
 #ifdef USE_KVM
 
-#include "kvmctl.h"
+#include "libkvm.h"
 extern kvm_context_t kvm_context;
 
 static int bitmap_get_dirty(unsigned long *bitmap, unsigned nr)
qemu/hw/vmport.c +1 -1
@@ -23,7 +23,7 @@
  */
 #include "vl.h"
 #include "cpu-all.h"
-#include "kvmctl.h"
+#include "libkvm.h"
 
 #define VMPORT_CMD_GETVERSION 0x0a
 #define VMPORT_CMD_GETRAMSIZE 0x14
qemu/qemu-kvm.c +1 -1
@@ -18,7 +18,7 @@ int kvm_irqchip = 1;
 #include "vl.h"
 
 #include "qemu-kvm.h"
-#include <kvmctl.h>
+#include <libkvm.h>
 #include <pthread.h>
 #include <sys/utsname.h>
 
qemu/qemu-kvm.h +1 -1
@@ -2,7 +2,7 @@
 #define QEMU_KVM_H
 
 #include "cpu.h"
-#include "kvmctl.h"
+#include "libkvm.h"
 
 int kvm_main_loop(void);
 int kvm_qemu_init(void);
user/Makefile +2 -12
@@ -20,8 +20,9 @@ CFLAGS += $(autodepend-flags) -g -fomit-
 CFLAGS += $(autodepend-flags) -g -fomit-frame-pointer -Wall
 CFLAGS += $(call cc-option, -fno-stack-protector, "")
 CFLAGS += $(call cc-option, -fno-stack-protector-all, "")
+CFLAGS += -I ../libkvm
 
-LDFLAGS += $(CFLAGS)
+LDFLAGS += $(CFLAGS) -L ../libkvm
 
 CXXFLAGS = $(autodepend-flags)
 
@@ -30,17 +31,6 @@ kvmctl: LDFLAGS += -pthread -lrt
 kvmctl: LDFLAGS += -pthread -lrt
 
 kvmctl: $(kvmctl_objs)
-
-libkvm.a: $(libkvm_objs)
-	$(AR) rcs $@ $^
-
-install:
-	install -D kvmctl.h $(DESTDIR)/$(PREFIX)/include/kvmctl.h
-	install -D $(KERNELDIR)/include/linux/kvm.h \
-		$(DESTDIR)/$(PREFIX)/include/linux/kvm.h
-	install -D $(KERNELDIR)/include/linux/kvm_para.h \
-		$(DESTDIR)/$(PREFIX)/include/linux/kvm_para.h
-	install -D libkvm.a $(DESTDIR)/$(PREFIX)/$(LIBDIR)/libkvm.a
 
 %.flat: %.o
 	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^
user/config-i386.mak +0 -1
@@ -1,4 +1,3 @@ LIBDIR = /lib
-LIBDIR = /lib
 TEST_DIR=test/x86
 cstart.o = $(TEST_DIR)/cstart.o
 bits = 32
user/config-x86-common.mak +2 -4
@@ -1,10 +1,8 @@
 #This is a make file with common rules for both x86 & x86-64
 
-all: kvmctl libkvm.a test_cases
+all: kvmctl test_cases
 
-kvmctl_objs=kvmctl.o main.o
-
-libkvm_objs=kvmctl.o
+kvmctl_objs=../libkvm/libkvm.a main.o
 
 balloon_ctl: balloon_ctl.o
 
user/config-x86_64.mak +0 -1
@@ -1,4 +1,3 @@ LIBDIR = /lib64
-LIBDIR = /lib64
 TEST_DIR=test/x86
 cstart.o = $(TEST_DIR)/cstart64.o
 bits = 64
user/main.c +1 -1
@@ -16,7 +16,7 @@
 
 #define _GNU_SOURCE
 
-#include "kvmctl.h"
+#include <libkvm.h>
 #include "test/x86/apic.h"
 
 #include <stdio.h>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

Applied
#1 lore raw
Quoted 3 lines · Hollis Blanchard

Move libkvm into its own directory. No functional changes.

Applied, thanks.

Signature · 8 lines
Any sufficiently difficult bug is indistinguishable from a feature.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
#2 lore raw
In reply to Hollis Blanchard

Hi Hollis and Avi,

I run into a compile problem with libkvm when compiling kvm-49. It
caused the compile problem mentioned in my email yesterday.

It has to with the line in libkvm/Makefile

CFLAGS += -I $(KERNELDIR)/include

when compiling kvm-49 (git or snapshot), this include points to my resident kernel's version of kvm.h instead of the local one copied with "make sync LINUX=<kvm git repo>").

in kvm-48, KERNELDIR points to the kvm-userspace/kernel/ directory (under the git repo), but in the more recent versions it changes to /lib/modules/2.6.22.9-61.fc6/build/include.

Here are the compiles from kvm-48 (kvmctl.c) and 49 (libkvm.c) respectively,

kvm-48:
gcc -m64 -I /home/cam/research/KVM/Sakwatamau/kvm-48/kernel/include -MMD -MF ./.kvmctl.d -g -fomit-frame-pointer -Wall -fno-stack-protector
-c -o kvmctl.o kvmctl.c

kvm-49:
cc -MMD -MF ./.libkvm.d -g -fomit-frame-pointer -Wall
-fno-stack-protector -I /lib/modules/2.6.22.9-61.fc6/build/include
-c -o libkvm.o libkvm.c

what is KERNELDIR supposed to point to - the install location for the modules or the location of kernel source?

When configuring, I tried setting --kerneldir to the repo copy, but that didn't work.

Thanks,
Cam

Quoted 301 lines · Hollis Blanchard

Move libkvm into its own directory. No functional changes.

---
I've build-tested this pretty thoroughly on x86(32).

Changes from v1: update libkvm.h #include guard macro.

Makefile +8 -6
@@ -5,16 +5,17 @@ DESTDIR=
 
 rpmrelease = devel
 
-.PHONY: kernel user qemu bios clean
+.PHONY: kernel user libkvm qemu bios clean
 
-all: $(if $(WANT_MODULE), kernel) user qemu
+all: $(if $(WANT_MODULE), kernel) user libkvm qemu
 
 kcmd = $(if $(WANT_MODULE),,@\#)
 
-qemu kernel user:
+qemu kernel user libkvm:
 	$(MAKE) -C $@
 
-qemu: user
+qemu: libkvm
+user: libkvm
 
 bios:
 	$(MAKE) -C $@
@@ -41,7 +42,7 @@ install-rpm:
 
 install:
 	$(kcmd)make -C kernel DESTDIR="$(DESTDIR)" install
-	make -C user DESTDIR="$(DESTDIR)" install
+	make -C libkvm DESTDIR="$(DESTDIR)" install
 	make -C qemu DESTDIR="$(DESTDIR)" install
 
 tmpspec = .tmp.kvm.spec
@@ -59,6 +60,7 @@ srpm:
 	sed 's/^Release:.*/Release: $(rpmrelease)/' kvm.spec > $(tmpspec)
 	tar czf SOURCES/kvm.tar.gz qemu
 	tar czf SOURCES/user.tar.gz user
+	tar czf SOURCES/libkvm.tar.gz libkvm
 	tar czf SOURCES/kernel.tar.gz kernel
 	tar czf SOURCES/scripts.tar.gz scripts
 	cp Makefile configure kvm_stat SOURCES
@@ -66,7 +68,7 @@ srpm:
 	$(RM) $(tmpspec)
 
 clean:
-	for i in $(if $(WANT_MODULE), kernel) user qemu; do \
+	for i in $(if $(WANT_MODULE), kernel) user libkvm qemu; do \
 		make -C $$i clean; \
 	done
 	rm -f config.mak user/config.mak
configure +2 -2
@@ -108,8 +108,8 @@ fi
 
 #configure qemu
 (cd qemu; ./configure --target-list=$target_exec \
-    --disable-kqemu --extra-cflags="-I $PWD/../user $qemu_cflags" \
-    --extra-ldflags="-L $PWD/../user $qemu_ldflags" \
+    --disable-kqemu --extra-cflags="-I $PWD/../libkvm $qemu_cflags" \
+    --extra-ldflags="-L $PWD/../libkvm $qemu_ldflags" \
     --enable-kvm --kernel-path="$libkvm_kerneldir" \
     ${enable_alsa:+"--enable-alsa"} \
     ${disable_vnc_tls:+"--disable-vnc-tls"} \
libkvm/Makefile new file +37 -0
new file mode 100644
@@ -0,0 +1,37 @@
+include ../config.mak
+include config-$(ARCH).mak
+
+# cc-option
+# Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
+cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \
+              > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
+
+CFLAGS += $(autodepend-flags) -g -fomit-frame-pointer -Wall
+CFLAGS += $(call cc-option, -fno-stack-protector, "")
+CFLAGS += $(call cc-option, -fno-stack-protector-all, "")
+CFLAGS += -I $(KERNELDIR)/include
+
+LDFLAGS += $(CFLAGS)
+
+CXXFLAGS = $(autodepend-flags)
+
+autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
+
+
+all: libkvm.a
+
+libkvm.a: libkvm.o
+	$(AR) rcs $@ $^
+
+install:
+	install -D libkvm.h $(DESTDIR)/$(PREFIX)/include/libkvm.h
+	install -D $(KERNELDIR)/include/linux/kvm.h \
+		$(DESTDIR)/$(PREFIX)/include/linux/kvm.h
+	install -D $(KERNELDIR)/include/linux/kvm_para.h \
+		$(DESTDIR)/$(PREFIX)/include/linux/kvm_para.h
+	install -D libkvm.a $(DESTDIR)/$(PREFIX)/$(LIBDIR)/libkvm.a
+
+-include .*.d
+
+clean:
+	$(RM) *.o *.a .*.d
libkvm/config-i386.mak new file +2 -0
new file mode 100644
@@ -0,0 +1,2 @@
+
+LIBDIR := /lib
libkvm/config-x86_64.mak new file +2 -0
new file mode 100644
@@ -0,0 +1,2 @@
+
+LIBDIR := /lib64
libkvm/kvm-abi-10.h renamed from user/kvm-abi-10.h +0 -0
rename from user/kvm-abi-10.h
rename to libkvm/kvm-abi-10.h
libkvm/libkvm.c +1 -1
rename from user/kvmctl.c
rename to libkvm/libkvm.c
@@ -34,7 +34,7 @@
 #include <string.h>
 #include <errno.h>
 #include <sys/ioctl.h>
-#include "kvmctl.h"
+#include "libkvm.h"
 #include "kvm-abi-10.h"
 
 static int kvm_abi = EXPECTED_KVM_API_VERSION;
libkvm/libkvm.h +2 -2
rename from user/kvmctl.h
rename to libkvm/libkvm.h
@@ -2,8 +2,8 @@
  * libkvm API
  */
 
-#ifndef KVMCTL_H
-#define KVMCTL_H
+#ifndef LIBKVM_H
+#define LIBKVM_H
 
 #include <stdint.h>
 
qemu/Makefile.target +1 -1
@@ -419,7 +419,7 @@ ifdef CONFIG_KVM_KERNEL_INC
 ifdef CONFIG_KVM_KERNEL_INC
 CFLAGS += -I $(CONFIG_KVM_KERNEL_INC)
 LIBS += -lkvm
-DEPLIBS += ../user/libkvm.a
+DEPLIBS += ../libkvm/libkvm.a
 endif
 
 ifdef CONFIG_VNC_TLS
qemu/hw/vga.c +1 -1
@@ -1413,7 +1413,7 @@ void vga_invalidate_scanlines(VGAState *
 
 #ifdef USE_KVM
 
-#include "kvmctl.h"
+#include "libkvm.h"
 extern kvm_context_t kvm_context;
 
 static int bitmap_get_dirty(unsigned long *bitmap, unsigned nr)
qemu/hw/vmport.c +1 -1
@@ -23,7 +23,7 @@
  */
 #include "vl.h"
 #include "cpu-all.h"
-#include "kvmctl.h"
+#include "libkvm.h"
 
 #define VMPORT_CMD_GETVERSION 0x0a
 #define VMPORT_CMD_GETRAMSIZE 0x14
qemu/qemu-kvm.c +1 -1
@@ -18,7 +18,7 @@ int kvm_irqchip = 1;
 #include "vl.h"
 
 #include "qemu-kvm.h"
-#include <kvmctl.h>
+#include <libkvm.h>
 #include <pthread.h>
 #include <sys/utsname.h>
 
qemu/qemu-kvm.h +1 -1
@@ -2,7 +2,7 @@
 #define QEMU_KVM_H
 
 #include "cpu.h"
-#include "kvmctl.h"
+#include "libkvm.h"
 
 int kvm_main_loop(void);
 int kvm_qemu_init(void);
user/Makefile +2 -12
@@ -20,8 +20,9 @@ CFLAGS += $(autodepend-flags) -g -fomit-
 CFLAGS += $(autodepend-flags) -g -fomit-frame-pointer -Wall
 CFLAGS += $(call cc-option, -fno-stack-protector, "")
 CFLAGS += $(call cc-option, -fno-stack-protector-all, "")
+CFLAGS += -I ../libkvm
 
-LDFLAGS += $(CFLAGS)
+LDFLAGS += $(CFLAGS) -L ../libkvm
 
 CXXFLAGS = $(autodepend-flags)
 
@@ -30,17 +31,6 @@ kvmctl: LDFLAGS += -pthread -lrt
 kvmctl: LDFLAGS += -pthread -lrt
 
 kvmctl: $(kvmctl_objs)
-
-libkvm.a: $(libkvm_objs)
-	$(AR) rcs $@ $^
-
-install:
-	install -D kvmctl.h $(DESTDIR)/$(PREFIX)/include/kvmctl.h
-	install -D $(KERNELDIR)/include/linux/kvm.h \
-		$(DESTDIR)/$(PREFIX)/include/linux/kvm.h
-	install -D $(KERNELDIR)/include/linux/kvm_para.h \
-		$(DESTDIR)/$(PREFIX)/include/linux/kvm_para.h
-	install -D libkvm.a $(DESTDIR)/$(PREFIX)/$(LIBDIR)/libkvm.a
 
 %.flat: %.o
 	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^
user/config-i386.mak +0 -1
@@ -1,4 +1,3 @@ LIBDIR = /lib
-LIBDIR = /lib
 TEST_DIR=test/x86
 cstart.o = $(TEST_DIR)/cstart.o
 bits = 32
user/config-x86-common.mak +2 -4
@@ -1,10 +1,8 @@
 #This is a make file with common rules for both x86 & x86-64
 
-all: kvmctl libkvm.a test_cases
+all: kvmctl test_cases
 
-kvmctl_objs=kvmctl.o main.o
-
-libkvm_objs=kvmctl.o
+kvmctl_objs=../libkvm/libkvm.a main.o
 
 balloon_ctl: balloon_ctl.o
 
user/config-x86_64.mak +0 -1
@@ -1,4 +1,3 @@ LIBDIR = /lib64
-LIBDIR = /lib64
 TEST_DIR=test/x86
 cstart.o = $(TEST_DIR)/cstart64.o
 bits = 64
user/main.c +1 -2
@@ -16,7 +16,7 @@
 
 #define _GNU_SOURCE
 
-#include "kvmctl.h"
+#include <libkvm.h>
 #include "test/x86/apic.h"
 
 #include <stdio.h>
 
-------------------------------------------------------------------------
Quoted 8 lines

This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

I think the KERNELDIR change is a red herring: you probably ran configure with different arguments.

I notice that the kvm-49 build line below is missing -m64. Try this:

libkvm/config-x86_64.mak +3 -0
@@ -1,2 +1,5 @@
 
 LIBDIR := /lib64
+
+CFLAGS += -m64
+CFLAGS += -D__x86_64__
Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
Quoted 339 lines · Cam Macdonell

Hi Hollis and Avi,

I run into a compile problem with libkvm when compiling kvm-49. It
caused the compile problem mentioned in my email yesterday.

It has to with the line in libkvm/Makefile

CFLAGS += -I $(KERNELDIR)/include

when compiling kvm-49 (git or snapshot), this include points to my resident kernel's version of kvm.h instead of the local one copied with "make sync LINUX=<kvm git repo>").

in kvm-48, KERNELDIR points to the kvm-userspace/kernel/ directory (under the git repo), but in the more recent versions it changes to /lib/modules/2.6.22.9-61.fc6/build/include.

Here are the compiles from kvm-48 (kvmctl.c) and 49 (libkvm.c) respectively,

kvm-48:
gcc -m64 -I /home/cam/research/KVM/Sakwatamau/kvm-48/kernel/include -MMD -MF ./.kvmctl.d -g -fomit-frame-pointer -Wall -fno-stack-protector
-c -o kvmctl.o kvmctl.c

kvm-49:
cc -MMD -MF ./.libkvm.d -g -fomit-frame-pointer -Wall

(quoted diff) +0 -2
-fno-stack-protector   -I /lib/modules/2.6.22.9-61.fc6/build/include 
-c -o libkvm.o libkvm.c

what is KERNELDIR supposed to point to - the install location for the modules or the location of kernel source?

When configuring, I tried setting --kerneldir to the repo copy, but that didn't work.

Thanks,
Cam

Quoted 300 lines · Hollis Blanchard

Move libkvm into its own directory. No functional changes.

---
I've build-tested this pretty thoroughly on x86(32).

Changes from v1: update libkvm.h #include guard macro.

Makefile +8 -6
@@ -5,16 +5,17 @@ DESTDIR=
 
 rpmrelease = devel
 
-.PHONY: kernel user qemu bios clean
+.PHONY: kernel user libkvm qemu bios clean
 
-all: $(if $(WANT_MODULE), kernel) user qemu
+all: $(if $(WANT_MODULE), kernel) user libkvm qemu
 
 kcmd = $(if $(WANT_MODULE),,@\#)
 
-qemu kernel user:
+qemu kernel user libkvm:
 	$(MAKE) -C $@
 
-qemu: user
+qemu: libkvm
+user: libkvm
 
 bios:
 	$(MAKE) -C $@
@@ -41,7 +42,7 @@ install-rpm:
 
 install:
 	$(kcmd)make -C kernel DESTDIR="$(DESTDIR)" install
-	make -C user DESTDIR="$(DESTDIR)" install
+	make -C libkvm DESTDIR="$(DESTDIR)" install
 	make -C qemu DESTDIR="$(DESTDIR)" install
 
 tmpspec = .tmp.kvm.spec
@@ -59,6 +60,7 @@ srpm:
 	sed 's/^Release:.*/Release: $(rpmrelease)/' kvm.spec > $(tmpspec)
 	tar czf SOURCES/kvm.tar.gz qemu
 	tar czf SOURCES/user.tar.gz user
+	tar czf SOURCES/libkvm.tar.gz libkvm
 	tar czf SOURCES/kernel.tar.gz kernel
 	tar czf SOURCES/scripts.tar.gz scripts
 	cp Makefile configure kvm_stat SOURCES
@@ -66,7 +68,7 @@ srpm:
 	$(RM) $(tmpspec)
 
 clean:
-	for i in $(if $(WANT_MODULE), kernel) user qemu; do \
+	for i in $(if $(WANT_MODULE), kernel) user libkvm qemu; do \
 		make -C $$i clean; \
 	done
 	rm -f config.mak user/config.mak
configure +2 -2
@@ -108,8 +108,8 @@ fi
 
 #configure qemu
 (cd qemu; ./configure --target-list=$target_exec \
-    --disable-kqemu --extra-cflags="-I $PWD/../user $qemu_cflags" \
-    --extra-ldflags="-L $PWD/../user $qemu_ldflags" \
+    --disable-kqemu --extra-cflags="-I $PWD/../libkvm $qemu_cflags" \
+    --extra-ldflags="-L $PWD/../libkvm $qemu_ldflags" \
     --enable-kvm --kernel-path="$libkvm_kerneldir" \
     ${enable_alsa:+"--enable-alsa"} \
     ${disable_vnc_tls:+"--disable-vnc-tls"} \
libkvm/Makefile new file +37 -0
new file mode 100644
@@ -0,0 +1,37 @@
+include ../config.mak
+include config-$(ARCH).mak
+
+# cc-option
+# Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
+cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \
+              > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
+
+CFLAGS += $(autodepend-flags) -g -fomit-frame-pointer -Wall
+CFLAGS += $(call cc-option, -fno-stack-protector, "")
+CFLAGS += $(call cc-option, -fno-stack-protector-all, "")
+CFLAGS += -I $(KERNELDIR)/include
+
+LDFLAGS += $(CFLAGS)
+
+CXXFLAGS = $(autodepend-flags)
+
+autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
+
+
+all: libkvm.a
+
+libkvm.a: libkvm.o
+	$(AR) rcs $@ $^
+
+install:
+	install -D libkvm.h $(DESTDIR)/$(PREFIX)/include/libkvm.h
+	install -D $(KERNELDIR)/include/linux/kvm.h \
+		$(DESTDIR)/$(PREFIX)/include/linux/kvm.h
+	install -D $(KERNELDIR)/include/linux/kvm_para.h \
+		$(DESTDIR)/$(PREFIX)/include/linux/kvm_para.h
+	install -D libkvm.a $(DESTDIR)/$(PREFIX)/$(LIBDIR)/libkvm.a
+
+-include .*.d
+
+clean:
+	$(RM) *.o *.a .*.d
libkvm/config-i386.mak new file +2 -0
new file mode 100644
@@ -0,0 +1,2 @@
+
+LIBDIR := /lib
libkvm/config-x86_64.mak new file +2 -0
new file mode 100644
@@ -0,0 +1,2 @@
+
+LIBDIR := /lib64
libkvm/kvm-abi-10.h renamed from user/kvm-abi-10.h +0 -0
rename from user/kvm-abi-10.h
rename to libkvm/kvm-abi-10.h
libkvm/libkvm.c +1 -1
rename from user/kvmctl.c
rename to libkvm/libkvm.c
@@ -34,7 +34,7 @@
 #include <string.h>
 #include <errno.h>
 #include <sys/ioctl.h>
-#include "kvmctl.h"
+#include "libkvm.h"
 #include "kvm-abi-10.h"
 
 static int kvm_abi = EXPECTED_KVM_API_VERSION;
libkvm/libkvm.h +2 -2
rename from user/kvmctl.h
rename to libkvm/libkvm.h
@@ -2,8 +2,8 @@
  * libkvm API
  */
 
-#ifndef KVMCTL_H
-#define KVMCTL_H
+#ifndef LIBKVM_H
+#define LIBKVM_H
 
 #include <stdint.h>
 
qemu/Makefile.target +1 -1
@@ -419,7 +419,7 @@ ifdef CONFIG_KVM_KERNEL_INC
 ifdef CONFIG_KVM_KERNEL_INC
 CFLAGS += -I $(CONFIG_KVM_KERNEL_INC)
 LIBS += -lkvm
-DEPLIBS += ../user/libkvm.a
+DEPLIBS += ../libkvm/libkvm.a
 endif
 
 ifdef CONFIG_VNC_TLS
qemu/hw/vga.c +1 -1
@@ -1413,7 +1413,7 @@ void vga_invalidate_scanlines(VGAState *
 
 #ifdef USE_KVM
 
-#include "kvmctl.h"
+#include "libkvm.h"
 extern kvm_context_t kvm_context;
 
 static int bitmap_get_dirty(unsigned long *bitmap, unsigned nr)
qemu/hw/vmport.c +1 -1
@@ -23,7 +23,7 @@
  */
 #include "vl.h"
 #include "cpu-all.h"
-#include "kvmctl.h"
+#include "libkvm.h"
 
 #define VMPORT_CMD_GETVERSION 0x0a
 #define VMPORT_CMD_GETRAMSIZE 0x14
qemu/qemu-kvm.c +1 -1
@@ -18,7 +18,7 @@ int kvm_irqchip = 1;
 #include "vl.h"
 
 #include "qemu-kvm.h"
-#include <kvmctl.h>
+#include <libkvm.h>
 #include <pthread.h>
 #include <sys/utsname.h>
 
qemu/qemu-kvm.h +1 -1
@@ -2,7 +2,7 @@
 #define QEMU_KVM_H
 
 #include "cpu.h"
-#include "kvmctl.h"
+#include "libkvm.h"
 
 int kvm_main_loop(void);
 int kvm_qemu_init(void);
user/Makefile +2 -12
@@ -20,8 +20,9 @@ CFLAGS += $(autodepend-flags) -g -fomit-
 CFLAGS += $(autodepend-flags) -g -fomit-frame-pointer -Wall
 CFLAGS += $(call cc-option, -fno-stack-protector, "")
 CFLAGS += $(call cc-option, -fno-stack-protector-all, "")
+CFLAGS += -I ../libkvm
 
-LDFLAGS += $(CFLAGS)
+LDFLAGS += $(CFLAGS) -L ../libkvm
 
 CXXFLAGS = $(autodepend-flags)
 
@@ -30,17 +31,6 @@ kvmctl: LDFLAGS += -pthread -lrt
 kvmctl: LDFLAGS += -pthread -lrt
 
 kvmctl: $(kvmctl_objs)
-
-libkvm.a: $(libkvm_objs)
-	$(AR) rcs $@ $^
-
-install:
-	install -D kvmctl.h $(DESTDIR)/$(PREFIX)/include/kvmctl.h
-	install -D $(KERNELDIR)/include/linux/kvm.h \
-		$(DESTDIR)/$(PREFIX)/include/linux/kvm.h
-	install -D $(KERNELDIR)/include/linux/kvm_para.h \
-		$(DESTDIR)/$(PREFIX)/include/linux/kvm_para.h
-	install -D libkvm.a $(DESTDIR)/$(PREFIX)/$(LIBDIR)/libkvm.a
 
 %.flat: %.o
 	$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^
user/config-i386.mak +0 -1
@@ -1,4 +1,3 @@ LIBDIR = /lib
-LIBDIR = /lib
 TEST_DIR=test/x86
 cstart.o = $(TEST_DIR)/cstart.o
 bits = 32
user/config-x86-common.mak +2 -4
@@ -1,10 +1,8 @@
 #This is a make file with common rules for both x86 & x86-64
 
-all: kvmctl libkvm.a test_cases
+all: kvmctl test_cases
 
-kvmctl_objs=kvmctl.o main.o
-
-libkvm_objs=kvmctl.o
+kvmctl_objs=../libkvm/libkvm.a main.o
 
 balloon_ctl: balloon_ctl.o
 
user/config-x86_64.mak +0 -1
@@ -1,4 +1,3 @@ LIBDIR = /lib64
-LIBDIR = /lib64
 TEST_DIR=test/x86
 cstart.o = $(TEST_DIR)/cstart64.o
 bits = 64
user/main.c +1 -1
@@ -16,7 +16,7 @@
 
 #define _GNU_SOURCE
 
-#include "kvmctl.h"
+#include <libkvm.h>
 #include "test/x86/apic.h"
 
 #include <stdio.h>
Quoted 9 lines
Quoted 9 lines

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

#5 lore raw
Quoted 2 lines · Hollis Blanchard

I think the KERNELDIR change is a red herring: you probably ran configure with different arguments.

Hi Hollis,

The only one I run with is --prefix. It seems Avi latest patches fix the problem (although I'm not sure how):

With Avi's latest changes, this now the compile line for libkvm.o.

gcc -MMD -MF ./.libkvm.d -g -fomit-frame-pointer -Wall
-fno-stack-protector -I
/compsci/brule7/cshome/cam/research/KVM/kvm-userspace/kernel/include -c -o libkvm.o libkvm.c

Thanks for your reply,
Cam

libkvm/config-x86_64.mak line 5

Quoted 13 lines

I notice that the kvm-49 build line below is missing -m64. Try this:

libkvm/config-x86_64.mak +3 -0
@@ -1,2 +1,5 @@
 
 LIBDIR := /lib64
+
+CFLAGS += -m64
+CFLAGS += -D__x86_64__

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

#6 lore raw
In reply to a message not in the archive
Quoted 31 lines · Cam Macdonell

Hi Hollis and Avi,

I run into a compile problem with libkvm when compiling kvm-49. It
caused the compile problem mentioned in my email yesterday.

It has to with the line in libkvm/Makefile

CFLAGS += -I $(KERNELDIR)/include

when compiling kvm-49 (git or snapshot), this include points to my resident kernel's version of kvm.h instead of the local one copied with "make sync LINUX=<kvm git repo>").

in kvm-48, KERNELDIR points to the kvm-userspace/kernel/ directory (under the git repo), but in the more recent versions it changes to /lib/modules/2.6.22.9-61.fc6/build/include.

Here are the compiles from kvm-48 (kvmctl.c) and 49 (libkvm.c) respectively,

kvm-48:
gcc -m64 -I /home/cam/research/KVM/Sakwatamau/kvm-48/kernel/include

(quoted diff) +0 -2
-MMD -MF ./.kvmctl.d -g -fomit-frame-pointer -Wall  
-fno-stack-protector     -c -o kvmctl.o kvmctl.c

kvm-49:
cc -MMD -MF ./.libkvm.d -g -fomit-frame-pointer -Wall

(quoted diff) +0 -2
-fno-stack-protector   -I /lib/modules/2.6.22.9-61.fc6/build/include 
-c -o libkvm.o libkvm.c
Quoted 3 lines

what is KERNELDIR supposed to point to - the install location for the modules or the location of kernel source?

I committed a patch from Uri that fixes this.

Signature · 8 lines
Any sufficiently difficult bug is indistinguishable from a feature.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/