Commit Graph

6703 Commits

Author SHA1 Message Date
Peter Krempa
715b5a9a08 tests: qemucapabilities: Add test data for qemu-6.0 release cycle
Add the capabilities test data for the next qemu development cycle so
that we stay up to date.

Based on v5.2.0-1374-g9cd69f1a27

Notable changes detected by libvirt are the new machine types and
'intel-pt-lip', 'avx512-fp16', 'kvm-msi-ext-dest-id' cpu features
reported by qemu.

Other qemu changes not detected by libvirt include removal of the
'change' command, addition of 'sev-inject-launch-secret', 'yank',
'query-yank' commands and other device properties.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-28 10:51:30 +01:00
Peter Krempa
ab82d41f41 tests: storage: Replace index testing in testStorageLookup
Test the actual index in the returned virStorageSource rather than the
parsed one. Some tests need to be adapted as they were on failed lookup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-01-27 07:49:58 +01:00
Peter Krempa
8fd72501c8 virStorageSourceChainLookup: Handle names like 'vda[4]' internally
All callers of this function called virStorageFileParseChainIndex
before. Internalize the logic of that function to prevent multiple calls
and passing around unnecessary temporary variables.

This is achieved by calling virStorageFileParseBackingStoreStr and using
it to fill the values internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-01-27 07:49:57 +01:00
Peter Krempa
49c89fa70e test: storage: Remove double testing in testStorageLookup
The function attempts two calls to virStorageSourceChainLookup to see
whether the function handles NULL correctly. This isn't very useful and
additionally upcoming patch will remove the 'idx' parameter thus the
test becomes obsolete. Remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-01-27 07:49:57 +01:00
Jiri Denemark
4901314d0d cpu_map: Remove intel-pt from x86 CPU models
As explained in QEMU commit 4c257911dcc7c4189768e9651755c849ce9db4e8
intel-pt features should never be included in the CPU models as it was
not supported by KVM back then and even once it started to be supported,
users have to enable it by passing pt_mode=1 parameter to kvm_intel
module. The Icelake-* CPU models with intel-pt included were added to
QEMU 3.1.0 and removed right in the following 4.0.0 release (and even in
3.1.1 maintenance release).

In libvirt 6.10.0 I introduced 'removed' attribute for features included
in our CPU model definitions which we can use to drop intel-pt from
Icelake-* CPU models. Back then I explained we can safely do so only for
features which could never be enabled, which is not the case of intel-pt.

Theoretically, it could be possible to create an environment in which
QEMU would enable intel-pt without asking for it explicitly: it would
need to use a new enough kernel (not available at the time of QEMU
3.1.0) and pt_mode KVM parameter in combination with QEMU 3.1.0 running
a domain with q35 machine type and all that on a CPU which didn't really
exist at that time.

Migrating such domain to a host with newer SW stack including libvirt
with this patch applied would result in incompatible guest ABI (the
virtual CPU would lose intel-pt). However, QEMU changed its CPU models
unconditionally and thus migration would not work even without this
patch. That said, it is safe to follow QEMU and remove the feature from
Icelake-* CPU models in our cpu_map.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-01-26 15:44:50 +01:00
Pavel Hrdina
836e0a960b storage_source: use virStorageSource prefix for all functions
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-22 11:10:27 +01:00
Pavel Hrdina
01f7ade912 util: extract virStorageFile code into storage_source
Up until now we had a runtime code and XML related code in the same
source file inside util directory.

This patch takes the runtime part and extracts it into the new
storage_file directory.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-22 11:10:27 +01:00
Jiri Denemark
36b47ffed9 meson: Fix build with -Dtest_coverage=true
As can be seen in commit 8a62a1592a (from
autoconf era), the coverage flags have to be used also when linking
objects. However, this was not reflected when we switched to meson.

Without this patch linking fails with undefined references to various
__gcov_* symbols.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-01-19 16:25:50 +01:00
Michal Privoznik
6cf2ce8e8b qemu: Build command line for virtio-pmem
Now we have everything prepared for generating the command line.
The device alias prefix was chosen to be 'virtiopmem'.

