From: Zhang Xiantao <[EMAIL PROTECTED]> Date: Mon, 3 Dec 2007 22:06:04 +0800 Subject: [PATCH] kvm: libkvm. Moving set and get shadow pages to x86 arch. Move kvm_set&get_shadow_pages to arch-x86 for libkvm Signed-off-by: Zhang Xiantao <[EMAIL PROTECTED]> --- libkvm/libkvm-x86.c | 34 ++++++++++++++++++++++++++++++++++ libkvm/libkvm.c | 35 ----------------------------------- libkvm/libkvm.h | 32 ++++++++++++++++---------------- 3 files changed, 50 insertions(+), 51 deletions(-)
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index 6dabfd8..d1e2e2d 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -658,3 +658,37 @@ int kvm_setup_cpuid(kvm_context_t kvm, int vcpu,
int nent,
return r;
}
+int kvm_set_shadow_pages(kvm_context_t kvm, unsigned int
nrshadow_pages)
+{
+#ifdef KVM_CAP_MMU_SHADOW_CACHE_CONTROL
+ int r;
+
+ r = ioctl(kvm->fd, KVM_CHECK_EXTENSION,
+ KVM_CAP_MMU_SHADOW_CACHE_CONTROL);
+ if (r > 0) {
+ r = ioctl(kvm->vm_fd, KVM_SET_NR_MMU_PAGES,
nrshadow_pages);
+ if (r == -1) {
+ fprintf(stderr, "kvm_set_shadow_pages: %m\n");
+ return -errno;
+ }
+ return 0;
+ }
+#endif
+ return -1;
+}
+
+int kvm_get_shadow_pages(kvm_context_t kvm, unsigned int
*nrshadow_pages)
+{
+#ifdef KVM_CAP_MMU_SHADOW_CACHE_CONTROL
+ int r;
+
+ r = ioctl(kvm->fd, KVM_CHECK_EXTENSION,
+ KVM_CAP_MMU_SHADOW_CACHE_CONTROL);
+ if (r > 0) {
+ *nrshadow_pages = ioctl(kvm->vm_fd,
KVM_GET_NR_MMU_PAGES);
+ return 0;
+ }
+#endif
+ return -1;
+}
+
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index e92266a..6bbf275 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -294,41 +294,6 @@ int kvm_create_vcpu(kvm_context_t kvm, int slot)
return 0;
}
-int kvm_set_shadow_pages(kvm_context_t kvm, unsigned int
nrshadow_pages)
-{
-#ifdef KVM_CAP_MMU_SHADOW_CACHE_CONTROL
- int r;
-
- r = ioctl(kvm->fd, KVM_CHECK_EXTENSION,
- KVM_CAP_MMU_SHADOW_CACHE_CONTROL);
- if (r > 0) {
- r = ioctl(kvm->vm_fd, KVM_SET_NR_MMU_PAGES,
nrshadow_pages);
- if (r == -1) {
- fprintf(stderr, "kvm_set_shadow_pages: %m\n");
- return -errno;
- }
- return 0;
- }
-#endif
- return -1;
-}
-
-int kvm_get_shadow_pages(kvm_context_t kvm, unsigned int
*nrshadow_pages)
-{
-#ifdef KVM_CAP_MMU_SHADOW_CACHE_CONTROL
- int r;
-
- r = ioctl(kvm->fd, KVM_CHECK_EXTENSION,
- KVM_CAP_MMU_SHADOW_CACHE_CONTROL);
- if (r > 0) {
- *nrshadow_pages = ioctl(kvm->vm_fd,
KVM_GET_NR_MMU_PAGES);
- return 0;
- }
-#endif
- return -1;
-}
-
-
int kvm_create_vm(kvm_context_t kvm)
{
int fd = kvm->fd;
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
index 7aaaaa9..41d76ca 100644
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -112,22 +112,6 @@ void kvm_finalize(kvm_context_t kvm);
void kvm_disable_irqchip_creation(kvm_context_t kvm);
/*!
- * \brief Setting the number of shadow pages to be allocated to the vm
- *
- * \param kvm pointer to kvm_context
- * \param nrshadow_pages number of pages to be allocated
- */
-int kvm_set_shadow_pages(kvm_context_t kvm, unsigned int
nrshadow_pages);
-
-/*!
- * \breif Getting the number of shadow pages that are allocated to the
vm
- *
- * \param kvm pointer to kvm_context
- * \param nrshadow_pages number of pages to be allocated
- */
-int kvm_get_shadow_pages(kvm_context_t kvm , unsigned int
*nrshadow_pages);
-
-/*!
* \brief Create new virtual machine
*
* This creates a new virtual machine, maps physical RAM to it, and
creates a
@@ -362,6 +346,22 @@ int kvm_guest_debug(kvm_context_t, int vcpu, struct
kvm_debug_guest *dbg);
*/
int kvm_setup_cpuid(kvm_context_t kvm, int vcpu, int nent,
struct kvm_cpuid_entry *entries);
+
+/*!
+ * \brief Setting the number of shadow pages to be allocated to the vm
+ *
+ * \param kvm pointer to kvm_context
+ * \param nrshadow_pages number of pages to be allocated
+ */
+int kvm_set_shadow_pages(kvm_context_t kvm, unsigned int
nrshadow_pages);
+
+/*!
+ * \breif Getting the number of shadow pages that are allocated to the
vm
+ *
+ * \param kvm pointer to kvm_context
+ * \param nrshadow_pages number of pages to be allocated
+ */
+int kvm_get_shadow_pages(kvm_context_t kvm , unsigned int
*nrshadow_pages);
#endif
/*!
--
1.5.2
0004-kvm-libkvm.-Moving-set-and-get-shadow-pages-to-x86.patch
Description: 0004-kvm-libkvm.-Moving-set-and-get-shadow-pages-to-x86.patch
------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________ kvm-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/kvm-devel
