[libvirt] [PATCH 00/22] qemu: Store default CPU in domain XML

Jiri Denemark posted 22 patches 4 years, 6 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/cover.1570111135.git.jdenemar@redhat.com
There is a newer version of this series
src/conf/cpu_conf.h                           |    1 +
src/conf/domain_capabilities.c                |   86 +-
src/conf/domain_capabilities.h                |    8 -
src/libvirt_private.syms                      |    3 +-
src/qemu/qemu_capabilities.c                  |  324 +--
src/qemu/qemu_capabilities.h                  |    8 +-
src/qemu/qemu_domain.c                        |   79 +-
src/qemu/qemu_driver.c                        |    4 +-
src/qemu/qemu_monitor.c                       |   74 +-
src/qemu/qemu_monitor.h                       |   18 +-
src/qemu/qemu_monitor_json.c                  |   81 +-
src/qemu/qemu_monitor_json.h                  |    2 +-
src/qemu/qemu_process.c                       |    7 +-
tests/cputest.c                               |    7 +-
.../caps_2.10.0.aarch64.xml                   |  126 +-
.../caps_2.10.0.ppc64.xml                     | 1734 ++++++++--------
.../caps_2.10.0.s390x.xml                     |  264 +--
.../caps_2.10.0.x86_64.xml                    |  132 +-
.../caps_2.11.0.s390x.xml                     |  264 +--
.../caps_2.11.0.x86_64.xml                    |  136 +-
.../caps_2.12.0.aarch64.xml                   |  136 +-
.../caps_2.12.0.ppc64.xml                     | 1750 ++++++++---------
.../caps_2.12.0.s390x.xml                     |  264 +--
.../caps_2.12.0.x86_64.xml                    |  180 +-
.../qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1734 ++++++++--------
.../qemucapabilitiesdata/caps_2.9.0.s390x.xml |  256 +--
.../caps_2.9.0.x86_64.xml                     |  128 +-
.../qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 1750 ++++++++---------
.../qemucapabilitiesdata/caps_3.0.0.s390x.xml |  272 +--
.../caps_3.0.0.x86_64.xml                     |  184 +-
.../qemucapabilitiesdata/caps_3.1.0.ppc64.xml | 1750 ++++++++---------
.../caps_3.1.0.x86_64.xml                     |  196 +-
.../caps_4.0.0.aarch64.xml                    |  148 +-
.../qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 1750 ++++++++---------
.../qemucapabilitiesdata/caps_4.0.0.s390x.xml |  284 +--
.../caps_4.0.0.x86_64.xml                     |  196 +-
.../caps_4.1.0.x86_64.xml                     |  400 ++--
.../caps_4.2.0.x86_64.xml                     |  492 ++---
tests/qemumonitorjsontest.c                   |   38 +-
.../disk-cache.x86_64-latest.args             |    1 +
.../disk-cdrom-network.x86_64-latest.args     |    1 +
.../disk-cdrom-tray.x86_64-latest.args        |    1 +
.../disk-copy_on_read.x86_64-latest.args      |    1 +
.../disk-detect-zeroes.x86_64-latest.args     |    1 +
.../disk-floppy-q35-2_11.x86_64-latest.args   |    1 +
.../disk-floppy-q35-2_9.x86_64-latest.args    |    1 +
.../os-firmware-bios.x86_64-latest.args       |    1 +
...os-firmware-efi-secboot.x86_64-latest.args |    1 +
.../os-firmware-efi.x86_64-latest.args        |    1 +
.../tpm-emulator-tpm2-enc.x86_64-latest.args  |    1 +
.../tpm-emulator-tpm2.x86_64-latest.args      |    1 +
.../tpm-emulator.x86_64-latest.args           |    1 +
.../tseg-explicit-size.x86_64-latest.args     |    1 +
.../vhost-vsock-auto.x86_64-latest.args       |    1 +
.../vhost-vsock.x86_64-latest.args            |    1 +
.../os-firmware-bios.x86_64-latest.xml        |    3 +
.../os-firmware-efi-secboot.x86_64-latest.xml |    3 +
.../os-firmware-efi.x86_64-latest.xml         |    3 +
.../tpm-emulator-tpm2-enc.x86_64-latest.xml   |    3 +
.../tpm-emulator-tpm2.x86_64-latest.xml       |    3 +
.../tpm-emulator.x86_64-latest.xml            |    3 +
.../tpm-passthrough-crb.x86_64-latest.xml     |    3 +
.../tpm-passthrough.x86_64-latest.xml         |    3 +
63 files changed, 7721 insertions(+), 7585 deletions(-)
[libvirt] [PATCH 00/22] qemu: Store default CPU in domain XML
Posted by Jiri Denemark 4 years, 6 months ago
When starting a domain without a CPU model specified in the domain XML,
QEMU will choose a default one. Which is fine unless the domain gets
migrated to another host because libvirt doesn't perform any CPU ABI
checks and the virtual CPU provided by QEMU on the destination host can
differ from the one on the source host.

