[libvirt] [PATCH v1 0/4] CPU Model Comparsion via QEMU

Daniel P. Berrangé berrange at redhat.com
Tue Apr 17 16:08:53 UTC 2018


On Tue, Apr 17, 2018 at 10:18:58AM +0200, Jiri Denemark wrote:
> On Mon, Apr 16, 2018 at 19:16:05 -0400, Collin Walling wrote:
> > [Overview]
> > 
> > This patch series implements an interface to "query-cpu-model-comparison"
> > (available QEMU ~2.8.0) via virsh cpu-compare.
> > 
> > [Using This Feature]
> > 
> > Run virsh cpu-compare (ensure you are running the virsh in your build dir) and
> > pass it an xml file describing a cpu definition. You can copy the cpu xml from
> > virsh capabilities (if you want to compare the host cpu to itself), or a cpu 
> > defined in any guest xml. Additionally, you can create a cpu xml as such (e.g.
> > for s390x):
> > 
> > <cpu>
> >     <arch>s390x</arch>
> >     <model fallback='forbid'>model_name</model>
> >     <feature policy='require|disable' name='feature_name'/>
> > </cpu>
> > 
> > NOTE: the presence of <arch> is optional and it will treat the cpu defined in 
> >       the xml as a host cpu. This will disregard all feature policies (i.e. 
> >       all features listed will behave with policy='require', even if disable 
> >       is specified).
> > 
> > NOTE: as s390x only supports feature policies 'require' and 'disable', I am
> >       uncertain how to handle the other policies when parsing CPUDef to JSON.
> > 
> > [Example Output]
> > 
> > On an s390x system running a z13.2, this is the expected output (where each file
> > describes a CPU model corresponding to the name of the file):
> > 
> >     $ virsh cpu-compare zEC12.xml
> >     Host CPU is a superset of CPU described in zEC12.xml
> > 
> >     $ virsh cpu-compare z13.2.xml
> >     CPU described in z13.2.xml is identical to host CPU
> > 
> >     $ virsh cpu-compare z14.xml
> >     CPU described in z14.xml is incompatible with host CPU
> > 
> >     $ virsh cpu-compare z14.xml --error
> >     error: Failed to compare host CPU with z14.xml
> >     error: the CPU is incompatible with host CPU
> > 
> >     $ virsh cpu-compare z12345.xml 
> >     error: Failed to compare host CPU with z12345cpu.xml
> >     error: internal error: unable to execute QEMU command 'query-cpu-model-comparison': The CPU definition 'z12345-base' is unknown.
> > 
> > [Patch Rundown]
> > 
> > The first patch copies the host CPU definition from qemuCaps to virCaps so
> > we can easily access the host CPU model and features when we handle the CPU
> > comparison in qemu_driver. Note that we take care to not clobber anything
> > already stored in the host CPU definition until we have successfully 
> > constructed a new host CPU definition.
> 
> I think this is a wrong approach. You'd be basically giving random
> answers depending on which QEMU binary is probed first. The reason for
> storing the CPU model in qemuCaps is that it is tight to a particular
> QEMU binary rather than the host itself. The model reported by one
> binary may not be usable with other binaries and this applies to any
> comparisons or other operations done with this CPU model.
> 
> In other words, we need to introduce a new set of CPU related APIs which
> will take more arguments so that the caller may specify what binary,
> virt type, and machine type they want to use. In other words, the APIs
> should support parameters similar to virConnectGetDomainCapabilities().

FYI, in addition to all this, the current 'virsh cpu-compare' command
is in fact 100% accurate in what it is reporting today and we can not
change it. The 'virsh cpu-compare' command is answering the question

   "Is this CPU model compatible with the host CPU model"

The problem is that when doing live migration, we don't care about
this question. We were asking the wrong question. We instead need
to ask

   "Is this CPU model compatible with the hypervisor CPU model"

We can't simply change the semantics of the existing API to answer
a different question, because the original question is still relevant
and useful for some usage scenarios. So yes, we must have a new API
that lets us ask the right question for live migration compat.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list