diff mbox

[v2,7/9] initialize i8259 chip

Message ID 1254953315-5761-8-git-send-email-glommer@redhat.com
State Changes Requested
Headers show

Commit Message

Glauber Costa Oct. 7, 2009, 10:08 p.m. UTC
If we have irqchip in kernel (which we currently do not), intialize
the i8259 chip. This code is heavily inspirated by the one in qemu-kvm.git

Note that we wire isa irqs trough it too.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 hw/pc.c   |   14 +++++++++++---
 kvm-all.c |    2 +-
 2 files changed, 12 insertions(+), 4 deletions(-)

Comments

Jan Kiszka Oct. 8, 2009, 12:02 p.m. UTC | #1
Glauber Costa wrote:
> diff --git a/kvm-all.c b/kvm-all.c
> index e98024a..418d8bc 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -429,7 +429,6 @@ int kvm_get_irqchip(struct kvm_irqchip *chip)
>  
>      return kvm_vm_ioctl(kvm_state, KVM_GET_IRQCHIP, chip);
>  }
> -#endif
>  
>  int kvm_set_irq(int irq, int level, int *status)
>  {
> @@ -454,6 +453,7 @@ int kvm_set_irq(int irq, int level, int *status)
>  
>      return 1;
>  }
> +#endif

I think these two changes could be avoided by including them in the
previous patch.

Jan
diff mbox

Patch

diff --git a/hw/pc.c b/hw/pc.c
index 2ca15a3..5cfe99f 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -39,6 +39,7 @@ 
 #include "ide.h"
 #include "loader.h"
 #include "elf.h"
+#include "kvm.h"
 
 /* output Bochs bios info messages */
 //#define DEBUG_BIOS
@@ -1171,10 +1172,17 @@  static void pc_init1(ram_addr_t ram_size,
     }
 
     cpu_irq = qemu_allocate_irqs(pic_irq_request, NULL, 1);
-    i8259 = i8259_init(cpu_irq[0]);
     isa_irq_state = qemu_mallocz(sizeof(*isa_irq_state));
-    isa_irq_state->i8259 = i8259;
-    isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24);
+
+#ifdef KVM_CAP_IRQCHIP
+    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
+        isa_irq = i8259 = kvm_i8259_init(cpu_irq[0]);
+    } else
+#endif
+    {
+        isa_irq_state->i8259 = i8259 = i8259_init(cpu_irq[0]);
+        isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24);
+    }
 
     if (pci_enabled) {
         pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, isa_irq);
diff --git a/kvm-all.c b/kvm-all.c
index e98024a..418d8bc 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -429,7 +429,6 @@  int kvm_get_irqchip(struct kvm_irqchip *chip)
 
     return kvm_vm_ioctl(kvm_state, KVM_GET_IRQCHIP, chip);
 }
-#endif
 
 int kvm_set_irq(int irq, int level, int *status)
 {
@@ -454,6 +453,7 @@  int kvm_set_irq(int irq, int level, int *status)
 
     return 1;
 }
+#endif
 
 int kvm_init(int smp_cpus)
 {