kvm: move kvm to use memory notifiers
remove direct kvm calls from exec.c, make kvm use memory notifiers framework instead. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
46dbef6ade
commit
7b8f3b7834
17
exec.c
17
exec.c
@ -1988,12 +1988,6 @@ int cpu_physical_memory_set_dirty_tracking(int enable)
|
||||
{
|
||||
int ret = 0;
|
||||
in_migration = enable;
|
||||
if (kvm_enabled()) {
|
||||
ret = kvm_set_migration_log(enable);
|
||||
}
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
ret = cpu_notify_migration_log(!!enable);
|
||||
return ret;
|
||||
}
|
||||
@ -2006,14 +2000,8 @@ int cpu_physical_memory_get_dirty_tracking(void)
|
||||
int cpu_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
|
||||
target_phys_addr_t end_addr)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret;
|
||||
|
||||
if (kvm_enabled()) {
|
||||
ret = kvm_physical_sync_dirty_bitmap(start_addr, end_addr);
|
||||
}
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
ret = cpu_notify_sync_dirty_bitmap(start_addr, end_addr);
|
||||
return ret;
|
||||
}
|
||||
@ -2426,9 +2414,6 @@ void cpu_register_physical_memory_offset(target_phys_addr_t start_addr,
|
||||
ram_addr_t orig_size = size;
|
||||
void *subpage;
|
||||
|
||||
if (kvm_enabled())
|
||||
kvm_set_phys_mem(start_addr, size, phys_offset);
|
||||
|
||||
cpu_notify_set_memory(start_addr, size, phys_offset);
|
||||
|
||||
if (phys_offset == IO_MEM_UNASSIGNED) {
|
||||
|
40
kvm-all.c
40
kvm-all.c
@ -265,7 +265,7 @@ int kvm_log_stop(target_phys_addr_t phys_addr, ram_addr_t size)
|
||||
KVM_MEM_LOG_DIRTY_PAGES);
|
||||
}
|
||||
|
||||
int kvm_set_migration_log(int enable)
|
||||
static int kvm_set_migration_log(int enable)
|
||||
{
|
||||
KVMState *s = kvm_state;
|
||||
KVMSlot *mem;
|
||||
@ -300,8 +300,8 @@ static int test_le_bit(unsigned long nr, unsigned char *addr)
|
||||
* @start_add: start of logged region.
|
||||
* @end_addr: end of logged region.
|
||||
*/
|
||||
int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
|
||||
target_phys_addr_t end_addr)
|
||||
static int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
|
||||
target_phys_addr_t end_addr)
|
||||
{
|
||||
KVMState *s = kvm_state;
|
||||
unsigned long size, allocated_size = 0;
|
||||
@ -402,9 +402,9 @@ int kvm_check_extension(KVMState *s, unsigned int extension)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void kvm_set_phys_mem(target_phys_addr_t start_addr,
|
||||
ram_addr_t size,
|
||||
ram_addr_t phys_offset)
|
||||
static void kvm_set_phys_mem(target_phys_addr_t start_addr,
|
||||
ram_addr_t size,
|
||||
ram_addr_t phys_offset)
|
||||
{
|
||||
KVMState *s = kvm_state;
|
||||
ram_addr_t flags = phys_offset & ~TARGET_PAGE_MASK;
|
||||
@ -540,6 +540,33 @@ void kvm_set_phys_mem(target_phys_addr_t start_addr,
|
||||
}
|
||||
}
|
||||
|
||||
static void kvm_client_set_memory(struct CPUPhysMemoryClient *client,
|
||||
target_phys_addr_t start_addr,
|
||||
ram_addr_t size,
|
||||
ram_addr_t phys_offset)
|
||||
{
|
||||
kvm_set_phys_mem(start_addr, size, phys_offset);
|
||||
}
|
||||
|
||||
static int kvm_client_sync_dirty_bitmap(struct CPUPhysMemoryClient *client,
|
||||
target_phys_addr_t start_addr,
|
||||
target_phys_addr_t end_addr)
|
||||
{
|
||||
return kvm_physical_sync_dirty_bitmap(start_addr, end_addr);
|
||||
}
|
||||
|
||||
static int kvm_client_migration_log(struct CPUPhysMemoryClient *client,
|
||||
int enable)
|
||||
{
|
||||
return kvm_set_migration_log(enable);
|
||||
}
|
||||
|
||||
static CPUPhysMemoryClient kvm_cpu_phys_memory_client = {
|
||||
.set_memory = kvm_client_set_memory,
|
||||
.sync_dirty_bitmap = kvm_client_sync_dirty_bitmap,
|
||||
.migration_log = kvm_client_migration_log,
|
||||
};
|
||||
|
||||
int kvm_init(int smp_cpus)
|
||||
{
|
||||
static const char upgrade_note[] =
|
||||
@ -636,6 +663,7 @@ int kvm_init(int smp_cpus)
|
||||
goto err;
|
||||
|
||||
kvm_state = s;
|
||||
cpu_register_phys_memory_client(&kvm_cpu_phys_memory_client);
|
||||
|
||||
return 0;
|
||||
|
||||
|
8
kvm.h
8
kvm.h
@ -35,16 +35,8 @@ int kvm_init_vcpu(CPUState *env);
|
||||
|
||||
int kvm_cpu_exec(CPUState *env);
|
||||
|
||||
void kvm_set_phys_mem(target_phys_addr_t start_addr,
|
||||
ram_addr_t size,
|
||||
ram_addr_t 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, ram_addr_t size);
|
||||
int kvm_log_stop(target_phys_addr_t phys_addr, ram_addr_t size);
|
||||
int kvm_set_migration_log(int enable);
|
||||
|
||||
int kvm_has_sync_mmu(void);
|
||||
int kvm_has_vcpu_events(void);
|
||||
|
Loading…
Reference in New Issue
Block a user