]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
2 years agoqemuDomainObjWait: Report error when VM is being destroyed
Peter Krempa [Wed, 10 Aug 2022 13:39:57 +0000 (15:39 +0200)]
qemuDomainObjWait: Report error when VM is being destroyed

Since we started handling the monitor EOF event inside a job any code
which uses virDomainObjWait would no longer properly abort in case when
the VM crashed during the wait.

This is because virDomainObjWait uses virDomainObjIsActive which checks
'vm->def->id' to see if the VM is still active. Unfortunately the domain
id is cleared in qemuProcessStop which is run only inside the job.

To fix this we can use the 'beingDestroyed' flag stored in the VM
private data which is set to true around the time when the condition is
signalled.

Reported-by: Pavel Hrdina <phrdina@redhat.com>
Fixes: 8c9ff9960b29d4703a99efdd1cadcf6f48799cc0
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoci: Fix paths shown in the website
Andrea Bolognani [Tue, 19 Jul 2022 13:21:30 +0000 (15:21 +0200)]
ci: Fix paths shown in the website

Right now we're setting the prefix to a custom path, which
results in paths like

  /builds/libvirt/libvirt/vroot/etc/libvirt/virtqemud.conf

ending up in the generated HTML. In order to avoid that,
set the prefix and other installation paths to reasonable
default values by passing

  -Dsystem=true

and then take advantage of $DESTDIR support to still be able
to write the HTML files without requiring root privileges.

Reported-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoscripts: Add $DESTDIR support to meson-install-web.py
Andrea Bolognani [Wed, 10 Aug 2022 16:06:24 +0000 (18:06 +0200)]
scripts: Add $DESTDIR support to meson-install-web.py

meson already supports $DESTDIR natively, but in this case
we're using a custom script and so we have to do some extra
work ourselves.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoqemu: Replace virDomainObjWait with qemuDomainObjWait
Peter Krempa [Wed, 10 Aug 2022 13:35:54 +0000 (15:35 +0200)]
qemu: Replace virDomainObjWait with qemuDomainObjWait

The qemu code will need to check other qemu-private conditions when
reporting success for waiting. Thus we must replace all use of it with a
qemu-specific helper. For now the helper forwards directly to
virDomainObjWait.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemuProcessBeginStopJob: Add debug log when waking up all threads waiting on domain...
Peter Krempa [Wed, 10 Aug 2022 13:31:12 +0000 (15:31 +0200)]
qemuProcessBeginStopJob: Add debug log when waking up all threads waiting on domain condition

Aid in debugging of potentially stuck threads.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoTranslated using Weblate (Japanese)
Ludek Janda [Tue, 9 Aug 2022 11:53:20 +0000 (13:53 +0200)]
Translated using Weblate (Japanese)

Currently translated at 99.0% (10379 of 10480 strings)

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

Co-authored-by: Ludek Janda <ljanda@redhat.com>
Signed-off-by: Ludek Janda <ljanda@redhat.com>
2 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Tue, 9 Aug 2022 11:53:19 +0000 (13:53 +0200)]
Translated using Weblate (Swedish)

Currently translated at 41.5% (4353 of 10480 strings)

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

Translated using Weblate (Swedish)

Currently translated at 41.3% (4338 of 10480 strings)

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

Translated using Weblate (Swedish)

Currently translated at 41.3% (4333 of 10480 strings)

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

Translated using Weblate (Swedish)

