From: Glauber Costa Subject: [PATCH] remove create_kernel_phys_mem Date: Mon, 8 Sep 2008 16:30:15 -0300 Message-ID: <1220902221-7536-7-git-send-email-gcosta@redhat.com> References: <1220902221-7536-1-git-send-email-gcosta@redhat.com> <1220902221-7536-2-git-send-email-gcosta@redhat.com> <1220902221-7536-3-git-send-email-gcosta@redhat.com> <1220902221-7536-4-git-send-email-gcosta@redhat.com> <1220902221-7536-5-git-send-email-gcosta@redhat.com> <1220902221-7536-6-git-send-email-gcosta@redhat.com> Cc: avi@qumranet.com, aliguori@us.ibm.com, Glauber Costa To: kvm@vger.kernel.org Return-path: Received: from mx2.redhat.com ([66.187.237.31]:58708 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755099AbYIHTgG (ORCPT ); Mon, 8 Sep 2008 15:36:06 -0400 In-Reply-To: <1220902221-7536-6-git-send-email-gcosta@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: From: Glauber Costa Wipe out create_kernel_phys_mem(), and all of its users. Signed-off-by: Glauber Costa --- libkvm/kvm-common.h | 3 --- libkvm/libkvm-ia64.c | 6 ------ libkvm/libkvm-powerpc.c | 7 ------- libkvm/libkvm-s390.c | 7 ------- libkvm/libkvm-x86.c | 33 --------------------------------- libkvm/libkvm.c | 14 +++----------- 6 files changed, 3 insertions(+), 67 deletions(-) diff --git a/libkvm/kvm-common.h b/libkvm/kvm-common.h index 93cea1b..0c04cbc 100644 --- a/libkvm/kvm-common.h +++ b/libkvm/kvm-common.h @@ -72,9 +72,6 @@ int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory, void **vm_mem); int kvm_alloc_userspace_memory(kvm_context_t kvm, unsigned long memory, void **vm_mem); -void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start, - unsigned long len, int log, int writable); - int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes, void **vm_mem); diff --git a/libkvm/libkvm-ia64.c b/libkvm/libkvm-ia64.c index 152d8fd..f3afc56 100644 --- a/libkvm/libkvm-ia64.c +++ b/libkvm/libkvm-ia64.c @@ -33,12 +33,6 @@ #include #include -void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start, - unsigned long len, int log, int writable) -{ - return NULL; -} - int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes, void **vm_mem) { diff --git a/libkvm/libkvm-powerpc.c b/libkvm/libkvm-powerpc.c index c523f26..aaebfef 100644 --- a/libkvm/libkvm-powerpc.c +++ b/libkvm/libkvm-powerpc.c @@ -43,13 +43,6 @@ int handle_dcr(struct kvm_run *run, kvm_context_t kvm, int vcpu) return ret; } -void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start, - unsigned long len, int log, int writable) -{ - fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__); - return NULL; -} - void kvm_show_code(kvm_context_t kvm, int vcpu) { fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__); diff --git a/libkvm/libkvm-s390.c b/libkvm/libkvm-s390.c index 59c534f..041c0ce 100644 --- a/libkvm/libkvm-s390.c +++ b/libkvm/libkvm-s390.c @@ -22,13 +22,6 @@ #include #include -void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start, - unsigned long len, int log, int writable) -{ - fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__); - return NULL; -} - void kvm_show_code(kvm_context_t kvm, int vcpu) { fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__); diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c index 4ca3d7b..a8cca15 100644 --- a/libkvm/libkvm-x86.c +++ b/libkvm/libkvm-x86.c @@ -145,39 +145,6 @@ int kvm_arch_run(struct kvm_run *run,kvm_context_t kvm, int vcpu) return r; } -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, memory.memory_size, - 0, 0, memory.flags); - - 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; -} - #define MAX_ALIAS_SLOTS 4 static struct { uint64_t start; diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c index cfb1195..5b48240 100644 --- a/libkvm/libkvm.c +++ b/libkvm/libkvm.c @@ -456,13 +456,8 @@ void kvm_destroy_userspace_phys_mem(kvm_context_t kvm, void *kvm_create_phys_mem(kvm_context_t kvm, unsigned long phys_start, unsigned long len, int log, int writable) { - r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_USER_MEMORY); - if (r > 0) - return kvm_create_userspace_phys_mem(kvm, phys_start, len, - log, writable); - else - return kvm_create_kernel_phys_mem(kvm, phys_start, len, - log, writable); + return kvm_create_userspace_phys_mem(kvm, phys_start, len, + log, writable); } int kvm_is_intersecting_mem(kvm_context_t kvm, unsigned long phys_start) @@ -595,10 +590,7 @@ void kvm_destroy_phys_mem(kvm_context_t kvm, unsigned long phys_start, phys_start = slots[slot].phys_addr; } - if (ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_USER_MEMORY) > 0) - kvm_destroy_userspace_phys_mem(kvm, phys_start); - else - kvm_create_kernel_phys_mem(kvm, phys_start, 0, 0, 0); + kvm_destroy_userspace_phys_mem(kvm, phys_start); } static int kvm_get_map(kvm_context_t kvm, int ioctl_num, int slot, void *buf) -- 1.5.5.1