misc qemu-kvm cleanups
cover misc qemu-kvm cleanups
See individual patches for details.
PATCH 1/6 remove kvm_update_dirty_pages_log call from ram_save_block
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.
vl.c +0 -9
@@ -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;
qemu-kvm.c +0 -14
@@ -2338,20 +2338,6 @@ static int kvm_get_dirty_bitmap_cb(unsigreturn 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) {
qemu-kvm.h +0 -1
@@ -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);
PATCH 2/6 make cpu_physical_memory_set_dirty_tracking equal to upstream
In reply to Marcelo TosattiProbably introduced by mismerge.
exec.c +1 -1
@@ -2003,7 +2003,7 @@ void cpu_physical_memory_reset_dirty(ramint cpu_physical_memory_set_dirty_tracking (int enable) {int ret =0 ; - + in_migration = enable; ret =cpu_notify_migration_log (!!enable);return ret; }
PATCH 3/6 remove unused bios_mem variable
In reply to Marcelo Tosatticpu-all.h +0 -1
@@ -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;
exec.c +0 -1
@@ -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 {
PATCH 4/6 qemu-kvm: use upstream kvm_flush_coalesced_mmio_buffer
In reply to Marcelo Tosattiqemu-kvm.c +1 -13
@@ -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 ) {
PATCH 5/6 qemu-kvm: remove unused qemu_kvm_get_dirty_pages
In reply to Marcelo Tosattiqemu-kvm.c +0 -5
@@ -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);
qemu-kvm.h +0 -2
@@ -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);
PATCH 6/6 qemu-kvm: use reset handler for vcpus
In reply to Marcelo TosattiHook into the reset handlers instead of using custom code in qemu_kvm_system_reset.
Also move kvm_arch_init_vcpu to kvm_create_vcpu.
qemu-kvm.c +14 -11
@@ -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(CPUStatstatic 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 ;
Avi Kivity
AppliedQuoted 4 lines · Marcelo Tosatti
See individual patches for details.
Applied, thanks.
Signature · 1 line
error compiling committee.c: too many arguments to function