Currently translated at 40.9% (4293 of 10480 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 agonodedev: support 'mtty' device for testing
Jonathon Jongsma [Fri, 15 Jul 2022 19:10:30 +0000 (14:10 -0500)]
nodedev: support 'mtty' device for testing

It would be nice to be able to test the mediated device capabilities
without having physical hardware which supports it. The 'mtty' kernel
module presents a virtual parent device which is capable of creating
'fake' mediated devices, and as such it would be useful for testing.

However, the 'mtty' device is not part of an existing device subsystem
(e.g. PCI, etc), so libvirt ignores it and it does not get added to the
node device list. And because it does not get added to the node device
list, it cannot be used to create child mdevs using `virsh
nodedev-create`.

There is already a node device type capability
VIR_NODE_DEV_CAP_MDEV_TYPES that indicates whether a device supports
creating child mediated devices, but libvirt assumes that this is a
nested capability (in other words, it assumes that the primary
capability of a device is something like PCI). If we allow this
MDEV_TYPES capability to be a primary device capability, then we can
support virtual devices like 'mtty' as a parent for mediated devices.

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

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agotests: Mock virQEMUCapsProbeHVF()
Andrea Bolognani [Wed, 10 Aug 2022 09:42:37 +0000 (11:42 +0200)]
tests: Mock virQEMUCapsProbeHVF()

Successfully returning without doing anything is what the
function already does on non-Apple platforms.

When building on macOS, however, the check for HVF availability
will be performed. When running on bare metal, that will result
in the QEMU_CAPS_HVF flag being added to the virQEMUCaps
instance, and a bunch of error messages along the lines of

  In 'tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml':
  Offset 7557
  Expect [c]
  Actual [hvf'/>
    <flag name=‘c]

showing up.

Up until now we hadn't noticed because our CI jobs run in VMs,
where HVF support is not available.

Reported-by: Christophe de Dinechin <dinechin@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Tested-by: Christophe de Dinechin <dinechin@redhat.com>
2 years agoqemu: Make virQEMUCapsProbeHVF() non-static
Andrea Bolognani [Wed, 10 Aug 2022 09:38:31 +0000 (11:38 +0200)]
qemu: Make virQEMUCapsProbeHVF() non-static

We need to do this so that we can mock it in the test suite.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Tested-by: Christophe de Dinechin <dinechin@redhat.com>
2 years agotests: Use domaincapsmock in qemucapabilitiestest
Andrea Bolognani [Tue, 9 Aug 2022 16:10:27 +0000 (18:10 +0200)]
tests: Use domaincapsmock in qemucapabilitiestest

This doesn't change anything at the moment, but is necessary
for the upcoming fix.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Tested-by: Christophe de Dinechin <dinechin@redhat.com>
2 years agohypervisor: domain_job: add JobData private callbacks into virDomainJobObj
Kristina Hanicova [Wed, 10 Aug 2022 12:57:04 +0000 (14:57 +0200)]
hypervisor: domain_job: add JobData private callbacks into virDomainJobObj

We need this callback structure for qemu driver only, but it
makes more sense to include it in the virDomainJobObj in case of
other future additions than as a parameter of a beginJob
functions.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: refactor functions with removed driver if possible
Kristina Hanicova [Wed, 10 Aug 2022 12:57:03 +0000 (14:57 +0200)]
qemu: refactor functions with removed driver if possible

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: remove unused driver and all its propagations
Kristina Hanicova [Wed, 10 Aug 2022 12:57:02 +0000 (14:57 +0200)]
qemu: remove unused driver and all its propagations

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agohypervisor: domain_job: add maxQueuedJobs
Kristina Hanicova [Wed, 10 Aug 2022 12:57:01 +0000 (14:57 +0200)]
hypervisor: domain_job: add maxQueuedJobs

This patch adds a new variable maxQueuedJobs into the job object
as it is the last hypervisor-based part of the begin job. Since
this patch, it will not be necessary to propagate driver
structure into the job functions.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: beginJob: move saveStatus into private job callbacks
Kristina Hanicova [Wed, 10 Aug 2022 12:57:00 +0000 (14:57 +0200)]
qemu: beginJob: move saveStatus into private job callbacks

It makes sense to move this to other hypervisor-based functions
into the private job callback structure to make begin job
general.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: Fix indentation
Andrea Bolognani [Tue, 9 Aug 2022 16:17:14 +0000 (18:17 +0200)]
qemu: Fix indentation

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2 years agobridge_driver: Enable virMacMap iff dnsmasq is started
Michal Privoznik [Tue, 9 Aug 2022 11:31:41 +0000 (13:31 +0200)]
bridge_driver: Enable virMacMap iff dnsmasq is started

The virMacMap module is used only for libvirt_guests NSS module
as it records list of MAC addresses used by certain guest. But
the module itself is usable if and only if the network assigns IP
addresses (i.e. has dnsmasq running). If it's some other
authority that assigns IP addresses then we do not need the
virMacMap module at all.

For instance, a network with no <forward/> type and no DHCP set
won't create /var/lib/libvirt/dnsmasq/ dir which is what the
module expects to exist. But there's no need for the module to
even care about such network.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/348
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agobridge_driver: Introduce a helper for virNetworkObjSetMacMap()
Michal Privoznik [Tue, 9 Aug 2022 11:42:32 +0000 (13:42 +0200)]
bridge_driver: Introduce a helper for virNetworkObjSetMacMap()

Currently, whenever virNetworkObjSetMacMap() is called the same
pattern is used:

1) call virMacMapFileName() to generate a filename,
2) pass this filename to virMacMapNew(), and finally
3) pass retval from previous step to virNetworkObjSetMacMap().

Move this code into a helper (networkSetMacMap()) and replace
both pattern occurrences with its call.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovirNetworkObjSetMacMap: take double pointer of @macmap
Michal Privoznik [Tue, 9 Aug 2022 09:38:43 +0000 (11:38 +0200)]
virNetworkObjSetMacMap: take double pointer of @macmap

The virNetworkObjSetMacMap() API effectively steals passed
@macmap argument. However, the argument is a plain, first order
pointer. This requires every caller to set the argument to NULL
after the function was called. Let's make the function take
double pointer instead to make it obvious that the argument is
consumed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agobridge_driver: Use g_autoptr() for virMacMap
Michal Privoznik [Tue, 9 Aug 2022 11:37:32 +0000 (13:37 +0200)]
bridge_driver: Use g_autoptr() for virMacMap

Let's annotate virMacMap variables in bridge_driver.c with
g_autoptr() so that they are automatically freed upon error. This
may look like a needless commit, since there's no memory leak
currently, but it simplifies the next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agobridge_driver: Set @dnsmasqStarted only after successful dnsmasq spawn
Michal Privoznik [Tue, 9 Aug 2022 11:48:34 +0000 (13:48 +0200)]
bridge_driver: Set @dnsmasqStarted only after successful dnsmasq spawn

The networkStartNetworkVirtual() function handles starting of
networks of different forward types (none, nat, route, open).
And as a part of startup process dnsmasq might be spawned but
doesn't have to be (depending on the network configuration). The
@dnsmasqStarted variable is supposed to track whether dnsmasq was
started or not (so that it can be killed when starting network
fails after it was started). But the variable is set even when
the code decided not to start it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agorpm: merge mingw sub-packages into native spec
Daniel P. Berrangé [Mon, 8 Aug 2022 15:40:56 +0000 (11:40 -0400)]
rpm: merge mingw sub-packages into native spec

One specfile containing both native and mingw builds is the
new best practice for Fedora. This reduces the maint burden
and ensures the mingw packages don't fall behind.

Note this adds many more BuildRequires for anyone building
on Fedora, which will now need installing.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agotests: Pass the flat_namespace option to the linker
Christophe de Dinechin [Mon, 8 Aug 2022 18:14:08 +0000 (20:14 +0200)]
tests: Pass the flat_namespace option to the linker

This fixes vircryptotest on macOS 12 (Monterey).

The test relies on library injection (using DYLD_INSERT_LIBRARIES)
to replace the normal random functions with functions giving predictable
results, defined in virrandommock.c. However, using DYLD_INSERT_LIBRARIES
only works when building with flat namespaces.

Adding the -Wl,-flat_namespace option to the linker fixes the problem.
The option was already defined in the top-level meson.build, but had been
forgotten in the test linker arguments.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoconf: Simplify IOMMU device validation
Andrea Bolognani [Mon, 8 Aug 2022 15:38:42 +0000 (17:38 +0200)]
conf: Simplify IOMMU device validation

