[libvirt PATCH 0/3] qemu: Include maximum physical address size in baseline CPU

Jiri Denemark (3): qemu: Report physical address size in domain capabilities qemu: Include maximum physical address size in baseline CPU NEWS: Mentioned an improvement for virConnectBaselineHypervisorCPU NEWS.rst | 7 ++++ docs/formatdomaincaps.rst | 6 +++- src/conf/schemas/domaincaps.rng | 3 ++ src/qemu/qemu_capabilities.c | 33 ++++++++++++++++++- src/qemu/qemu_driver.c | 17 ++++++++++ .../domaincapsdata/qemu_4.2.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_4.2.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_4.2.0.s390x.xml | 1 + tests/domaincapsdata/qemu_4.2.0.x86_64.xml | 1 + .../domaincapsdata/qemu_5.0.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_5.0.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_5.0.0.x86_64.xml | 1 + .../domaincapsdata/qemu_5.1.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_5.1.0.x86_64.xml | 1 + .../domaincapsdata/qemu_5.2.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_5.2.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_5.2.0.s390x.xml | 1 + tests/domaincapsdata/qemu_5.2.0.x86_64.xml | 1 + .../domaincapsdata/qemu_6.0.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_6.0.0.s390x.xml | 1 + tests/domaincapsdata/qemu_6.0.0.x86_64.xml | 1 + .../domaincapsdata/qemu_6.1.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_6.1.0.x86_64.xml | 1 + .../domaincapsdata/qemu_6.2.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_6.2.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_6.2.0.x86_64.xml | 1 + .../domaincapsdata/qemu_7.0.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_7.0.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_7.0.0.x86_64.xml | 1 + .../domaincapsdata/qemu_7.1.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_7.1.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_7.1.0.x86_64.xml | 1 + .../domaincapsdata/qemu_7.2.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_7.2.0.x86_64.xml | 1 + .../domaincapsdata/qemu_8.0.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_8.0.0.x86_64.xml | 1 + .../domaincapsdata/qemu_8.1.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_8.1.0.x86_64.xml | 1 + tests/domaincapsmock.c | 7 ++++ 39 files changed, 104 insertions(+), 2 deletions(-) -- 2.41.0

