All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 0/6] misc qemu-kvm cleanups
@ 2010-03-23 16:53 Marcelo Tosatti
  2010-03-23 16:53 ` [patch 1/6] remove kvm_update_dirty_pages_log call from ram_save_block Marcelo Tosatti
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2010-03-23 16:53 UTC (permalink / raw)
  To: kvm

See individual patches for details.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch 1/6] remove kvm_update_dirty_pages_log call from ram_save_block
  2010-03-23 16:53 [patch 0/6] misc qemu-kvm cleanups Marcelo Tosatti
@ 2010-03-23 16:53 ` Marcelo Tosatti
  2010-03-23 16:53 ` [patch 2/6] make cpu_physical_memory_set_dirty_tracking equal to upstream Marcelo Tosatti
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2010-03-23 16:53 UTC (permalink / raw)
  To: kvm; +Cc: Marcelo Tosatti

[-- Attachment #1: remove-saveram-kvm-update-dirty-log --]
[-- Type: text/plain, Size: 2300 bytes --]

There is no need to update the dirty log from inside ram_save_block, 
since this happens through cpu_physical_sync_dirty_bitmap.

In stage 3, where the VM is stopped, cpu_physical_sync_dirty_bitmap
guarantees dirty log is synchronized before migration finishes.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu-kvm-cleanups/vl.c
===================================================================
--- qemu-kvm-cleanups.orig/vl.c
+++ qemu-kvm-cleanups/vl.c
@@ -2782,15 +2782,6 @@ static int ram_save_block(QEMUFile *f)
     int found = 0;
 
     while (addr < last_ram_offset) {
-        if (kvm_enabled() && current_addr == 0) {
-            int r;
-            r = kvm_update_dirty_pages_log();
-            if (r) {
-                fprintf(stderr, "%s: update dirty pages log failed %d\n", __FUNCTION__, r);
-                qemu_file_set_error(f);
-                return 0;
-            }
-        }
         if (cpu_physical_memory_get_dirty(current_addr, MIGRATION_DIRTY_FLAG)) {
             uint8_t *p;
 
Index: qemu-kvm-cleanups/qemu-kvm.c
===================================================================
--- qemu-kvm-cleanups.orig/qemu-kvm.c
+++ qemu-kvm-cleanups/qemu-kvm.c
@@ -2338,20 +2338,6 @@ static int kvm_get_dirty_bitmap_cb(unsig
     return kvm_get_dirty_pages_log_range(start, bitmap, start, len);
 }
 
-/* 
- * get kvm's dirty pages bitmap and update qemu's
- * we only care about physical ram, which resides in slots 0 and 3
- */
-int kvm_update_dirty_pages_log(void)
-{
-    int r = 0;
-
-
-    r = kvm_get_dirty_pages_range(kvm_context, 0, -1UL, NULL,
-                                  kvm_get_dirty_bitmap_cb);
-    return r;
-}
-
 void kvm_qemu_log_memory(target_phys_addr_t start, target_phys_addr_t size,
                          int log)
 {
Index: qemu-kvm-cleanups/qemu-kvm.h
===================================================================
--- qemu-kvm-cleanups.orig/qemu-kvm.h
+++ qemu-kvm-cleanups/qemu-kvm.h
@@ -836,7 +836,6 @@ void kvm_hpet_disable_kpit(void);
 int kvm_set_irq(int irq, int level, int *status);
 
 int kvm_physical_memory_set_dirty_tracking(int enable);
-int kvm_update_dirty_pages_log(void);
 
 void qemu_kvm_call_with_env(void (*func)(void *), void *data, CPUState *env);
 void qemu_kvm_cpuid_on_env(CPUState *env);



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch 2/6] make cpu_physical_memory_set_dirty_tracking equal to upstream
  2010-03-23 16:53 [patch 0/6] misc qemu-kvm cleanups Marcelo Tosatti
  2010-03-23 16:53 ` [patch 1/6] remove kvm_update_dirty_pages_log call from ram_save_block Marcelo Tosatti
