Skip to contentSkip to conversation

Xen conditionals

PATCH In review John Baboval 2 participants 2 messages Oct 28, 2011 – Nov 7, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 Xen conditionals

Don't perform RTC or APIC setup when running in xen mode.

---
 hw/pc.c      |   56 
+++++++++++++++++++++++++++++---------------------------
 hw/pc_piix.c |    2 +-
 2 files changed, 30 insertions(+), 28 deletions(-)
hw/pc.c +29 -26
index eb4c2d8..e571d38 100644
@@ -40,6 +40,7 @@
 #include "sysbus.h"
 #include "sysemu.h"
 #include "blockdev.h"
+#include "xen.h"
 #include "ui/qemu-spice.h"
 #include "memory.h"
 #include "exec-memory.h"
@@ -340,35 +341,36 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
     static pc_cmos_init_late_arg arg;
      /* various important CMOS locations needed by PC/Bochs bios */
-
-    /* memory size */
-    val = 640; /* base memory in K */
-    rtc_set_memory(s, 0x15, val);
-    rtc_set_memory(s, 0x16, val >> 8);
-
-    val = (ram_size / 1024) - 1024;
-    if (val > 65535)
-        val = 65535;
-    rtc_set_memory(s, 0x17, val);
-    rtc_set_memory(s, 0x18, val >> 8);
-    rtc_set_memory(s, 0x30, val);
-    rtc_set_memory(s, 0x31, val >> 8);
-
-    if (above_4g_mem_size) {
-        rtc_set_memory(s, 0x5b, (unsigned int)above_4g_mem_size >> 16);
-        rtc_set_memory(s, 0x5c, (unsigned int)above_4g_mem_size >> 24);
-        rtc_set_memory(s, 0x5d, (uint64_t)above_4g_mem_size >> 32);
+    if (!xen_enabled()) {
+	    /* memory size */
+	    val = 640; /* base memory in K */
+	    rtc_set_memory(s, 0x15, val);
+	    rtc_set_memory(s, 0x16, val >> 8);
+
+	    val = (ram_size / 1024) - 1024;
+	    if (val > 65535)
+		    val = 65535;
+	    rtc_set_memory(s, 0x17, val);
+	    rtc_set_memory(s, 0x18, val >> 8);
+	    rtc_set_memory(s, 0x30, val);
+	    rtc_set_memory(s, 0x31, val >> 8);
+
+	    if (above_4g_mem_size) {
+		    rtc_set_memory(s, 0x5b, (unsigned int)above_4g_mem_size >> 16);
+		    rtc_set_memory(s, 0x5c, (unsigned int)above_4g_mem_size >> 24);
+		    rtc_set_memory(s, 0x5d, (uint64_t)above_4g_mem_size >> 32);
+	    }
+
+	    if (ram_size > (16 * 1024 * 1024))
+		    val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536);
+	    else
+		    val = 0;
+	    if (val > 65535)
+		    val = 65535;
+	    rtc_set_memory(s, 0x34, val);
+	    rtc_set_memory(s, 0x35, val >> 8);
     }
 -    if (ram_size > (16 * 1024 * 1024))
-        val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536);
-    else
-        val = 0;
-    if (val > 65535)
-        val = 65535;
-    rtc_set_memory(s, 0x34, val);
-    rtc_set_memory(s, 0x35, val >> 8);
-
     /* set the number of CPU */
     rtc_set_memory(s, 0x5f, smp_cpus - 1);
 diff --git a/hw/pc_piix.c b/hw/pc_piix.c

index 8c7f2b7..f91658c 100644

hw/pc_piix.c +1 -1
@@ -162,7 +162,7 @@ static void pc_init1(MemoryRegion *system_memory,
     for (i = 0; i < ISA_NUM_IRQS; i++) {
         gsi_state->i8259_irq[i] = i8259[i];
     }
-    if (pci_enabled) {
+    if (pci_enabled && !xen_enabled()) {
         ioapic_init(gsi_state);
     }
 -- 1.7.4.1
#1 lore raw
Quoted 1 line · John Baboval

Don't perform RTC or APIC setup when running in xen mode.

Both are actually emulated in Xen so registering the two devices in Qemu is harmless because they are never going to receive any events from the hypervisor.
Thus I would rather keep the difference with the non-xen case smaller and avoid introducing more if (xen_enabled()).