Skip to contentSkip to conversation

libxl: Disable relocating memory for qemu-xen in stubdomain too

PATCH In review Marek Marczykowski-Górecki 6 participants 6 messages Dec 27, 2023 – Feb 21, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: Disable relocating memory for qemu-xen in stubdomain too

According to comments (and experiments) qemu-xen cannot handle memory reolcation done by hvmloader. The code was already disabled when running qemu-xen in dom0 (see libxl__spawn_local_dm()), but it was missed when adding qemu-xen support to stubdomain. Adjust libxl__spawn_stub_dm() to be consistent in this regard.

---
 tools/libs/light/libxl_dm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
tools/libs/light/libxl_dm.c +10 -0
index 14b593110f7c..ed620a9d8e14 100644
@@ -2432,6 +2432,16 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
                         "%s",
                         libxl_bios_type_to_string(guest_config->b_info.u.hvm.bios));
     }
+    /* Disable relocating memory to make the MMIO hole larger
+     * unless we're running qemu-traditional and vNUMA is not
+     * configured. */
+    libxl__xs_printf(gc, XBT_NULL,
+                     libxl__sprintf(gc, "%s/hvmloader/allow-memory-relocate",
+                                    libxl__xs_get_dompath(gc, guest_domid)),
+                     "%d",
+                     guest_config->b_info.device_model_version
+                        == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
+                     !libxl__vnuma_configured(&guest_config->b_info));
     ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid);
     if (ret<0) {
         LOGED(ERROR, guest_domid, "setting target domain %d -> %d",
Signature · 1 line
2.41.0
#1 lore raw
Quoted 35 lines · Marek Marczykowski-Górecki

According to comments (and experiments) qemu-xen cannot handle memory reolcation done by hvmloader. The code was already disabled when running qemu-xen in dom0 (see libxl__spawn_local_dm()), but it was missed when adding qemu-xen support to stubdomain. Adjust libxl__spawn_stub_dm() to be consistent in this regard.

---
 tools/libs/light/libxl_dm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
tools/libs/light/libxl_dm.c +10 -0
index 14b593110f7c..ed620a9d8e14 100644
@@ -2432,6 +2432,16 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
                         "%s",
                         libxl_bios_type_to_string(guest_config->b_info.u.hvm.bios));
     }
+    /* Disable relocating memory to make the MMIO hole larger
+     * unless we're running qemu-traditional and vNUMA is not
+     * configured. */
+    libxl__xs_printf(gc, XBT_NULL,
+                     libxl__sprintf(gc, "%s/hvmloader/allow-memory-relocate",
+                                    libxl__xs_get_dompath(gc, guest_domid)),
+                     "%d",
+                     guest_config->b_info.device_model_version
+                        == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
+                     !libxl__vnuma_configured(&guest_config->b_info));
     ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid);
     if (ret<0) {
         LOGED(ERROR, guest_domid, "setting target domain %d -> %d",
Signature · 1 line
2.41.0

Seems to work as expected

Thanks,
Neowutran

#2 lore raw
Quoted 30 lines · Neowutran
Quoted 29 lines · Marek Marczykowski-Górecki

According to comments (and experiments) qemu-xen cannot handle memory reolcation done by hvmloader. The code was already disabled when running qemu-xen in dom0 (see libxl__spawn_local_dm()), but it was missed when adding qemu-xen support to stubdomain. Adjust libxl__spawn_stub_dm() to be consistent in this regard.

---
 tools/libs/light/libxl_dm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
tools/libs/light/libxl_dm.c +9 -0
index 14b593110f7c..ed620a9d8e14 100644
@@ -2432,6 +2432,16 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
                         "%s",
                         libxl_bios_type_to_string(guest_config->b_info.u.hvm.bios));
     }
+    /* Disable relocating memory to make the MMIO hole larger
+     * unless we're running qemu-traditional and vNUMA is not
+     * configured. */
+    libxl__xs_printf(gc, XBT_NULL,
+                     libxl__sprintf(gc, "%s/hvmloader/allow-memory-relocate",
+                                    libxl__xs_get_dompath(gc, guest_domid)),
+                     "%d",
+                     guest_config->b_info.device_model_version
+                        == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
Quoted 8 lines
Quoted 6 lines
tools/libs/light/libxl_dm.c +1 -0
+                     !libxl__vnuma_configured(&guest_config->b_info));
     ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid);
     if (ret<0) {
         LOGED(ERROR, guest_domid, "setting target domain %d -> %d",
Signature · 1 line
2.41.0

Seems to work as expected

May we translate this to Tested-by: ?

Jan

Reviewed-by on v1 1/1
#3 lore raw
In reply to Marek Marczykowski-Górecki
Quoted 9 lines · Marek Marczykowski-Górecki

According to comments (and experiments) qemu-xen cannot handle memory reolcation done by hvmloader. The code was already disabled when running qemu-xen in dom0 (see libxl__spawn_local_dm()), but it was missed when adding qemu-xen support to stubdomain. Adjust libxl__spawn_stub_dm() to be consistent in this regard.

Thanks,
Jason

#4 lore raw
Quoted 9 lines · Jason Andryuk
Quoted 7 lines · Marek Marczykowski-Górecki

According to comments (and experiments) qemu-xen cannot handle memory reolcation done by hvmloader. The code was already disabled when running qemu-xen in dom0 (see libxl__spawn_local_dm()), but it was missed when adding qemu-xen support to stubdomain. Adjust libxl__spawn_stub_dm() to be consistent in this regard.

Quoted 4 lines
Quoted 2 lines

Thanks,

Signature · 1 line
Anthony PERARD
#5 lore raw
In reply to Marek Marczykowski-Górecki
Quoted 8 lines · Marek Marczykowski-Górecki

According to comments (and experiments) qemu-xen cannot handle memory reolcation done by hvmloader. The code was already disabled when running qemu-xen in dom0 (see libxl__spawn_local_dm()), but it was missed when adding qemu-xen support to stubdomain. Adjust libxl__spawn_stub_dm() to be consistent in this regard.

It turns out that it's unconditionally clobbered in XenServer too.

https://github.com/xapi-project/xen-api/blob/53d2e8cdff76ca6805c7018948a9c414b9ac7c72/ocaml/xenopsd/scripts/qemu-wrapper#L146

Not that I'm surprised - this falls squarely into guest-physmap mess which is broken in several well-documented ways already.

~Andrew