We already report the hosts physical address size in host capabilities, but computing a baseline CPU definition is done from domain capabilities. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- docs/formatdomaincaps.rst | 6 +++- src/conf/schemas/domaincaps.rng | 3 ++ src/qemu/qemu_capabilities.c | 33 ++++++++++++++++++- .../domaincapsdata/qemu_4.2.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_4.2.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_4.2.0.s390x.xml | 1 + tests/domaincapsdata/qemu_4.2.0.x86_64.xml | 1 + .../domaincapsdata/qemu_5.0.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_5.0.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_5.0.0.x86_64.xml | 1 + .../domaincapsdata/qemu_5.1.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_5.1.0.x86_64.xml | 1 + .../domaincapsdata/qemu_5.2.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_5.2.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_5.2.0.s390x.xml | 1 + tests/domaincapsdata/qemu_5.2.0.x86_64.xml | 1 + .../domaincapsdata/qemu_6.0.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_6.0.0.s390x.xml | 1 + tests/domaincapsdata/qemu_6.0.0.x86_64.xml | 1 + .../domaincapsdata/qemu_6.1.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_6.1.0.x86_64.xml | 1 + .../domaincapsdata/qemu_6.2.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_6.2.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_6.2.0.x86_64.xml | 1 + .../domaincapsdata/qemu_7.0.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_7.0.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_7.0.0.x86_64.xml | 1 + .../domaincapsdata/qemu_7.1.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_7.1.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_7.1.0.x86_64.xml | 1 + .../domaincapsdata/qemu_7.2.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_7.2.0.x86_64.xml | 1 + .../domaincapsdata/qemu_8.0.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_8.0.0.x86_64.xml | 1 + .../domaincapsdata/qemu_8.1.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_8.1.0.x86_64.xml | 1 + tests/domaincapsmock.c | 7 ++++ 37 files changed, 80 insertions(+), 2 deletions(-) diff --git a/docs/formatdomaincaps.rst b/docs/formatdomaincaps.rst index e93c765aff..9dae941d18 100644 --- a/docs/formatdomaincaps.rst +++ b/docs/formatdomaincaps.rst @@ -187,6 +187,7 @@ CPUs <formatdomain.html#cpu-model-and-topology>`__. <mode name='host-model' supported='yes'> <model fallback='allow'>Broadwell</model> <vendor>Intel</vendor> + <maxphysaddr mode="passthrough" limit="39"/> <feature policy='disable' name='aes'/> <feature policy='require' name='vmx'/> </mode> @@ -218,7 +219,10 @@ more details about it: indicated by the ``fallback`` attribute of the ``model`` sub element: ``allow`` means not all specifics were accounted for and thus the CPU a guest will see may be different; ``forbid`` indicates that the CPU a guest will see - should match this CPU definition. + should match this CPU definition. The optional ``maxphysaddr`` element + reports physical address size of the host CPU if this value is available and + applicable for the requested domain type. This is useful for computing + baseline CPU definition which should be compatible with several hosts. ``custom`` The ``mode`` element contains a list of supported CPU models, each described by a dedicated ``model`` element. The ``usable`` attribute specifies whether diff --git a/src/conf/schemas/domaincaps.rng b/src/conf/schemas/domaincaps.rng index 28f545bd4b..19bd6f7128 100644 --- a/src/conf/schemas/domaincaps.rng +++ b/src/conf/schemas/domaincaps.rng @@ -132,6 +132,9 @@ <optional> <ref name="cpuVendor"/> </optional> + <optional> + <ref name="cpuMaxPhysAddr"/> + </optional> <zeroOrMore> <ref name="cpuFeature"/> </zeroOrMore> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index cf85d42198..0552486805 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -717,6 +717,8 @@ struct _virQEMUCapsHostCPUData { * probe QEMU or load the cache. */ qemuMonitorCPUModelInfo *info; + /* Physical address size of the host CPU or 0 if unknown or not applicable. */ + unsigned int physAddrSize; /* Host CPU definition reported in domain capabilities. */ virCPUDef *reported; /* Migratable host CPU definition used for updating guest CPU. */ @@ -2236,6 +2238,7 @@ virQEMUCapsGetHostModel(virQEMUCaps *qemuCaps, static void virQEMUCapsSetHostModel(virQEMUCaps *qemuCaps, virDomainVirtType type, + unsigned int physAddrSize, virCPUDef *reported, virCPUDef *migratable, virCPUDef *full) @@ -2243,12 +2246,34 @@ virQEMUCapsSetHostModel(virQEMUCaps *qemuCaps, virQEMUCapsHostCPUData *cpuData; cpuData = &virQEMUCapsGetAccel(qemuCaps, type)->hostCPU; + cpuData->physAddrSize = physAddrSize; cpuData->reported = reported; cpuData->migratable = migratable; cpuData->full = full; } +static virCPUMaxPhysAddrDef * +virQEMUCapsGetHostPhysAddr(virQEMUCaps *qemuCaps, + virDomainVirtType type) +{ + virQEMUCapsHostCPUData *cpuData; + virCPUMaxPhysAddrDef *addr = NULL; + + cpuData = &virQEMUCapsGetAccel(qemuCaps, type)->hostCPU; + + if (cpuData->physAddrSize != 0) { + addr = g_new0(virCPUMaxPhysAddrDef, 1); + + addr->mode = VIR_CPU_MAX_PHYS_ADDR_MODE_PASSTHROUGH; + addr->limit = cpuData->physAddrSize; + addr->bits = -1; + } + + return addr; +} + + bool virQEMUCapsIsArchSupported(virQEMUCaps *qemuCaps, virArch arch) @@ -3805,6 +3830,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, virCPUDef *migCPU = NULL; virCPUDef *hostCPU = NULL; virCPUDef *fullCPU = NULL; + unsigned int physAddrSize = 0; size_t i; int rc; @@ -3878,7 +3904,10 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, goto error; } - virQEMUCapsSetHostModel(qemuCaps, type, cpu, migCPU, fullCPU); + if (virQEMUCapsTypeIsAccelerated(type)) + virHostCPUGetPhysAddrSize(&physAddrSize); + + virQEMUCapsSetHostModel(qemuCaps, type, physAddrSize, cpu, migCPU, fullCPU); cleanup: virCPUDefFree(cpuExpanded); @@ -6224,6 +6253,8 @@ virQEMUCapsFillDomainCPUCaps(virQEMUCaps *qemuCaps, virCPUDef *cpu = virQEMUCapsGetHostModel(qemuCaps, domCaps->virttype, VIR_QEMU_CAPS_HOST_CPU_REPORTED); domCaps->cpu.hostModel = virCPUDefCopy(cpu); + domCaps->cpu.hostModel->addr = virQEMUCapsGetHostPhysAddr(qemuCaps, + domCaps->virttype); } if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttype, diff --git a/tests/domaincapsdata/qemu_4.2.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_4.2.0-q35.x86_64.xml index 17799b15e3..f408c2a969 100644 --- a/tests/domaincapsdata/qemu_4.2.0-q35.x86_64.xml +++ b/tests/domaincapsdata/qemu_4.2.0-q35.x86_64.xml @@ -44,6 +44,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>Skylake-Client-IBRS</model> <vendor>Intel</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='ss'/> <feature policy='require' name='vmx'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_4.2.0.ppc64.xml b/tests/domaincapsdata/qemu_4.2.0.ppc64.xml index 6ade73c86a..a3289573bd 100644 --- a/tests/domaincapsdata/qemu_4.2.0.ppc64.xml +++ b/tests/domaincapsdata/qemu_4.2.0.ppc64.xml @@ -38,6 +38,7 @@ </mode> <mode name='host-model' supported='yes'> <model fallback='allow'>POWER8</model> + <maxphysaddr mode='passthrough' limit='64'/> </mode> <mode name='custom' supported='yes'> <model usable='unknown' vendor='IBM'>POWER9</model> diff --git a/tests/domaincapsdata/qemu_4.2.0.s390x.xml b/tests/domaincapsdata/qemu_4.2.0.s390x.xml index 81395f43bf..c35bed1326 100644 --- a/tests/domaincapsdata/qemu_4.2.0.s390x.xml +++ b/tests/domaincapsdata/qemu_4.2.0.s390x.xml @@ -38,6 +38,7 @@ </mode> <mode name='host-model' supported='yes'> <model fallback='forbid'>gen15a-base</model> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='aen'/> <feature policy='require' name='cmmnt'/> <feature policy='require' name='vxpdeh'/> diff --git a/tests/domaincapsdata/qemu_4.2.0.x86_64.xml b/tests/domaincapsdata/qemu_4.2.0.x86_64.xml index 1b7e4014c5..cbe083f1f1 100644 --- a/tests/domaincapsdata/qemu_4.2.0.x86_64.xml +++ b/tests/domaincapsdata/qemu_4.2.0.x86_64.xml @@ -43,6 +43,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>Skylake-Client-IBRS</model> <vendor>Intel</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='ss'/> <feature policy='require' name='vmx'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_5.0.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_5.0.0-q35.x86_64.xml index 1278e930d2..6b68d4f2a5 100644 --- a/tests/domaincapsdata/qemu_5.0.0-q35.x86_64.xml +++ b/tests/domaincapsdata/qemu_5.0.0-q35.x86_64.xml @@ -44,6 +44,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>Skylake-Client-IBRS</model> <vendor>Intel</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='ss'/> <feature policy='require' name='vmx'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_5.0.0.ppc64.xml b/tests/domaincapsdata/qemu_5.0.0.ppc64.xml index da40c0a876..4b3f490942 100644 --- a/tests/domaincapsdata/qemu_5.0.0.ppc64.xml +++ b/tests/domaincapsdata/qemu_5.0.0.ppc64.xml @@ -38,6 +38,7 @@ </mode> <mode name='host-model' supported='yes'> <model fallback='allow'>POWER8</model> + <maxphysaddr mode='passthrough' limit='64'/> </mode> <mode name='custom' supported='yes'> <model usable='unknown' vendor='IBM'>POWER10</model> diff --git a/tests/domaincapsdata/qemu_5.0.0.x86_64.xml b/tests/domaincapsdata/qemu_5.0.0.x86_64.xml index 71a01cbcbc..603d842dfe 100644 --- a/tests/domaincapsdata/qemu_5.0.0.x86_64.xml +++ b/tests/domaincapsdata/qemu_5.0.0.x86_64.xml @@ -43,6 +43,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>Skylake-Client-IBRS</model> <vendor>Intel</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='ss'/> <feature policy='require' name='vmx'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_5.1.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_5.1.0-q35.x86_64.xml index 1b3fc889d4..cdbbe86ede 100644 --- a/tests/domaincapsdata/qemu_5.1.0-q35.x86_64.xml +++ b/tests/domaincapsdata/qemu_5.1.0-q35.x86_64.xml @@ -44,6 +44,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_5.1.0.x86_64.xml b/tests/domaincapsdata/qemu_5.1.0.x86_64.xml index 228b0a17c4..1ef28a71e4 100644 --- a/tests/domaincapsdata/qemu_5.1.0.x86_64.xml +++ b/tests/domaincapsdata/qemu_5.1.0.x86_64.xml @@ -43,6 +43,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_5.2.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_5.2.0-q35.x86_64.xml index d1f0ec76aa..46a3a44cdd 100644 --- a/tests/domaincapsdata/qemu_5.2.0-q35.x86_64.xml +++ b/tests/domaincapsdata/qemu_5.2.0-q35.x86_64.xml @@ -44,6 +44,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_5.2.0.ppc64.xml b/tests/domaincapsdata/qemu_5.2.0.ppc64.xml index 33f60ec813..b465ad1030 100644 --- a/tests/domaincapsdata/qemu_5.2.0.ppc64.xml +++ b/tests/domaincapsdata/qemu_5.2.0.ppc64.xml @@ -38,6 +38,7 @@ </mode> <mode name='host-model' supported='yes'> <model fallback='allow'>POWER8</model> + <maxphysaddr mode='passthrough' limit='64'/> </mode> <mode name='custom' supported='yes'> <model usable='unknown' vendor='IBM'>POWER10</model> diff --git a/tests/domaincapsdata/qemu_5.2.0.s390x.xml b/tests/domaincapsdata/qemu_5.2.0.s390x.xml index 1e615dab7c..9dbf118713 100644 --- a/tests/domaincapsdata/qemu_5.2.0.s390x.xml +++ b/tests/domaincapsdata/qemu_5.2.0.s390x.xml @@ -38,6 +38,7 @@ </mode> <mode name='host-model' supported='yes'> <model fallback='forbid'>gen15a-base</model> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='aen'/> <feature policy='require' name='cmmnt'/> <feature policy='require' name='vxpdeh'/> diff --git a/tests/domaincapsdata/qemu_5.2.0.x86_64.xml b/tests/domaincapsdata/qemu_5.2.0.x86_64.xml index 18c2e6b0f7..09db834535 100644 --- a/tests/domaincapsdata/qemu_5.2.0.x86_64.xml +++ b/tests/domaincapsdata/qemu_5.2.0.x86_64.xml @@ -43,6 +43,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_6.0.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_6.0.0-q35.x86_64.xml index 2c22538349..b1a2be10e6 100644 --- a/tests/domaincapsdata/qemu_6.0.0-q35.x86_64.xml +++ b/tests/domaincapsdata/qemu_6.0.0-q35.x86_64.xml @@ -44,6 +44,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_6.0.0.s390x.xml b/tests/domaincapsdata/qemu_6.0.0.s390x.xml index f3287347aa..f0a8b196f5 100644 --- a/tests/domaincapsdata/qemu_6.0.0.s390x.xml +++ b/tests/domaincapsdata/qemu_6.0.0.s390x.xml @@ -38,6 +38,7 @@ </mode> <mode name='host-model' supported='yes'> <model fallback='forbid'>gen15a-base</model> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='aen'/> <feature policy='require' name='cmmnt'/> <feature policy='require' name='vxpdeh'/> diff --git a/tests/domaincapsdata/qemu_6.0.0.x86_64.xml b/tests/domaincapsdata/qemu_6.0.0.x86_64.xml index f0ff745f92..693ae0a7f1 100644 --- a/tests/domaincapsdata/qemu_6.0.0.x86_64.xml +++ b/tests/domaincapsdata/qemu_6.0.0.x86_64.xml @@ -43,6 +43,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml index bdaf28ec3e..a161d6aa20 100644 --- a/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml +++ b/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml @@ -44,6 +44,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_6.1.0.x86_64.xml b/tests/domaincapsdata/qemu_6.1.0.x86_64.xml index ded6604e04..8c4f8cc860 100644 --- a/tests/domaincapsdata/qemu_6.1.0.x86_64.xml +++ b/tests/domaincapsdata/qemu_6.1.0.x86_64.xml @@ -43,6 +43,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_6.2.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_6.2.0-q35.x86_64.xml index e1f1539140..0449f562df 100644 --- a/tests/domaincapsdata/qemu_6.2.0-q35.x86_64.xml +++ b/tests/domaincapsdata/qemu_6.2.0-q35.x86_64.xml @@ -44,6 +44,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_6.2.0.ppc64.xml b/tests/domaincapsdata/qemu_6.2.0.ppc64.xml index 69f6818a81..a9f7aefbc9 100644 --- a/tests/domaincapsdata/qemu_6.2.0.ppc64.xml +++ b/tests/domaincapsdata/qemu_6.2.0.ppc64.xml @@ -38,6 +38,7 @@ </mode> <mode name='host-model' supported='yes'> <model fallback='allow'>POWER8</model> + <maxphysaddr mode='passthrough' limit='64'/> </mode> <mode name='custom' supported='yes'> <model usable='unknown' vendor='IBM'>POWER10</model> diff --git a/tests/domaincapsdata/qemu_6.2.0.x86_64.xml b/tests/domaincapsdata/qemu_6.2.0.x86_64.xml index 688783d267..fa1f7a2316 100644 --- a/tests/domaincapsdata/qemu_6.2.0.x86_64.xml +++ b/tests/domaincapsdata/qemu_6.2.0.x86_64.xml @@ -43,6 +43,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_7.0.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_7.0.0-q35.x86_64.xml index ee6abd2f9d..e793278d41 100644 --- a/tests/domaincapsdata/qemu_7.0.0-q35.x86_64.xml +++ b/tests/domaincapsdata/qemu_7.0.0-q35.x86_64.xml @@ -44,6 +44,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_7.0.0.ppc64.xml b/tests/domaincapsdata/qemu_7.0.0.ppc64.xml index 349223b689..78f8d3cac4 100644 --- a/tests/domaincapsdata/qemu_7.0.0.ppc64.xml +++ b/tests/domaincapsdata/qemu_7.0.0.ppc64.xml @@ -38,6 +38,7 @@ </mode> <mode name='host-model' supported='yes'> <model fallback='allow'>POWER8</model> + <maxphysaddr mode='passthrough' limit='64'/> </mode> <mode name='custom' supported='yes'> <model usable='unknown' vendor='IBM'>POWER10</model> diff --git a/tests/domaincapsdata/qemu_7.0.0.x86_64.xml b/tests/domaincapsdata/qemu_7.0.0.x86_64.xml index 45e226e434..1d1505f757 100644 --- a/tests/domaincapsdata/qemu_7.0.0.x86_64.xml +++ b/tests/domaincapsdata/qemu_7.0.0.x86_64.xml @@ -43,6 +43,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_7.1.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_7.1.0-q35.x86_64.xml index 3fc7ae5551..047763bd43 100644 --- a/tests/domaincapsdata/qemu_7.1.0-q35.x86_64.xml +++ b/tests/domaincapsdata/qemu_7.1.0-q35.x86_64.xml @@ -44,6 +44,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_7.1.0.ppc64.xml b/tests/domaincapsdata/qemu_7.1.0.ppc64.xml index b68fb91c98..f3a436d859 100644 --- a/tests/domaincapsdata/qemu_7.1.0.ppc64.xml +++ b/tests/domaincapsdata/qemu_7.1.0.ppc64.xml @@ -33,6 +33,7 @@ <mode name='maximum' supported='no'/> <mode name='host-model' supported='yes'> <model fallback='allow'>POWER8</model> + <maxphysaddr mode='passthrough' limit='64'/> </mode> <mode name='custom' supported='yes'> <model usable='unknown' vendor='IBM'>POWER10</model> diff --git a/tests/domaincapsdata/qemu_7.1.0.x86_64.xml b/tests/domaincapsdata/qemu_7.1.0.x86_64.xml index fe5ac06df3..95452bb0a4 100644 --- a/tests/domaincapsdata/qemu_7.1.0.x86_64.xml +++ b/tests/domaincapsdata/qemu_7.1.0.x86_64.xml @@ -43,6 +43,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_7.2.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_7.2.0-q35.x86_64.xml index 50615d437e..d0029c65da 100644 --- a/tests/domaincapsdata/qemu_7.2.0-q35.x86_64.xml +++ b/tests/domaincapsdata/qemu_7.2.0-q35.x86_64.xml @@ -44,6 +44,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_7.2.0.x86_64.xml b/tests/domaincapsdata/qemu_7.2.0.x86_64.xml index 513042e7f2..fecb7e4a0a 100644 --- a/tests/domaincapsdata/qemu_7.2.0.x86_64.xml +++ b/tests/domaincapsdata/qemu_7.2.0.x86_64.xml @@ -43,6 +43,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_8.0.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_8.0.0-q35.x86_64.xml index c1a1c0b733..ef2637ab26 100644 --- a/tests/domaincapsdata/qemu_8.0.0-q35.x86_64.xml +++ b/tests/domaincapsdata/qemu_8.0.0-q35.x86_64.xml @@ -44,6 +44,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_8.0.0.x86_64.xml b/tests/domaincapsdata/qemu_8.0.0.x86_64.xml index 412847aa62..ebae9e34d6 100644 --- a/tests/domaincapsdata/qemu_8.0.0.x86_64.xml +++ b/tests/domaincapsdata/qemu_8.0.0.x86_64.xml @@ -43,6 +43,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_8.1.0-q35.x86_64.xml b/tests/domaincapsdata/qemu_8.1.0-q35.x86_64.xml index f4a9c43340..0fccb2ef47 100644 --- a/tests/domaincapsdata/qemu_8.1.0-q35.x86_64.xml +++ b/tests/domaincapsdata/qemu_8.1.0-q35.x86_64.xml @@ -44,6 +44,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsdata/qemu_8.1.0.x86_64.xml b/tests/domaincapsdata/qemu_8.1.0.x86_64.xml index 89f7ff5250..f555cca9db 100644 --- a/tests/domaincapsdata/qemu_8.1.0.x86_64.xml +++ b/tests/domaincapsdata/qemu_8.1.0.x86_64.xml @@ -43,6 +43,7 @@ <mode name='host-model' supported='yes'> <model fallback='forbid'>EPYC-Rome</model> <vendor>AMD</vendor> + <maxphysaddr mode='passthrough' limit='64'/> <feature policy='require' name='x2apic'/> <feature policy='require' name='tsc-deadline'/> <feature policy='require' name='hypervisor'/> diff --git a/tests/domaincapsmock.c b/tests/domaincapsmock.c index d382d06e27..cecb333602 100644 --- a/tests/domaincapsmock.c +++ b/tests/domaincapsmock.c @@ -36,6 +36,13 @@ virHostCPUGetMicrocodeVersion(virArch hostArch G_GNUC_UNUSED) return 0; } +int +virHostCPUGetPhysAddrSize(unsigned int *size) +{ + *size = 64; + return 0; +} + #if WITH_QEMU static bool (*real_virQEMUCapsGetKVMSupportsSecureGuest)(virQEMUCaps *qemuCaps); -- 2.41.0