Since virtio-pmem-pci device goes onto PCI bus generating device
alias must have been changed slightly because
qemuAssignDeviceMemoryAlias() might have used DIMM slot number to
generate the alias. This obviously won't work and thus the "old"
way (which includes qemuDomainDeviceAliasIndex()) must be used.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1735375
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-01-18 11:53:49 +01:00
Michal Privoznik
173733b7a8 conf: Introduce virtio-pmem <memory/> model
The virtio-pmem is a virtio variant of NVDIMM and just like
NVDIMM virtio-pmem also allows accessing host pages bypassing
guest page cache. The difference is that if a regular file is
used to back guest's NVDIMM (model='nvdimm') the persistence of
guest writes might not be guaranteed while with virtio-pmem it
is.

To express this new model at domain XML level, I've chosen the
following:

  <memory model='virtio-pmem' access='shared'>
    <source>
      <path>/tmp/virtio_pmem</path>
    </source>
    <target>
      <size unit='KiB'>524288</size>
    </target>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
  </memory>

Another difference between NVDIMM and virtio-pmem is that while
the former supports NUMA node locality the latter doesn't. And
also, the latter goes onto PCI bus and not into a DIMM module.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-01-18 11:53:33 +01:00
Michal Privoznik
f06c1d908f qemu_capabilities: Introduce QEMU_CAPS_DEVICE_VIRTIO_PMEM_PCI
This commit introduces a new capability that reflects virtio-pmem-pci
device support in qemu:

  QEMU_CAPS_DEVICE_VIRTIO_PMEM_PCI, /* -device virtio-pmem-pci */

The virtio-pmem-pci device was introduced in QEMU 4.1.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2021-01-18 11:53:31 +01:00
Peter Krempa
964650ed2a conf: disk: Parse and format <metadata_cache> also for <mirror>
Commit 154df5840d added support for <metadata_cache> as property of a
<disk>. Since the same parser is used to parse the XML used with
virDomainBlockCopy it starts the copy job with the appropriate cache
configured, but the <mirror> doesn't show this configuration nor it's
preserved if libvirtd is restarted during the mirror.

Add parsing, formatting and tests for <metadata_cache> for a <mirror>.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-14 18:28:47 +01:00
Tim Wiederhake
10b5e789c5 cpu-data: Pretend to always run on logical processor #0
The output of cpuid depends on the logical processor id the process
runs on, as reflected by the "local apic id" present in cpuid leaves
(eax=1,ebx=0), (eax=11,ebx=0), and (eax=11,ebx=1). This produces
arbitrary changes in the output files that complicate comparisons.

This patch masks the occurences of the local apic id with 0x00, so
that two consecutive runs of "./cpu-data.py gather" produce identical
results.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-08 18:07:00 +01:00
Peter Krempa
dc837a412f qemu: Implement '<metadata_cache><max_size>' control for qcow2
qemu's qcow2 driver allows control of the metadata cache of qcow2 driver
by the 'cache-size' property. Wire it up to the recently introduced
elements.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-08 15:27:44 +01:00
Peter Krempa
06380cb587 conf: snapshot: Add support for <metadata_cache>
Similarly to the domain config code it may be beneficial to control the
cache size of images introduced as snapshots into the backing chain.
Wire up handling of the 'metadata_cache' element.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-08 15:27:00 +01:00
Peter Krempa
154df5840d conf: Introduce <metadata_cache> subelement of <disk><driver>
In certain specific cases it might be beneficial to be able to control
the metadata caching of storage image format drivers of a hypervisor.

Introduce XML machinery to set the maximum size of the metadata cache
which will be used by qemu's qcow2 driver.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-08 15:27:00 +01:00
Ryan Gahagan
08a5dc59c3 tests: Add tests for NFS disk protocol
Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-08 15:11:15 +01:00
Ryan Gahagan
0f1f3f1228 util: virstoragefile: Add 'json:' pseudo-protocol parser for 'nfs' protocol
Enable parsing of backing store strings containing the native 'nfs'
protocol specification.

Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-08 15:09:26 +01:00
Jiri Denemark
51d1a2cacf cpu-gather: Rename the script as cpu-data.py
It is now doing way more than gathering the CPU data from a host as the
other scripts were merged in it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-08 11:00:45 +01:00
Jiri Denemark
07b7fd6a29 cpu-gather: Remove redundant "processor" from CPU data file names
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-08 11:00:45 +01:00
Peter Krempa
9aa1a1ea77 schema: secret: Relax requirements for usage name
There's plenty of existing documentation [1] which shows as example a
name which contains a space and a dot ('client.admin secret') as ceph
usage name.

