[PATCH 09 of 19] Move kvm_create_memory_alias & kvm_destroy_memory_alias to libkvm-x86.c

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

# Date 1194027873 18000
# Node ID 76218015a52046be4d77069c3e999b6ca60d0528
# Parent 098efe35de4493a3eda631cb2f9fd958ae303897
Move kvm_create_memory_alias & kvm_destroy_memory_alias 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
@@ -348,3 +348,32 @@ void kvm_destroy_phys_mem(kvm_context_t
kvm_create_phys_mem(kvm, phys_start, 0, 0, 0);
}

+int kvm_create_memory_alias(kvm_context_t kvm,
+ uint64_t phys_addr,
+ uint64_t phys_start,
+ uint64_t len,
+ uint64_t target_phys)
+{
+ struct kvm_memory_alias alias = {
+ .flags = 0,
+ .guest_phys_addr = phys_start,
+ .memory_size = len,
+ .target_phys_addr = target_phys,
+ };
+ int fd = kvm->vm_fd;
+ int r;
+
+ alias.slot = get_slot(phys_addr);
+
+ r = ioctl(fd, KVM_SET_MEMORY_ALIAS, &alias);
+ if (r == -1)
+ return -errno;
+
+ return 0;
+}
+
+int kvm_destroy_memory_alias(kvm_context_t kvm, uint64_t phys_addr)
+{
+ return kvm_create_memory_alias(kvm, phys_addr, 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
@@ -11,4 +11,23 @@ void kvm_destroy_phys_mem(kvm_context_t,
void kvm_destroy_phys_mem(kvm_context_t, unsigned long phys_start,
unsigned long len);

+/*!
+ * \brief Create a memory alias
+ *
+ * Aliases a portion of physical memory to another portion. If the guest
+ * accesses the alias region, it will behave exactly as if it accessed
+ * the target memory.
+ */
+int kvm_create_memory_alias(kvm_context_t, uint64_t phys_addr,
+ uint64_t phys_start, uint64_t len,
+ uint64_t target_phys);
+
+/*!
+ * \brief Destroy a memory alias
+ *
+ * Removes an alias created with kvm_create_memory_alias().
+ */
+int kvm_destroy_memory_alias(kvm_context_t, uint64_t phys_addr);
+
+
#endif
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -445,35 +445,6 @@ int kvm_register_userspace_phys_mem(kvm_
#else
return -ENOSYS;
#endif
-}
-
-int kvm_create_memory_alias(kvm_context_t kvm,
- uint64_t phys_addr,
- uint64_t phys_start,
- uint64_t len,
- uint64_t target_phys)
-{
- struct kvm_memory_alias alias = {
- .flags = 0,
- .guest_phys_addr = phys_start,
- .memory_size = len,
- .target_phys_addr = target_phys,
- };
- int fd = kvm->vm_fd;
- int r;
-
- alias.slot = get_slot(phys_addr);
-
- r = ioctl(fd, KVM_SET_MEMORY_ALIAS, &alias);
- if (r == -1)
- return -errno;
-
- return 0;
-}
-
-int kvm_destroy_memory_alias(kvm_context_t kvm, uint64_t phys_addr)
-{
- return kvm_create_memory_alias(kvm, phys_addr, 0, 0, 0);
}

static int kvm_get_map(kvm_context_t kvm, int ioctl_num, int slot, void *buf)
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -427,24 +427,6 @@ int kvm_get_dirty_pages(kvm_context_t, u

/*!
- * \brief Create a memory alias
- *
- * Aliases a portion of physical memory to another portion. If the guest
- * accesses the alias region, it will behave exactly as if it accessed
- * the target memory.
- */
-int kvm_create_memory_alias(kvm_context_t, uint64_t phys_addr,
- uint64_t phys_start, uint64_t len,
- uint64_t target_phys);
-
-/*!
- * \brief Destroy a memory alias
- *
- * Removes an alias created with kvm_create_memory_alias().
- */
-int kvm_destroy_memory_alias(kvm_context_t, uint64_t phys_addr);
-
-/*!
* \brief Get a bitmap of guest ram pages which are allocated to the guest.
*
* \param kvm Pointer to the current kvm_context