Instead of duplicating the list of attributes that are not
allowed for some of the IOMMU models, use two separate switch
statements: one for the attributes and one for the address.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: deprecate query-cpus-fast capability
Paolo Bonzini [Mon, 8 Aug 2022 15:15:08 +0000 (17:15 +0200)]
qemu: deprecate query-cpus-fast capability

All supported versions of QEMU have the command.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: remove support for query-cpus
Paolo Bonzini [Mon, 8 Aug 2022 15:15:07 +0000 (17:15 +0200)]
qemu: remove support for query-cpus

The query-cpus-fast command was introduced in 2.12, therefore
query-cpus is never used on supported versions of QEMU.  Remove
the logic to parse its output, as well as the parameters to
choose between the two commands.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agotests: remove query-cpus tests
Paolo Bonzini [Mon, 8 Aug 2022 15:15:06 +0000 (17:15 +0200)]
tests: remove query-cpus tests

All tests now use query-cpus-fast.  Since the QEMU driver will lose
support for query-cpus soon, go ahead and remove support for testing
it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agotests: convert x86_64 tests to query-cpus-fast
Paolo Bonzini [Mon, 8 Aug 2022 15:15:05 +0000 (17:15 +0200)]
tests: convert x86_64 tests to query-cpus-fast

All supported versions of QEMU include the query-cpus-fast QMP command.
In preparation for dropping support for the old "query-cpus" commands,
convert the JSON output for x86 tests to the new format, and drop the
"halted" field from the expected output as it is not available anymore.

The CPU properties were obtained from the query-hotpluggable-cpus output
in tests/qemumonitorjsondata.  CPU, thread_id, and qom_path are renamed
respectively to cpu-index, qom-path and thread-id, while nip and halted
are removed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agotests: convert ppc64 tests to query-cpus-fast
Paolo Bonzini [Mon, 8 Aug 2022 15:15:04 +0000 (17:15 +0200)]
tests: convert ppc64 tests to query-cpus-fast

All supported versions of QEMU include the query-cpus-fast QMP command.
In preparation for dropping support for the old "query-cpus" commands,
convert the JSON output for PPC tests to the new format, and drop the
"halted" field from the expected output as it is not available anymore.

The CPU properties were obtained from the query-hotpluggable-cpus output
in tests/qemumonitorjsondata.  CPU, thread_id, and qom_path are renamed
respectively to cpu-index, qom-path and thread-id, while nip and halted
are removed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agotests: drop "-fast" from query-cpus-fast tests
Paolo Bonzini [Mon, 8 Aug 2022 15:15:03 +0000 (17:15 +0200)]
tests: drop "-fast" from query-cpus-fast tests

All supported versions of QEMU include the query-cpus-fast QMP command.
In preparation for dropping support for the old "query-cpus" commands,
remove the "-fast" suffix from both x86-full-fast and s390-fast.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agotests: remove duplicate cpuinfo test
Paolo Bonzini [Mon, 8 Aug 2022 15:15:02 +0000 (17:15 +0200)]
tests: remove duplicate cpuinfo test

All supported versions of QEMU include the query-cpus-fast QMP command.
In preparation for dropping support for the old "query-cpus" commands,
remove the query-cpus version of the x86-full test.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoconf: Check IOMMU for unsupported attributes
Michal Privoznik [Fri, 8 Jul 2022 09:33:02 +0000 (11:33 +0200)]
conf: Check IOMMU for unsupported attributes

Currently, it's possible to pass various attributes to an IOMMU's
<driver/> element hoping that we enable them in underlying
hypervisor. However, depending on the IOMMU model, some of these
attributes can't be enabled and are simply ignored. This is
suboptimal and we should reject such configuration in the
validate phase.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2101633
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agonews: qemu: Add support for zero-copy migration
Fangge Jin [Fri, 22 Jul 2022 08:49:40 +0000 (16:49 +0800)]
news: qemu: Add support for zero-copy migration

Signed-off-by: Fangge Jin <fjin@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: move virDomainObjCanSetJob() into hypervisor
Kristina Hanicova [Wed, 3 Aug 2022 12:43:22 +0000 (14:43 +0200)]
qemu: move virDomainObjCanSetJob() into hypervisor

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: move virDomainNestedJobAllowed into hypervisor
Kristina Hanicova [Wed, 3 Aug 2022 12:43:21 +0000 (14:43 +0200)]
qemu: move virDomainNestedJobAllowed into hypervisor

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu & hypervisor: move qemuDomainTrackJob() into hypervisor
Kristina Hanicova [Wed, 3 Aug 2022 12:43:20 +0000 (14:43 +0200)]
qemu & hypervisor: move qemuDomainTrackJob() into hypervisor

This patch moves qemuDomainTrackJob() as virDomainTrackJob() into
hypervisor because it is called in begin job and end job
functions that will be generalized in the following series.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoCH: use virDomainObjClearJob() instead of virCHDomainObjFreeJob()
Kristina Hanicova [Wed, 3 Aug 2022 12:43:19 +0000 (14:43 +0200)]
CH: use virDomainObjClearJob() instead of virCHDomainObjFreeJob()

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoLXC: use virDomainObjClearJob() instead of virLXCDomainObjFreeJob()
Kristina Hanicova [Wed, 3 Aug 2022 12:43:18 +0000 (14:43 +0200)]
LXC: use virDomainObjClearJob() instead of virLXCDomainObjFreeJob()

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agolibxl: use virDomainObjClearJob() instead of libxlDomainObjFreeJob()
Kristina Hanicova [Wed, 3 Aug 2022 12:43:17 +0000 (14:43 +0200)]
libxl: use virDomainObjClearJob() instead of libxlDomainObjFreeJob()

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu & hypervisor: move qemuDomainObjClearJob() into hypervisor
Kristina Hanicova [Wed, 3 Aug 2022 12:43:16 +0000 (14:43 +0200)]
qemu & hypervisor: move qemuDomainObjClearJob() into hypervisor

