[libvirt] [PATCH] qemu: Translate features in virQEMUCapsGetCPUFeatures

Jiri Denemark posted 1 patch 4 years, 8 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/67022e47bf4a2ce669fd229f8d4f776f4da62a4a.1564043854.git.jdenemar@redhat.com
src/qemu/qemu_capabilities.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[libvirt] [PATCH] qemu: Translate features in virQEMUCapsGetCPUFeatures
Posted by Jiri Denemark 4 years, 8 months ago
Starting with QEMU 4.1 qemuMonitorCPUModelInfo structure in virQEMUCaps
stores only canonical feature names which may differ from the name used
by libvirt. We need translate these canonical names into libvirt names
for further consumption.

This fixes a bug in qemuConnectBaselineHypervisorCPU which would remove
all features for which libvirt's spelling differs from the QEMU's
preferred name. For example, the following result of
qemuConnectBaselineHypervisorCPU on my host with QEMU 4.1 is wrong:

    <cpu mode='custom' match='exact'>
      <model fallback='forbid'>Skylake-Client</model>
      <vendor>Intel</vendor>
      <feature policy='require' name='ss'/>
      <feature policy='require' name='vmx'/>
      <feature policy='require' name='hypervisor'/>
      <feature policy='require' name='clflushopt'/>
      <feature policy='require' name='umip'/>
      <feature policy='require' name='arch-capabilities'/>
      <feature policy='require' name='xsaves'/>
      <feature policy='require' name='pdpe1gb'/>
      <feature policy='require' name='invtsc'/>
      <feature policy='disable' name='pclmuldq'/>
      <feature policy='disable' name='lahf_lm'/>
    </cpu>

The 'pclmuldq' and 'lahf_lm' should not be disabled in the baseline CPU
as they are supported by QEMU on this host.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_capabilities.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 65192469da..2388f145af 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2598,7 +2598,8 @@ virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps,
         if (migratable && prop->migratable == VIR_TRISTATE_BOOL_NO)
             continue;
 
-        if (VIR_STRDUP(list[n++], prop->name) < 0)
+        if (VIR_STRDUP(list[n++],
+                       virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name)) < 0)
             goto cleanup;
     }
 
-- 
2.22.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Translate features in virQEMUCapsGetCPUFeatures
Posted by Andrea Bolognani 4 years, 8 months ago
On Thu, 2019-07-25 at 10:37 +0200, Jiri Denemark wrote:
> Starting with QEMU 4.1 qemuMonitorCPUModelInfo structure in virQEMUCaps
> stores only canonical feature names which may differ from the name used
> by libvirt. We need translate these canonical names into libvirt names
> for further consumption.
> 
> This fixes a bug in qemuConnectBaselineHypervisorCPU which would remove
> all features for which libvirt's spelling differs from the QEMU's
> preferred name. For example, the following result of
> qemuConnectBaselineHypervisorCPU on my host with QEMU 4.1 is wrong:
> 
>     <cpu mode='custom' match='exact'>
>       <model fallback='forbid'>Skylake-Client</model>
>       <vendor>Intel</vendor>
>       <feature policy='require' name='ss'/>
>       <feature policy='require' name='vmx'/>
>       <feature policy='require' name='hypervisor'/>
>       <feature policy='require' name='clflushopt'/>
>       <feature policy='require' name='umip'/>
>       <feature policy='require' name='arch-capabilities'/>
>       <feature policy='require' name='xsaves'/>
>       <feature policy='require' name='pdpe1gb'/>
>       <feature policy='require' name='invtsc'/>
>       <feature policy='disable' name='pclmuldq'/>
>       <feature policy='disable' name='lahf_lm'/>
>     </cpu>

You can indent this by two spaces instead of four.

> The 'pclmuldq' and 'lahf_lm' should not be disabled in the baseline CPU
> as they are supported by QEMU on this host.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/qemu/qemu_capabilities.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list