qemu-kvm: Remove qemu_system_is_ready side-channel
PATCH 1/1 qemu-kvm: Remove qemu_system_is_ready side-channel
From: Jan Kiszka <[email protected]>
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.
--- 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(-)
cpus.c +0 -5
@@ -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;
cpus.h +0 -1
@@ -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 );
hw/device-assignment.c +4 -2
@@ -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) {
qemu-kvm.c +7 -5
@@ -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); }
qemu-kvm.h +4 -2
@@ -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,
Signature · 1 line
1.7.3.4
Marcelo Tosatti
AppliedQuoted 10 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
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_readyfor this purpose which exportedqemu_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 <[email protected]>
Applied, thanks.