@ 2010-03-23 16:53 ` Marcelo Tosatti
  2010-03-23 16:53 ` [patch 3/6] remove unused bios_mem variable Marcelo Tosatti
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2010-03-23 16:53 UTC (permalink / raw)
  To: kvm; +Cc: Marcelo Tosatti

[-- Attachment #1: remove-in-migration-removal --]
[-- Type: text/plain, Size: 490 bytes --]

Probably introduced by mismerge.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu-kvm-cleanups/exec.c
===================================================================
--- qemu-kvm-cleanups.orig/exec.c
+++ qemu-kvm-cleanups/exec.c
@@ -2003,7 +2003,7 @@ void cpu_physical_memory_reset_dirty(ram
 int cpu_physical_memory_set_dirty_tracking(int enable)
 {
     int ret = 0;
-
+    in_migration = enable;
     ret = cpu_notify_migration_log(!!enable);
     return ret;
 }



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch 3/6] remove unused bios_mem variable
  2010-03-23 16:53 [patch 0/6] misc qemu-kvm cleanups Marcelo Tosatti
  2010-03-23 16:53 ` [patch 1/6] remove kvm_update_dirty_pages_log call from ram_save_block Marcelo Tosatti
  2010-03-23 16:53 ` [patch 2/6] make cpu_physical_memory_set_dirty_tracking equal to upstream Marcelo Tosatti
@ 2010-03-23 16:53 ` Marcelo Tosatti
  2010-03-23 16:53 ` [patch 4/6] qemu-kvm: use upstream kvm_flush_coalesced_mmio_buffer Marcelo Tosatti
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2010-03-23 16:53 UTC (permalink / raw)
  To: kvm; +Cc: Marcelo Tosatti

[-- Attachment #1: remove-bios-mem --]
[-- Type: text/plain, Size: 812 bytes --]

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu-kvm-cleanups/cpu-all.h
===================================================================
--- qemu-kvm-cleanups.orig/cpu-all.h
+++ qemu-kvm-cleanups/cpu-all.h
@@ -846,7 +846,6 @@ extern int phys_ram_fd;
 extern uint8_t *phys_ram_dirty;
 extern ram_addr_t ram_size;
 extern ram_addr_t last_ram_offset;
-extern uint8_t *bios_mem;
 
 extern const char *mem_path;
 extern int mem_prealloc;
Index: qemu-kvm-cleanups/exec.c
===================================================================
--- qemu-kvm-cleanups.orig/exec.c
+++ qemu-kvm-cleanups/exec.c
@@ -120,7 +120,6 @@ uint8_t *code_gen_ptr;
 #if !defined(CONFIG_USER_ONLY)
 int phys_ram_fd;
 uint8_t *phys_ram_dirty;
-uint8_t *bios_mem;
 static int in_migration;
 
 typedef struct RAMBlock {



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch 4/6] qemu-kvm: use upstream kvm_flush_coalesced_mmio_buffer
  2010-03-23 16:53 [patch 0/6] misc qemu-kvm cleanups Marcelo Tosatti
                   ` (2 preceding siblings ...)
  2010-03-23 16:53 ` [patch 3/6] remove unused bios_mem variable Marcelo Tosatti
@ 2010-03-23 16:53 ` Marcelo Tosatti
  2010-03-23 16:53 ` [patch 5/6] qemu-kvm: remove unused qemu_kvm_get_dirty_pages Marcelo Tosatti
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2010-03-23 16:53 UTC (permalink / raw)
  To: kvm; +Cc: Marcelo Tosatti

[-- Attachment #1: flush-coalesced-cleanup --]
[-- Type: text/plain, Size: 978 bytes --]

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu-kvm-cleanups/qemu-kvm.c
===================================================================
--- qemu-kvm-cleanups.orig/qemu-kvm.c
+++ qemu-kvm-cleanups/qemu-kvm.c
@@ -935,19 +935,7 @@ int kvm_run(CPUState *env)
 
     post_kvm_run(kvm, env);
 
-#if defined(KVM_CAP_COALESCED_MMIO)
-    if (kvm_state->coalesced_mmio) {
-        struct kvm_coalesced_mmio_ring *ring =
-            (void *) run + kvm_state->coalesced_mmio * PAGE_SIZE;
-        while (ring->first != ring->last) {
-            cpu_physical_memory_rw(ring->coalesced_mmio[ring->first].phys_addr,
-                           &ring->coalesced_mmio[ring->first].data[0],
-                           ring->coalesced_mmio[ring->first].len, 1);
-            smp_wmb();
-            ring->first = (ring->first + 1) % KVM_COALESCED_MMIO_MAX;
-        }
-    }
-#endif
+    kvm_flush_coalesced_mmio_buffer();
 
 #if !defined(__s390__)
     if (r == -1) {



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch 5/6] qemu-kvm: remove unused qemu_kvm_get_dirty_pages
  2010-03-23 16:53 [patch 0/6] misc qemu-kvm cleanups Marcelo Tosatti
                   ` (3 preceding siblings ...)
  2010-03-23 16:53 ` [patch 4/6] qemu-kvm: use upstream kvm_flush_coalesced_mmio_buffer Marcelo Tosatti
@ 2010-03-23 16:53 ` Marcelo Tosatti
  2010-03-23 16:53 ` [patch 6/6] qemu-kvm: use reset handler for vcpus Marcelo Tosatti
  2010-03-24  9:42 ` [patch 0/6] misc qemu-kvm cleanups Avi Kivity
  6 siblings, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2010-03-23 16:53 UTC (permalink / raw)
  To: kvm; +Cc: Marcelo Tosatti

[-- Attachment #1: qemukvm-remove-get-dirty-pages --]
[-- Type: text/plain, Size: 992 bytes --]

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu-kvm-cleanups/qemu-kvm.c
===================================================================
--- qemu-kvm-cleanups.orig/qemu-kvm.c
+++ qemu-kvm-cleanups/qemu-kvm.c
@@ -2349,11 +2349,6 @@ int kvm_set_irq(int irq, int level, int 
 
 #endif
 
-int qemu_kvm_get_dirty_pages(unsigned long phys_addr, void *buf)
-{
-    return kvm_get_dirty_pages(kvm_context, phys_addr, buf);
-}
-
 void kvm_mutex_unlock(void)
 {
     assert(!cpu_single_env);
Index: qemu-kvm-cleanups/qemu-kvm.h
===================================================================
--- qemu-kvm-cleanups.orig/qemu-kvm.h
+++ qemu-kvm-cleanups/qemu-kvm.h
@@ -874,8 +874,6 @@ void qemu_kvm_notify_work(void);
 
 void kvm_tpr_access_report(CPUState *env, uint64_t rip, int is_write);
 
-int qemu_kvm_get_dirty_pages(unsigned long phys_addr, void *buf);
-
 int kvm_arch_init_irq_routing(void);
 
 int kvm_mmio_read(void *opaque, uint64_t addr, uint8_t * data, int len);



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch 6/6] qemu-kvm: use reset handler for vcpus
  2010-03-23 16:53 [patch 0/6] misc qemu-kvm cleanups Marcelo Tosatti
                   ` (4 preceding siblings ...)
  2010-03-23 16:53 ` [patch 5/6] qemu-kvm: remove unused qemu_kvm_get_dirty_pages Marcelo Tosatti
@ 2010-03-23 16:53 ` Marcelo Tosatti
  2010-03-24  9:42 ` [patch 0/6] misc qemu-kvm cleanups Avi Kivity
  6 siblings, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2010-03-23 16:53 UTC (permalink / raw)
  To: kvm; +Cc: Marcelo Tosatti

[-- Attachment #1: register-reset-vcpu --]
[-- Type: text/plain, Size: 1978 bytes --]

Hook into the reset handlers instead of using custom code in
qemu_kvm_system_reset.

Also move kvm_arch_init_vcpu to kvm_create_vcpu.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu-kvm-cleanups/qemu-kvm.c
===================================================================
--- qemu-kvm-cleanups.orig/qemu-kvm.c
+++ qemu-kvm-cleanups/qemu-kvm.c
@@ -439,6 +439,13 @@ void kvm_disable_pit_creation(kvm_contex
     kvm->no_pit_creation = 1;
 }
 
+static void kvm_reset_vcpu(void *opaque)
+{
+    CPUState *env = opaque;
+
+    kvm_arch_cpu_reset(env);
+}
+
 static void kvm_create_vcpu(CPUState *env, int id)
 {
     long mmap_size;
@@ -473,6 +480,11 @@ static void kvm_create_vcpu(CPUState *en
                s->coalesced_mmio * PAGE_SIZE;
 #endif
 
+    r = kvm_arch_init_vcpu(env);
+    if (r == 0) {
+        qemu_register_reset(kvm_reset_vcpu, env);
+    }
+
     return;
   err_fd:
     close(env->kvm_fd);
@@ -1777,17 +1789,10 @@ static void setup_kernel_sigmask(CPUStat
 
 static void qemu_kvm_system_reset(void)
 {
-    CPUState *penv = first_cpu;
-
     pause_all_threads();
 
     qemu_system_reset();
 
-    while (penv) {
-        kvm_arch_cpu_reset(penv);
-        penv = (CPUState *) penv->next_cpu;
-    }
-
     resume_all_threads();
 }
 
@@ -1829,7 +1834,6 @@ static void *ap_main_loop(void *_env)
     env->thread_id = kvm_get_thread_id();
     sigfillset(&signals);
     sigprocmask(SIG_BLOCK, &signals, NULL);
-    kvm_create_vcpu(env, env->cpu_index);
 
 #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
     /* do ioperm for io ports of assigned devices */
@@ -1837,12 +1841,11 @@ static void *ap_main_loop(void *_env)
         on_vcpu(env, kvm_arch_do_ioperm, data);
 #endif
 
-    setup_kernel_sigmask(env);
-
     pthread_mutex_lock(&qemu_mutex);
     cpu_single_env = env;
 
-    kvm_arch_init_vcpu(env);
+    kvm_create_vcpu(env, env->cpu_index);
+    setup_kernel_sigmask(env);
 
     /* signal VCPU creation */
     current_env->created = 1;



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 0/6] misc qemu-kvm cleanups
  2010-03-23 16:53 [patch 0/6] misc qemu-kvm cleanups Marcelo Tosatti
                   ` (5 preceding siblings ...)
  2010-03-23 16:53 ` [patch 6/6] qemu-kvm: use reset handler for vcpus Marcelo Tosatti
@ 2010-03-24  9:42 ` Avi Kivity
  6 siblings, 0 replies; 8+ messages in thread
From: Avi Kivity @ 2010-03-24  9:42 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: kvm

On 03/23/2010 06:53 PM, Marcelo Tosatti wrote:
> See individual patches for details.
>
>
>    

Applied, thanks.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-03-24  9:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-23 16:53 [patch 0/6] misc qemu-kvm cleanups Marcelo Tosatti
2010-03-23 16:53 ` [patch 1/6] remove kvm_update_dirty_pages_log call from ram_save_block Marcelo Tosatti
2010-03-23 16:53 ` [patch 2/6] make cpu_physical_memory_set_dirty_tracking equal to upstream Marcelo Tosatti
2010-03-23 16:53 ` [patch 3/6] remove unused bios_mem variable Marcelo Tosatti
2010-03-23 16:53 ` [patch 4/6] qemu-kvm: use upstream kvm_flush_coalesced_mmio_buffer Marcelo Tosatti
2010-03-23 16:53 ` [patch 5/6] qemu-kvm: remove unused qemu_kvm_get_dirty_pages Marcelo Tosatti
2010-03-23 16:53 ` [patch 6/6] qemu-kvm: use reset handler for vcpus Marcelo Tosatti
2010-03-24  9:42 ` [patch 0/6] misc qemu-kvm cleanups Avi Kivity

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.