Bug 1804549 - vendor_id is never formatted in host-model CPU definition XML
Summary: vendor_id is never formatted in host-model CPU definition XML
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.2
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: Jiri Denemark
QA Contact: jiyan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-02-19 05:57 UTC by jiyan
Modified: 2020-11-02 07:49 UTC (History)
7 users (show)

Fixed In Version: libvirt-6.0.0-6.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-05-05 09:57:19 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:2017 0 None None None 2020-05-05 09:58:26 UTC

Description jiyan 2020-02-19 05:57:36 UTC
Description:
vendor_id parameter will disappear after restarting VM

How reproducible:
100%

Version:
kernel-4.18.0-178.el8.x86_64
qemu-kvm-4.2.0-10.module+el8.2.0+5740+c3dff59e.x86_64
libvirt-6.0.0-5.module+el8.2.0+5765+64816f89.x86_64

Steps:
1: Edit a shutdown VM with the following XML, and check inactive dumpxml of VM
# virsh domstate test82
shut off

# virsh edit test82
  <cpu mode='host-model'>
    <model fallback='forbid' vendor_id='GenuineIntel'/>
    <numa>
      <cell id='0' cpus='0' memory='512000' unit='KiB'/>
      <cell id='1' cpus='1' memory='512000' unit='KiB'/>
    </numa>
  </cpu>
Domain test82 XML configuration edited.

2: Start VM and check active dumpxml of VM
# virsh dumpxml test82 --inactive |grep "<cpu" -A5
  <cpu mode='host-model' check='partial'>
    <numa>
      <cell id='0' cpus='0' memory='512000' unit='KiB'/>
      <cell id='1' cpus='1' memory='512000' unit='KiB'/>
    </numa>
  </cpu>

# virsh dumpxml test82  |grep "<cpu" -A26
  <cpu mode='custom' match='exact' check='full'>
    <model fallback='forbid' vendor_id='GenuineIntel'>Haswell-noTSX-IBRS</model>
    <vendor>Intel</vendor>
    <feature policy='require' name='vme'/>
    <feature policy='require' name='ss'/>
    <feature policy='require' name='vmx'/>
    <feature policy='require' name='f16c'/>
    <feature policy='require' name='rdrand'/>
    <feature policy='require' name='hypervisor'/>
    <feature policy='require' name='arat'/>
    <feature policy='require' name='tsc_adjust'/>
    <feature policy='require' name='umip'/>
    <feature policy='require' name='md-clear'/>
    <feature policy='require' name='stibp'/>
    <feature policy='require' name='arch-capabilities'/>
    <feature policy='require' name='ssbd'/>
    <feature policy='require' name='xsaveopt'/>
    <feature policy='require' name='pdpe1gb'/>
    <feature policy='require' name='abm'/>
    <feature policy='require' name='ibpb'/>
    <feature policy='require' name='amd-ssbd'/>
    <feature policy='require' name='skip-l1dfl-vmentry'/>
    <numa>
      <cell id='0' cpus='0' memory='512000' unit='KiB'/>
      <cell id='1' cpus='1' memory='512000' unit='KiB'/>
    </numa>
  </cpu>

# ps -ef |grep test82
...
 -cpu Haswell-noTSX-IBRS,vendor=GenuineIntel,vme=on,ss=on,vmx=on,f16c=on,rdrand=on,hypervisor=on,arat=on,tsc-adjust=on,umip=on,md-clear=on,stibp=on,arch-capabilities=on,ssbd=on,xsaveopt=on,pdpe1gb=on,abm=on,ibpb=on,amd-ssbd=on,skip-l1dfl-vmentry=on,hv-synic 

3. Restart VM and check active dumpxml again
# virsh destroy test82 ;virsh start test82
Domain test82 destroyed

Domain test82 started

