Commit Graph

341 Commits

Author SHA1 Message Date
Kothapally Madhu Pavan
9cdf3a1c06 Adding POWER9 cpu model to cpu_map.xml
As POWER9 model is not available in cpu_map.xml virsh capabilities
donot display the cpu model and vendor details. This patch
provides those details
2017-05-09 15:52:22 +02:00
Jiri Denemark
bf1a881715 cpu: Introduce virCPUGetHostIsSupported
Sometimes we want to call virCPUGetHost only when it is implemented for
a given architecture to avoid logging expected and possibly misleading
errors. The new virCPUGetHostIsSupported API may be used to guard such
calls to virCPUGetHost.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-19 16:36:38 +02:00
Jiri Denemark
232d87c7dd cpu: Drop feature filtering from virCPUUpdate
Because of the changes done in the previous commit, @host is already a
migratable CPU and there's no need to do any additional filtering.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-19 16:36:38 +02:00
Jiri Denemark
8a1c7ed6d5 Revert "cpu: Drop feature filtering from virCPUUpdate"
This reverts commit 5f96b3feb6 which was
pushed accidentally.
2017-04-07 13:19:47 +02:00
Jiri Denemark
5f96b3feb6 cpu: Drop feature filtering from virCPUUpdate
Because of the changes done in the previous commit, @host is already a
migratable CPU and there's no need to do any additional filtering.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-07 10:12:24 +02:00
Jiri Denemark
05e91c79f1 cpu: Introduce virCPUCopyMigratable
This new internal API makes a copy of virCPUDef while removing all
features which would block migration. It uses cpu_map.xml as a database
of such features, which should only be used as a fallback when we cannot
get the data from a hypervisor. The main goal of this API is to decouple
this filtering from virCPUUpdate so that the hypervisor driver can
filter the features according to the hypervisor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-07 10:12:24 +02:00
Jiri Denemark
c117ecec91 cpu: Do not pass virConnectBaselineCPUFlags to cpuBaseline
The public API flags are handled by the cpuBaselineXML wrapper. The
internal cpuBaseline API only needs to know whether it is supposed to
drop non-migratable features.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-27 16:29:27 +02:00
Jiri Denemark
d8b3dd16cb cpu: Move feature expansion out of cpuBaseline
cpuBaseline is responsible for computing a baseline CPU while feature
expansion is done by virCPUExpandFeatures. The cpuBaselineXML wrapper
(used by hypervisor drivers to implement virConnectBaselineCPU API)
calls cpuBaseline followed by virCPUExpandFeatures if requested by
VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES flag.

The features in the three changed test files had to be sorted using
"sort -k 3" because virCPUExpandFeatures returns a sorted list of
features.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-27 16:29:27 +02:00
Jiri Denemark
86e2df6e71 cpu: Drop unused flags from cpuArchDecode
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-27 16:29:27 +02:00
Jiri Denemark
0aa9383f3c cpu: Introduce virCPUExpandFeatures
Having to use cpuBaseline with VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES
flag to expand CPU features is strange. Not to mention that cpuBaseline
can only expand host CPU definitions (i.e., it completely ignores
feature policies). The new virCPUExpandFeatures API is designed to work
with both host and guest CPU definitions.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-27 16:29:27 +02:00
Martin Kletzander
26ae4e482a Remove src/nodeinfo
There is no "node driver" as there was before, drivers have to do
their own ACL checking anyway, so they all specify their functions and
nodeinfo is basically just extending conf/capablities.  Hence moving
the code to src/conf/ is the right way to go.

Also that way we can de-duplicate some code that is in virsysfs and/or
virhostcpu that got duplicated during the virhostcpu.c split.  And
Some cleanup is done throughout the changes, like adding the vir*
prefix etc.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
86d4a558d8 cpu: Don't use prefixes for no reason
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Martin Kletzander
272d78a5ef Introduce virCPUProbeHost
Both QEMU and bhyve are using the same function for setting up the CPU
in virCapabilities, so de-duplicate it, save code and time, and help
other drivers adopt it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
John Ferlan
0b785be4ca cpu: Remove NONNULL(1) for cpuBaseline
Since the code checks and handles a NULL 'cpus' anyway, so no need
for the NONNULL.
2017-03-22 13:50:00 -04:00
Jiri Denemark
77ca2f6d8f qemu: Enforce guest CPU specification
When guest CPU definition uses VIR_CPU_CHECK_FULL checks, we need to
make sure QEMU does not add or remove any features.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-17 11:50:48 +01:00
Jiri Denemark
def9401acb qemu: Update CPU definition according to QEMU
When starting a domain with custom guest CPU specification QEMU may add
or remove some CPU features. There are several reasons for this, e.g.,
QEMU/KVM does not support some requested features or the definition of
the requested CPU model in libvirt's cpu_map.xml differs from the one
QEMU is using. We can't really avoid this because CPU models are allowed
to change with machine types and libvirt doesn't know (and probably
doesn't even want to know) about such changes.