Use a more relaxed type in the RNG schema since the usage name is
actually just a string used to look up the secret.

[1]:
https://docs.ceph.com/en/latest/rbd/libvirt/#configuring-the-vm
https://documentation.suse.com/ses/6/html/ses-all/cha-ceph-libvirt.html#ceph-libvirt-cfg-vm
Libvirt docs were correct though:
https://libvirt.org/formatsecret.html#CephUsageType

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-01-08 09:18:21 +01:00
Peter Krempa
3580dfdfd0 testCompareXMLToArgvValidateSchema: Populate autoNodeset
We create a new 'vm' so we must also fake the nodeset.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:26 +01:00
Peter Krempa
b908f4566e tests: qemuxml2argv: Don't check whether -netdev was QAPIfied repeatedly
Check once before looping through the args.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:26 +01:00
Peter Krempa
812b0e9122 testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities: refactor cleanup
Use automatic memory freeing to remove the 'cleanup:' label and 'ret'
variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:25 +01:00
Peter Krempa
d430b5ab31 qemuMonitorSetMigrationCapabilities: Take double pointer for @caps
This allows simplification of the callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-08 09:17:25 +01:00
Tim Wiederhake
f0a5cf4b8a cpu_map: Define and enable Snowridge model
Due to missing pdpe1gb support in the host CPU data, the CPU is still
incorrectly detected as Westmere-IBRS for host capabilities because we
don't have the option to disable features included in the base model
there.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 23:23:41 +01:00
Tim Wiederhake
13db542cf3 cpu_map: Add support for split-lock-detect CPU feature
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 23:23:31 +01:00
Tim Wiederhake
e06dd56032 cpu_map: Add support for core-capability CPU feature
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 23:23:04 +01:00
Tim Wiederhake
8c5c660b99 cpu_map: Add support for fsrm CPU feature
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 23:22:49 +01:00
Tim Wiederhake
59a585fdb0 cputestdata: Add test data for Snowridge
It's obvious the CPU model detection provides strange results, which
will be fixed by adding a new Snowridge CPU model few patches later.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 23:20:03 +01:00
Tim Wiederhake
a42adc2714 cpu-gather: Merge cpu-cpuid.py
Old usage:
  cpu-cpuid.py diff FILE...
New usage:
  cpu-gather.py diff FILE...

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 18:13:22 +01:00
Tim Wiederhake
bd05de35ef cpu-gather: Factor out call to cpu-cpuid.py
This is a preparatory step to merge cpu-cpuid.py.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 18:11:12 +01:00
Tim Wiederhake
ba05774f57 cpu-gather: Use actions instead of flags for action argument
This allows for the functionality of cpu-cpuid.py script to be
integrated more naturally in a later patch.

Changes the way this script should be called:
  cpu-gather.py                   -> cpu-gather.py
  cpu-gather.py --gather          -> cpu-gather.py gather
  cpu-gather.py --parse           -> cpu-gather.py parse
  cpu-gather.py --gather --parse  -> cpu-gather.py full

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 18:11:07 +01:00
Tim Wiederhake
d90738bacc cpu-cpuid: Deduplicate register list
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 18:11:01 +01:00
Tim Wiederhake
21d097c4e1 cpu-cpuid: Merge checkFeature functions
Prepare to deduplicate the list of relevant registers for cpuid and
msr information.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 18:10:56 +01:00
Tim Wiederhake
41460d4c15 cpu-cpuid: Merge addFeature functions
Prepare to deduplicate the list of relevant registers for cpuid and
msr information.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 18:10:50 +01:00
Tim Wiederhake
5868cfc490 cpu-cpuid: Remove xmltodict usage in parseCPU
'xmltodict' is a Python module that is not installed by default.
Replace it, so the dependencies of cpu-gather.py do not change
when both scripts are merged.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 18:10:44 +01:00
Tim Wiederhake
dc6e527b2d cpu-cpuid: Remove xmltodict usage in parseMap
'xmltodict' is a Python module that is not installed by default.
Replace it, so the dependencies of cpu-gather.py do not change
when both scripts are merged.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 18:10:39 +01:00
Tim Wiederhake
b53eb0db35 cpu-cpuid: Use argparse to parse arguments
Using 'argparse' for argument handling simplifies merging this script
with cpu-gather.py in a later patch.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-01-07 18:09:38 +01:00
Pavel Hrdina
ba9b419910 virstoragefile: remove unused virStorageFileChainCheckBroken
The last usage outside of tests was removed by commit
<780f8c94ca8b3dee7eb59c1bfbc32f672f965df8>.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-01-06 13:15:17 +01:00
Eiichi Tsukata
cc6c49f6cd conf: Add support for keeping TPM emulator state
Currently, swtpm TPM state file is removed when a transient domain is
powered off or undefined. When we store TPM state on a shared storage
such as NFS and use transient domain, TPM states should be kept as it is.

