Bug 1532980

Summary: guest shutoff after upgrade from 7.3 to 7.5 on skylake host
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED ERRATA QA Contact: Luyao Huang <lhuang>
Severity: medium Docs Contact:
Priority: high    
Version: 7.5CC: dyuan, lhuang, mtessun, rbalakri, salmy, xuzhang, yalzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-3.9.0-8.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 11:04:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Luyao Huang 2018-01-10 07:20:19 UTC
Description of problem:
guest shutoff after upgrade from 7.3 to 7.5 on skylake host

Version-Release number of selected component (if applicable):
7.3:
libvirt-2.0.0-10.el7_3.10.x86_64
qemu-img-rhev-2.6.0-28.el7_3.15.x86_64

7.5:
qemu-kvm-rhev-2.10.0-15.el7.x86_64
libvirt-3.9.0-7.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. start a guest with host-model cpu on 7.3

  <cpu mode='host-model' check='partial'>
    <model fallback='forbid'/>
    <numa>
      <cell id='0' cpus='0-3' memory='512000' unit='KiB'/>
      <cell id='1' cpus='4-7' memory='512000' unit='KiB'/>
      <cell id='2' cpus='8-11' memory='512000' unit='KiB'/>
      <cell id='3' cpus='12-15' memory='512000' unit='KiB'/>
    </numa>
  </cpu>


2. and check qemu command line:

 -cpu Skylake-Client-IBRS,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,+smx,+est,+tm2,+xtpr,+pdcm,+dca,+osxsave,+tsc_adjust,+avx512f,+clflushopt,+avx512cd,+stibp,+pdpe1gb

3. upgrade libvirt and qemu to 7.5:

4. recheck guest status

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     vm1                            shut off
 -     vm2                            shut off

5. check log and libvirtd shut down the vm:

2018-01-10 06:58:51.369+0000: 21017: error : virCPUTranslate:911 : unsupported configuration: CPU model Skylake-Server is not supported by hypervisor
...
2018-01-10 06:58:51.369+0000: 21017: debug : qemuProcessStop:6337 : Shutting down vm=0x7f8b942d7e30 name=vm1 id=1 pid=20765, reason=crashed, asyncJob=none, flags=0x0


Actual results:

guest shut down after upgrade

Expected results:

guest still running

Additional info:

Comment 4 Jiri Denemark 2018-01-11 09:00:08 UTC
The problem is in the fallback attribute:

  <cpu mode='host-model' check='partial'>
    <model fallback='forbid'/>
  </cpu>

when libvirtd reconnects to a domain with such CPU configuration started by old libvirt, the host-model CPU gets replaced with a custom one (the one found in host capabilities), but the fallback attribute remains 'forbid'. If libvirtd detects the host CPU as a model which is too new to be supported by the already running QEMU, we need to translate it to a supported model. But this is impossible if fallback == 'forbid'. So the translation fails, reconnecting to the domains fails, and the domain gets killed by libvirtd.

We need to reset the fallback attribute to 'allow' when replacing host-model with the CPU model from host capabilities as such CPU is not (by design) tailored to any specific QEMU binary and it is expected to be translated when being passed to QEMU.

Comment 5 Jiri Denemark 2018-01-12 10:23:11 UTC
This is now fixed upstream by

commit 237f045d9a9d84a52e645b490d14ad0b66e5b8ed
Refs: v3.10.0-182-g237f045d9a
Author:     Jiri Denemark <jdenemar>
AuthorDate: Wed Jan 10 15:56:21 2018 +0100
Commit:     Jiri Denemark <jdenemar>
CommitDate: Fri Jan 12 10:45:31 2018 +0100

    qemu: Ignore fallback CPU attribute on reconnect

    When reconnecting to a running domain with host-model CPU started by old
    libvirt which did not store the actual CPU in the status XML, we need to
    ignore the fallback attribute to make sure we can translate the detected
    host CPU model to a model which is supported by the running QEMU.

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

    Signed-off-by: Jiri Denemark <jdenemar>
    Reviewed-by: Pavel Hrdina <phrdina>

Comment 8 Luyao Huang 2018-01-22 08:42:55 UTC
Verify this bug on libvirt-3.9.0-8.el7.x86_64:

1. guest xml on 7.3:

  <cpu mode='host-model'>
    <model fallback='forbid'/>
    <numa>
      <cell id='0' cpus='0-1' memory='512000' unit='KiB'/>
      <cell id='1' cpus='2-3' memory='512000' unit='KiB'/>
    </numa>
  </cpu>

2. start guest:

# virsh start vm1
Domain vm1 started

3. update libvirt and qemu to 7.5:

4. check guest status:

# virsh list
 Id    Name                           State
----------------------------------------------------
 1     vm1                            running

5. check guest xml

# virsh dumpxml vm1

  <cpu mode='custom' match='exact' check='full'>
    <model fallback='allow'>Skylake-Client-IBRS</model>
    <vendor>Intel</vendor>

Comment 12 errata-xmlrpc 2018-04-10 11:04:21 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/RHEA-2018:0704