Patchwork [2/3] Xen conditionals

login
register
mail settings
Submitter John Baboval
Date Oct. 28, 2011, 7:38 p.m.
Message ID <4EAB04AF.5060803@virtualcomputer.com>
Download mbox | patch
Permalink /patch/122490/
State New
Headers show

Comments

John Baboval - Oct. 28, 2011, 7:38 p.m.
Don't perform RTC or APIC setup when running in xen mode.

Signed-off-by: John V. Baboval <john.baboval@virtualcomputer.com>
---
  hw/pc.c      |   56 
+++++++++++++++++++++++++++++---------------------------
  hw/pc_piix.c |    2 +-
  2 files changed, 30 insertions(+), 28 deletions(-)
Stefano Stabellini - Nov. 7, 2011, 4:43 p.m.
On Fri, 28 Oct 2011, John Baboval wrote:
> 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()).

Patch

diff --git a/hw/pc.c b/hw/pc.c
index eb4c2d8..e571d38 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -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
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -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