This patch moves qemuDomainObjClearJob() as
virDomainObjClearJob() into hypervisor in order to be used by
other hypervisors as well.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu & hypervisor: move qemuDomainObjPreserveJob() into hypervisor
Kristina Hanicova [Wed, 3 Aug 2022 12:43:15 +0000 (14:43 +0200)]
qemu & hypervisor: move qemuDomainObjPreserveJob() into hypervisor

This patch moves qemuDomainObjPreserveJob() as
virDomainObjPreserveJob() into hypervisor in order to be used by
other hypervisors as well.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: propagate virDomainJobObj into qemuDomainObjPreserveJob()
Kristina Hanicova [Wed, 3 Aug 2022 12:43:14 +0000 (14:43 +0200)]
qemu: propagate virDomainJobObj into qemuDomainObjPreserveJob()

It does not make sense to propagate virDomainObj and get
qemuDomainObjPrivate from it, when it is already accessible in
the only function qemuDomainObjPreserveJob() is called from. That
being said, we can also propagate virDomainJobObj directly and
avoid using qemu private structure.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu & hypervisor: move qemuDomainObjResetAsyncJob() into hypervisor
Kristina Hanicova [Wed, 3 Aug 2022 12:43:13 +0000 (14:43 +0200)]
qemu & hypervisor: move qemuDomainObjResetAsyncJob() into hypervisor

This patch moves qemuDomainObjResetAsyncJob() as
virDomainObjResetAsyncJob() into hypervisor.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu & hypervisor: move qemuDomainObjResetAgentJob() into hypervisor
Kristina Hanicova [Wed, 3 Aug 2022 12:43:12 +0000 (14:43 +0200)]
qemu & hypervisor: move qemuDomainObjResetAgentJob() into hypervisor

This patch moves qemuDomainObjResetAgentJob() as
virDomainObjResetAgentJob() into hypervisor.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agovmx: Add support for dummy network interface
Martin Kletzander [Thu, 4 Aug 2022 08:27:40 +0000 (10:27 +0200)]
vmx: Add support for dummy network interface

Also map it to an ethernet without connectionType and networkName.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoconf, docs: Add support for dummy network interface
Martin Kletzander [Thu, 4 Aug 2022 08:26:40 +0000 (10:26 +0200)]
conf, docs: Add support for dummy network interface

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agovmx: Fix indentation
Martin Kletzander [Mon, 1 Aug 2022 14:02:53 +0000 (16:02 +0200)]
vmx: Fix indentation

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu_process: Destroy domain's namespace after killing QEMU
Michal Privoznik [Wed, 3 Aug 2022 10:27:19 +0000 (12:27 +0200)]
qemu_process: Destroy domain's namespace after killing QEMU

After QEMU is killed in qemuProcessStop() its mount namespace
doesn't exist anymore, because it was the only process running
there. Thus we should clear our internal flag that the domain has
namespace enabled so that seclabel restore code does not try to
enter it. We do the same in qemuProcessHandleMonitorEOF() but
when it is us, who decides to kill QEMU rather than QEMU quitting
we haven't seen EOF by the time qemuProcessStop() is called.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2 years agokbase: Document how to disable Secure Boot entirely
Andrea Bolognani [Thu, 4 Aug 2022 08:43:09 +0000 (10:43 +0200)]
kbase: Document how to disable Secure Boot entirely

In most cases, disabling the secure-boot or the enrolled-keys
firmware feature will achieve the same result: allowing an
unsigned operating system to run.

Right now we're only documenting the latter configuration. Add
the former as well, and explain the difference between the two.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agokbase: Always explicitly enable secure-boot firmware feature
Andrea Bolognani [Wed, 3 Aug 2022 16:07:12 +0000 (18:07 +0200)]
kbase: Always explicitly enable secure-boot firmware feature

It should be enough to enable or disable the enrolled-keys feature
to control whether Secure Boot is enforced, but there's a slight
complication: many distro packages for edk2 include, in addition
to general purpose firmware images, builds that are targeting the
Confidential Computing use case.

For those, the firmware descriptor will not advertise the
enrolled-keys feature, which will technically make them suitable
for satisfying a configuration such as

  <os firmware='efi'>
    <firmware>
      <feature state='off' name='enrolled-keys'/>
    </firmware>
  </os>

In practice, users will expect the general purpose build to be
used in this case. Explicitly asking for the secure-boot feature
to be enabled achieves that result at the cost of some slight
additional verbosity.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agovirhostcpu: Fix non-Linux virHostCPUGetPhysAddrSize() stub
Michal Privoznik [Thu, 4 Aug 2022 08:27:56 +0000 (10:27 +0200)]
virhostcpu: Fix non-Linux virHostCPUGetPhysAddrSize() stub

The non-Linux version of virHostCPUGetPhysAddrSize() is lacking
G_GNUC_UNUSED attribute to its @size argument which triggers an
error on all non-Linux builds. And while at it, make the function
actually signal error (ENOSYS) since it does not set the
argument.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Add support for max physical address size
Dario Faggioli [Fri, 29 Jul 2022 19:34:35 +0000 (13:34 -0600)]
qemu: Add support for max physical address size

This patch maps /domain/cpu/maxphysaddr into -cpu parameters:

  - <maxphysaddr mode='passthrough'/> becomes host-phys-bits=on
  - <maxphysaddr mode='emualte' bits='42'/> becomes phys-bits=42

Passthrough mode can only be used if the chosen CPU model is
'host-passthrough'. Also validate that an explicitly specified
bits value does not exceed the physical address bits on the host.

The feature is available since QEMU 2.7.0.

Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agocapabilities: Report number of host CPU physical address bits
Jim Fehlig [Fri, 29 Jul 2022 19:34:34 +0000 (13:34 -0600)]
capabilities: Report number of host CPU physical address bits

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: Add support for specifying CPU max physical address size
Dario Faggioli [Fri, 29 Jul 2022 19:34:33 +0000 (13:34 -0600)]
conf: Add support for specifying CPU max physical address size

This patch introduces the

    <maxphysaddr mode='passthrough'/>
    <maxphysaddr mode='emulate' bits='42'/>

sub element of /domain/cpu, which allows specifying the guest virtual CPU
address size. This can be useful if the guest needs to have a large amount
of memory.

If mode='passthrough', the virtual CPU will have the same number of address
bits as the host. If mode='emulate', the mandatory bits attribute specifies
the number of address bits.

Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemuxml2argvtest: Add negative cases for TPM version
Michal Privoznik [Tue, 2 Aug 2022 08:23:42 +0000 (10:23 +0200)]
qemuxml2argvtest: Add negative cases for TPM version

Now that we have all the machinery needed, we can introduce two
simple test cases:

1) only TPM 1.2 is supported, but TPM 2.0 was requested in domain XML,
2) only TPM 2.0 is supported, but TPM 1.2 was requested in domain XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2 years agoqemu_validate: Validate TPM version
Michal Privoznik [Tue, 2 Aug 2022 08:23:23 +0000 (10:23 +0200)]
qemu_validate: Validate TPM version

Supported TPM versions are reported in domain capabilities. These
are used already to validate TPM type and model, but not TPM
version. This is suboptimal, because otherwise we leave users to
meet the error when starting a guest and libvirt spawns swtpm
binary which in turn reports an error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2 years agotestutilsqemu: Fake TPM versions
Michal Privoznik [Wed, 20 Jul 2022 07:51:55 +0000 (09:51 +0200)]
testutilsqemu: Fake TPM versions

Because of v8.5.0-rc1~25 we are already faking TPM support for
domaincaps. Might as well fake supported TPM versions.
The swtpm binary supports both TPM versions since its first
release, but pretend it isn't the case. For QEMU-5.2 and older
pretend only TPM-1.2 is available, QEMU-6.* has both TPM-1.2 and
TPM-2.0 and QEMU-7.0 and newer has only TPM-2.0 available.
This way, domaincaps are more dispersed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2 years agosrc: Export virDomainTPMVersion enum conversion helpers
Michal Privoznik [Tue, 2 Aug 2022 08:21:07 +0000 (10:21 +0200)]
src: Export virDomainTPMVersion enum conversion helpers

The virDomainTPMVersion enum is declared in domain_conf.h among
with its TypeFromString() and TypeToString() helpers (which are
then implemented in domain_conf.c). However, neither of these
helpers is exposed in libvirt_private.syms which makes it
impossible for other modules to use.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Tue, 2 Aug 2022 08:51:50 +0000 (10:51 +0200)]
Translated using Weblate (Swedish)

Currently translated at 40.2% (4213 of 10480 strings)

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

Translated using Weblate (Swedish)

Currently translated at 40.0% (4193 of 10480 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 agoqemu: Do not try to set memlock on inactive domain
Jiri Denemark [Wed, 3 Aug 2022 11:25:06 +0000 (13:25 +0200)]
qemu: Do not try to set memlock on inactive domain

When we call qemuDomainSetMaxMemLock to reset memory locking limit back
to its original value the domain can already be stopped (for example
after the domain shuts down during migration) in which case it does not
make sense to set any limit. Doing so can even be harmful as we may end
up setting the limit for the daemon itself as the PID is 0.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2 years agoqemu: Reset stored memlock limit when stopping QEMU
Jiri Denemark [Wed, 3 Aug 2022 11:18:59 +0000 (13:18 +0200)]
qemu: Reset stored memlock limit when stopping QEMU

When resetting private data after stopping QEMU process we should also
reset the original memory locking limit (both normal and pre-migration)
as they are not relevant anymore.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agoqemu: Move CPU validation out of PostParse
Michal Privoznik [Mon, 1 Aug 2022 14:56:25 +0000 (16:56 +0200)]
qemu: Move CPU validation out of PostParse

The qemuDomainDefCPUPostParse() does a bit more than filling in
missing info. It also validates CPU cache configuration. Move
that code into qemuValidateDomainDefCpu() where the code fits
better.

And since I need to fix indentation of existing code in
qemuValidateDomainDefCpu(), I'm taking this opportunity and move
error messages onto single line. Interestingly, this uncovers a
bug we have in sc_prohibit_diagnostic_without_format syntax-check
rule, because previously a virReportError() with a message
spawned over three lines was not caught but not it is. But
trying to understand that regex is a job for another time.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2 years agoqemuMonitorOpenUnix: Don't overwrite 'ret' needlessly
Peter Krempa [Tue, 2 Aug 2022 12:41:31 +0000 (14:41 +0200)]
qemuMonitorOpenUnix: Don't overwrite 'ret' needlessly

Directly check the return value of 'connect'. Unfortunately we can't
remove it as we have to undo auto-closing of the socket on success.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoqemuMonitorOpenUnix: Remove 'retry' argument
Peter Krempa [Thu, 3 Feb 2022 12:48:09 +0000 (13:48 +0100)]
qemuMonitorOpenUnix: Remove 'retry' argument

All callers now pass false for 'retry' we are guaranteed to have a
monitor socket present. This means that the retry code can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoqemuProcessQMPConnectMonitor: Connect to probing monitor with 'retry' set to false
Peter Krempa [Tue, 2 Aug 2022 12:26:41 +0000 (14:26 +0200)]
qemuProcessQMPConnectMonitor: Connect to probing monitor with 'retry' set to false

In 'qemuProcessQMPLaunch' qemu is very specifically launched using it's
internal '-daemonize' flag (see comment in the function) to ensure that
the monitor socket is ready and opened prior to attempting the monitor
connection.

This means we don't have to retry the connection to the monitor in
qemuMonitorOpen as the socket will be already there.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoqemuMonitorTestNew: Call qemuMonitorOpen with 'retry' false
Peter Krempa [Tue, 2 Aug 2022 11:54:35 +0000 (13:54 +0200)]
qemuMonitorTestNew: Call qemuMonitorOpen with 'retry' false

The 'retry' argument makes the monitor connection opening re-try the
connection in case the monitor socket doesn't exist or isn't properly
listening. In case of the test code this can't happen because the socket
is created and made listening in 'qemuMonitorCommonTestNew' which is
called prior to calling 'qemuMonitorOpen'.

We can thus avoit the code which attempts retries in monitor connection.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoqemu: monitor: Remove 'timeout' argument from qemuMonitorOpen
Peter Krempa [Tue, 2 Aug 2022 11:45:49 +0000 (13:45 +0200)]
qemu: monitor: Remove 'timeout' argument from qemuMonitorOpen

The 'timeout' argument is used by 'qemuMonitorOpenUnix' only when the
'retry' argument is true. The callers of 'qemuMonitorOpen' only pass '0'
for timeout when they call it with 'retry' true and use other values
when 'retry' is false and thus ignored.

This means we can remove the argument and simply have it set to the
default value of QEMU_DEFAULT_MONITOR_WAIT.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoqemu: process: Remove 'retry' argument from qemuConnectMonitor
Peter Krempa [Tue, 2 Aug 2022 11:36:47 +0000 (13:36 +0200)]
qemu: process: Remove 'retry' argument from qemuConnectMonitor

Both callers pass 'false' as the argument via a variable which is not
modified. Remove the argument and pass 'false' directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoqemu_capabilities: replace code with function call
Kristina Hanicova [Tue, 2 Aug 2022 15:50:13 +0000 (17:50 +0200)]
qemu_capabilities: replace code with function call

Since functions virQEMUCapsFillDomainFeatureSEVCaps() and
virQEMUCapsSEVInfoCopy() essentially do the same thing it does
not make sense to have the code duplicated. This patch replaces
the relevant code in the first function with the function call to
the second one.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agovirfile: Fix build with glibc 2.36
Cole Robinson [Mon, 1 Aug 2022 19:24:01 +0000 (15:24 -0400)]
virfile: Fix build with glibc 2.36

With glibc 2.36, sys/mount.h and linux/mount.h conflict:
https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E

virfile.c imports sys/mount.h and linux/fs.h, which pulls in
linux/mount.h.

Manually define the constants we need from linux/fs.h, like was
done in llvm:

https://reviews.llvm.org/rGb379129c4beb3f26223288627a1291739f33af02

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2 years agolxc: containter: fix build with glibc 2.36
Cole Robinson [Mon, 1 Aug 2022 19:20:38 +0000 (15:20 -0400)]
lxc: containter: fix build with glibc 2.36

With glibc 2.36, sys/mount.h and linux/mount.h conflict:
https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E

lxc_container.c imports sys/mount.h and linux/fs.h, which pulls in
linux/mount.h.

linux/fs.h isn't required here though. glibc sys/mount.h has had
MS_MOVE since 2.12 in 2010

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2 years agoCH: use virDomainObjResetJob()
Kristina Hanicova [Fri, 22 Jul 2022 14:25:34 +0000 (16:25 +0200)]
CH: use virDomainObjResetJob()

This patch removes and replaces virCHDomainObjResetJob() with
general virDomainObjResetJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoLXC: use virDomainObjResetJob()
Kristina Hanicova [Fri, 22 Jul 2022 14:25:33 +0000 (16:25 +0200)]
LXC: use virDomainObjResetJob()

This patch removes and replaces virLXCDomainObjResetJob() with
general virDomainObjResetJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agolibxl: use virDomainObjResetJob()
Kristina Hanicova [Fri, 22 Jul 2022 14:25:32 +0000 (16:25 +0200)]
libxl: use virDomainObjResetJob()

This patch removes and replaces libxlDomainObjResetJob() with
general virDomainObjResetJob().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agoqemu & hypervisor: move qemuDomainObjResetJob() into hypervisor
Kristina Hanicova [Fri, 22 Jul 2022 14:25:31 +0000 (16:25 +0200)]
qemu & hypervisor: move qemuDomainObjResetJob() into hypervisor

This patch moves qemuDomainObjResetJob() as
virDomainObjResetJob() into hypervisor in order to be used by
other hypervisors as well.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2 years agotpm: Refactor open-coded bitmap 'activePcrBanks' to virBitmap
Peter Krempa [Mon, 1 Aug 2022 11:52:47 +0000 (13:52 +0200)]
tpm: Refactor open-coded bitmap 'activePcrBanks' to virBitmap

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agotestutilsqemu: Mock virTPMSwtpmSetupCapsGet()
Michal Privoznik [Wed, 20 Jul 2022 07:11:38 +0000 (09:11 +0200)]
testutilsqemu: Mock virTPMSwtpmSetupCapsGet()

In a recent commit of v8.5.0-85-g430ab88ab1 I've made domaincaps
XML report supported TPM versions. This was done by calling
virTPMSwtpmSetupCapsGet(). But this function isn't mocked and
thus domaincapstest calls the real implementation, which tries to
execute swtpm_setup binary. This fails, because
virFindFileInPath() is mocked in such way that it returns NULL
for anything else than qemu-*.

Anyway, while the real binary is not executed after all, we
should mock the function which tries to execute it so that
predictable result is returned.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agovirtpm: Use corresponding type for argument for virTPM*CapsGet()
Michal Privoznik [Wed, 20 Jul 2022 07:11:31 +0000 (09:11 +0200)]
virtpm: Use corresponding type for argument for virTPM*CapsGet()

In virtpm.h there are two functions exposed for querying swtpm
and swtpm_setup capabilities: virTPMSwtpmCapsGet() and
virTPMSwtpmSetupCapsGet(), respectively. The capabilities we are
interested in are defined in two separate enums
(virTPMSwtpmFeature and virTPMSwtpmSetupFeature), but these
functions accept capability as an unsigned int rather than their
respective enum. While this makes sense for
virTPMBinaryGetCaps(), which is a module internal helper that
both exposed functions call, there's no need for the functions
themselves to accept unsigned int.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agospec: Remove duplicate check of libvirtd status
Jim Fehlig [Tue, 19 Jul 2022 23:10:01 +0000 (17:10 -0600)]
spec: Remove duplicate check of libvirtd status

The %posttrans scriptlet checks if libvirtd is active within a
condition that is only executed if libvirtd is active. Remove the
duplicate check.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: Don't lose <active_pcr_banks/> when no TPM version is provided
Michal Privoznik [Fri, 15 Jul 2022 16:04:30 +0000 (18:04 +0200)]
conf: Don't lose <active_pcr_banks/> when no TPM version is provided

When no TPM version is provided in the input XML we may default
to version 2.0 (see qemuDomainTPMDefPostParse()). However,
<active_pcr_banks/> are parsed iff a version 2.0 was specified.
This means that this piece of information might be lost.

It's better to parse everything we've been given and then
validate that the configuration is valid.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2084046
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: Move TPMs validation out of PostParse
Michal Privoznik [Mon, 18 Jul 2022 07:32:19 +0000 (09:32 +0200)]
qemu: Move TPMs validation out of PostParse

After previous cleanup, the qemuDomainDefTPMsPostParse() function
does nothing more than validates TPM devices. Therefore, it
should live in qemu_validate.c instead of qemu_domain.c. Move it
there and rename to reflect the fact that the function is doing
validation instead of PostParsing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_domain: Move TPM post parse code into qemuDomainTPMDefPostParse()
Michal Privoznik [Mon, 18 Jul 2022 07:10:12 +0000 (09:10 +0200)]
qemu_domain: Move TPM post parse code into qemuDomainTPMDefPostParse()

In the qemuDomainDefPostParse() we aim to fill in top level
values, which require overall view of domain, or those parts of
configuration that are not a device in domain XML (e.g. vCPUs).
However, inside of qemuDomainDefTPMsPostParse(), which is called
from aforementioned function, we do two tings:

  1) fill in missing info (TPM version), and
  2) validate TPM definition.

Now, if 1) is moved into qemuDomainTPMDefPostParse() (the device
post parse callback), then 2) can be moved into validation step.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoconf: Use virXMLPropEnum more when parsing TPM
Michal Privoznik [Mon, 18 Jul 2022 07:00:40 +0000 (09:00 +0200)]
conf: Use virXMLPropEnum more when parsing TPM

When parsing a TPM device plenty of virXMLPropString() +
enum2int() combos are used. These can be replaced with
virXMLPropEnum().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoconf: Move _virDomainTPMDef::version into _virDomainTPMDef::data::emulator
Michal Privoznik [Fri, 15 Jul 2022 16:04:21 +0000 (18:04 +0200)]
conf: Move _virDomainTPMDef::version into _virDomainTPMDef::data::emulator

The _virDomainTPMDef structure has 'version' member, which is a
bit misplaced. It's only emulator type of TPM that can have a
version, even our documentation says so:

``version``
   The ``version`` attribute indicates the version of the TPM. This attribute
   only works with the ``emulator`` backend. The following versions are
   supported:

Therefore, move the member into that part of union that's
covering emulated TPM devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoconf: Drop needless setting of VIR_DOMAIN_TPM_VERSION_DEFAULT
Michal Privoznik [Mon, 18 Jul 2022 07:58:38 +0000 (09:58 +0200)]
conf: Drop needless setting of VIR_DOMAIN_TPM_VERSION_DEFAULT

In previous commit the VIR_DOMAIN_TPM_VERSION_DEFAULT value was
made just an alias to value of 0. And since all newly allocated
memory is zeroed out (due to use of g_new0()), the def->version
inside of virDomainTPMDefParseXML() is also 0 and thus there is
no need to set it explicitly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoconf: Report error when default TPM version is provided
Michal Privoznik [Mon, 18 Jul 2022 07:55:08 +0000 (09:55 +0200)]
conf: Report error when default TPM version is provided

When "default" version of TPM was provided, our parses accepts it
happily even though the value is forbidden by our RNG and not
documented as accepted value. This is because of < 0 vs <= 0
comparison of virDomainTPMModelTypeFromString() retval.

Make the parser error out explicitly in this case. Users can
always chose to not specify the attribute in which case we pick a
sane default (in qemuDomainDefTPMsPostParse()).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoconf: Report an error when default TPM model is provided
Michal Privoznik [Mon, 18 Jul 2022 07:11:19 +0000 (09:11 +0200)]
conf: Report an error when default TPM model is provided

When "default" model of a TPM was provided, our parses accepts it
happily even though the value is forbidden by our RNG and not
documented as accepted value. This is because of < 0 vs <= 0
comparison of virDomainTPMModelTypeFromString() retval.

Make the parser error out explicitly in this case. Users can
always chose to not specify the attribute in which case we pick a
sane default (in qemuDomainTPMDefPostParse()).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_cgroup: Don't ignore ENOENT in qemuCgroupAllowDevicesPaths()
Michal Privoznik [Wed, 27 Jul 2022 08:31:03 +0000 (10:31 +0200)]
qemu_cgroup: Don't ignore ENOENT in qemuCgroupAllowDevicesPaths()

There's no need to skip over ENOENT error in
qemuCgroupAllowDevicesPaths(). The path must exists when
qemuCgroupAllowDevicePath() is called because of virFileExists()
check done right above.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_command: Separate domain memory building into a helper
Michal Privoznik [Tue, 26 Jul 2022 13:53:07 +0000 (15:53 +0200)]
qemu_command: Separate domain memory building into a helper

The qemuBuildMachineCommandLine() function is needlessly long.
Separate out parts that generate memory related arguments into
qemuAppendDomainMemoryMachineParams(). Unfortunately, expected
outputs for some qemuxml2argvdata cases needed to be updated
because the order in which arguments are generated is changed.
But there's no functional change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu_command: Separate domain features building into a helper
Michal Privoznik [Tue, 26 Jul 2022 13:45:08 +0000 (15:45 +0200)]
qemu_command: Separate domain features building into a helper

The qemuBuildMachineCommandLine() function is needlessly long.
Separate out parts that generate arguments based on
domainDef->features[] into
qemuAppendDomainFeaturesMachineParam(). Unfortunately, expected
outputs for some qemuxml2argvdata cases needed to be updated
because the order in which features are generated is changed. But
there's no functional change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoconf: Validate virDomainMemoryDef::targetNode
Michal Privoznik [Tue, 26 Jul 2022 17:27:06 +0000 (19:27 +0200)]
conf: Validate virDomainMemoryDef::targetNode

Almost all of memory models we currently support allow setting
virDomainMemoryDef::targetNode so that the memory module is
associated with given guest NUMA node. And we do have a check
whether the requested node is within bounds, but it's executed
only when building QEMU's cmd line. Move it into validation
phase.

While this commit is moving the validation to a place that does
not validate all the possible code paths, it's okay, because only
the explicit memory device has user-configurable target node
which could break the assumption.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemuxml2xmltest: Test memory-hotplug-dimm-addr
Michal Privoznik [Tue, 26 Jul 2022 17:26:52 +0000 (19:26 +0200)]
qemuxml2xmltest: Test memory-hotplug-dimm-addr

After previous commit, when memory-hotplug-dimm-addr.xml file was
fixed, we can also introduce the test case to qemuxml2xmltest.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemuxml2argvtest: Switch memory-hotplug-dimm-addr to latest caps
Michal Privoznik [Tue, 26 Jul 2022 17:42:33 +0000 (19:42 +0200)]
qemuxml2argvtest: Switch memory-hotplug-dimm-addr to latest caps

So far, we are testing memory-hotplug-dimm-addr against a set of
explicitly listed capabilities. While this works, lets switch it
to DO_TEST_CAPS_LATEST() so that the latest capabilities are
used. This in turn means, we have to update the <emulator/>
because the latest capabilities don't contain caps for
qemu-system-i386.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agovirjson: Change virJSONValueObjectHasKey() signature
Michal Privoznik [Thu, 28 Jul 2022 10:36:19 +0000 (12:36 +0200)]
virjson: Change virJSONValueObjectHasKey() signature

Currently, virJSONValueObjectHasKey() can return one of three
values:

  -1 if passed object type is not VIR_JSON_TYPE_OBJECT,
   0 if the key is not present, and finally
   1 if the key is present.

But, neither of callers is interested in the -1 case. In fact,
some callers call this function treating -1 and 1 cases the same.
Therefore, make the function return just true/false and fix few
callers that explicitly checked for == 1 case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoPost-release version bump to 8.7.0
Jiri Denemark [Mon, 1 Aug 2022 07:39:36 +0000 (09:39 +0200)]
Post-release version bump to 8.7.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoRelease of libvirt-8.6.0
Jiri Denemark [Mon, 1 Aug 2022 07:25:44 +0000 (09:25 +0200)]
Release of libvirt-8.6.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoqemu_migration_params: Avoid deadlock in qemuMigrationParamsReset
Jiri Denemark [Thu, 28 Jul 2022 13:35:45 +0000 (15:35 +0200)]
qemu_migration_params: Avoid deadlock in qemuMigrationParamsReset

In my recent comnmit v8.5.0-188-gc47f1abb81 I accidentally moved
qemuMigrationParamsResetTLS after qemuDomainObjEnterMonitorAsync not
noticing qemuMigrationParamsResetTLS will try to enter the monitor
again. The second call will time out and return with a domain object
locked. But we're still in monitor section and the object should be
unlocked which means qemuDomainObjExitMonitor will deadlock trying to
lock it again.

Fixes: c47f1abb81194461377a0c608a7ecd87f9ce9146
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: don't call qemuMigrationSrcIsAllowedHostdev() from qemuMigrationDstPrepareFresh()
Laine Stump [Wed, 27 Jul 2022 16:14:10 +0000 (12:14 -0400)]
qemu: don't call qemuMigrationSrcIsAllowedHostdev() from qemuMigrationDstPrepareFresh()

This call to qemuMigrationSrcIsAllowedHostdev() (which does a
hardcoded fail of the migration if there is any PCI or mdev hostdev
device in the domain) while doing the destination side of migration
prep was found once the call to that same function was removed from
the source side migration prep (commit 25883cd5).

According to jdenemar, for the V2 migration protocol, prep of the
destination is the first step, so this *was* the proper place to do
the check, but for V3 migration this is in a way redundant (since we
will have already done the check on the source side (updated by
25883cd5 to query QEMU rather than do a hardcoded fail)).

Of course it's possible that the source could support migration of a
particular VFIO device, but the destination doesn't. But the current
check on the destination side is worthless even in that case, since it
is just *always* failing rather than querying QEMU; and QEMU can't be
queried at the point where the destination check is happening, since
it isn't yet running.

Anyway QEMU should complain when it's started if it's going to fail,
so removing this check should just move the failure to happen a bit
later. So the best solution to this problem is to simply remove the
hardcoded check/fail from qemuMigrationDstPrepareFresh() and rely on
QEMU to fail if it needs to.

Fixes: 25883cd5f0b188f2417f294b7d219a77b219f7c2
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Thu, 28 Jul 2022 00:20:33 +0000 (02:20 +0200)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10480 of 10480 strings)

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

Co-authored-by: Yuri Chornoivan <yurchor@ukr.net>
Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>