[PATCH 07 of 17] Move kvm_create_memory_alias & kvm_destroy_memory_alias to libkvm-x86.c

Jerone Young
2007-11-06T16:48:48Z

# Date 1194367649 21600
# Node ID cb186258bc6ecf05ded03d81a3d2ee820e58f605
# Parent 7ea01f673a05fe66cb0d9c514b5a43ddcd72c07f
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
@@ -294,3 +294,32 @@ void *kvm_create_kernel_phys_mem(kvm_con
return ptr;
}

+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);
+}