Skip to contentSkip to conversation

Xen patch queue 2011-07-23

GIT PULL New Alexander Graf 1 participant 6 messages Jul 23, 2011

lore
Share & tools
lore
#0 lore raw

Hi Anthony,

This is a rebase of the last xen-next pull request, this time without the xen-mapcache build breakage fix, as that's been fixed meanwhile.

Please pull.

Alex

The following changes since commit 1167bfd63d983eaa4816ee0edb185f98ff070d6d:
Anthony Liguori (1):
Open 1.0 development branch.

are available in the git repository at:

git://repo.or.cz/qemu/agraf.git xen-next

Alexander Graf (2):
xen: remove CONFIG_XEN_MAPCACHE
xen: make xen_enabled even more clever

Anthony PERARD (3):
xen: introduce xen_change_state_handler
xen: Fix xen_enabled().
exec.c: Use ram_addr_t in cpu_physical_memory_rw(...).

 configure |    8 +++++---
 exec.c    |    4 ++--
 hw/xen.h  |    2 +-
 xen-all.c |   25 ++++++++++++++++++-------
 4 files changed, 26 insertions(+), 13 deletions(-)
#1 lore raw

PATCH 1/5 xen: introduce xen_change_state_handler

From: Anthony PERARD <[email protected]>

Remove the call to xenstore_record_dm_state from xen_main_loop_prepare that is HVM specific.
Add a new vm_change_state_handler shared between xen_pv and xen_hvm machines to record the VM state to xenstore.

---
 xen-all.c |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)
xen-all.c +18 -7
index 167bed6..83c5476 100644
@@ -797,12 +797,17 @@ void xenstore_store_pv_console_info(int i, CharDriverState *chr)
     }
 }
 
-static void xenstore_record_dm_state(XenIOState *s, const char *state)
+static void xenstore_record_dm_state(struct xs_handle *xs, const char *state)
 {
     char path[50];
 
+    if (xs == NULL) {
+        fprintf(stderr, "xenstore connection not initialized\n");
+        exit(1);
+    }
+
     snprintf(path, sizeof (path), "/local/domain/0/device-model/%u/state", xen_domid);
-    if (!xs_write(s->xenstore, XBT_NULL, path, state, strlen(state))) {
+    if (!xs_write(xs, XBT_NULL, path, state, strlen(state))) {
         fprintf(stderr, "error recording dm state\n");
         exit(1);
     }
@@ -823,15 +828,20 @@ static void xen_main_loop_prepare(XenIOState *state)
     if (evtchn_fd != -1) {
         qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, state);
     }
-
-    /* record state running */
-    xenstore_record_dm_state(state, "running");
 }
 
 
 /* Initialise Xen */
 
-static void xen_vm_change_state_handler(void *opaque, int running, int reason)
+static void xen_change_state_handler(void *opaque, int running, int reason)
+{
+    if (running) {
+        /* record state running */
+        xenstore_record_dm_state(xenstore, "running");
+    }
+}
+
+static void xen_hvm_change_state_handler(void *opaque, int running, int reason)
 {
     XenIOState *state = opaque;
     if (running) {
@@ -854,6 +864,7 @@ int xen_init(void)
         xen_be_printf(NULL, 0, "can't open xen interface\n");
         return -1;
     }
+    qemu_add_vm_change_state_handler(xen_change_state_handler, NULL);
 
     return 0;
 }
@@ -915,7 +926,7 @@ int xen_hvm_init(void)
     xen_map_cache_init();
     xen_ram_init(ram_size);
 
-    qemu_add_vm_change_state_handler(xen_vm_change_state_handler, state);
+    qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
 
     state->client = xen_cpu_phys_memory_client;
     QLIST_INIT(&state->physmap);
Signature · 1 line
1.6.0.2
#3 lore raw

PATCH 3/5 exec.c: Use ram_addr_t in cpu_physical_memory_rw(...).

