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

Ján Tomko posted 4 patches 2 years, 11 months ago
There is a newer version of this series
[libvirt PATCH 4/4] qemu: allow forcing emulated maxphysaddr
Posted by Ján Tomko 2 years, 11 months ago
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@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

Re: [libvirt PATCH 4/4] qemu: allow forcing emulated maxphysaddr
Posted by Peter Krempa 2 years, 10 months ago
On Wed, Mar 01, 2023 at 13:34:35 +0100, Ján Tomko wrote:
> 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@redhat.com>
> ---
>  src/qemu/qemu_command.c  | 5 ++++-
>  tests/qemuxml2argvtest.c | 1 +
>  2 files changed, 5 insertions(+), 1 deletion(-)

So I guess this kind of belongs together with 3/4, right? I think they
can and should be justified together.