The current implementation of virConnectBaselineHypervisorCPU in QEMU driver can provide a CPU definition that will not work on all hosts in case they have different maximum physical address size. So when we get the info from domain capabilities, we need to choose the smallest physical address size for the computed baseline CPU definition. https://bugzilla.redhat.com/show_bug.cgi?id=2171860 Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/qemu/qemu_driver.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 857fbfb799..c4bd766531 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11778,6 +11778,8 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, virCPUDef *cpu = NULL; char *cpustr = NULL; g_auto(GStrv) features = NULL; + unsigned int physAddrSize = 0; + size_t i; virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); @@ -11845,6 +11847,21 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, virCPUExpandFeatures(arch, cpu) < 0) goto cleanup; + for (i = 0; i < ncpus; i++) { + if (!cpus[i]->addr || cpus[i]->addr->limit == 0) + continue; + + if (physAddrSize == 0 || cpus[i]->addr->limit < physAddrSize) + physAddrSize = cpus[i]->addr->limit; + } + + if (physAddrSize > 0) { + cpu->addr = g_new0(virCPUMaxPhysAddrDef, 1); + cpu->addr->mode = VIR_CPU_MAX_PHYS_ADDR_MODE_PASSTHROUGH; + cpu->addr->limit = physAddrSize; + cpu->addr->bits = -1; + } + cpustr = virCPUDefFormat(cpu, NULL); cleanup: -- 2.41.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- NEWS.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index b1cccee4fa..c520a96177 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -19,6 +19,13 @@ v9.5.0 (unreleased) * **Improvements** + * qemu: Include maximum physical address size in baseline CPU + + When computing a baseline CPU definition for a set of hosts, we need to + include maximum physical address size in the result to make sure it is + compatible with all hosts even if their supported physical address sizes + differ. + * **Bug fixes** -- 2.41.0

