diff options
author | Glauber Costa <glommer@redhat.com> | 2008-09-10 16:20:55 -0300 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-09-11 11:54:34 +0300 |
commit | 4aa7093b9dcd168c426bfd8d1c9f3d94703ca46c (patch) | |
tree | d159f57a7978c083e79e2ed1182e2564fc49da19 /libkvm | |
parent | 0c1e6b46ce82fe7f2fb26d457f7f561335625000 (diff) |
kvm: libkvm: start removing kernel memory functions
kvm_arch_create_default_phys_mem and kvm_alloc_kernel_memory
are legacy. Remove them, and their callers. The whole removal
will be split for bisectability. These ones goes first because they are
only called at initialization
Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'libkvm')
-rw-r--r-- | libkvm/kvm-common.h | 3 | ||||
-rw-r--r-- | libkvm/libkvm-ia64.c | 25 | ||||
-rw-r--r-- | libkvm/libkvm-powerpc.c | 14 | ||||
-rw-r--r-- | libkvm/libkvm-s390.c | 14 | ||||
-rw-r--r-- | libkvm/libkvm-x86.c | 91 | ||||
-rw-r--r-- | libkvm/libkvm.c | 19 |
6 files changed, 5 insertions, 161 deletions
diff --git a/libkvm/kvm-common.h b/libkvm/kvm-common.h index 7092085a..93cea1b7 100644 --- a/libkvm/kvm-common.h +++ b/libkvm/kvm-common.h @@ -78,9 +78,6 @@ void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start, int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes, void **vm_mem); -int kvm_arch_create_default_phys_mem(kvm_context_t kvm, - unsigned long phys_mem_bytes, - void **vm_mem); int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu); diff --git a/libkvm/libkvm-ia64.c b/libkvm/libkvm-ia64.c index f35a16c5..152d8fd4 100644 --- a/libkvm/libkvm-ia64.c +++ b/libkvm/libkvm-ia64.c @@ -33,31 +33,6 @@ #include <fcntl.h> #include <stdlib.h> -int kvm_arch_create_default_phys_mem(kvm_context_t kvm, - unsigned long phys_mem_bytes, - void **vm_mem) -{ - int zfd; - - zfd = open("/dev/zero", O_RDONLY); - if (zfd == -1) { - perror("open /dev/zero"); - return -1; - } - mmap(*vm_mem + 0xa8000, 0x8000, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_FIXED, zfd, 0); - close(zfd); - - return 0; -} - - -int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory, - void **vm_mem) -{ - return 0; -} - void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start, unsigned long len, int log, int writable) { diff --git a/libkvm/libkvm-powerpc.c b/libkvm/libkvm-powerpc.c index 376aca47..c523f26a 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; } -int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory, - void **vm_mem) -{ - fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__); - return -1; -} - void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start, unsigned long len, int log, int writable) { @@ -102,13 +95,6 @@ int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes, return 0; } -int kvm_arch_create_default_phys_mem(kvm_context_t kvm, - unsigned long phys_mem_bytes, - void **vm_mem) -{ - return 0; -} - int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu) { int ret = 0; diff --git a/libkvm/libkvm-s390.c b/libkvm/libkvm-s390.c index b3e4e92f..59c534fc 100644 --- a/libkvm/libkvm-s390.c +++ b/libkvm/libkvm-s390.c @@ -22,13 +22,6 @@ #include <stdio.h> #include <inttypes.h> -int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory, - void **vm_mem) -{ - fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__); - return -1; -} - void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start, unsigned long len, int log, int writable) { @@ -87,13 +80,6 @@ int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes, return 0; } -int kvm_arch_create_default_phys_mem(kvm_context_t kvm, - unsigned long phys_mem_bytes, - void **vm_mem) -{ - return 0; -} - int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu) { int ret = 0; diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c index ea97bdd2..4ca3d7ba 100644 --- a/libkvm/libkvm-x86.c +++ b/libkvm/libkvm-x86.c @@ -13,79 +13,6 @@ #include <fcntl.h> #include <stdlib.h> -int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory, - void **vm_mem) -{ - unsigned long dosmem = 0xa0000; - unsigned long exmem = 0xc0000; - unsigned long pcimem = 0xe0000000; - int r; - int tss_ext; - struct kvm_memory_region low_memory = { - .memory_size = memory < dosmem ? memory : dosmem, - .guest_phys_addr = 0, - }; - struct kvm_memory_region extended_memory = { - .memory_size = memory < exmem ? 0 : memory - exmem, - .guest_phys_addr = exmem, - }; - struct kvm_memory_region above_4g_memory = { - .memory_size = memory < pcimem ? 0 : memory - pcimem, - .guest_phys_addr = 0x100000000ULL, - }; - -#ifdef KVM_CAP_SET_TSS_ADDR - tss_ext = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_SET_TSS_ADDR); -#else - tss_ext = 0; -#endif - - if (memory >= pcimem) - extended_memory.memory_size = pcimem - exmem; - - /* 640K should be enough. */ - low_memory.slot = get_free_slot(kvm); - r = ioctl(kvm->vm_fd, KVM_SET_MEMORY_REGION, &low_memory); - if (r == -1) { - fprintf(stderr, "kvm_create_memory_region: %m\n"); - return -1; - } - register_slot(low_memory.slot, low_memory.guest_phys_addr, - low_memory.memory_size, 0, 0, 0); - - - if (extended_memory.memory_size) { - if (tss_ext > 0) - extended_memory.slot = get_free_slot(kvm); - else - extended_memory.slot = 0; - r = ioctl(kvm->vm_fd, KVM_SET_MEMORY_REGION, &extended_memory); - if (r == -1) { - fprintf(stderr, "kvm_create_memory_region: %m\n"); - return -1; - } - register_slot(extended_memory.slot, - extended_memory.guest_phys_addr, - extended_memory.memory_size, 0, 0, 0); - } - - if (above_4g_memory.memory_size) { - above_4g_memory.slot = get_free_slot(kvm); - r = ioctl(kvm->vm_fd, KVM_SET_MEMORY_REGION, &above_4g_memory); - if (r == -1) { - fprintf(stderr, "kvm_create_memory_region: %m\n"); - return -1; - } - register_slot(above_4g_memory.slot, - above_4g_memory.guest_phys_addr, - above_4g_memory.memory_size, 0, 0, 0); - } - - *vm_mem = mmap(NULL, memory, PROT_READ|PROT_WRITE, MAP_SHARED, kvm->vm_fd, 0); - - return 0; -} - int kvm_set_tss_addr(kvm_context_t kvm, unsigned long addr) { #ifdef KVM_CAP_SET_TSS_ADDR @@ -126,24 +53,6 @@ static int kvm_init_tss(kvm_context_t kvm) return 0; } -int kvm_arch_create_default_phys_mem(kvm_context_t kvm, - unsigned long phys_mem_bytes, - void **vm_mem) -{ - int zfd; - - zfd = open("/dev/zero", O_RDONLY); - if (zfd == -1) { - perror("open /dev/zero"); - return -1; - } - mmap(*vm_mem + 0xa8000, 0x8000, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_FIXED, zfd, 0); - close(zfd); - - return 0; -} - int kvm_create_pit(kvm_context_t kvm) { #ifdef KVM_CAP_PIT diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c index 250a821d..d0c65cbe 100644 --- a/libkvm/libkvm.c +++ b/libkvm/libkvm.c @@ -328,24 +328,15 @@ static int kvm_create_default_phys_mem(kvm_context_t kvm, unsigned long phys_mem_bytes, void **vm_mem) { - unsigned long memory = (phys_mem_bytes + PAGE_SIZE - 1) & PAGE_MASK; - int r; - #ifdef KVM_CAP_USER_MEMORY - r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_USER_MEMORY); + int r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_USER_MEMORY); if (r > 0) return 0; - else + fprintf(stderr, "Hypervisor too old: KVM_CAP_USER_MEMORY extension not supported\n"); +#else +#error Hypervisor too old: KVM_CAP_USER_MEMORY extension not supported #endif - r = kvm_alloc_kernel_memory(kvm, memory, vm_mem); - if (r < 0) - return r; - - r = kvm_arch_create_default_phys_mem(kvm, phys_mem_bytes, vm_mem); - if (r < 0) - return r; - - return 0; + return -1; } int kvm_check_extension(kvm_context_t kvm, int ext) |