With QEMU 4.2.0 we can probe for the default CPU model used by QEMU for
a particular machine type and store it in the domain XML. This way the
chosen CPU model is more visible to users and libvirt will make sure
the guest will see the exact same CPU after migration.

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

Jiri Denemark (22):
  conf: Use VIR_AUTO* in virDomainCapsCPUModelsAdd
  conf: Drop nameLen parameter from virDomainCapsCPUModelsAdd
  qemu: Copy CPU models in virQEMUCapsGetCPUDefinitions
  qemu: Filter models in virQEMUCapsGetCPUDefinitions
  qemu: Use virQEMUCapsGetCPUDefinitions more
  qemu: Use VIR_AUTOPTR in qemuMonitorJSONGetCPUDefinitions
  qemu: Introduce qemuMonitorCPUDefs struct
  qemu: Flatten qemuMonitorCPUDefs.cpus
  build: Export virStringListCopy internal API
  qemu: Add qemuMonitorCPUDefsCopy
  qemu: Use VIR_AUTOFREE in virQEMUCapsLoadCPUModels
  qemu: Introduce virQEMUCapsCPUDefsToModels
  qemu: Switch qemuCaps to use qemuMonitorCPUDefs
  conf: Drop unused virDomainCapsCPUModelsFilter
  conf: Drop virDomainCapsCPUModelsAddSteal
  qemu: Store typename from query-cpu-definitions in qemuCaps
  qemu: Probe for default CPU types
  qemu: Introduce virQEMUCapsGetMachineDefaultCPU
  qemu: Drop unused virQEMUCapsGetDefaultMachine
  qemu: Use VIR_AUTOUNREF in qemuDomainDefPostParse
  conf: Define VIR_AUTOPTR for virCPUDef
  qemu: Store default CPU in domain XML

 src/conf/cpu_conf.h                           |    1 +
 src/conf/domain_capabilities.c                |   86 +-
 src/conf/domain_capabilities.h                |    8 -
 src/libvirt_private.syms                      |    3 +-
 src/qemu/qemu_capabilities.c                  |  324 +--
 src/qemu/qemu_capabilities.h                  |    8 +-
 src/qemu/qemu_domain.c                        |   79 +-
 src/qemu/qemu_driver.c                        |    4 +-
 src/qemu/qemu_monitor.c                       |   74 +-
 src/qemu/qemu_monitor.h                       |   18 +-
 src/qemu/qemu_monitor_json.c                  |   81 +-
 src/qemu/qemu_monitor_json.h                  |    2 +-
 src/qemu/qemu_process.c                       |    7 +-
 tests/cputest.c                               |    7 +-
 .../caps_2.10.0.aarch64.xml                   |  126 +-
 .../caps_2.10.0.ppc64.xml                     | 1734 ++++++++--------
 .../caps_2.10.0.s390x.xml                     |  264 +--
 .../caps_2.10.0.x86_64.xml                    |  132 +-
 .../caps_2.11.0.s390x.xml                     |  264 +--
 .../caps_2.11.0.x86_64.xml                    |  136 +-
 .../caps_2.12.0.aarch64.xml                   |  136 +-
 .../caps_2.12.0.ppc64.xml                     | 1750 ++++++++---------
 .../caps_2.12.0.s390x.xml                     |  264 +--
 .../caps_2.12.0.x86_64.xml                    |  180 +-
 .../qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1734 ++++++++--------
 .../qemucapabilitiesdata/caps_2.9.0.s390x.xml |  256 +--
 .../caps_2.9.0.x86_64.xml                     |  128 +-
 .../qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 1750 ++++++++---------
 .../qemucapabilitiesdata/caps_3.0.0.s390x.xml |  272 +--
 .../caps_3.0.0.x86_64.xml                     |  184 +-
 .../qemucapabilitiesdata/caps_3.1.0.ppc64.xml | 1750 ++++++++---------
 .../caps_3.1.0.x86_64.xml                     |  196 +-
 .../caps_4.0.0.aarch64.xml                    |  148 +-
 .../qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 1750 ++++++++---------
 .../qemucapabilitiesdata/caps_4.0.0.s390x.xml |  284 +--
 .../caps_4.0.0.x86_64.xml                     |  196 +-
 .../caps_4.1.0.x86_64.xml                     |  400 ++--
 .../caps_4.2.0.x86_64.xml                     |  492 ++---
 tests/qemumonitorjsontest.c                   |   38 +-
 .../disk-cache.x86_64-latest.args             |    1 +
 .../disk-cdrom-network.x86_64-latest.args     |    1 +
 .../disk-cdrom-tray.x86_64-latest.args        |    1 +
 .../disk-copy_on_read.x86_64-latest.args      |    1 +
 .../disk-detect-zeroes.x86_64-latest.args     |    1 +
 .../disk-floppy-q35-2_11.x86_64-latest.args   |    1 +
 .../disk-floppy-q35-2_9.x86_64-latest.args    |    1 +
 .../os-firmware-bios.x86_64-latest.args       |    1 +
 ...os-firmware-efi-secboot.x86_64-latest.args |    1 +
 .../os-firmware-efi.x86_64-latest.args        |    1 +
 .../tpm-emulator-tpm2-enc.x86_64-latest.args  |    1 +
 .../tpm-emulator-tpm2.x86_64-latest.args      |    1 +
 .../tpm-emulator.x86_64-latest.args           |    1 +
 .../tseg-explicit-size.x86_64-latest.args     |    1 +
 .../vhost-vsock-auto.x86_64-latest.args       |    1 +
 .../vhost-vsock.x86_64-latest.args            |    1 +
 .../os-firmware-bios.x86_64-latest.xml        |    3 +
 .../os-firmware-efi-secboot.x86_64-latest.xml |    3 +
 .../os-firmware-efi.x86_64-latest.xml         |    3 +
 .../tpm-emulator-tpm2-enc.x86_64-latest.xml   |    3 +
 .../tpm-emulator-tpm2.x86_64-latest.xml       |    3 +
 .../tpm-emulator.x86_64-latest.xml            |    3 +
 .../tpm-passthrough-crb.x86_64-latest.xml     |    3 +
 .../tpm-passthrough.x86_64-latest.xml         |    3 +
 63 files changed, 7721 insertions(+), 7585 deletions(-)