Thus when we want to make sure guest ABI doesn't change when a domain
gets migrated to another host, we need to update our live CPU definition
according to the CPU QEMU created. Once updated, we will change CPU
checking to VIR_CPU_CHECK_FULL to make sure the virtual CPU created
after migration exactly matches the one on the source.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-17 11:50:48 +01:00
Jiri Denemark
79a78c13ec cpu: Add list of allowed CPU models to virCPUGetHost
When creating host CPU definition usable with a given emulator, the CPU
should not be defined using an unsupported CPU model. The new @models
and @nmodels parameters can be used to limit CPU models which can be
used in the result.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-13 23:49:57 +01:00
Jiri Denemark
5677b9b336 cpu: Add virCPUType parameter to virCPUGetHost
The parameter can be used to request either VIR_CPU_TYPE_HOST (which has
been assumed so far) or VIR_CPU_TYPE_GUEST definition.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-13 23:49:57 +01:00
Jiri Denemark
23a3f5f50c cpu: Replace cpuNodeData with virCPUGetHost
cpuNodeData has always been followed by cpuDecode as no hypervisor
driver is really interested in raw CPUID data for a host CPU. Let's
create a new CPU driver API which returns virCPUDefPtr directly.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-13 23:49:57 +01:00
Philipp Hahn
d7dcea6f60 doc: fix writing of QEMU
QEMU should be written all upper or all lower case.
2017-03-08 17:33:07 +01:00
Jiri Denemark
d60012b4e7 cpu_x86: Disable TSX on broken models
All Intel Haswell processors (except Xeon E7 v3 with stepping >= 4) have
TSX disabled by microcode update. As not all CPUs are guaranteed to be
patched with microcode updates we need to explicitly disable TSX on
affected CPUs to avoid its accidental usage.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-03 19:57:57 +01:00
Jiri Denemark
14aeba2dfd cpu_x86: Introduce virCPUx86DataAddFeature
The API is useful for creating virCPUData in a hypervisor driver from
data we got by querying the hypervisor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Jiri Denemark
8da3ca8419 cpu_x86: Introduce virCPUx86DataSetVendor
The API is useful for creating virCPUData in a hypervisor driver from
data we got by querying the hypervisor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Jiri Denemark
f358a75ab3 cpu_x86: Introduce virCPUx86DataSetSignature
The API is useful for creating virCPUData in a hypervisor driver from
data we got by querying the hypervisor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Jiri Denemark
d3f831a97a cpu_x86: Make virCPUx86DataAddCPUID work with virCPUDataPtr
The CPU driver provides APIs to create and free virCPUDataPtr. Thus all
APIs exported from the driver should work with that rather than
requiring the caller to pass a pointer to an internal part of the
structure.

In other words

    virCPUx86DataAddCPUID(cpudata, &cpuid)

is much better than the original

    virCPUx86DataAddCPUID(&cpudata->data.x86, &cpuid)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Jiri Denemark
f6d55a5f42 cpu: Rework cpuDataFree
The new API is called virCPUDataFree. Individual CPU drivers are no
longer required to implement their own freeing function unless they need
to free architecture specific data from virCPUData.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Jiri Denemark
5acdd4a6b4 cpu_x86: Make virCPUx86DataClear static
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Jiri Denemark
035d81b10a cpu_x86: Drop virCPUx86MakeData and use virCPUDataNew
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Jiri Denemark
82ddd0b155 cpu: Use virCPUData.arch in cpuDecode
virCPUDef.arch is not required to be filled in for guest CPU
definitions. It doesn't make sense to artificially mandate it to be set
when cpuDecode is called especially when virCPUData.arch passed to
cpuDecode already contains the architecture.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-22 12:09:00 +01:00
Jiri Denemark
4cd9545d89 cpu: Introduce virCPUDataNew
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-22 12:09:00 +01:00
Maxim Nestratov
c3ee75e5aa cpu: fix typo: rename __kvm_hv_spinlock to __kvm_hv_spinlocks
Strings associated with virDomainHyperv values in domain_conf.c are used to
construct HyperV CPU features names to be compared with names defined in
cpu_x86_data.h and the names for HyperV "spinlocks" feature don't match.
This leads to a misleading warning:
"host doesn't support hyperv 'spinlocks' feature" even when it's supported.
Let's fix it and rename along with it VIR_CPU_x86_KVM_HV_SPINLOCK to
VIR_CPU_x86_KVM_HV_SPINLOCKS.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2017-02-09 13:52:16 +01:00
Jiri Denemark
b97839b835 cpu_x86: Fix memory leak in virCPUx86Translate
virCPUDefStealModel is called with keepVendor == true which means the
cpu structure will keep its original vendor/vendor_id values. Thus it
makes no sense to copy them to the translated definition as they won't
be used there anyway. Except that the translated->vendor pointer might
get lost in x86Decode.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-09 11:48:10 +01:00
Jason J. Herne
8f77821522 s390-cpu: Remove nodeData and decode
On s390, the host's features are heavily influenced by not only the host
hardware but also by hardware microcode level, host OS version, qemu
version and kvm version. In this environment it does not make sense to
attempt to report exact host details.

Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Acked-by: Jiri Denemark <jdenemar@redhat.com>
2017-01-06 12:24:56 +01:00
Jason J. Herne
79d72011ee s390: Cpu driver support for update and compare
Implement compare for s390. Required to test the guest against the host for
guest cpu model runnability checking. We always return IDENTICAL to bypass
Libvirt's checking. s390 will rely on Qemu to perform the runnability checking.

