summaryrefslogtreecommitdiff
path: root/libkvm
diff options
context:
space:
mode:
Diffstat (limited to 'libkvm')
-rw-r--r--libkvm/libkvm.c69
-rw-r--r--libkvm/libkvm.h2
2 files changed, 2 insertions, 69 deletions
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index a850caa3..c2610530 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -439,74 +439,9 @@ int kvm_is_allocated_mem(kvm_context_t kvm, unsigned long phys_start,
return 0;
}
-int kvm_create_mem_hole(kvm_context_t kvm, unsigned long phys_start,
- unsigned long len)
-{
- int slot;
- int r;
- struct kvm_userspace_memory_region rmslot;
- struct kvm_userspace_memory_region newslot1;
- struct kvm_userspace_memory_region newslot2;
-
- len = (len + PAGE_SIZE - 1) & PAGE_MASK;
-
- slot = get_intersecting_slot(phys_start);
- /* no need to create hole, as there is already hole */
- if (slot == -1)
- return 0;
-
- memset(&rmslot, 0, sizeof(struct kvm_userspace_memory_region));
- memset(&newslot1, 0, sizeof(struct kvm_userspace_memory_region));
- memset(&newslot2, 0, sizeof(struct kvm_userspace_memory_region));
-
- rmslot.guest_phys_addr = slots[slot].phys_addr;
- rmslot.slot = slot;
-
- newslot1.guest_phys_addr = slots[slot].phys_addr;
- newslot1.memory_size = phys_start - slots[slot].phys_addr;
- newslot1.slot = slot;
- newslot1.userspace_addr = slots[slot].userspace_addr;
- newslot1.flags = slots[slot].flags;
-
- newslot2.guest_phys_addr = newslot1.guest_phys_addr +
- newslot1.memory_size + len;
- newslot2.memory_size = slots[slot].phys_addr +
- slots[slot].len - newslot2.guest_phys_addr;
- newslot2.userspace_addr = newslot1.userspace_addr +
- newslot1.memory_size;
- newslot2.slot = get_free_slot(kvm);
- newslot2.flags = newslot1.flags;
-
- r = ioctl(kvm->vm_fd, KVM_SET_USER_MEMORY_REGION, &rmslot);
- if (r == -1) {
- fprintf(stderr, "kvm_create_mem_hole: %s\n", strerror(errno));
- return -1;
- }
- free_slot(slot);
-
- r = ioctl(kvm->vm_fd, KVM_SET_USER_MEMORY_REGION, &newslot1);
- if (r == -1) {
- fprintf(stderr, "kvm_create_mem_hole: %s\n", strerror(errno));
- return -1;
- }
- register_slot(newslot1.slot, newslot1.guest_phys_addr,
- newslot1.memory_size, newslot1.userspace_addr,
- newslot1.flags);
-
- r = ioctl(kvm->vm_fd, KVM_SET_USER_MEMORY_REGION, &newslot2);
- if (r == -1) {
- fprintf(stderr, "kvm_create_mem_hole: %s\n", strerror(errno));
- return -1;
- }
- register_slot(newslot2.slot, newslot2.guest_phys_addr,
- newslot2.memory_size, newslot2.userspace_addr,
- newslot2.flags);
- return 0;
-}
-
int kvm_register_phys_mem(kvm_context_t kvm,
- unsigned long phys_start, void *userspace_addr,
- unsigned long len, int log)
+ unsigned long phys_start, void *userspace_addr,
+ unsigned long len, int log)
{
struct kvm_userspace_memory_region memory = {
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
index 79dd7698..77fd903f 100644
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -457,8 +457,6 @@ void kvm_destroy_phys_mem(kvm_context_t, unsigned long phys_start,
int kvm_is_intersecting_mem(kvm_context_t kvm, unsigned long phys_start);
int kvm_is_allocated_mem(kvm_context_t kvm, unsigned long phys_start,
unsigned long len);
-int kvm_create_mem_hole(kvm_context_t kvm, unsigned long phys_start,
- unsigned long len);
int kvm_register_phys_mem(kvm_context_t kvm,
unsigned long phys_start, void *userspace_addr,
unsigned long len, int log);