-- 
2.23.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 00/22] qemu: Store default CPU in domain XML
Posted by Andrea Bolognani 4 years, 6 months ago
On Thu, 2019-10-03 at 16:00 +0200, Jiri Denemark wrote:
> When starting a domain without a CPU model specified in the domain XML,
> QEMU will choose a default one. Which is fine unless the domain gets
> migrated to another host because libvirt doesn't perform any CPU ABI
> checks and the virtual CPU provided by QEMU on the destination host can
> differ from the one on the source host.
> 
> With QEMU 4.2.0 we can probe for the default CPU model used by QEMU for
> a particular machine type and store it in the domain XML. This way the
> chosen CPU model is more visible to users and libvirt will make sure
> the guest will see the exact same CPU after migration.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1598151
> https://bugzilla.redhat.com/show_bug.cgi?id=1598162

Also, this is definitely a user-visible change significant enough to
be documented in the release notes, so please provide a patch that
does so :)

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 00/22] qemu: Store default CPU in domain XML
Posted by Andrea Bolognani 4 years, 6 months ago
On Thu, 2019-10-03 at 16:00 +0200, Jiri Denemark wrote:
> When starting a domain without a CPU model specified in the domain XML,
> QEMU will choose a default one. Which is fine unless the domain gets
> migrated to another host because libvirt doesn't perform any CPU ABI
> checks and the virtual CPU provided by QEMU on the destination host can
> differ from the one on the source host.
> 
> With QEMU 4.2.0 we can probe for the default CPU model used by QEMU for
> a particular machine type and store it in the domain XML. This way the
> chosen CPU model is more visible to users and libvirt will make sure
> the guest will see the exact same CPU after migration.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1598151
> https://bugzilla.redhat.com/show_bug.cgi?id=1598162

