From: Jan Kiszka <jan.kis...@siemens.com> kvm_add/remove_ioport_region need to know if the change is done during init or while the system is running. We added qemu_system_is_ready for this purpose which exported qemu_system_ready. The latter will be gone soon, but we can also obtain the information "hot-plug or not" from the callers of those services. They can retrieve it from the associated qdev device state.
Signed-off-by: Jan Kiszka <jan.kis...@siemens.com> --- cpus.c | 5 ----- cpus.h | 1 - hw/device-assignment.c | 6 ++++-- qemu-kvm.c | 12 +++++++----- qemu-kvm.h | 6 ++++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cpus.c b/cpus.c index 007345a..3035314 100644 --- a/cpus.c +++ b/cpus.c @@ -687,11 +687,6 @@ void qemu_main_loop_start(void) qemu_cond_broadcast(&qemu_system_cond); } -bool qemu_system_is_ready(void) -{ - return qemu_system_ready; -} - void run_on_cpu(CPUState *env, void (*func)(void *data), void *data) { struct qemu_work_item wi; diff --git a/cpus.h b/cpus.h index f6d37af..f42b54e 100644 --- a/cpus.h +++ b/cpus.h @@ -7,7 +7,6 @@ void qemu_main_loop_start(void); void resume_all_vcpus(void); void pause_all_vcpus(void); void cpu_stop_current(void); -bool qemu_system_is_ready(void); void cpu_synchronize_all_states(void); void cpu_synchronize_all_post_reset(void); diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 5c24c78..4a3e9b5 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -277,7 +277,8 @@ static void assigned_dev_ioport_map(PCIDevice *pci_dev, int region_num, addr, region->u.r_baseport, type, size, region_num); if (first_map && region->region->resource_fd < 0) { - r = kvm_add_ioport_region(region->u.r_baseport, region->r_size); + r = kvm_add_ioport_region(region->u.r_baseport, region->r_size, + pci_dev->qdev.hotplugged); if (r < 0) { fprintf(stderr, "%s: failed to enable ioport access (%m)\n", __func__); @@ -676,7 +677,8 @@ static void free_assigned_device(AssignedDevice *dev) } if (pci_region->type & IORESOURCE_IO) { if (pci_region->resource_fd < 0) { - kvm_remove_ioport_region(region->u.r_baseport, region->r_size); + kvm_remove_ioport_region(region->u.r_baseport, region->r_size, + dev->dev.qdev.hotplugged); } } else if (pci_region->type & IORESOURCE_MEM) { if (region->u.r_virtbase) { diff --git a/qemu-kvm.c b/qemu-kvm.c index 80cc077..4a10616 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -589,7 +589,8 @@ static void do_set_ioport_access(void *data) } } -int kvm_add_ioport_region(unsigned long start, unsigned long size) +int kvm_add_ioport_region(unsigned long start, unsigned long size, + bool is_hot_plug) { KVMIOPortRegion *region = qemu_mallocz(sizeof(KVMIOPortRegion)); CPUState *env; @@ -600,12 +601,12 @@ int kvm_add_ioport_region(unsigned long start, unsigned long size) region->status = 1; QLIST_INSERT_HEAD(&ioport_regions, region, entry); - if (qemu_system_is_ready()) { + if (is_hot_plug) { for (env = first_cpu; env != NULL; env = env->next_cpu) { run_on_cpu(env, do_set_ioport_access, region); if (region->status < 0) { r = region->status; - kvm_remove_ioport_region(start, size); + kvm_remove_ioport_region(start, size, is_hot_plug); break; } } @@ -613,7 +614,8 @@ int kvm_add_ioport_region(unsigned long start, unsigned long size) return r; } -int kvm_remove_ioport_region(unsigned long start, unsigned long size) +int kvm_remove_ioport_region(unsigned long start, unsigned long size, + bool is_hot_unplug) { KVMIOPortRegion *region, *tmp; CPUState *env; @@ -623,7 +625,7 @@ int kvm_remove_ioport_region(unsigned long start, unsigned long size) if (region->start == start && region->size == size) { region->status = 0; } - if (qemu_system_is_ready()) { + if (is_hot_unplug) { for (env = first_cpu; env != NULL; env = env->next_cpu) { run_on_cpu(env, do_set_ioport_access, region); } diff --git a/qemu-kvm.h b/qemu-kvm.h index 845880e..90bcca9 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -252,8 +252,10 @@ void kvm_tpr_access_report(CPUState *env, uint64_t rip, int is_write); int kvm_arch_init_irq_routing(void); -int kvm_add_ioport_region(unsigned long start, unsigned long size); -int kvm_remove_ioport_region(unsigned long start, unsigned long size); +int kvm_add_ioport_region(unsigned long start, unsigned long size, + bool is_hot_plug); +int kvm_remove_ioport_region(unsigned long start, unsigned long size, + bool is_hot_unplug); int kvm_update_ioport_access(CPUState *env); int kvm_arch_set_ioport_access(unsigned long start, unsigned long size, -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html