hw/i386: De-duplicate gsi_handler() to remove kvm_pc_gsi_handler()
PATCH 1/1 hw/i386: De-duplicate gsi_handler() to remove kvm_pc_gsi_handler()
Both gsi_handler() and kvm_pc_gsi_handler() have the same content, except one comment. Move the comment, and de-duplicate the code.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
--- include/sysemu/kvm.h | 1 - hw/i386/kvm/ioapic.c | 12 ------------ hw/i386/pc.c | 5 ++--- 3 files changed, 2 insertions(+), 16 deletions(-)
include/sysemu/kvm.h +0 -1
@@ -515,7 +515,6 @@ int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n,int kvm_irqchip_remove_irqfd_notifier (KVMState *s,EventNotifier *n,qemu_irq irq);void kvm_irqchip_set_qemuirq_gsi (KVMState *s,qemu_irq irq,int gsi); -void kvm_pc_gsi_handler (void *opaque,int n,int level);void kvm_pc_setup_irq_routing (bool pci_enabled);void kvm_init_irq_routing (KVMState *s);
hw/i386/kvm/ioapic.c +0 -12
@@ -48,18 +48,6 @@ void kvm_pc_setup_irq_routing(bool pci_enabled) } } -void kvm_pc_gsi_handler (void *opaque,int n,int level) -{ -GSIState *s = opaque; - -if (n <ISA_NUM_IRQS ) { -/* Kernel will forward to both PIC and IOAPIC */ -qemu_set_irq (s->i8259_irq[n], level); - }else { -qemu_set_irq (s->ioapic_irq[n], level); - } -} -typedef struct KVMIOAPICState KVMIOAPICState ;struct KVMIOAPICState {
hw/i386/pc.c +2 -3
@@ -350,6 +350,7 @@ void gsi_handler(void *opaque, int n, int level)DPRINTF ("pc: %s GSI %d\n" , level ?"raising" :"lowering" , n);if (n <ISA_NUM_IRQS ) { +/* Under KVM, Kernel will forward to both PIC and IOAPIC */ qemu_set_irq (s->i8259_irq[n], level); }qemu_set_irq (s->ioapic_irq[n], level);
@@ -362,10 +363,8 @@ GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled) s =g_new0 (GSIState,1 );if (kvm_ioapic_in_kernel ()) {kvm_pc_setup_irq_routing (pci_enabled); - *irqs =qemu_allocate_irqs (kvm_pc_gsi_handler, s,GSI_NUM_PINS ); - }else { - *irqs =qemu_allocate_irqs (gsi_handler, s,GSI_NUM_PINS ); } + *irqs =qemu_allocate_irqs (gsi_handler, s,GSI_NUM_PINS );return s; }
Signature · 1 line
2.21.0
Quoted 60 lines · Philippe Mathieu-Daudé
Both
gsi_handler()andkvm_pc_gsi_handler()have the same content, except one comment. Move the comment, and de-duplicate the code.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/sysemu/kvm.h | 1 - hw/i386/kvm/ioapic.c | 12 ------------ hw/i386/pc.c | 5 ++--- 3 files changed, 2 insertions(+), 16 deletions(-)include/sysemu/kvm.h +0
-1@@ -515,7 +515,6 @@ int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n,int kvm_irqchip_remove_irqfd_notifier (KVMState *s,EventNotifier *n,qemu_irq irq);void kvm_irqchip_set_qemuirq_gsi (KVMState *s,qemu_irq irq,int gsi); -void kvm_pc_gsi_handler (void *opaque,int n,int level);void kvm_pc_setup_irq_routing (bool pci_enabled);void kvm_init_irq_routing (KVMState *s);hw/i386/kvm/ioapic.c +0
-12@@ -48,18 +48,6 @@ void kvm_pc_setup_irq_routing(bool pci_enabled) } } -void kvm_pc_gsi_handler (void *opaque,int n,int level) -{ -GSIState *s = opaque; - -if (n <ISA_NUM_IRQS ) { -/* Kernel will forward to both PIC and IOAPIC */ -qemu_set_irq (s->i8259_irq[n], level); - }else { -qemu_set_irq (s->ioapic_irq[n], level); - } -} -typedef struct KVMIOAPICState KVMIOAPICState ;struct KVMIOAPICState {hw/i386/pc.c +1
-0@@ -350,6 +350,7 @@ void gsi_handler(void *opaque, int n, int level)DPRINTF ("pc: %s GSI %d\n" , level ?"raising" :"lowering" , n);if (n <ISA_NUM_IRQS ) { +/* Under KVM, Kernel will forward to both PIC and IOAPIC */ qemu_set_irq (s->i8259_irq[n], level); }qemu_set_irq (s->ioapic_irq[n], level);@@ -362,10 +363,8 @@ GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled) s =g_new0 (GSIState,1 );
hw/i386/pc.c GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled) · line 370
Quoted 10 lines
hw/i386/pc.c +1
-3if (kvm_ioapic_in_kernel ()) {kvm_pc_setup_irq_routing (pci_enabled); - *irqs =qemu_allocate_irqs (kvm_pc_gsi_handler, s,GSI_NUM_PINS ); - }else { - *irqs =qemu_allocate_irqs (gsi_handler, s,GSI_NUM_PINS ); } + *irqs =qemu_allocate_irqs (gsi_handler, s,GSI_NUM_PINS );return s; }
Queued, thanks.
Paolo
Quoted 60 lines · Philippe Mathieu-Daudé
Both
gsi_handler()andkvm_pc_gsi_handler()have the same content, except one comment. Move the comment, and de-duplicate the code.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/sysemu/kvm.h | 1 - hw/i386/kvm/ioapic.c | 12 ------------ hw/i386/pc.c | 5 ++--- 3 files changed, 2 insertions(+), 16 deletions(-)include/sysemu/kvm.h +0
-1@@ -515,7 +515,6 @@ int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n,int kvm_irqchip_remove_irqfd_notifier (KVMState *s,EventNotifier *n,qemu_irq irq);void kvm_irqchip_set_qemuirq_gsi (KVMState *s,qemu_irq irq,int gsi); -void kvm_pc_gsi_handler (void *opaque,int n,int level);void kvm_pc_setup_irq_routing (bool pci_enabled);void kvm_init_irq_routing (KVMState *s);hw/i386/kvm/ioapic.c +0
-12@@ -48,18 +48,6 @@ void kvm_pc_setup_irq_routing(bool pci_enabled) } } -void kvm_pc_gsi_handler (void *opaque,int n,int level) -{ -GSIState *s = opaque; - -if (n <ISA_NUM_IRQS ) { -/* Kernel will forward to both PIC and IOAPIC */ -qemu_set_irq (s->i8259_irq[n], level); - }else { -qemu_set_irq (s->ioapic_irq[n], level); - } -} -typedef struct KVMIOAPICState KVMIOAPICState ;struct KVMIOAPICState {hw/i386/pc.c +1
-0@@ -350,6 +350,7 @@ void gsi_handler(void *opaque, int n, int level)DPRINTF ("pc: %s GSI %d\n" , level ?"raising" :"lowering" , n);if (n <ISA_NUM_IRQS ) { +/* Under KVM, Kernel will forward to both PIC and IOAPIC */ qemu_set_irq (s->i8259_irq[n], level); }qemu_set_irq (s->ioapic_irq[n], level);@@ -362,10 +363,8 @@ GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled) s =g_new0 (GSIState,1 );
hw/i386/pc.c GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled) · line 370
Quoted 10 lines
hw/i386/pc.c +1
-3if (kvm_ioapic_in_kernel ()) {kvm_pc_setup_irq_routing (pci_enabled); - *irqs =qemu_allocate_irqs (kvm_pc_gsi_handler, s,GSI_NUM_PINS ); - }else { - *irqs =qemu_allocate_irqs (gsi_handler, s,GSI_NUM_PINS ); } + *irqs =qemu_allocate_irqs (gsi_handler, s,GSI_NUM_PINS );return s; }
Queued, thanks.
Paolo