Unfortunately this will break all ppc64 guests that have been defined
without specifying a CPU model, because it will result in something
like

  <cpu mode='custom' match='exact' check='partial'>
    <model fallback='allow'>power8</model>
  </cpu>

being added to the domain XML, which in turn at runtime will cause

  error: internal error: Unknown CPU model power8

For a while, QEMU has been reporting (and accepting) CPU models for
ppc64 guests as lowercase strings, but historically they were all
uppercase and our CPU map, which the user-provided CPU model is
validated against, still contains those variants.

For the record, our documentation[1] recommends using something like

  <cpu mode='host-model'>
    <model>power8</model>
  </cpu>

to obtain a POWER8 CPU that can be safely migrated back and forth
between POWER8 and POWER9 machines, but we can't assume everyone is
following that recommendation.


[1] https://libvirt.org/formatdomain.html#elementsCPU
-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 00/22] qemu: Store default CPU in domain XML
Posted by Jiri Denemark 4 years, 6 months ago
On Mon, Oct 07, 2019 at 17:24:11 +0200, Andrea Bolognani wrote:
> On Thu, 2019-10-03 at 16:00 +0200, Jiri Denemark wrote:
> > When starting a domain without a CPU model specified in the domain XML,
> > QEMU will choose a default one. Which is fine unless the domain gets
> > migrated to another host because libvirt doesn't perform any CPU ABI
> > checks and the virtual CPU provided by QEMU on the destination host can
> > differ from the one on the source host.
> > 
> > With QEMU 4.2.0 we can probe for the default CPU model used by QEMU for
> > a particular machine type and store it in the domain XML. This way the
> > chosen CPU model is more visible to users and libvirt will make sure
> > the guest will see the exact same CPU after migration.
> > 
> > https://bugzilla.redhat.com/show_bug.cgi?id=1598151
> > https://bugzilla.redhat.com/show_bug.cgi?id=1598162
> 
> Unfortunately this will break all ppc64 guests that have been defined
> without specifying a CPU model, because it will result in something
> like
> 
>   <cpu mode='custom' match='exact' check='partial'>
>     <model fallback='allow'>power8</model>
>   </cpu>
> 
> being added to the domain XML, which in turn at runtime will cause
> 
>   error: internal error: Unknown CPU model power8

This should be fixed by an old forgotten series "Fix ppc64 CPU
configuration for QEMU 2.11+". I'll send a rebased version of that
series and once approved, I will base a v2 of this series on top.

Thanks for checking the behaviour on a different architecture.

Jirka

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