Re: [PATCH 11 of 17] Move msrs functions to libkvm-x86.c

Carlo Marcelo Arenas Belon
2007-11-08T05:57:00Z

On Tue, Nov 06, 2007 at 10:48:52AM -0600, Jerone Young wrote:
> Move msrs functions to libkvm-x86.c
>
> This patch moves functions:
> kvm_msr_list
> move kvm_get_msrs
> move kvm_set_msrs

the problem is that with this the definitions were moved as well from libkvm.h
to kvm-x86.h which is private and not meant to be exported outside of libkvm
but those 3 functions are used by qemu-kvm.c as shown by :

/var/tmp/portage/app-emulation/kvm-51/work/kvm-51/qemu/qemu-kvm.c: In function
`load_regs':
/var/tmp/portage/app-emulation/kvm-51/work/kvm-51/qemu/qemu-kvm.c:319:
warning: implicit declaration of function `kvm_set_msrs'
/var/tmp/portage/app-emulation/kvm-51/work/kvm-51/qemu/qemu-kvm.c: In function
`save_regs':
/var/tmp/portage/app-emulation/kvm-51/work/kvm-51/qemu/qemu-kvm.c:457:
warning: implicit declaration of function `kvm_get_msrs'
/var/tmp/portage/app-emulation/kvm-51/work/kvm-51/qemu/qemu-kvm.c: In function
`kvm_qemu_create_context':
/var/tmp/portage/app-emulation/kvm-51/work/kvm-51/qemu/qemu-kvm.c:1020:
warning: implicit declaration of function `kvm_get_msr_list'
/var/tmp/portage/app-emulation/kvm-51/work/kvm-51/qemu/qemu-kvm.c:1020:
warning: assignment makes pointer from integer without a cast

the following patch moves them to a new public arch specific header for libkvm
named libkvm-x86.h and that needs to be installed in userspace as well but is
not completely independent and would had been as well ifdef inside libkvm.h
for simplicity.

Jerone or anyone else that is working in the architectural work care to
comment?

Carlo

PS. tested in amd64
--
diff --git a/libkvm/Makefile b/libkvm/Makefile
index 65efb3a..bbeb564 100644
--- a/libkvm/Makefile
+++ b/libkvm/Makefile
@@ -26,6 +26,7 @@ libkvm.a: libkvm.o $(libkvm-$(ARCH)-objs)

install:
install -D libkvm.h $(DESTDIR)/$(PREFIX)/include/libkvm.h
+ install -D libkvm-x86.h $(DESTDIR)/$(PREFIX)/include/libkvm-x86.h
install -D $(KERNELDIR)/include/linux/kvm.h \
$(DESTDIR)/$(PREFIX)/include/linux/kvm.h
install -D $(KERNELDIR)/include/linux/kvm_para.h \
diff --git a/libkvm/kvm-x86.h b/libkvm/kvm-x86.h
index b531a3b..1e1c718 100644
--- a/libkvm/kvm-x86.h
+++ b/libkvm/kvm-x86.h
@@ -19,8 +19,7 @@
#define KVM_X86_H

#include "kvm-common.h"
-
-#include "kvm-common.h"
+#include "libkvm-x86.h"

#define PAGE_SIZE 4096ul
#define PAGE_MASK (~(PAGE_SIZE - 1))
@@ -42,8 +41,4 @@ int kvm_run_abi10(kvm_context_t kvm, int vcpu);

void kvm_show_code(kvm_context_t kvm, int vcpu);

-struct kvm_msr_list *kvm_get_msr_list(kvm_context_t);
-int kvm_get_msrs(kvm_context_t, int vcpu, struct kvm_msr_entry *msrs, int n);
-int kvm_set_msrs(kvm_context_t, int vcpu, struct kvm_msr_entry *msrs, int n);
-
#endif
diff --git a/libkvm/libkvm-x86.h b/libkvm/libkvm-x86.h
new file mode 100644
index 0000000..6531d1f
--- /dev/null
+++ b/libkvm/libkvm-x86.h
@@ -0,0 +1,12 @@
+/** \file libkvm-x86.h
+ * libkvm for x86 API
+ */
+
+#ifndef LIBKVM_X86_H
+#define LIBKVM_X86_H
+
+struct kvm_msr_list *kvm_get_msr_list(kvm_context_t kvm);
+int kvm_get_msrs(kvm_context_t kvm, int vcpu, struct kvm_msr_entry *msrs, int n);
+int kvm_set_msrs(kvm_context_t kvm, int vcpu, struct kvm_msr_entry *msrs, int n);
+
+#endif
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
index b00d658..173566f 100644
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -19,6 +19,10 @@ struct kvm_context;

typedef struct kvm_context *kvm_context_t;

+#if defined(__x86_64__) || defined(__i386__)
+#include <libkvm-x86.h>
+#endif
+
/*!
* \brief KVM callbacks structure
*