# virsh dumpxml test82  |grep "<cpu" -A26
  <cpu mode='custom' match='exact' check='full'>
    <model fallback='forbid'>Haswell-noTSX-IBRS</model>   "No GenuineIntel here"
    <vendor>Intel</vendor>
    <feature policy='require' name='vme'/>
    <feature policy='require' name='ss'/>
    <feature policy='require' name='vmx'/>
    <feature policy='require' name='f16c'/>
    <feature policy='require' name='rdrand'/>
    <feature policy='require' name='hypervisor'/>
    <feature policy='require' name='arat'/>
    <feature policy='require' name='tsc_adjust'/>
    <feature policy='require' name='umip'/>
    <feature policy='require' name='md-clear'/>
    <feature policy='require' name='stibp'/>
    <feature policy='require' name='arch-capabilities'/>
    <feature policy='require' name='ssbd'/>
    <feature policy='require' name='xsaveopt'/>
    <feature policy='require' name='pdpe1gb'/>
    <feature policy='require' name='abm'/>
    <feature policy='require' name='ibpb'/>
    <feature policy='require' name='amd-ssbd'/>
    <feature policy='require' name='skip-l1dfl-vmentry'/>
    <numa>
      <cell id='0' cpus='0' memory='512000' unit='KiB'/>
      <cell id='1' cpus='1' memory='512000' unit='KiB'/>
    </numa>
  </cpu>
# ps -ef |grep test82
...
-cpu Haswell-noTSX-IBRS,vme=on,ss=on,vmx=on,f16c=on,rdrand=on,hypervisor=on,arat=on,tsc-adjust=on,umip=on,md-clear=on,stibp=on,arch-capabilities=on,ssbd=on,xsaveopt=on,pdpe1gb=on,abm=on,ibpb=on,amd-ssbd=on,skip-l1dfl-vmentry=on,hv-synic

Expected result:
In step-1; there should be "GenuineIntel" info in the inactive dumpxml after saving the changes.

Actual result:
In step-1; there is no "GenuineIntel" info in the inactive dumpxml after saving the changes, which also cause the restarting action in step-3 wrong.
And when there is no "GenuineIntel" in inactive dumpxml, starting VM with "GenuineIntel" in active dumpxml in step-2 will also unreasonable.

Additional info:
Original bug related to this issue: https://bugzilla.redhat.com/show_bug.cgi?id=858147

