From: Jes Sorensen <[email protected]>

Platform specific IRQ routing doesn't belong in the generic codepath.
Create kvm_arch_init_irq_routing() and move the x86 specific routing
setup to the appropriate place.

With this interrupts are delivered again on ia64.

[avi: make it build on x86, properly handle errors]

Signed-off-by: Jes Sorensen <[email protected]>
Signed-off-by: Avi Kivity <[email protected]>

diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 06ef775..8cb6faa 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -856,3 +856,34 @@ void kvm_arch_do_ioperm(void *_data)
     struct ioperm_data *data = _data;
     ioperm(data->start_port, data->num, data->turn_on);
 }
+
+/*
+ * Setup x86 specific IRQ routing
+ */
+int kvm_arch_init_irq_routing(void)
+{
+    int i, r;
+
+    if (kvm_irqchip && kvm_has_gsi_routing(kvm_context)) {
+        kvm_clear_gsi_routes(kvm_context);
+        for (i = 0; i < 8; ++i) {
+            if (i == 2)
+                continue;
+            r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_PIC_MASTER, i);
+            if (r < 0)
+                return r;
+        }
+        for (i = 8; i < 16; ++i) {
+            r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_PIC_SLAVE, i - 
8);
+            if (r < 0)
+                return r;
+        }
+        for (i = 0; i < 24; ++i) {
+            r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_IOAPIC, i);
+            if (r < 0)
+                return r;
+        }
+        kvm_commit_irq_routes(kvm_context);
+    }
+    return 0;
+}
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 8c0d463..d6d0253 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -780,10 +780,17 @@ int kvm_qemu_init()
 static int destroy_region_works = 0;
 #endif
 
+
+#if !defined(TARGET_I386)
+int kvm_arch_init_irq_routing(void)
+{
+    return 0;
+}
+#endif
+
 int kvm_qemu_create_context(void)
 {
     int r;
-    int i;
 
     if (!kvm_irqchip) {
         kvm_disable_irqchip_creation(kvm_context);
@@ -808,27 +815,11 @@ int kvm_qemu_create_context(void)
     destroy_region_works = kvm_destroy_memory_region_works(kvm_context);
 #endif
 
-    if (kvm_irqchip && kvm_has_gsi_routing(kvm_context)) {
-        kvm_clear_gsi_routes(kvm_context);
-        for (i = 0; i < 8; ++i) {
-            if (i == 2)
-                continue;
-            r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_PIC_MASTER, i);
-            if (r < 0)
-                return r;
-        }
-        for (i = 8; i < 16; ++i) {
-            r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_PIC_SLAVE, i - 
8);
-            if (r < 0)
-                return r;
-        }
-        for (i = 0; i < 24; ++i) {
-            r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_IOAPIC, i);
-            if (r < 0)
-                return r;
-        }
-        kvm_commit_irq_routes(kvm_context);
+    r = kvm_arch_init_irq_routing();
+    if (r < 0) {
+        return r;
     }
+
     return 0;
 }
 
diff --git a/qemu-kvm.h b/qemu-kvm.h
index c0549df..8226001 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -122,6 +122,8 @@ int qemu_kvm_unregister_coalesced_mmio(target_phys_addr_t 
addr,
 int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size);
 int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size);
 
+int kvm_arch_init_irq_routing(void);
+
 #ifdef USE_KVM_DEVICE_ASSIGNMENT
 struct ioperm_data;
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to