# HG changeset patch
# User Jerone Young <[EMAIL PROTECTED]>
# Date 1194027872 18000
# Node ID 02f38e54018070bafd501df846147f4ae7661109
# Parent  7f802db02478d5d5ec63348e126b54e85681c66f
Move kvm_create_kernel_phys_mem to libkvm-x86.c

This patch moves kvm_create_kernel_phys_mem to x86 as this is
the only arch that will be allocating memory for guest in the
kernel (at least for older kvm versions).

Signed-off-by: Jerone Young <[EMAIL PROTECTED]>

diff --git a/libkvm/kvm-x86.h b/libkvm/kvm-x86.h
--- a/libkvm/kvm-x86.h
+++ b/libkvm/kvm-x86.h
@@ -5,6 +5,8 @@
  */
 #ifndef KVM_X86_H
 #define KVM_X86_H
+
+#include "kvm-common.h"
 
 #include "kvm-common.h"
 
@@ -33,4 +35,7 @@ int kvm_arch_create(kvm_context_t kvm, u
 int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
                        void **vm_mem);
 
+void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start,
+                       unsigned long len, int log, int writable);
+
 #endif
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -273,4 +273,36 @@ int kvm_arch_create(kvm_context_t kvm, u
        return 0;
 }
 
-
+void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start,
+                       unsigned long len, int log, int writable)
+{
+       int r;
+       int prot = PROT_READ;
+       void *ptr;
+       struct kvm_memory_region memory = {
+               .memory_size = len,
+               .guest_phys_addr = phys_start,
+               .flags = log ? KVM_MEM_LOG_DIRTY_PAGES : 0,
+       };
+
+       memory.slot = get_free_slot(kvm);
+       r = ioctl(kvm->vm_fd, KVM_SET_MEMORY_REGION, &memory);
+       if (r == -1) {
+               fprintf(stderr, "create_kernel_phys_mem: %s", strerror(errno));
+               return 0;
+       }
+       register_slot(memory.slot, memory.guest_phys_addr);
+       kvm_memory_region_save_params(kvm, &memory);
+
+       if (writable)
+               prot |= PROT_WRITE;
+
+       ptr = mmap(NULL, len, prot, MAP_SHARED, kvm->vm_fd, phys_start);
+       if (ptr == MAP_FAILED) {
+               fprintf(stderr, "create_kernel_phys_mem: %s", strerror(errno));
+               return 0;
+       }
+
+       return ptr;
+}
+
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -373,38 +373,6 @@ int kvm_create(kvm_context_t kvm, unsign
        return 0;
 }
 
-void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start,
-                       unsigned long len, int log, int writable)
-{
-       int r;
-       int prot = PROT_READ;
-       void *ptr;
-       struct kvm_memory_region memory = {
-               .memory_size = len,
-               .guest_phys_addr = phys_start,
-               .flags = log ? KVM_MEM_LOG_DIRTY_PAGES : 0,
-       };
-
-       memory.slot = get_free_slot(kvm);
-       r = ioctl(kvm->vm_fd, KVM_SET_MEMORY_REGION, &memory);
-       if (r == -1) {
-               fprintf(stderr, "create_kernel_phys_mem: %s", strerror(errno));
-               return 0;
-       }
-       register_slot(memory.slot, memory.guest_phys_addr);
-       kvm_memory_region_save_params(kvm, &memory);
-
-       if (writable)
-               prot |= PROT_WRITE;
-
-       ptr = mmap(NULL, len, prot, MAP_SHARED, kvm->vm_fd, phys_start);
-       if (ptr == MAP_FAILED) {
-               fprintf(stderr, "create_kernel_phys_mem: %s", strerror(errno));
-               return 0;
-       }
-
-       return ptr;
-}
 
 #ifdef KVM_CAP_USER_MEMORY
 

-------------------------------------------------------------------------
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
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to