Comment 1 Jiri Denemark 2020-02-19 11:56:36 UTC
(In reply to jiyan from comment #0)
> # virsh edit test82
>   <cpu mode='host-model'>
>     <model fallback='forbid' vendor_id='GenuineIntel'/>
>     <numa>
>       <cell id='0' cpus='0' memory='512000' unit='KiB'/>
>       <cell id='1' cpus='1' memory='512000' unit='KiB'/>
>     </numa>
>   </cpu>
> Domain test82 XML configuration edited.

At this point the vendor_id attribute only exists in the libvirtd's internal
domain definition, but it's not propagated into the domain XML. You can check
that using "virsh dumpxml" without even starting the domain. That is, even
restarting libvirtd here would cause the domain to be started without
vendor_id.

Comment 2 Jiri Denemark 2020-02-19 12:29:45 UTC
Broken by upstream commit v5.9.0-400-gaf8e39921a present in libvirt-6.0.0-1.el8

Comment 3 Jiri Denemark 2020-02-19 13:09:38 UTC
Patches sent upstream for review: https://www.redhat.com/archives/libvir-list/2020-February/msg00665.html

Comment 4 Jiri Denemark 2020-02-19 14:20:53 UTC
Fixed upstream by

commit 1939fbef989e6990cb5dd2d2d7ff8ea002c517c2
Refs: v6.0.0-408-g1939fbef98
Author:     Jiri Denemark <jdenemar>
AuthorDate: Wed Feb 19 13:10:27 2020 +0100
Commit:     Jiri Denemark <jdenemar>
CommitDate: Wed Feb 19 15:11:40 2020 +0100

    qemuxml2xmltest: Add case for host-model vendor_id

    This patch shows a bug in our code: the

        <model vendor_id="Libvirt QEMU"/>

    element present in the source XML is lost when the parsed CPU definition
    is formatted back to XML.

    https://bugzilla.redhat.com/show_bug.cgi?id=1804549

    Signed-off-by: Jiri Denemark <jdenemar>
    Reviewed-by: Ján Tomko <jtomko>

commit 0905f222f1bfd9d741e94a8d653e05bb174846d3
Refs: v6.0.0-409-g0905f222f1
Author:     Jiri Denemark <jdenemar>
AuthorDate: Wed Feb 19 13:48:39 2020 +0100
Commit:     Jiri Denemark <jdenemar>
CommitDate: Wed Feb 19 15:11:40 2020 +0100

    cpu_conf: Format vendor_id for host-model CPUs

    In commit v5.9.0-400-gaf8e39921a I removed printing model's fallback and
    vendor_id attributes when no model is specified. However, vendor_id
    makes sense even without a specific CPU model (for host-model CPUs).

    https://bugzilla.redhat.com/show_bug.cgi?id=1804549

    Signed-off-by: Jiri Denemark <jdenemar>
    Reviewed-by: Ján Tomko <jtomko>

Comment 9 jiyan 2020-02-26 06:52:47 UTC
Verified this bug with libvirt-6.0.0-6.module+el8.2.0+5821+109ee33c.x86_64.

Version:
libvirt-6.0.0-6.module+el8.2.0+5821+109ee33c.x86_64
qemu-kvm-4.2.0-12.module+el8.2.0+5858+afd073bc.x86_64
kernel-4.18.0-180.el8.x86_64

Steps:
1. Prepare a shutdown VM with vendor_id parameter
# virsh domstate test82-1 
shut off

# virsh dumpxml test82-1 |grep "<cpu" -A6
  <cpu mode='host-model' check='partial'>
    <model vendor_id='AuthenticAMD'/>
    <numa>
      <cell id='0' cpus='0' memory='512000' unit='KiB'/>
      <cell id='1' cpus='1' memory='512000' unit='KiB'/>
    </numa>
  </cpu>

2. Start VM, check whether vendor_id parameter exists in active dumpxml and qemu cmd line
# virsh start test82-1 
Domain test82-1 started

# virsh dumpxml test82-1 |grep "<cpu" -A20
  <cpu mode='custom' match='exact' check='full'>
    <model fallback='forbid' vendor_id='AuthenticAMD'>EPYC-IBPB</model>
    <vendor>AMD</vendor>
    <feature policy='require' name='x2apic'/>
    <feature policy='require' name='tsc-deadline'/>
    <feature policy='require' name='hypervisor'/>
    <feature policy='require' name='tsc_adjust'/>
    <feature policy='require' name='arch-capabilities'/>
    <feature policy='require' name='ssbd'/>
    <feature policy='require' name='cmp_legacy'/>
    <feature policy='require' name='perfctr_core'/>
    <feature policy='require' name='clzero'/>
    <feature policy='require' name='amd-ssbd'/>
    <feature policy='require' name='virt-ssbd'/>
    <feature policy='require' name='rdctl-no'/>
    <feature policy='require' name='skip-l1dfl-vmentry'/>
    <feature policy='require' name='mds-no'/>
    <feature policy='disable' name='monitor'/>
    <feature policy='disable' name='svm'/>
    <feature policy='require' name='topoext'/>
    <numa>

# ps -ef |grep test
...-cpu EPYC-IBPB,vendor=AuthenticAMD,x2apic=on,tsc-deadline=on,hypervisor=on,tsc-adjust=on,arch-capabilities=on,ssbd=on,cmp-legacy=on,perfctr-core=on,clzero=on,amd-ssbd=on,virt-ssbd=on,rdctl-no=on,skip-l1dfl-vmentry=on,mds-no=on,monitor=off,svm=off,tsc-frequency=2096055000,hv-relaxed

3. Restart libvirtd and check whether vendor_id parameter exists in active dumpxml 
# systemctl restart libvirtd

# virsh dumpxml test82-1 |grep AuthenticAMD
    <model fallback='forbid' vendor_id='AuthenticAMD'>EPYC-IBPB</model>

4. Restart VM and check whether vendor_id parameter exists in active dumpxml 
# virsh destroy test82-1 ; virsh start test82-1
Domain test82-1 destroyed

Domain test82-1 started

# virsh dumpxml test82-1 |grep AuthenticAMD
    <model fallback='forbid' vendor_id='AuthenticAMD'>EPYC-IBPB</model>

All the test results are as expected, move this bug to be verified.

Comment 11 errata-xmlrpc 2020-05-05 09:57:19 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:2017


Note You need to log in before you can comment on or make changes to this bug.