Implement update for s390. required to support use of cpu "host-model" mode.

Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Acked-by: Jiri Denemark <jdenemar@redhat.com>
2017-01-06 12:24:56 +01:00
Pavel Hrdina
a96a256083 configure: remove check for CPUID
This check is not required because all i386 and x86_64 cpus have the
cpuid instruction.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-12-07 16:21:31 +01:00
Lin Ma
c80e6b96e5 cpu: Add support for pku and ospke Intel features for Memory Protection Keys
qemu commit: f74eefe0
https://lwn.net/Articles/667156/

Signed-off-by: Lin Ma <lma@suse.com>
2016-12-05 22:18:28 +01:00
Lin Ma
2922cd9bbc cpu: Add support for more AVX512 Intel features
These features are included:
AVX512DQ, AVX512IFMA, AVX512BW, AVX512VL, AVX512VBMI, AVX512_4VNNIW and
AVX512_4FMAPS.

qemu commits: cc728d14 and 95ea69fb

Signed-off-by: Lin Ma <lma@suse.com>
2016-12-05 13:38:17 +01:00
Jiri Denemark
4d8d7c02d7 cpu: Add alternative feature spellings to CPU map
We can't change feature names for compatibility reasons even if they
contain typos or other software uses different names for the same
features. By adding alternative spellings in our CPU map we at least
allow anyone to grep for them and find the correct libvirt's name.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-30 14:19:40 +01:00
Jiri Denemark
29cabba3d7 cpu: Remove useless comments from CPU map
They didn't really help anything.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-30 14:19:40 +01:00
Michal Privoznik
c2a5a4e7ea virstring: Unify string list function names
We have couple of functions that operate over NULL terminated
lits of strings. However, our naming sucks:

virStringJoin
virStringFreeList
virStringFreeListCount
virStringArrayHasString
virStringGetFirstWithPrefix

We can do better:

virStringListJoin
virStringListFree
virStringListFreeCount
virStringListHasString
virStringListGetFirstWithPrefix

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-11-25 13:54:05 +01:00
Jiri Denemark
03fa904c0c cpu: Drop cpuGuestData
The API is not used anywhere in the code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:16 +01:00
Jiri Denemark
98b7c37d37 cpu: Avoid adding <vendor> to custom CPUs
Guest CPU definitions with mode='custom' and missing <vendor> are
expected to run on a host CPU from any vendor as long as the required
CPU model can be used as a guest CPU on the host. But even though no CPU
vendor was explicitly requested we would sometimes force it due to a bug
in virCPUUpdate and virCPUTranslate.

The bug would effectively forbid cross vendor migrations even if they
were previously working just fine.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:16 +01:00
Jiri Denemark
d73422c186 cpu: Introduce virCPUConvertLegacy API
PPC driver needs to convert POWERx_v* legacy CPU model names into POWERx
to maintain backward compatibility with existing domains. This patch
adds a new step into the guest CPU configuration work flow which CPU
drivers can use to convert legacy CPU definitions.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:16 +01:00
Jiri Denemark
2a2ce08a6d cpu: Make models array in virCPUTranslate constant
The API doesn't change the array so let's make it constant.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:16 +01:00
Jiri Denemark
53a5986ad6 cpu: Rename cpuDataFormat
The new name is virCPUDataFormat.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:15 +01:00
Jiri Denemark
be57e68954 cpu: Rename cpuDataParse
The new name is virCPUDataParse.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:15 +01:00
Jiri Denemark
938ec1620a cpu: Rename and document cpuModelIsAllowed
The new name is virCPUModelIsAllowed.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:15 +01:00
Jiri Denemark
b7011dfe44 cpu: Rename cpuGetModels
The new name is virCPUGetModels.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:15 +01:00
Jiri Denemark
c944a63461 Move CMT feature filtering to QEMU driver
It really doesn't belong to the generic CPU driver.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:09 +02:00
Jiri Denemark
7f127ded65 cpu: Rework cpuCompare* APIs
Both cpuCompare* APIs are renamed to virCPUCompare*. And they should now
work for any guest CPU definition, i.e., even for host-passthrough
(trivial) and host-model CPUs. The implementation in x86 driver is
enhanced to provide a hint about -noTSX Broadwell and Haswell models
when appropriate.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:09 +02:00