[libvirt] [PATCH 4/5] conf: include x86 microcode version in virsh capabilities

Peter Krempa pkrempa at redhat.com
Thu Jan 4 15:25:49 UTC 2018


On Thu, Jan 04, 2018 at 15:58:11 +0100, Jiri Denemark wrote:
> From: Paolo Bonzini <pbonzini at redhat.com>
> 
> A microcode update can cause the CPUID bits to change; an example
> from the past was the update that disabled TSX on several Haswell and
> Broadwell machines.
> 
> In order to track the x86 microcode version in the QEMU capabilities,
> we have to fetch it and store it in the host CPU.  This also makes the
> version visible in "virsh capabilities", which is a nice side effect.
> 
> Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
>  src/conf/cpu_conf.c | 14 ++++++++++++++
>  src/conf/cpu_conf.h |  1 +
>  src/cpu/cpu_x86.c   |  9 +++++++++
>  3 files changed, 24 insertions(+)

[...]

> @@ -382,6 +384,14 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
>              goto cleanup;
>          }
>          VIR_FREE(arch);
> +
> +        if (virXPathBoolean("boolean(./microcode[1]/@version)", ctxt) > 0 &&
> +            virXPathUInt("string(./microcode[1]/@version)", ctxt,
> +                         &def->microcodeVersion) < 0) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                           _("invalid microcode version"));
> +            goto cleanup;
> +        }
>      }
>  
>      if (!(def->model = virXPathString("string(./model[1])", ctxt)) &&
> @@ -720,6 +730,10 @@ virCPUDefFormatBuf(virBufferPtr buf,
>      if (formatModel && def->vendor)
>          virBufferEscapeString(buf, "<vendor>%s</vendor>\n", def->vendor);
>  
> +    if (def->type == VIR_CPU_TYPE_HOST && def->microcodeVersion)

Hmm, looks like you should add a comment to virHostCPUGetMicrocodeVersion
stating that 0 is a special value.

> +        virBufferAsprintf(buf, "<microcode version='%u'/>\n",
> +                          def->microcodeVersion);
> +

ACK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180104/fb222110/attachment-0001.sig>


More information about the libvir-list mailing list