In reply to Alexander Graf

From: Anthony PERARD <[email protected]>

As the variable pd and addr1 inside the function cpu_physical_memory_rw are mean to handle a RAM address, they should be of the ram_addr_t type instead of unsigned long.

---
 exec.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
exec.c +2 -2
index 2160ded..0393d39 100644
@@ -3858,7 +3858,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
     uint8_t *ptr;
     uint32_t val;
     target_phys_addr_t page;
-    unsigned long pd;
+    ram_addr_t pd;
     PhysPageDesc *p;
 
     while (len > 0) {
@@ -3898,7 +3898,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
                     l = 1;
                 }
             } else {
-                unsigned long addr1;
+                ram_addr_t addr1;
                 addr1 = (pd & TARGET_PAGE_MASK) + (addr & ~TARGET_PAGE_MASK);
                 /* RAM case */
                 ptr = qemu_get_ram_ptr(addr1);
Signature · 1 line
1.6.0.2
#2 lore raw

PATCH 2/5 xen: Fix xen_enabled().

In reply to Alexander Graf

From: Anthony PERARD <[email protected]>

Use the "host" CONFIG_ define instead of the "target" one.

---
 hw/xen.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/xen.h +1 -1
index e432705..43b95d6 100644
@@ -24,7 +24,7 @@ extern int xen_allowed;
 
 static inline int xen_enabled(void)
 {
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_BACKEND
     return xen_allowed;
 #else
     return 0;
Signature · 1 line
1.6.0.2
#4 lore raw

PATCH 4/5 xen: remove CONFIG_XEN_MAPCACHE

In reply to Alexander Graf

We were still exporting CONFIG_XEN_MAPCACHE, even though it's completely unused by now. Remove it.

---
 configure |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
configure +0 -3
index 6911c3b..90fe09f 100755
@@ -3277,9 +3277,6 @@ case "$target_arch2" in
     if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
       target_phys_bits=64
       echo "CONFIG_XEN=y" >> $config_target_mak
-      if test "$cpu" = "i386" -o "$cpu" = "x86_64"; then
-          echo "CONFIG_XEN_MAPCACHE=y" >> $config_target_mak
-      fi
     fi
 esac
 case "$target_arch2" in
Signature · 1 line
1.6.0.2
#5 lore raw

PATCH 5/5 xen: make xen_enabled even more clever

In reply to Alexander Graf

When using xen_enabled() we're currently only checking if xen is enabled at all during the build. But what if you want to build multiple targets out of which only one can potentially run xen code?

That means that for generic code we'll still have to fall back to the variable and potentially slow the code down, but it's not as important as that is mostly xen device emulation which is not touched for non-xen targets.

The target specific code however can with this patch see that it's unable to ever execute xen code. We can thus always return 0 on xen_enabled(), giving gcc enough hints to evict the mapcache code from the target memory management code.

---
 configure |    5 +++++
 hw/xen.h  |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)
configure +5 -0
index 90fe09f..e5ecec9 100755
@@ -3277,7 +3277,12 @@ case "$target_arch2" in
     if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
       target_phys_bits=64
       echo "CONFIG_XEN=y" >> $config_target_mak
+    else
+      echo "CONFIG_NO_XEN=y" >> $config_target_mak
     fi
+    ;;
+  *)
+    echo "CONFIG_NO_XEN=y" >> $config_target_mak
 esac
 case "$target_arch2" in
   i386|x86_64|ppcemb|ppc|ppc64|s390x)
hw/xen.h +1 -1
index 43b95d6..2162111 100644
@@ -24,7 +24,7 @@ extern int xen_allowed;
 
 static inline int xen_enabled(void)
 {
-#ifdef CONFIG_XEN_BACKEND
+#if defined(CONFIG_XEN_BACKEND) && !defined(CONFIG_NO_XEN)
     return xen_allowed;
 #else
     return 0;
Signature · 1 line
1.6.0.2