[PATCH v3 1/5] qemu-kvm.c memory cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now that libkvm is merged into this file, there is a lot of things we
don't need.

kvm_create_phys_mem() is only used by user/ files, and so can be
removed from this implementation.
kvm_cpu_register_physical_memory() morphs into kvm_set_phys_mem(),
and uses qemu types.

Signed-off-by: Glauber Costa <glommer@xxxxxxxxxx>
---
 qemu-kvm.c |   70 +----------------------------------------------------------
 qemu-kvm.h |   16 +------------
 2 files changed, 4 insertions(+), 82 deletions(-)

diff --git a/qemu-kvm.c b/qemu-kvm.c
index c5cd038..44cea10 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -534,52 +534,6 @@ int kvm_create(kvm_context_t kvm, unsigned long phys_mem_bytes, void **vm_mem)
 }
 
 
-void *kvm_create_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_userspace_memory_region memory = {
-		.memory_size = len,
-		.guest_phys_addr = phys_start,
-		.flags = log ? KVM_MEM_LOG_DIRTY_PAGES : 0,
-	};
-
-	if (writable)
-		prot |= PROT_WRITE;
-
-#if !defined(__s390__)
-	ptr = mmap(NULL, len, prot, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
-#else
-	ptr = mmap(LIBKVM_S390_ORIGIN, len, prot | PROT_EXEC,
-		MAP_FIXED | MAP_SHARED | MAP_ANONYMOUS, -1, 0);
-#endif
-	if (ptr == MAP_FAILED) {
-		fprintf(stderr, "%s: %s", __func__, strerror(errno));
-		return 0;
-	}
-
-	memset(ptr, 0, len);
-
-	memory.userspace_addr = (unsigned long)ptr;
-	memory.slot = get_free_slot(kvm);
-	DPRINTF("slot %d start %llx len %llx flags %x\n",
-		memory.slot,
-		memory.guest_phys_addr,
-		memory.memory_size,
-		memory.flags);
-	r = ioctl(kvm->vm_fd, KVM_SET_USER_MEMORY_REGION, &memory);
-	if (r == -1) {
-		fprintf(stderr, "%s: %s", __func__, strerror(errno));
-		return 0;
-	}
-	register_slot(memory.slot, memory.guest_phys_addr, memory.memory_size,
-		      memory.userspace_addr, memory.flags);
-
-        return ptr;
-}
-
 int kvm_register_phys_mem(kvm_context_t kvm,
 			  unsigned long phys_start, void *userspace_addr,
 			  unsigned long len, int log)
@@ -2394,9 +2348,8 @@ static void drop_mapping(target_phys_addr_t start_addr)
 }
 #endif
 
-void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr,
-                                      unsigned long size,
-                                      unsigned long phys_offset)
+void kvm_set_phys_mem(target_phys_addr_t start_addr, ram_addr_t size,
+                      ram_addr_t phys_offset)
 {
     int r = 0;
     unsigned long area_flags;
@@ -2473,13 +2426,6 @@ void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr,
     return;
 }
 
-void kvm_cpu_unregister_physical_memory(target_phys_addr_t start_addr,
-                                        target_phys_addr_t size,
-                                        unsigned long phys_offset)
-{
-    kvm_unregister_memory_area(kvm_context, start_addr, size);
-}
-
 int kvm_setup_guest_memory(void *area, unsigned long size)
 {
     int ret = 0;
@@ -2801,18 +2747,6 @@ int qemu_kvm_get_dirty_pages(unsigned long phys_addr, void *buf)
     return kvm_get_dirty_pages(kvm_context, phys_addr, buf);
 }
 
-void *kvm_cpu_create_phys_mem(target_phys_addr_t start_addr,
-			      unsigned long size, int log, int writable)
-{
-    return kvm_create_phys_mem(kvm_context, start_addr, size, log, writable);
-}
-
-void kvm_cpu_destroy_phys_mem(target_phys_addr_t start_addr,
-			      unsigned long size)
-{
-    kvm_destroy_phys_mem(kvm_context, start_addr, size);
-}
-
 void kvm_mutex_unlock(void)
 {
     assert(!cpu_single_env);
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 18a5b7f..de90259 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -48,12 +48,8 @@ void qemu_kvm_cpuid_on_env(CPUState *env);
 void kvm_inject_interrupt(CPUState *env, int mask);
 void kvm_update_after_sipi(CPUState *env);
 void kvm_update_interrupt_request(CPUState *env);
-void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr,
-                                      unsigned long size,
-                                      unsigned long phys_offset);
-void kvm_cpu_unregister_physical_memory(target_phys_addr_t start_addr,
-                                        target_phys_addr_t size,
-                                        unsigned long phys_offset);
+void kvm_set_phys_mem(target_phys_addr_t start_addr, ram_addr_t size,
+                      ram_addr_t phys_offset);
 void *kvm_cpu_create_phys_mem(target_phys_addr_t start_addr,
 			      unsigned long size, int log, int writable);
 
@@ -198,14 +194,6 @@ static inline void kvm_sleep_end(void)
 	kvm_mutex_lock();
 }
 
-static inline void kvm_set_phys_mem(target_phys_addr_t start_addr,
-                      ram_addr_t size,
-                      ram_addr_t phys_offset)
-{
-    kvm_cpu_register_physical_memory(start_addr, size, phys_offset);
-}
-
-
 int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, target_phys_addr_t end_addr);
 
 int kvm_log_start(target_phys_addr_t phys_addr, target_phys_addr_t len);
-- 
1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux