]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
2 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Wed, 23 Nov 2022 09:20:02 +0000 (10:20 +0100)]
Translated using Weblate (Swedish)

Currently translated at 50.9% (5296 of 10386 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2 years agorpc: Mark close callback (un-)register as high priority
Michal Privoznik [Wed, 23 Nov 2022 08:50:29 +0000 (09:50 +0100)]
rpc: Mark close callback (un-)register as high priority

Our RPC calls can be divided into two groups: regular and high
priority. The latter can be then processed by so called high
priority worker threads. This is our way of defeating a
'deadlock' and allowing some RPCs to be processed even when all
(regular) worker threads are stuck. For instance: if all regular
worker threads get stuck when talking to QEMU on monitor, the
virDomainDestroy() can be processed by a high priority worker
thread(s) and thus unstuck those threads.

Now, this is all fine, except if users want to use virsh
non interactively:

  virsh destroy $dom

This does a bit more - it needs to open a connection. And that
consists of multiple RPC calls: AUTH_LIST,
CONNECT_SUPPORTS_FEATURE, CONNECT_OPEN, and finally
CONNECT_REGISTER_CLOSE_CALLBACK. All of them are marked as high
priority except the last one. Therefore, virsh just sits there
with a partially open connection.

There's one requirement for high priority calls though: they can
not get stuck. Hopefully, the reason is obvious by now. And
looking into the server side implementation the
CONNECT_REGISTER_CLOSE_CALLBACK processing can't ever get stuck.
The only driver that implements the callback for public API is
Parallels (vz). And that can't block really.

And for virConnectUnregisterCloseCallback() it's the same story.

Therefore, both can be marked as high priority.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2143840
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agokbase: virtiofs: Add 'queue' setting to example
Lu Ke [Mon, 14 Nov 2022 15:00:09 +0000 (15:00 +0000)]
kbase: virtiofs: Add 'queue' setting to example
The setting is needed for the windows driver to work properly and doesn't have negative effects on other usage.
Signed-off-by: Lukas Ke nicelukas@hotmail.com
2 years agolib: Use the same style in the 'struct option'
Jiang Jiacheng [Tue, 22 Nov 2022 01:50:01 +0000 (09:50 +0800)]
lib: Use the same style in the 'struct option'

Use same style in the 'struct option' as:
    struct option opt[] = {
        { a, b },
        { a, b },
        ...
        { a, b },
    };

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoapparmor: allow getattr on usb devices
Christian Ehrhardt [Thu, 17 Nov 2022 08:35:05 +0000 (09:35 +0100)]
apparmor: allow getattr on usb devices

For the handling of usb we already allow plenty of read access,
but so far /sys/bus/usb/devices only needed read access to the directory
to enumerate the symlinks in there that point to the actual entries via
relative links to ../../../devices/.

But in more recent systemd with updated libraries a program might do
getattr calls on those symlinks. And while symlinks in apparmor usually
do not matter, as it is the effective target of an access that has to be
allowed, here the getattr calls are on the links themselves.

On USB hostdev usage that causes a set of denials like:
 apparmor="DENIED" operation="getattr" class="file"
 name="/sys/bus/usb/devices/usb1" comm="qemu-system-x86"
 requested_mask="r" denied_mask="r" ...

It is safe to read the links, therefore add a rule to allow it to
the block of rules that covers the usb related access.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Michal Privoznik <mprivozn at redhat.com>
2 years agoqemu: fix memlock without vIOMMU
Jonathon Jongsma [Thu, 17 Nov 2022 18:15:23 +0000 (12:15 -0600)]
qemu: fix memlock without vIOMMU

When there is no vIOMMU, vfio devices don't need to lock the entire guest
memory per-device, but they still need to lock the entire guest memory to
share between all vfio devices. This memory accounting is not shared
with vDPA devices, so it should be added to the memlock limit separately.

Commit 8d5704e2 added support for multiple vfio/vdpa devices but
calculated the limits incorrectly when there were both vdpa and vfio
devices and no vIOMMU. In this case, the memory lock limit was not
increased separately for the vfio devices.

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

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agoqemu: Ignore failure in post-copy migration when QEMU says completed
Jiri Denemark [Fri, 18 Nov 2022 15:19:33 +0000 (16:19 +0100)]
qemu: Ignore failure in post-copy migration when QEMU says completed

When post-copy migration is running in Finish phase we already did
everything needed and we're just waiting for all the memory to transfer
to the destination. The domain is already running on there at this
point. Once all data is transferred (QEMU sends a MIGRATION completed
event) we're done. So in this specific post-copy case the source does
not need to care about the result of the Finish call as long as QEMU
says migration completed. The Finish call to the destination daemon may
fail for reasons that do not affect QEMU, e.g., libvirt daemon was
restarted there or the libvirt connection broke.

Currently we just mark the post-copy migration as failed on the source
and keep the domain paused there. But when libvirt daemon is restarted
at this point, it will detect migration finished successfully and kill
the domain as migrated. It make sense to do this even without having to
restart the daemon.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/338
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: Always restore post-copy migration job on reconnect
Jiri Denemark [Fri, 18 Nov 2022 15:19:16 +0000 (16:19 +0100)]
qemu: Always restore post-copy migration job on reconnect

We need the restored job even in case the migration already finished
even though we will stop it just a few lines below as the functions we
call in between require an existing migration job.

This fixes a crash on reconnect when post-copy migration finished while
the daemon was not running.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agovirmockstathelpers: Load aliases for 64-bit time
Michal Privoznik [Fri, 18 Nov 2022 16:13:22 +0000 (17:13 +0100)]
virmockstathelpers: Load aliases for 64-bit time

On 32-bit arches, it's possible not only to request
-D_FILE_OFFSET_BITS=64 (which is always done with meson) but also
-D_TIME_BITS=64. With glibc, both of these affect what variant of
stat() or lstat() is called. With 64 bit time it's:
__stat64_time64() or __lstat64_time64(), respectively.

Fortunately, no other variant (__xstat(), __xstat64()) has
_time64 alternative and thus does not need similar treatment.

Similarly, musl is not affected by this.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/404
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agotests: Drop needless virrandom mock from two tests
Michal Privoznik [Mon, 21 Nov 2022 11:40:21 +0000 (12:40 +0100)]
tests: Drop needless virrandom mock from two tests

Nothing in virnettlscontexttest nor virnettlssessiontest calls
any of random number generator functions overridden
virrandommock. GnuTLS handles RNG within itself.

Therefore, there's no need to preload the mock.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemucapabilitiesdata: Update caps for qemu-7.2.0 rc1 on x86_64
Peter Krempa [Fri, 11 Nov 2022 08:45:12 +0000 (09:45 +0100)]
qemucapabilitiesdata: Update caps for qemu-7.2.0 rc1 on x86_64

Update to v7.2.0-rc1

Notable changes:
 - 'virtio-blk-vfio-pci' blockdev backend added
 - 'cryptodev-backend-lkcf' object added
 - new options/parameters for virtio-*-pci, virtio-*-device, and
   vhost-user-* devices:
    - 'queue_reset'
     - use-started
     - use-disabled-flags
 - 'dma-translation' option for 'intel-iommu' device
 - 'zpcii-disable' commandline parameter removed (not applicable on x86)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agocpu_arm: fix the compile warning of unexpected format
Jiang Jiacheng [Thu, 17 Nov 2022 02:11:03 +0000 (10:11 +0800)]
cpu_arm: fix the compile warning of unexpected format

These format are left unchanged when convert 'unsigned long' to
'unsigned long long', which caused compile warning.

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Thu, 17 Nov 2022 07:30:41 +0000 (08:30 +0100)]
Translated using Weblate (Swedish)

Currently translated at 49.8% (5177 of 10386 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Translated using Weblate (Swedish)

Currently translated at 49.6% (5157 of 10386 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2 years agoTranslated using Weblate (Korean)
김인수 [Thu, 17 Nov 2022 07:30:40 +0000 (08:30 +0100)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10386 of 10386 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: 김인수 <simmon@nplob.com>
Signed-off-by: 김인수 <simmon@nplob.com>
2 years agoAdd vms cli tool to the list of applications using libvirt
Cédric Bosdonnat [Wed, 16 Nov 2022 08:24:19 +0000 (09:24 +0100)]
Add vms cli tool to the list of applications using libvirt

Just adds a tool to the applications list. This tool helps managing
multiple VMs at once using the python binding.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
2 years agoutil: virFirewallDGetPolicies: gracefully handle older firewalld
Eric Garver [Thu, 10 Nov 2022 16:31:45 +0000 (11:31 -0500)]
util: virFirewallDGetPolicies: gracefully handle older firewalld

If the running firewalld doesn't support getPolicies() then we fallback
to the "libvirt" zone. Throwing an error log is excessive since we
gracefully fallback.

Avoids these logs:

error : virGDBusCallMethod:242 : error from service: \
GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod

Fixes: ab56f84976e0 ("util: add virFirewallDGetPolicies()")
Signed-off-by: Eric Garver <eric@garver.life>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: Declare and use autoptr for virDomainMemoryDef
Michal Privoznik [Mon, 17 Oct 2022 12:59:29 +0000 (14:59 +0200)]
conf: Declare and use autoptr for virDomainMemoryDef

Register virDomainMemoryDefFree() to do the cleanup.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agoconf: Introduce virDomainMemoryDefNew()
Michal Privoznik [Mon, 17 Oct 2022 12:55:04 +0000 (14:55 +0200)]
conf: Introduce virDomainMemoryDefNew()

This is new allocator for virDomainMemoryDef struct which also
sets some default values: @model and @targetNode.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agovmx: Rework virVMXConfigScanResultsCollector slightly
Michal Privoznik [Mon, 17 Oct 2022 10:18:40 +0000 (12:18 +0200)]
vmx: Rework virVMXConfigScanResultsCollector slightly

The idea here is that virVMXConfigScanResultsCollector() sets the
networks_max_index to the highest ethernet index seen. Well, the
struct member is signed int, we parse just seen index into uint
and then typecast to compare the two. This is not necessary,
because the maximum number of NICs a vSphere domain can have is
(<drumrolll/>): ten [1]. This will fit into signed int easily
anywhere.

1: https://configmax.esp.vmware.com/guest?vmwareproduct=vSphere&release=vSphere%208.0&categories=1-0

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agovmx: Convert virVMXConfigScanResultsCollector() to use STRCASESKIP()
Michal Privoznik [Thu, 10 Nov 2022 13:24:43 +0000 (14:24 +0100)]
vmx: Convert virVMXConfigScanResultsCollector() to use STRCASESKIP()

Now that we have STRCASESKIP() there's no need to open code it.
Convert virVMXConfigScanResultsCollector() so that it uses this
new macro.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agointernal: Introduce STRCASESKIP()
Michal Privoznik [Thu, 10 Nov 2022 11:52:56 +0000 (12:52 +0100)]
internal: Introduce STRCASESKIP()

There is so far one case where STRCASEPREFIX(a, b) && a +
strlen(b) combo is used (in virVMXConfigScanResultsCollector()),
but there will be more. Do what we do usually: introduce a macro.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agodocs: Fill missing docs on STRCASEPREFIX() and STRSKIP()
Michal Privoznik [Thu, 10 Nov 2022 11:51:41 +0000 (12:51 +0100)]
docs: Fill missing docs on STRCASEPREFIX() and STRSKIP()

We document use of our STR*() macros, but somehow missed
STRCASEPREFIX() and STRSKIP().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agocoding-style: Follow our own recommendation wrt spacing around commas
Michal Privoznik [Thu, 10 Nov 2022 12:00:16 +0000 (13:00 +0100)]
coding-style: Follow our own recommendation wrt spacing around commas

We require a space after a comma and even document this in our
coding style document. However, our own rule is broken in the
very same document when listing string comparison macros.
Separate macro arguments properly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2 years agoci: integration: Lock the Avocado version to 98.0 for now
Erik Skultety [Tue, 15 Nov 2022 16:27:41 +0000 (17:27 +0100)]
ci: integration: Lock the Avocado version to 98.0 for now

Avocado 99.0 causes the TCK test suite to fail with the nwfilter tests
(which is another Bash framework underneath). Until the culprit is
identified and fixed in Avocado, let's lock the version to 98.0 which
worked with the test suite just fine.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agodocs/manpages: add checklist of problems for SEV attestation
Daniel P. Berrangé [Fri, 7 Oct 2022 10:53:35 +0000 (11:53 +0100)]
docs/manpages: add checklist of problems for SEV attestation

Despite efforts to make the virt-qemu-sev-validate tool friendly, it is
a certainty that almost everyone who tries it will hit false negative
results, getting a failure despite the VM being trustworthy.

Diagnosing these problems is no easy matter, especially for those not
familiar with SEV/SEV-ES in general. This extra docs text attempts to
set out a checklist of items to look at to identify what went wrong.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoscripts: add systemtap script for capturing SEV-ES VMSA
Daniel P. Berrangé [Fri, 7 Jan 2022 19:53:08 +0000 (19:53 +0000)]
scripts: add systemtap script for capturing SEV-ES VMSA

In general we expect to be able to construct a SEV-ES VMSA
blob from knowledge about the AMD achitectural CPU register
defaults, KVM setup and QEMU setup. If any of this unexpectedly
changes, figuring out what's wrong could be horrible. This
systemtap script demonstrates how to capture the real VMSA
that is used for a SEV-ES as it is booted. The captured data
can be fed into the 'sevctl vmsa show' command in order to
produce formatted info with named registers, allowing a
'diff' to be performed.

This script will need updating for any kernel version that is
not 6.0, to set the correct line numbers.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agodocs/kbase: describe attestation for SEV guests
Daniel P. Berrangé [Thu, 6 Oct 2022 16:46:56 +0000 (17:46 +0100)]
docs/kbase: describe attestation for SEV guests

Expand the SEV guest kbase guide with information about how to configure
a SEV/SEV-ES guest when attestation is required, and mention the use of
virt-qemu-sev-validate as a way to confirm it.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agotools: support generating SEV secret injection tables
Daniel P. Berrangé [Fri, 7 Jan 2022 11:45:27 +0000 (11:45 +0000)]
tools: support generating SEV secret injection tables

It is possible to build OVMF for SEV with an embedded Grub that can
fetch LUKS disk secrets. This adds support for injecting secrets in
the required format.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agotools: load CPU count and CPU SKU from libvirt
Daniel P. Berrangé [Thu, 6 Oct 2022 13:34:46 +0000 (14:34 +0100)]
tools: load CPU count and CPU SKU from libvirt

When validating a SEV-ES guest, we need to know the CPU count and VMSA
state. We can get the CPU count directly from libvirt's guest info. The
VMSA state can be constructed automatically if we query the CPU SKU from
host capabilities XML. Neither of these is secure, however, so this
behaviour is restricted.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agotools: support automatically constructing SEV-ES vCPU state
Daniel P. Berrangé [Wed, 5 Oct 2022 12:08:17 +0000 (13:08 +0100)]
tools: support automatically constructing SEV-ES vCPU state

The VMSA files contain the expected CPU register state for the VM. Their
content varies based on a few pieces of the stack

  - AMD CPU architectural initial state
  - KVM hypervisor VM CPU initialization
  - QEMU userspace VM CPU initialization
  - AMD CPU SKU (family/model/stepping)

The first three pieces of information we can obtain through code
inspection. The last piece of information we can take on the command
line. This allows a user to validate a SEV-ES guest merely by providing
the CPU SKU information, using --cpu-family, --cpu-model,
--cpu-stepping. This avoids the need to obtain or construct VMSA files
directly.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agotools: support validating SEV-ES initial vCPU state measurements
Daniel P. Berrangé [Fri, 7 Jan 2022 17:25:23 +0000 (17:25 +0000)]
tools: support validating SEV-ES initial vCPU state measurements

With the SEV-ES policy the VMSA state of each vCPU must be included in
the measured data. The VMSA state can be generated using the 'sevctl'
tool, by telling it a QEMU VMSA is required, and passing the hypevisor's
CPU SKU (family, model, stepping).

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agotools: load direct kernel config from libvirt
Daniel P. Berrangé [Thu, 6 Oct 2022 11:35:40 +0000 (12:35 +0100)]
tools: load direct kernel config from libvirt

When connected to libvirt we can validate that the guest configuration
has the kernel hashes property enabled, otherwise including the kernel
GUID table in our expected measurements is not likely to match the
actual measurement.

When running locally we can also automatically detect the kernel/initrd
paths, along with the cmdline string from the XML.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agotools: support validating SEV direct kernel boot measurements
Daniel P. Berrangé [Fri, 7 Jan 2022 16:15:23 +0000 (16:15 +0000)]
tools: support validating SEV direct kernel boot measurements

When doing direct kernel boot we need to include the kernel, initrd and
cmdline in the measurement.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agotools: load guest config from libvirt
Daniel P. Berrangé [Wed, 5 Oct 2022 16:39:14 +0000 (17:39 +0100)]
tools: load guest config from libvirt

Accept information about a connection to libvirt and a guest on the
command line. Talk to libvirt to obtain the running guest state and
automatically detect as much configuration as possible.

It will refuse to use a libvirt connection that is thought to be local
to the current machine, as running this tool on the hypervisor itself is
not considered secure. This can be overridden using the --insecure flag.

When querying the guest, it will also analyse the XML configuration in
an attempt to detect any options that are liable to be mistakes. For
example the NVRAM being measured should not have a persistent varstore.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agotools: support validating SEV firmware boot measurements
Daniel P. Berrangé [Thu, 9 Dec 2021 20:33:22 +0000 (20:33 +0000)]
tools: support validating SEV firmware boot measurements

The virt-qemu-sev-validate program will compare a reported SEV/SEV-ES
domain launch measurement, to a computed launch measurement. This
determines whether the domain has been tampered with during launch.

This initial implementation requires all inputs to be provided
explicitly, and as such can run completely offline, without any
connection to libvirt.

The tool is placed in the libvirt-client-qemu sub-RPM since it is
specific to the QEMU driver.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agobuild-aux: only forbid gethostname in C files
Daniel P. Berrangé [Fri, 7 Jan 2022 16:29:36 +0000 (16:29 +0000)]
build-aux: only forbid gethostname in C files

This function is fine to use in other languages

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu_command: Generate thread-context object for main guest memory
Michal Privoznik [Wed, 2 Nov 2022 13:07:49 +0000 (14:07 +0100)]
qemu_command: Generate thread-context object for main guest memory

When generating memory for main guest memory memory-backend-*
might be used. This means, we may need to generate thread-context
objects too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu: Generate thread-context object for memory devices
Michal Privoznik [Wed, 2 Nov 2022 13:07:21 +0000 (14:07 +0100)]
qemu: Generate thread-context object for memory devices

When generating memory for memory devices memory-backend-* might
be used. This means, we may need to generate thread-context
objects too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_command: Generate thread-context object for guest NUMA memory
Michal Privoznik [Wed, 2 Nov 2022 12:48:45 +0000 (13:48 +0100)]
qemu_command: Generate thread-context object for guest NUMA memory

When generating memory for guest NUMA memory-backend-* might be
used. This means, we may need to generate thread-context objects
too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu: Delete thread-context objects at domain startup
Michal Privoznik [Fri, 4 Nov 2022 12:52:43 +0000 (13:52 +0100)]
qemu: Delete thread-context objects at domain startup

While technically thread-context objects can be reused, we only
use them (well, will use them) to pin memory allocation threads.
Therefore, once we connect to QEMU monitor, all memory (with
prealloc=yes) was allocated and thus these objects are no longer
needed and can be removed. For on demand allocation the TC object
is left behind.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_command: Introduce qemuBuildThreadContextProps()
Michal Privoznik [Wed, 2 Nov 2022 11:08:52 +0000 (12:08 +0100)]
qemu_command: Introduce qemuBuildThreadContextProps()

The aim of thread-context object is to set affinity on threads
that allocate memory for a memory-backend-* object. For instance:

-object '{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":[3]}' \
-object '{"qom-type":"memory-backend-memfd","id":"ram-node0","hugetlb":true,\
          "hugetlbsize":2097152,"share":true,"prealloc":true,"prealloc-threads":8,\
          "size":15032385536,"host-nodes":[3],"policy":"preferred",\
          "prealloc-context":"tc-ram-node0"}' \

allocates 14GiB worth of memory, backed by 2MiB hugepages from
host NUMA node 3, using 8 threads. If it weren't for
thread-context these threads wouldn't have any affinity and thus
theoretically could be scheduled to run on CPUs of different NUMA
node (which is what I saw occasionally).

Therefore, whenever we are pinning memory (IOW setting host-nodes
attribute), we can generate thread-context object with the same
affinity.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoqemu_capabilities: Introduce QEMU_CAPS_THREAD_CONTEXT
Michal Privoznik [Thu, 4 Aug 2022 07:54:16 +0000 (09:54 +0200)]
qemu_capabilities: Introduce QEMU_CAPS_THREAD_CONTEXT

In its commit v7.1.0-1429-g7208429223 QEMU gained new object
thread-context, which allows running specialized tasks with
affinity set to a given subset of host CPUs/NUMA nodes. Even
though only memory allocation task accepts this new object, it's
exactly what we aim to implement in libvirt. Therefore, introduce
a new capability to track whether QEMU is capable of this object.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agoconf: skip resource cache init if sysfs files are missing
Daniel P. Berrangé [Mon, 10 Oct 2022 16:45:02 +0000 (17:45 +0100)]
conf: skip resource cache init if sysfs files are missing

On aarch64 the 'id' file is not present for CPU cache information in
sysfs. This causes the local stateful hypervisor drivers to fail to
initialize capabilities:

virStateInitialize:657 : Initialisation of cloud-hypervisor state driver failed: no error

The 'no error' is because the 'virFileReadValueNNN' methods return
ret==-2, with no error raised, when the requeted file does not exist.
None of the callers were checking for this scenario when populating
capabilities. The most graceful way to handle this is to skip the
cache bank in question.  This fixes failure to launch libvirt drivers
on certain aarch64 hardware.

Fixes: https://gitlab.com/libvirt/libvirt/-/issues/389
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoconf: define autoptr func for virCapsHostCacheBankFree
Daniel P. Berrangé [Tue, 11 Oct 2022 09:02:47 +0000 (10:02 +0100)]
conf: define autoptr func for virCapsHostCacheBankFree

This lets us simplify the cleanup paths when populating the host cache
bank information in capabilities XML.

Tested-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agovirGetConnectGeneric: Only delegate existing identities
Martin Kletzander [Fri, 11 Nov 2022 13:19:50 +0000 (14:19 +0100)]
virGetConnectGeneric: Only delegate existing identities

Inside virt-qemu-run, just like in virsh for example, there is no
identity set in the current thread, so we should not try to set it,
otherwise things like connecting to other drivers might fail and on
top of that there is no error set so the user can't even see what's
wrong.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2000075
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoutil: Remove return value from virTypedParamsCopy
Martin Kletzander [Fri, 11 Nov 2022 13:15:43 +0000 (14:15 +0100)]
util: Remove return value from virTypedParamsCopy

It is already nonfallible, so just change the return type to void.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoci: regenerate with lcitool manifest
Daniel P. Berrangé [Mon, 14 Nov 2022 10:47:29 +0000 (10:47 +0000)]
ci: regenerate with lcitool manifest

Two notable changes:

 * the macOS platform has switched from x86_64 to aarch64
 * if a new pipeline starts before a previous one finishes,
   jobs marked 'interruptible: true' will be auto-cancelled

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu_validate: Use proper printf directive for ssize_t
Michal Privoznik [Fri, 11 Nov 2022 13:55:14 +0000 (14:55 +0100)]
qemu_validate: Use proper printf directive for ssize_t

In one of recent commits an error message was introduced. In this
message a variable of type ssize_t is being printed out, but the
corresponding format directive is %ld instead of %zd which breaks
on 32bits systems. Switch to proper format.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoFix spelling
Tim Wiederhake [Fri, 11 Nov 2022 15:48:48 +0000 (16:48 +0100)]
Fix spelling

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
2 years agotests: Fix libxlxml2domconfigtest
Jim Fehlig [Fri, 11 Nov 2022 00:55:38 +0000 (17:55 -0700)]
tests: Fix libxlxml2domconfigtest

Downstream CI recently encountered failures of libxlxml2domconfigtest when
building libvirt packages against Xen 4.17 rc3 packages. The test fails on
vnuma_hvm config, where suddently the actual json produced by
libxl_domain_config_to_json() contains a 'pnode' entry in the 'vnuma_nodes'
list, which is absent in the expected json. It appears the test has thus far
passed by luck. E.g. I was able to make the test pass in the failing
environment by changing the meson buildtype from debugoptimized to debug.

When a VM config contains vnuma settings, libxlMakeVnumaList() checks if the
number of requested vnuma nodes exceeds the number of physical nodes. The
number of physical nodes is retrieved with libxl_get_physinfo(), which can
return wildly different results in the context of unit tests. This change
mocks libxl_get_physinfo() to return consistent results. All fields of the
libxl_physinfo struct are set to 0 except nr_nodes, which is set to 6 to
ensure the vnuma_hvm configuration is properly tested.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Add command-line to generate SGX EPC memory backend
Lin Yang [Fri, 11 Nov 2022 01:21:27 +0000 (17:21 -0800)]
qemu: Add command-line to generate SGX EPC memory backend

According to the result parsing from xml, add the argument of
SGX EPC memory backend into QEMU command line.

$ qemu-system-x86_64 \
    ...... \
    -object '{"qom-type":"memory-backend-epc","id":"memepc0","prealloc":true,"size":67108864,"host-nodes":[0,1],"policy":"bind"}' \
    -object '{"qom-type":"memory-backend-epc","id":"memepc1","prealloc":true,"size":16777216,"host-nodes":[2,3],"policy":"bind"}' \
    -machine sgx-epc.0.memdev=memepc0,sgx-epc.0.node=0,sgx-epc.1.memdev=memepc1,sgx-epc.1.node=1

Signed-off-by: Lin Yang <lin.a.yang@intel.com>
Signed-off-by: Haibin Huang <haibin.huang@intel.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agosecurity_dac: Set DAC label on SGX /dev nodes
Michal Privoznik [Fri, 11 Nov 2022 01:21:26 +0000 (17:21 -0800)]
security_dac: Set DAC label on SGX /dev nodes

As advertised in previous commits, QEMU needs to access
/dev/sgx_vepc and /dev/sgx_provision files when SGX memory
backend is configured. And if it weren't for QEMU's namespaces,
we wouldn't dare to relabel them, because they are system wide
files. But if namespaces are used, then we can set label on
domain's private copies, just like we do for /dev/sev.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Haibin Huang <haibin.huang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu_namespace: Create SGX related nodes in domain's namespace
Michal Privoznik [Fri, 11 Nov 2022 01:21:25 +0000 (17:21 -0800)]
qemu_namespace: Create SGX related nodes in domain's namespace

This is similar to the previous commit. SGX memory backend needs
to access /dev/sgx_vepc and /dev/sgx_provision. Create these
nodes in domain's private /dev when required by domain's config.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Haibin Huang <haibin.huang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu_cgroup: Allow SGX in devices controller
Michal Privoznik [Fri, 11 Nov 2022 01:21:24 +0000 (17:21 -0800)]
qemu_cgroup: Allow SGX in devices controller

SGX memory backend needs to access /dev/sgx_vepc (which allows
userspace to allocate "raw" EPC without an associated enclave)
and /dev/sgx_provision (which allows creating provisioning
enclaves). Allow these two devices in CGroups if a domain is
configured so.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Haibin Huang <haibin.huang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: Introduce SGX EPC element into device memory xml
Lin Yang [Fri, 11 Nov 2022 01:21:23 +0000 (17:21 -0800)]
conf: Introduce SGX EPC element into device memory xml

<devices>
  ...
  <memory model='sgx-epc'>
    <source>
      <nodemask>0-1</nodemask>
    </source>
    <target>
      <size unit='KiB'>512</size>
      <node>0</node>
    </target>
  </memory>
  ...
</devices>

Signed-off-by: Lin Yang <lin.a.yang@intel.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Haibin Huang <haibin.huang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: expose SGX feature in domain capabilities
Haibin Huang [Fri, 11 Nov 2022 01:21:22 +0000 (17:21 -0800)]
conf: expose SGX feature in domain capabilities

Extend hypervisor capabilities to include sgx feature. When available,
the hypervisor supports launching an VM with SGX on Intel platfrom.
The SGX feature tag privides additional details like section size and
sgx1 or sgx2.

Signed-off-by: Haibin Huang <haibin.huang@intel.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoConvert QMP capabilities to domain capabilities
Haibin Huang [Fri, 11 Nov 2022 01:21:21 +0000 (17:21 -0800)]
Convert QMP capabilities to domain capabilities

the QMP capabilities:
  {"return":
    {
      "sgx": true,
      "section-size": 1024,
      "flc": true
    }
  }

the domain capabilities:
  <sgx>
    <flc>yes</flc>
    <epc_size>1</epc_size>
  </sgx>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Haibin Huang <haibin.huang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Get SGX capabilities form QMP
Haibin Huang [Fri, 11 Nov 2022 01:21:20 +0000 (17:21 -0800)]
qemu: Get SGX capabilities form QMP

Generate the QMP command for query-sgx-capabilities and the command
return SGX capabilities from QMP.

{"execute":"query-sgx-capabilities"}

the right reply:
  {"return":
    {
      "sgx": true,
      "section-size": 197132288,
      "flc": true
    }
  }

the error reply:
  {"error":
    {"class": "GenericError", "desc": "SGX is not enabled in KVM"}
  }

Signed-off-by: Haibin Huang <haibin.huang@intel.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agodomain_capabilities: Define SGX capabilities structs
Haibin Huang [Fri, 11 Nov 2022 01:21:19 +0000 (17:21 -0800)]
domain_capabilities: Define SGX capabilities structs

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Haibin Huang <haibin.huang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: capabilities: Detect support for JSON args for -netdev
Peter Krempa [Wed, 9 Nov 2022 17:12:12 +0000 (18:12 +0100)]
qemu: capabilities: Detect support for JSON args for -netdev

JSON args for -netdev were added as precursor for adding the 'dgram'
network backend type. Enable the detection and update test cases using
DO_TEST_CAPS_LATEST.

Enabling the capability also ensures that the -netdev argument is
validated against the QAPI schema of 'netdev_add' which was already
implemented but not enabled.

The parser supporting JSON was added by qemu commit f3eedcddba3 and
enabled when adding stream/dgram netdevs in commit 5166fe0ae46.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agonodedev: ignore EINVAL from libudev in udevEventHandleThread
Christian Ehrhardt [Thu, 10 Nov 2022 09:36:28 +0000 (10:36 +0100)]
nodedev: ignore EINVAL from libudev in udevEventHandleThread

Certain udev entries might be of a size that makes libudev emit EINVAL
which right now leads to udevEventHandleThread exiting. Due to no more
handling events other elements of libvirt will start pushing for events
to be consumed which never happens causing a busy loop burning a cpu
without any gain.

After evaluation of the example case discussed in in #245 and a test
run ignoring EINVAL it was considered safe to add EINVAL to the ignored
errnos to not exit udevEventHandleThread giving it more resilience.

The root cause is in systemd and by now was discussed and fixed via
https://github.com/systemd/systemd/issues/24987, but hardening libvirt
to be able to better deal with EINVAL returned still is the right thing
to avoid the reported busy loops on systemd with older systemd versions.

Fixes: https://gitlab.com/libvirt/libvirt/-/issues/245
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agomaint: fix "mixing declarations and code" errors
Roman Bogorodskiy [Tue, 8 Nov 2022 19:12:22 +0000 (20:12 +0100)]
maint: fix "mixing declarations and code" errors

clang 14.0.5 complains:

../src/bhyve/bhyve_device.c:42:29: error: mixing declarations and code
is incompatible with standards before C99
[-Werror,-Wdeclaration-after-statement]
    virDomainPCIAddressSet *addrs = opaque;
                            ^
1 error generated.

And a few similar errors in some other places, mainly bhyve related.
Apply a trivial fix to resolve that.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Wed, 9 Nov 2022 13:20:00 +0000 (14:20 +0100)]
Translated using Weblate (Swedish)

Currently translated at 48.3% (5017 of 10386 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2 years agoqemuMonitorJSONQueryNamedBlockNodes: Drop 'flat' argument
Peter Krempa [Wed, 9 Nov 2022 10:12:48 +0000 (11:12 +0100)]
qemuMonitorJSONQueryNamedBlockNodes: Drop 'flat' argument

All callers pass the equivalent of looking up whether qemu supports
QEMU_CAPS_QMP_QUERY_NAMED_BLOCK_NODES_FLAT. Use
'mon->queryNamedBlockNodesFlat' directly and refactor all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemuMonitorJSONBlockStatsUpdateCapacityBlockdev: Use 'flat' mode of query-named-block...
Peter Krempa [Wed, 9 Nov 2022 10:06:25 +0000 (11:06 +0100)]
qemuMonitorJSONBlockStatsUpdateCapacityBlockdev: Use 'flat' mode of query-named-block-nodes

'query-named-block-nodes' in non-flat mode returns redundantly nested
data under the 'backing-image' field. Fortunately we don't need it when
updating the capacity stats.

This function was unfortunately not fixed originally when the support
for flat mode was added. Use the flat cached in the monitor object to
force flat mode if available.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: monitor: Store whether 'query-named-block-nodes' supports 'flat' parameter
Peter Krempa [Wed, 9 Nov 2022 09:53:49 +0000 (10:53 +0100)]
qemu: monitor: Store whether 'query-named-block-nodes' supports 'flat' parameter

Rather than having callers always pass this flag store it in the
qemuMonitor object. Following patches will convert the code to use this
internal flag.

In the future this will also simplify removal when all supported qemu
versions will support the new mode.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: qemuBlockGetNamedNodeData: Remove pointless error path
Peter Krempa [Wed, 9 Nov 2022 09:45:27 +0000 (10:45 +0100)]
qemu: qemuBlockGetNamedNodeData: Remove pointless error path

We don't need automatic freeing for 'blockNamedNodeData' and we can
directly return it rather than checking it for NULL-ness first.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: Introduce support for 'hv-avic' Hyper-V enlightenment
Peter Krempa [Tue, 8 Nov 2022 12:29:04 +0000 (13:29 +0100)]
conf: Introduce support for 'hv-avic' Hyper-V enlightenment

qemu-6.2 introduced support for the hv-avic enlightenment which allows
to use Hyper-V SynIC with hardware APICv/AVIC enabled.

Implement the libvirt support for it.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/402
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agocpu: x86: Introduce the 'hv-avic' feature
Peter Krempa [Tue, 8 Nov 2022 12:51:54 +0000 (13:51 +0100)]
cpu: x86: Introduce the 'hv-avic' feature

Based on qemu commit e1f9a8e8c90ae54387922e33e5ac4fd759747d01 introduce
the hv-avic feature in leaf 0x40000004, EAX 0x00000200 (1 << 9).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agocpu: x86: Group and order hyperv enlightenment features by leaf and register
Peter Krempa [Tue, 8 Nov 2022 12:42:41 +0000 (13:42 +0100)]
cpu: x86: Group and order hyperv enlightenment features by leaf and register

'VIR_CPU_x86_HV_STIMER_DIRECT' is reported under leaf 0x40000003,
but the data is in the EDX register. Create a new group for such
features and move them after the 0x40000003 EAX group.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf: virDomainDefFormatFeatures: Realign line
Peter Krempa [Tue, 8 Nov 2022 12:42:51 +0000 (13:42 +0100)]
conf: virDomainDefFormatFeatures: Realign line

Don't break line after opening bracket of a funtion call.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Add missing 'break' statement in couple of switch()-es
Michal Privoznik [Wed, 9 Nov 2022 12:52:40 +0000 (13:52 +0100)]
qemu: Add missing 'break' statement in couple of switch()-es

In recent commits migration of TPM on shared storage was
introduced. However, I've only complied it with gcc and thus did
not notice that clang build fails due to missing break; at the
end of some (empty) cases in switch() statements.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: tpm: Never remove state on outgoing migration and shared storage
Stefan Berger [Mon, 24 Oct 2022 10:28:48 +0000 (06:28 -0400)]
qemu: tpm: Never remove state on outgoing migration and shared storage

Never remove the TPM state on outgoing migration if the storage setup
has shared storage for the TPM state files. Also, do not do the security
cleanup on outgoing migration if shared storage is detected.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: tpm: Avoid security labels on incoming migration with shared storage
Stefan Berger [Mon, 24 Oct 2022 10:28:47 +0000 (06:28 -0400)]
qemu: tpm: Avoid security labels on incoming migration with shared storage

When using shared storage there is no need to apply security labels on the
storage since the files have to have been labeled already on the source
side and we must assume that the source and destination side have been
setup to use the same uid and gid for running swtpm as well as share the
same security labels. Whether the security labels can be used at all
depends on the shared storage and whether and how it supports them.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: tpm: Pass --migration option to swtpm if supported and needed
Stefan Berger [Mon, 24 Oct 2022 10:28:46 +0000 (06:28 -0400)]
qemu: tpm: Pass --migration option to swtpm if supported and needed

Pass the --migration option to swtpm if swptm supports it (starting
with v0.8) and if the TPM's state is written on shared storage. If this
is the case apply the 'release-lock-outgoing' parameter with this
option and apply the 'incoming' parameter for incoming migration so that
swtpm releases the file lock on the source side when the state is migrated
and locks the file on the destination side when the state is received.

If a started swtpm instance is running with the necessary options of
migrating with share storage then remember this with a flag in the
virDomainTPMPrivateDef.

Report an error if swtpm does not support the --migration option and an
incoming migration across shared storage is requested.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: tpm: Add support for storing private TPM-related data
Stefan Berger [Mon, 24 Oct 2022 10:28:45 +0000 (06:28 -0400)]
qemu: tpm: Add support for storing private TPM-related data

Add support for storing private TPM-related data. The first private data
will be related to the capability of the started swtpm indicating whether
it is capable of migration with a shared storage setup since that requires
support for certain command line flags that were only becoming available
in v0.8.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: tpm: Conditionally create storage on incoming migration
Stefan Berger [Mon, 24 Oct 2022 10:28:44 +0000 (06:28 -0400)]
qemu: tpm: Conditionally create storage on incoming migration

Do not create storage if the TPM state files are on shared storage and
there's an incoming migration since in this case the storage directory
must already exist. Also do not run swtpm_setup in this case.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: tpm: Introduce qemuTPMHasSharedStorage()
Stefan Berger [Mon, 24 Oct 2022 10:28:43 +0000 (06:28 -0400)]
qemu: tpm: Introduce qemuTPMHasSharedStorage()

New qemuTPMHasSharedStorage() function is introduced which
returns whether the swtpm state directory is on a shared
filesystem (e.g. NFS).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoutil: Add parsing support for swtpm's cmdarg-migration capability
Stefan Berger [Mon, 24 Oct 2022 10:28:42 +0000 (06:28 -0400)]
util: Add parsing support for swtpm's cmdarg-migration capability

Add support for parsing swtpm 'cmdarg-migration' capability (since v0.8).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agocpu_map: Add missing x86 feature "vgif"
Tim Wiederhake [Wed, 19 Oct 2022 13:43:15 +0000 (15:43 +0200)]
cpu_map: Add missing x86 feature "vgif"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "v-vmsave-vmload"
Tim Wiederhake [Wed, 19 Oct 2022 13:42:49 +0000 (15:42 +0200)]
cpu_map: Add missing x86 feature "v-vmsave-vmload"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "avic"
Tim Wiederhake [Wed, 19 Oct 2022 13:42:29 +0000 (15:42 +0200)]
cpu_map: Add missing x86 feature "avic"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "intel-pt-lip"
Tim Wiederhake [Wed, 19 Oct 2022 13:42:08 +0000 (15:42 +0200)]
cpu_map: Add missing x86 feature "intel-pt-lip"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "xfd"
Tim Wiederhake [Wed, 19 Oct 2022 13:41:46 +0000 (15:41 +0200)]
cpu_map: Add missing x86 feature "xfd"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "arch-lbr"
Tim Wiederhake [Wed, 19 Oct 2022 13:41:35 +0000 (15:41 +0200)]
cpu_map: Add missing x86 feature "arch-lbr"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "tsx-ldtrk"
Tim Wiederhake [Wed, 19 Oct 2022 13:41:14 +0000 (15:41 +0200)]
cpu_map: Add missing x86 feature "tsx-ldtrk"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "serialize"
Tim Wiederhake [Wed, 19 Oct 2022 13:41:00 +0000 (15:41 +0200)]
cpu_map: Add missing x86 feature "serialize"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "avx512-fp16"
Tim Wiederhake [Wed, 19 Oct 2022 13:40:28 +0000 (15:40 +0200)]
cpu_map: Add missing x86 feature "avx512-fp16"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "avx512-vp2intersect"
Tim Wiederhake [Wed, 19 Oct 2022 13:40:11 +0000 (15:40 +0200)]
cpu_map: Add missing x86 feature "avx512-vp2intersect"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "pks"
Tim Wiederhake [Wed, 19 Oct 2022 13:39:37 +0000 (15:39 +0200)]
cpu_map: Add missing x86 feature "pks"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "bus-lock-detect"
Tim Wiederhake [Wed, 19 Oct 2022 13:39:15 +0000 (15:39 +0200)]
cpu_map: Add missing x86 feature "bus-lock-detect"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 features "sgx-..."
Tim Wiederhake [Wed, 19 Oct 2022 13:37:26 +0000 (15:37 +0200)]
cpu_map: Add missing x86 features "sgx-..."

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "sgx2"
Tim Wiederhake [Wed, 19 Oct 2022 13:37:02 +0000 (15:37 +0200)]
cpu_map: Add missing x86 feature "sgx2"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "sgx1"
Tim Wiederhake [Wed, 19 Oct 2022 13:36:37 +0000 (15:36 +0200)]
cpu_map: Add missing x86 feature "sgx1"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "sgx-exinfo"
Tim Wiederhake [Wed, 19 Oct 2022 13:36:16 +0000 (15:36 +0200)]
cpu_map: Add missing x86 feature "sgx-exinfo"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "sgxlc"
Tim Wiederhake [Wed, 19 Oct 2022 13:35:51 +0000 (15:35 +0200)]
cpu_map: Add missing x86 feature "sgxlc"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature "sgx"
Tim Wiederhake [Wed, 19 Oct 2022 13:35:24 +0000 (15:35 +0200)]
cpu_map: Add missing x86 feature "sgx"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add missing x86 feature alias names
Tim Wiederhake [Wed, 19 Oct 2022 12:58:43 +0000 (14:58 +0200)]
cpu_map: Add missing x86 feature alias names

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Rename sync_qemu_i386.py
Tim Wiederhake [Mon, 17 Oct 2022 14:20:45 +0000 (16:20 +0200)]
cpu_map: Rename sync_qemu_i386.py

This makes the naming more consistent beween the two scripts
synching the feature list and the model list.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agocpu_map: Add script to sync from QEMU i386 cpu features
Tim Wiederhake [Fri, 14 Oct 2022 15:45:40 +0000 (17:45 +0200)]
cpu_map: Add script to sync from QEMU i386 cpu features

This script is intended to help in synchronizing i386 QEMU cpu
feature definitions with libvirt.

QEMU's attribute list for the "max-x86_64-cpu" contains non-cpu-feature
items and needs to be filtered before being useful.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>