[PATCH 05/16] qemu-kvm: Clean up IRQ0 override configuration

Jan Kiszka
2011-05-13T12:14:15Z

Introduce kvm_allows_irq0_override to overcome the global irq0override
variable and convert the BIOS initialization.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
hw/pc.c | 2 +-
kvm-all.c | 5 +++++
kvm-stub.c | 5 +++++
kvm.h | 1 +
qemu-kvm.c | 1 -
sysemu.h | 1 -
vl.c | 1 -
7 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 944f766..73398eb 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -605,7 +605,7 @@ static void *bochs_bios_init(void)
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES, (uint8_t *)acpi_tables,
acpi_tables_len);
- fw_cfg_add_bytes(fw_cfg, FW_CFG_IRQ0_OVERRIDE, &irq0override, 1);
+ fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override());

smbios_table = smbios_get_table(&smbios_len);
if (smbios_table)
diff --git a/kvm-all.c b/kvm-all.c
index d744cb2..d936d35 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1121,6 +1121,11 @@ int kvm_has_many_ioeventfds(void)
return kvm_state->many_ioeventfds;
}

+int kvm_allows_irq0_override(void)
+{
+ return !kvm_enabled() || !kvm_irqchip_in_kernel() || kvm_has_gsi_routing();
+}
+
void kvm_setup_guest_memory(void *start, size_t size)
{
if (!kvm_has_sync_mmu()) {
diff --git a/kvm-stub.c b/kvm-stub.c
index 31bd77b..4f1f7d3 100644
--- a/kvm-stub.c
+++ b/kvm-stub.c
@@ -93,6 +93,11 @@ int kvm_has_many_ioeventfds(void)
return 0;
}

+int kvm_allows_irq0_override(void)
+{
+ return 1;
+}
+
void kvm_setup_guest_memory(void *start, size_t size)
{
}
diff --git a/kvm.h b/kvm.h
index 2445d40..4ba5465 100644
--- a/kvm.h
+++ b/kvm.h
@@ -220,6 +220,7 @@ typedef struct KVMMsiMessage {
} KVMMsiMessage;

int kvm_has_gsi_routing(void);
+int kvm_allows_irq0_override(void);
int kvm_get_irq_route_gsi(void);

int kvm_msi_message_add(KVMMsiMessage *msg);
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 1f9ddea..fee6cdf 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1426,7 +1426,6 @@ static int kvm_create_context(void)
kvm_init_ap();
if (kvm_irqchip) {
if (!qemu_kvm_has_gsi_routing()) {
- irq0override = 0;
#ifdef TARGET_I386
/* if kernel can't do irq routing, interrupt source
* override 0->2 can not be set up as required by hpet,
diff --git a/sysemu.h b/sysemu.h
index d58bec1..69e2e7e 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -102,7 +102,6 @@ extern int vga_interface_type;
extern int graphic_width;
extern int graphic_height;
extern int graphic_depth;
-extern uint8_t irq0override;
extern DisplayType display_type;
extern const char *keyboard_layout;
extern int win2k_install_hack;
diff --git a/vl.c b/vl.c
index a143250..501d52c 100644
--- a/vl.c
+++ b/vl.c
@@ -217,7 +217,6 @@ int no_reboot = 0;
int no_shutdown = 0;
int cursor_hide = 1;
int graphic_rotate = 0;
-uint8_t irq0override = 1;
const char *watchdog;
QEMUOptionRom option_rom[MAX_OPTION_ROMS];
int nb_option_roms;
--
1.7.1