Add per-TPM emulator option `persistent_sate` for keeping TPM state.
This option only works for the emulator type backend and looks as follows:

  <tpm model='tpm-tis'>
    <backend type='emulator' persistent_state='yes'/>
  </tpm>

Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-06 11:44:12 +01:00
Peter Krempa
781bc9201b virsh-domain: Add quotes around '%s' formatting domain name
Domain name can contain spaces in which case it's not immediately clear
from virsh messages where the boundary of the name is. Enclose all %s
formatters in apostrophes as delimiters.

Done via the following vim regex:

 %s/omain %s/omain '%s'/g

This patch changes:

 $ virsh undefine --snapshots-metadata 'OWASP Broken Web Apps VM v1.2'
 Domain OWASP Broken Web Apps VM v1.2 has been undefined

to:

 $ virsh undefine --snapshots-metadata 'OWASP Broken Web Apps VM v1.2'
 Domain 'OWASP Broken Web Apps VM v1.2' has been undefined

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-01-06 09:25:07 +01:00
Martin Kletzander
3b364c6509 vmx: Treat missing cdrom-image as empty drive
This is perfectly valid in VMWare and the VM just boots with an empty drive.  We
used to just skip the whole drive before, but since we changed how we parse
empty cdrom drives this results in an error.  Make it behave more closer to
VMWare.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2021-01-06 02:05:10 +01:00
Martin Kletzander
6c001a37e4 tests: Test vmx files with missing images
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2021-01-06 02:05:10 +01:00
Martin Kletzander
eb07c7e563 vmx: Allow missing cdrom image file in virVMXParseFileName
This will be used later.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2021-01-06 02:05:10 +01:00
Martin Kletzander
152be66eaf tests: Allow testing for parse failures in vmx2xmltest
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2021-01-06 02:05:10 +01:00
Martin Kletzander
c1286d50e2 vmx: Make virVMXParseFileName return an integer
And return the actual extracted value in a parameter.  This way we can later
return success even without any extracted value.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2021-01-06 02:05:10 +01:00
Martin Kletzander
49d0e0c3e6 tests: Use g_autofree in testParseVMXFileName
There's only one variable to clean-up, others are just tokens inside that
variable, but it is nicer anyway.  Positive returns have not been converted
because the function will change soon and it would not make much sense.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2021-01-06 02:05:10 +01:00
Michal Privoznik
bf14a9be1e qemu: Don't prealloc mem for real NVDIMMs
Currently, we configure QEMU to prealloc memory almost by
default. Well, by default for NVDIMMs, hugepages and if user
asked us to (via memoryBacking <allocation mode="immediate"/>).

However, when guest's NVDIMM is backed by real life NVDIMM this
approach is not the best. In this case users should put <pmem/>
into the <memory/> device <source/>, like this:

  <memory model='nvdimm' access='shared'>
    <source>
      <path>/dev/pmem0</path>
      <pmem/>
    </source>
  </memory>

Instructing QEMU to do prealloc in this case means that each
page of the NVDIMM is "touched" (the first byte is read and
written back - see QEMU commit v2.9.0-rc1~26^2) which cripples
device wear.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1894053
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-05 13:19:22 +01:00
Michal Privoznik
7f93905e45 nss: handle leases with infinite expiry time
After v6.3.0-rc1~64 a lease can have infinite expiry time. This
means that the expiration time will appear as a value of zero.
Do the expiration check only if the expiration time is not zero.

Fixes: 97a0aa2467
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-04 15:33:31 +01:00