[PATCH 08 of 19] Move kvm_destroy_phys_mem to libkvm-x86.c

Jerone Young
2007-11-02T18:24:57Z

# Date 1194027873 18000
# Node ID 098efe35de4493a3eda631cb2f9fd958ae303897
# Parent 8e77064ea82d0b7fbd8bb77429bbfd62f99c00f6
Move kvm_destroy_phys_mem to libkvm-x86.c

Signed-off-by: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -322,3 +322,29 @@ void *kvm_create_phys_mem(kvm_context_t
log, writable);
}

+/* destroy/free a whole slot.
+ * phys_start, len and slot are the params passed to kvm_create_phys_mem()
+ */
+void kvm_destroy_phys_mem(kvm_context_t kvm, unsigned long phys_start,
+ unsigned long len)
+{
+ int slot;
+ struct kvm_memory_region *mem;
+
+ slot = get_slot(phys_start);
+
+ if (slot >= KVM_MAX_NUM_MEM_REGIONS) {
+ fprintf(stderr, "BUG: %s: invalid parameters (slot=%d)\n",
+ __FUNCTION__, slot);
+ return;
+ }
+ mem = &kvm->mem_regions[slot];
+ if (phys_start != mem->guest_phys_addr) {
+ fprintf(stderr,
+ "WARNING: %s: phys_start is 0x%lx expecting 0x%llx\n",
+ __FUNCTION__, phys_start, mem->guest_phys_addr);
+ phys_start = mem->guest_phys_addr;
+ }
+ kvm_create_phys_mem(kvm, phys_start, 0, 0, 0);
+}
+
diff --git a/libkvm/libkvm-x86.h b/libkvm/libkvm-x86.h
--- a/libkvm/libkvm-x86.h
+++ b/libkvm/libkvm-x86.h
@@ -8,4 +8,7 @@ void *kvm_create_phys_mem(kvm_context_t,
void *kvm_create_phys_mem(kvm_context_t, unsigned long phys_start,
unsigned long len, int log, int writable);

+void kvm_destroy_phys_mem(kvm_context_t, unsigned long phys_start,
+ unsigned long len);
+
#endif
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -445,33 +445,6 @@ int kvm_register_userspace_phys_mem(kvm_
#else
return -ENOSYS;
#endif
-}
-
-
-/* destroy/free a whole slot.
- * phys_start, len and slot are the params passed to kvm_create_phys_mem()
- */
-void kvm_destroy_phys_mem(kvm_context_t kvm, unsigned long phys_start,
- unsigned long len)
-{
- int slot;
- struct kvm_memory_region *mem;
-
- slot = get_slot(phys_start);
-
- if (slot >= KVM_MAX_NUM_MEM_REGIONS) {
- fprintf(stderr, "BUG: %s: invalid parameters (slot=%d)\n",
- __FUNCTION__, slot);
- return;
- }
- mem = &kvm->mem_regions[slot];
- if (phys_start != mem->guest_phys_addr) {
- fprintf(stderr,
- "WARNING: %s: phys_start is 0x%lx expecting 0x%llx\n",
- __FUNCTION__, phys_start, mem->guest_phys_addr);
- phys_start = mem->guest_phys_addr;
- }
- kvm_create_phys_mem(kvm, phys_start, 0, 0, 0);
}

int kvm_create_memory_alias(kvm_context_t kvm,