On 6/16/23 10:14, Jiri Denemark wrote:
Jiri Denemark (3): qemu: Report physical address size in domain capabilities qemu: Include maximum physical address size in baseline CPU NEWS: Mentioned an improvement for virConnectBaselineHypervisorCPU
NEWS.rst | 7 ++++ docs/formatdomaincaps.rst | 6 +++- src/conf/schemas/domaincaps.rng | 3 ++ src/qemu/qemu_capabilities.c | 33 ++++++++++++++++++- src/qemu/qemu_driver.c | 17 ++++++++++ .../domaincapsdata/qemu_4.2.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_4.2.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_4.2.0.s390x.xml | 1 + tests/domaincapsdata/qemu_4.2.0.x86_64.xml | 1 + .../domaincapsdata/qemu_5.0.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_5.0.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_5.0.0.x86_64.xml | 1 + .../domaincapsdata/qemu_5.1.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_5.1.0.x86_64.xml | 1 + .../domaincapsdata/qemu_5.2.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_5.2.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_5.2.0.s390x.xml | 1 + tests/domaincapsdata/qemu_5.2.0.x86_64.xml | 1 + .../domaincapsdata/qemu_6.0.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_6.0.0.s390x.xml | 1 + tests/domaincapsdata/qemu_6.0.0.x86_64.xml | 1 + .../domaincapsdata/qemu_6.1.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_6.1.0.x86_64.xml | 1 + .../domaincapsdata/qemu_6.2.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_6.2.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_6.2.0.x86_64.xml | 1 + .../domaincapsdata/qemu_7.0.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_7.0.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_7.0.0.x86_64.xml | 1 + .../domaincapsdata/qemu_7.1.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_7.1.0.ppc64.xml | 1 + tests/domaincapsdata/qemu_7.1.0.x86_64.xml | 1 + .../domaincapsdata/qemu_7.2.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_7.2.0.x86_64.xml | 1 + .../domaincapsdata/qemu_8.0.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_8.0.0.x86_64.xml | 1 + .../domaincapsdata/qemu_8.1.0-q35.x86_64.xml | 1 + tests/domaincapsdata/qemu_8.1.0.x86_64.xml | 1 + tests/domaincapsmock.c | 7 ++++ 39 files changed, 104 insertions(+), 2 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Jiri Denemark
-
Michal Prívozník