[libvirt PATCH 4/4] qemu: allow forcing emulated maxphysaddr

Ján Tomko jtomko at redhat.com
Wed Mar 1 12:34:35 UTC 2023


Treat:
  <maxphysaddr mode="emulate"/>
as a request not to take the maximum address size from the host.
This is useful if QEMU changes the default.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/qemu/qemu_command.c  | 5 ++++-
 tests/qemuxml2argvtest.c | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7eae858813..24a211d9f7 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6456,7 +6456,10 @@ qemuBuildCpuCommandLine(virCommand *cmd,
             break;
 
         case VIR_CPU_MAX_PHYS_ADDR_MODE_EMULATE:
-            virBufferAsprintf(&buf, ",phys-bits=%d", addr->bits);
+            if (addr->bits > 0)
+                virBufferAsprintf(&buf, ",phys-bits=%d", addr->bits);
+            else
+                virBufferAddLit(&buf, ",host-phys-bits=off");
             break;
 
         case VIR_CPU_MAX_PHYS_ADDR_MODE_LAST:
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a7c6b1639e..41116c9571 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2987,6 +2987,7 @@ mymain(void)
     DO_TEST("cpu-phys-bits-emulate2", QEMU_CAPS_KVM);
     DO_TEST_PARSE_ERROR("cpu-phys-bits-passthrough2", QEMU_CAPS_KVM);
     DO_TEST_CAPS_LATEST("cpu-phys-bits-limit");
+    DO_TEST_CAPS_LATEST("cpu-phys-bits-emulate-bare");
 
     DO_TEST_CAPS_VER("sgx-epc", "7.0.0");
 
-- 
2.39.2



More information about the libvir-list mailing list