]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 months agovmx: Do not require all ID data for VMWare Distributed Switch
Martin Kletzander [Mon, 8 Jul 2024 11:04:13 +0000 (13:04 +0200)]
vmx: Do not require all ID data for VMWare Distributed Switch

Similarly to commit 2482801608b8 we can safely ignore connectionId,
portId and portgroupId in both XML and VMX as they are only a blind
pass-through between XML and VMX and an ethernet without such parameters
was spotted in the wild.  On top of that even our documentation says the
whole VMWare Distrubuted Switch configuration is a best-effort.

Resolves: https://issues.redhat.com/browse/RHEL-46099

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
9 months agovirt-aa-helper: Allow RO access to /usr/share/edk2-ovmf
Michal Privoznik [Thu, 4 Jul 2024 11:07:47 +0000 (13:07 +0200)]
virt-aa-helper: Allow RO access to /usr/share/edk2-ovmf

When binary version of edk2 is distributed, the files reside
under /usr/share/edk2-ovmf as can be seen from Gentoo's ebuild
[1]. Allow virt-aa-helper to generate paths under that dir.

1: https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-firmware/edk2-ovmf-bin/edk2-ovmf-bin-202202.ebuild
Resolves: https://bugs.gentoo.org/911786
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
9 months agodocs: Drop trailing blank in formatdomain.rst
Michal Privoznik [Sun, 7 Jul 2024 05:23:49 +0000 (07:23 +0200)]
docs: Drop trailing blank in formatdomain.rst

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemu: set swtpm log level parameter
Daniel P. Berrangé [Thu, 4 Jul 2024 11:24:08 +0000 (12:24 +0100)]
qemu: set swtpm log level parameter

This wires up the emulator 'debug' parameter to control the
/usr/bin/swtpm 'level' parameter for logging.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoconf: add support for 'debug' parameter on TPM emulator
Daniel P. Berrangé [Thu, 4 Jul 2024 11:08:55 +0000 (12:08 +0100)]
conf: add support for 'debug' parameter on TPM emulator

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agotest_driver: support VIR_DOMAIN_AFFECT_LIVE in testUpdateDeviceFlags()
John Levon [Thu, 4 Jul 2024 12:59:46 +0000 (13:59 +0100)]
test_driver: support VIR_DOMAIN_AFFECT_LIVE in testUpdateDeviceFlags()

Pick up some more of the qemu_driver.c code so this function supports
both CONFIG and LIVE updates.

Note that qemuDomainUpdateDeviceFlags() passed vm->def to
virDomainDeviceDefParse() for the VIR_DOMAIN_AFFECT_CONFIG case, which
is technically incorrect; in the test driver code we'll fix this.

Signed-off-by: John Levon <john.levon@nutanix.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoconf: Fix out-of-bounds write during cleanup of virDomainNumaDefNodeDistanceParseXML
Rayhan Faizel [Thu, 4 Jul 2024 09:52:07 +0000 (15:22 +0530)]
conf: Fix out-of-bounds write during cleanup of virDomainNumaDefNodeDistanceParseXML

mem_nodes[i].ndistances is written outside the loop causing an out-of-bounds
write leading to heap corruption.

While we are at it, the entire cleanup portion can be removed as it can be
handled in virDomainNumaFree. One instance of VIR_FREE is also removed and
replaced with g_autofree.

This patch also adds a testcase which would be picked up by ASAN, if this
portion regresses.

Fixes: 742494eed8dbdde8b1d05a306032334e6226beea
Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agotests: Move domainEventState initialization to qemuTestDriverInit
Rayhan Faizel [Wed, 3 Jul 2024 21:40:13 +0000 (03:10 +0530)]
tests: Move domainEventState initialization to qemuTestDriverInit

Under the test environment, driver->domainEventState is uninitialized. If a
disk gets dropped, it will attempt to queue an event which will cause a
segmentation fault. This crash does not occur during normal use.

This patch moves driver->domainEventState initialization from qemuhotplugtest
to qemuTestDriverInit in testutilsqemu (Credit goes to Michal Privoznik as he
had already provided the diff).

An additional test case is added to test dropping of disks with startupPolicy
set as optional.

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agocpu_map: Ignore feature "kvm-asyncpf-vmexit"
Tim Wiederhake [Fri, 21 Jun 2024 12:20:39 +0000 (14:20 +0200)]
cpu_map: Ignore feature "kvm-asyncpf-vmexit"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agocpu_map: Add missing feature "vmx-nested-exception"
Tim Wiederhake [Fri, 21 Jun 2024 12:10:00 +0000 (14:10 +0200)]
cpu_map: Add missing feature "vmx-nested-exception"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agocpu_map: Add missing feature "rfds-clear"
Tim Wiederhake [Fri, 21 Jun 2024 12:09:49 +0000 (14:09 +0200)]
cpu_map: Add missing feature "rfds-clear"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agocpu_map: Add missing feature "rfds-no"
Tim Wiederhake [Fri, 21 Jun 2024 12:09:37 +0000 (14:09 +0200)]
cpu_map: Add missing feature "rfds-no"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agocpu_map: Add missing feature "succor"
Tim Wiederhake [Fri, 21 Jun 2024 12:09:11 +0000 (14:09 +0200)]
cpu_map: Add missing feature "succor"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agocpu_map: Add missing feature "overflow-recov"
Tim Wiederhake [Fri, 21 Jun 2024 12:08:56 +0000 (14:08 +0200)]
cpu_map: Add missing feature "overflow-recov"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agocpu_map: Add missing feature "lam"
Tim Wiederhake [Fri, 21 Jun 2024 12:08:09 +0000 (14:08 +0200)]
cpu_map: Add missing feature "lam"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agocpu_map: Add missing feature "wrmsrns"
Tim Wiederhake [Fri, 21 Jun 2024 12:08:01 +0000 (14:08 +0200)]
cpu_map: Add missing feature "wrmsrns"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agocpu_map: Add missing feature "lkgs"
Tim Wiederhake [Fri, 21 Jun 2024 12:07:42 +0000 (14:07 +0200)]
cpu_map: Add missing feature "lkgs"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agocpu_map: Add missing feature "fred"
Tim Wiederhake [Fri, 21 Jun 2024 12:07:23 +0000 (14:07 +0200)]
cpu_map: Add missing feature "fred"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoTranslated using Weblate (English (United Kingdom))
Andi Chandler [Tue, 2 Jul 2024 19:36:11 +0000 (21:36 +0200)]
Translated using Weblate (English (United Kingdom))

Currently translated at 47.7% (5015 of 10497 strings)

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

Co-authored-by: Andi Chandler <andi@gowling.com>
Signed-off-by: Andi Chandler <andi@gowling.com>
10 months agoqemuDomainChangeNet: forbid changing portgroup
Adam Julis [Mon, 1 Jul 2024 11:17:22 +0000 (13:17 +0200)]
qemuDomainChangeNet: forbid changing portgroup

Changing the postgroup attribute caused unexpected behavior.
Although it can be implemented, it has a non-trivial solution.
No requirement or use has yet been found for implementing this
feature, so it has been disabled for hot-plug.

Resolves: https://issues.redhat.com/browse/RHEL-7299
Signed-off-by: Adam Julis <ajulis@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoconf: Fix rawio/sgio checks for non-scsi hostdev devices
Rayhan Faizel [Tue, 2 Jul 2024 14:57:13 +0000 (20:27 +0530)]
conf: Fix rawio/sgio checks for non-scsi hostdev devices

The current hostdev parsing logic sets rawio or sgio even if the hostdev type
is not 'scsi'. The rawio field in virDomainHostdevSubsysSCSI overlaps with
wwpn field in virDomainHostdevSubsysSCSIVHost, consequently setting a bogus
pointer value such as 0x1 or 0x2 from virDomainHostdevSubsysSCSIVHost's
point of view. This leads to a segmentation fault when it attempts to free
wwpn.

While setting sgio does not appear to crash, it shares the same flawed logic
as setting rawio.

Instead, we ensure these are set only after the hostdev type check succeeds.
This patch also adds two test cases to exercise both scenarios.

Fixes: bdb95b520c53f9bacc6504fc51381bac4813be38
Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agotest_driver: add testUpdateDeviceFlags implementation
John Levon [Mon, 1 Jul 2024 20:29:55 +0000 (21:29 +0100)]
test_driver: add testUpdateDeviceFlags implementation

Add basic coverage of device update; for now, only support disk updates
until other types are needed or tested.

Signed-off-by: John Levon <john.levon@nutanix.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemu: Drop _virQEMUDriver::hostFips
Michal Privoznik [Thu, 27 Jun 2024 15:01:17 +0000 (17:01 +0200)]
qemu: Drop _virQEMUDriver::hostFips

The 'hostFips' member of _virQEMUDriver struct is not used
really, due to previous cleanups. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoqemu_capabilities: Retire QEMU_CAPS_VXHS
Michal Privoznik [Thu, 27 Jun 2024 14:57:13 +0000 (16:57 +0200)]
qemu_capabilities: Retire QEMU_CAPS_VXHS

The support for VXHS device was removed in QEMU commit
v5.1.0-rc1~16^2~10. Since we require QEMU-5.2.0 at least there's
no QEMU that has the device and thus the corresponding capability
can be retired.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoqemu_capabilities: Retire QEMU_CAPS_ENABLE_FIPS
Michal Privoznik [Thu, 27 Jun 2024 15:00:08 +0000 (17:00 +0200)]
qemu_capabilities: Retire QEMU_CAPS_ENABLE_FIPS

The capability is no longer used. Retire it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoqemu_capabilities: Drop version check for QEMU_CAPS_ENABLE_FIPS and QEMU_CAPS_NETDEV_USER
Michal Privoznik [Thu, 27 Jun 2024 14:15:03 +0000 (16:15 +0200)]
qemu_capabilities: Drop version check for QEMU_CAPS_ENABLE_FIPS and QEMU_CAPS_NETDEV_USER

Now that the minimal required version of QEMU is 5.2.0 the
conditional setting of QEMU_CAPS_ENABLE_FIPS and
QEMU_CAPS_NETDEV_USER is effectively a dead code. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoqemu_capabilities: Require QEMU-5.2.0 or newer
Michal Privoznik [Thu, 27 Jun 2024 13:39:33 +0000 (15:39 +0200)]
qemu_capabilities: Require QEMU-5.2.0 or newer

According to repology.org and/or distro repos these are the version of QEMU:

     CentOS Stream 9: qemu-kvm-9.0.0
           Debian 11: qemu-5.2.0
           Fedora 39: qemu-8.3.1
  openSUSE Leap 15.3: qemu-5.2.0
              RHEL-8: qemu-6.2.0
        Ubuntu 22.04: qemu-6.2.0

Since the minimal version is 5.2.0 we can bump from 4.2.0 to
5.2.0.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemucapabilitiesdata: Drop tests relying on <qemu-5.2.0
Michal Privoznik [Fri, 28 Jun 2024 12:25:04 +0000 (14:25 +0200)]
qemucapabilitiesdata: Drop tests relying on <qemu-5.2.0

Soon, the minimal version of QEMU is going to be bumped to 5.2.0.
Drop capabilities for older versions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoqemuxmlconfdata: Drop tests relying on <qemu-5.2.0
Michal Privoznik [Thu, 27 Jun 2024 14:29:53 +0000 (16:29 +0200)]
qemuxmlconfdata: Drop tests relying on <qemu-5.2.0

Soon, the minimal version of QEMU is going to be bumped to 5.2.0.
Drop test cases that require older version.

NB, iothreads-disk-virtio-ccw test is removed completely as we
already have plenty of other tests covering the same code paths.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoqemusecuritytest: drop disk-network-tlsx509-vxhs test case
Michal Privoznik [Thu, 27 Jun 2024 14:53:16 +0000 (16:53 +0200)]
qemusecuritytest: drop disk-network-tlsx509-vxhs test case

The disk-network-tlsx509-vxhs.xml file will be removed soon. Drop
the test case in qemusecuritytest that relies on it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoqemucapabilitiestest: Add 'qemu_9.0.0.sparc' capabilities from TCG
Peter Krempa [Mon, 1 Jul 2024 12:14:50 +0000 (14:14 +0200)]
qemucapabilitiestest: Add 'qemu_9.0.0.sparc' capabilities from TCG

As I don't have a sparc machine handy add emulated capabilities.

This patch is in preparation for bumping minimum qemu version beyond the
oldest 'sparc' caps we currently have.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemu_domain: Set 'passt' net backend if 'default' is unsupported
Michal Privoznik [Fri, 28 Jun 2024 07:56:46 +0000 (09:56 +0200)]
qemu_domain: Set 'passt' net backend if 'default' is unsupported

It may happen that QEMU is compiled without SLIRP but with
support for passt. In such case it is acceptable to alter user
provided configuration and switch backend to passt as it offers
all the features as SLIRP.

Resolves: https://issues.redhat.com/browse/RHEL-45518
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoqemu_validate: Use domaincaps to validate supported net backend type
Michal Privoznik [Fri, 28 Jun 2024 07:53:10 +0000 (09:53 +0200)]
qemu_validate: Use domaincaps to validate supported net backend type

Now that the logic for detecting supported net backend types has
been moved to domain capabilities generation, we can just use it
when validating net backend type. Just like we do for device
models and so on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoconf: Accept 'default' backend type for <interface type='user'/>
Michal Privoznik [Fri, 28 Jun 2024 07:36:24 +0000 (09:36 +0200)]
conf: Accept 'default' backend type for <interface type='user'/>

After previous commits, domain capabilities XML reports basically
two possible values for backend type: 'default' and 'passt'.
Despite its misleading name, 'default' really means 'use
hypervisor's builtin SLIRP'. Since it's reported in domain
capabilities as a value accepted, make our parser and XML schema
accept it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoqemu_capabilities: Fill supported net backend types
Michal Privoznik [Thu, 27 Jun 2024 08:31:45 +0000 (10:31 +0200)]
qemu_capabilities: Fill supported net backend types

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agodomain_capabilities: Introduce netdev capabilities
Michal Privoznik [Thu, 27 Jun 2024 07:42:38 +0000 (09:42 +0200)]
domain_capabilities: Introduce netdev capabilities

If mgmt apps on top of libvirt want to make a decision on the
backend type for <interface type='user'/> (e.g. whether past is
supported) we currently offer them no way to learn this fact.
Domain capabilities were invented exactly for this reason. Report
supported net backend types there.

Now, because of backwards compatibility, specifying no backend
type (which translates to VIR_DOMAIN_NET_BACKEND_DEFAULT) means
"use hyperviosr's builtin SLIRP". That behaviour can not be
changed. But it may happen that the hypervisor has no support for
SLIRP. So we have to report it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoqemu_validate: Validate net backends against QEMU caps
Michal Privoznik [Thu, 27 Jun 2024 12:09:52 +0000 (14:09 +0200)]
qemu_validate: Validate net backends against QEMU caps

Now that we have a capability for each domain net backend we can
start validating user's selection against QEMU capabilities.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoqemu_capabilities: Introduce QEMU_CAPS_NETDEV_USER
Michal Privoznik [Thu, 27 Jun 2024 08:45:31 +0000 (10:45 +0200)]
qemu_capabilities: Introduce QEMU_CAPS_NETDEV_USER

Since -netdev user can be disabled during QEMU compilation, we
can't blindly expect it to just be there. We need a capability
that tracks its presence.

For qemu-4.2.0 we are not able to detect the capability so do the
next best thing - assume the capability is there. This is
consistent with our current behaviour where we blindly assume the
capability, anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agolibvirt_private.syms: Export virDomainNetBackendType enum handlers
Michal Privoznik [Thu, 27 Jun 2024 12:10:32 +0000 (14:10 +0200)]
libvirt_private.syms: Export virDomainNetBackendType enum handlers

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoPost-release version bump to 10.6.0
Jiri Denemark [Mon, 1 Jul 2024 09:13:02 +0000 (11:13 +0200)]
Post-release version bump to 10.6.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoRelease of libvirt-10.5.0
Jiri Denemark [Mon, 1 Jul 2024 08:57:44 +0000 (10:57 +0200)]
Release of libvirt-10.5.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoTranslated using Weblate (Korean)
김인수 [Sun, 30 Jun 2024 20:36:10 +0000 (22:36 +0200)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10497 of 10497 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>
10 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sun, 30 Jun 2024 20:36:09 +0000 (22:36 +0200)]
Translated using Weblate (Swedish)

Currently translated at 77.8% (8185 of 10516 strings)

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

Translated using Weblate (Swedish)

Currently translated at 77.4% (8145 of 10516 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>
10 months agovircgroup: fix g_variant_new_parsed format string causing abort
Pavel Hrdina [Thu, 27 Jun 2024 16:05:18 +0000 (18:05 +0200)]
vircgroup: fix g_variant_new_parsed format string causing abort

The original code was incorrect and never tested because at the time of
implementing it the cgroup file `io.weight` was not available.

Resolves: https://issues.redhat.com/browse/RHEL-45185
Introduced-by: 9c1693eff427661616ce1bd2795688f87288a412
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoNEWS: Mention crash when VM shuts down during migration
Peter Krempa [Fri, 28 Jun 2024 12:52:31 +0000 (14:52 +0200)]
NEWS: Mention crash when VM shuts down during migration

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoNEWS: Mention migration fix with disabled vmx-* CPU features
Jiri Denemark [Fri, 28 Jun 2024 11:38:21 +0000 (13:38 +0200)]
NEWS: Mention migration fix with disabled vmx-* CPU features

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoNEWS: Document features/improvements/bug fixes I've participated in
Michal Privoznik [Fri, 28 Jun 2024 08:49:23 +0000 (10:49 +0200)]
NEWS: Document features/improvements/bug fixes I've participated in

There are some features/improvements/bug fixes I've either
contributed or reviewed/merged. Document them for upcoming
release.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoqemu: fix switchover-ack regression for old qemu
Jon Kohler [Thu, 27 Jun 2024 18:11:56 +0000 (11:11 -0700)]
qemu: fix switchover-ack regression for old qemu

When enabling switchover-ack on qemu from libvirt, the .party value
was set to both source and target; however, qemuMigrationParamsCheck()
only takes that into account to validate that the remote side of the
migration supports the flag if it is marked optional or auto/always on.

In the case of switchover-ack, when enabled on only the dst and not
the src, the migration will fail if the src qemu does not support
switchover-ack, as the dst qemu will issue a switchover-ack msg:
qemu/migration/savevm.c ->
  loadvm_process_command ->
    migrate_send_rp_switchover_ack(mis) ->
      migrate_send_rp_message(mis, MIG_RP_MSG_SWITCHOVER_ACK, 0, NULL)

Since the src qemu doesn't understand messages with header_type ==
MIG_RP_MSG_SWITCHOVER_ACK, qemu will kill the migration with error:
  qemu-kvm: RP: Received invalid message 0x0007 length 0x0000
  qemu-kvm: Unable to write to socket: Bad file descriptor

Looking at the original commit [1] for optional migration capabilities,
it seems that the spirit of optional handling was to enhance a given
existing capability where possible. Given that switchover-ack
exclusively depends on return-path, adding it as optional to that cap
feels right.

[1] 61e34b08568 ("qemu: Add support for optional migration capabilities")

Fixes: 1cc7737f69e ("qemu: add support for qemu switchover-ack")
Signed-off-by: Jon Kohler <jon@nutanix.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Avihai Horon <avihaih@nvidia.com>
Cc: Jiri Denemark <jdenemar@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: YangHang Liu <yanghliu@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Fri, 28 Jun 2024 02:43:04 +0000 (04:43 +0200)]
Translated using Weblate (Swedish)

Currently translated at 77.2% (8125 of 10516 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>
10 months agoremote_daemon_dispatch: Unref sasl session when closing client connection
Michal Privoznik [Fri, 14 Jun 2024 11:18:25 +0000 (13:18 +0200)]
remote_daemon_dispatch: Unref sasl session when closing client connection

In ideal world, where clients close connection gracefully their
SASL session is freed in virNetServerClientDispose() as it's
stored in client->sasl. Unfortunately, if client connection is
closed prematurely (e.g. the moment virsh asks for credentials),
the _virNetServerClient member is never set and corresponding
SASL session is never freed. The handler is still stored in
client private data, so free it in remoteClientCloseFunc().

  20,862 (288 direct, 20,574 indirect) bytes in 3 blocks are definitely lost in loss record 1,763 of 1,772
     at 0x50390C4: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.7800.6)
     by 0x501BDAF: g_object_new_internal.part.0 (in /usr/lib64/libgobject-2.0.so.0.7800.6)
     by 0x501D43D: g_object_new_with_properties (in /usr/lib64/libgobject-2.0.so.0.7800.6)
     by 0x501E318: g_object_new (in /usr/lib64/libgobject-2.0.so.0.7800.6)
     by 0x49BAA63: virObjectNew (virobject.c:252)
     by 0x49BABC6: virObjectLockableNew (virobject.c:274)
     by 0x4B0526C: virNetSASLSessionNewServer (virnetsaslcontext.c:230)
     by 0x18EEFC: remoteDispatchAuthSaslInit (remote_daemon_dispatch.c:3696)
     by 0x15E128: remoteDispatchAuthSaslInitHelper (remote_daemon_dispatch_stubs.h:74)
     by 0x4B0FA5E: virNetServerProgramDispatchCall (virnetserverprogram.c:423)
     by 0x4B0F591: virNetServerProgramDispatch (virnetserverprogram.c:299)
     by 0x4B18AE3: virNetServerProcessMsg (virnetserver.c:135)

Resolves: https://issues.redhat.com/browse/RHEL-22574
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Thu, 27 Jun 2024 09:36:18 +0000 (11:36 +0200)]
Translated using Weblate (Swedish)

Currently translated at 77.0% (8086 of 10497 strings)

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

Translated using Weblate (Swedish)

Currently translated at 77.3% (8082 of 10454 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>
10 months agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Thu, 27 Jun 2024 09:36:22 +0000 (11:36 +0200)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10497 of 10497 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>
10 months agoUpdate translation files
Weblate [Thu, 27 Jun 2024 09:36:21 +0000 (11:36 +0200)]
Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

Co-authored-by: Weblate <noreply@weblate.org>
Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
10 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Thu, 27 Jun 2024 09:36:18 +0000 (11:36 +0200)]
Translated using Weblate (Swedish)

Currently translated at 77.0% (8086 of 10497 strings)

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

Translated using Weblate (Swedish)

Currently translated at 77.3% (8082 of 10454 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>
10 months agopo: Refresh potfile for v10.5.0
Jiri Denemark [Tue, 25 Jun 2024 13:41:07 +0000 (15:41 +0200)]
po: Refresh potfile for v10.5.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 months agovirt-host-validate: Detect SEV-ES and SEV-SNP
Michal Privoznik [Mon, 24 Jun 2024 07:31:09 +0000 (09:31 +0200)]
virt-host-validate: Detect SEV-ES and SEV-SNP

With a simple cpuid (Section "E.4.17 Function
8000_001Fh—Encrypted Memory Capabilities" in "AMD64 Architecture
Programmer’s Manual Vol. 3") we can detect whether CPU is capable
of running SEV-ES and/or SEV-SNP guests. Report these in
virt-host-validate tool.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agovirt-host-validate: Move AMD SEV into a separate func
Michal Privoznik [Mon, 24 Jun 2024 07:22:16 +0000 (09:22 +0200)]
virt-host-validate: Move AMD SEV into a separate func

The code that validates AMD SEV is going to be expanded soon.
Move it into its own function to avoid lengthening
virHostValidateSecureGuests() where the code lives now, even
more.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemu_validate: Use domaincaps to validate supported launchSecurity type
Michal Privoznik [Tue, 25 Jun 2024 08:51:55 +0000 (10:51 +0200)]
qemu_validate: Use domaincaps to validate supported launchSecurity type

Now that the logic for detecting supported launchSecurity types
has been moved to domain capabilities generation, we can just use
it when validating launchSecurity type. Just like we do for
device models and so on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemu: Fill launchSecurity in domaincaps
Michal Privoznik [Tue, 25 Jun 2024 08:45:43 +0000 (10:45 +0200)]
qemu: Fill launchSecurity in domaincaps

The inspiration for these rules comes from
qemuValidateDomainDef().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agodomcaps: Report launchSecurity
Michal Privoznik [Tue, 25 Jun 2024 07:53:57 +0000 (09:53 +0200)]
domcaps: Report launchSecurity

In order to learn what types of <launchSecurity/> are supported
users can turn to domain capabilities and find <sev/> and
<s390-pv/> elements. While these may expose some additional info
on individual launchSecurity types, we are lacking clean
enumeration (like we do for say device models). And given that
SEV and SEV SNP share the same basis (info found under <sev/> is
applicable to SEV SNP too) we have no other way to report SEV SNP
support.

Therefore, report supported launchSecurity types in domain
capabilities.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemu_capabilities: Probe SEV capabilities even for QEMU_CAPS_SEV_SNP_GUEST
Michal Privoznik [Fri, 21 Jun 2024 12:00:32 +0000 (14:00 +0200)]
qemu_capabilities: Probe SEV capabilities even for QEMU_CAPS_SEV_SNP_GUEST

While it's very unlikely to have QEMU that supports SEV-SNP but
doesn't support plain SEV, for completeness sake we ought to
query SEV capabilities if QEMU supports either. And similarly to
QEMU_CAPS_SEV_GUEST we need to clear the capability if talking to
QEMU proves SEV is not really supported.

This in turn removes the 'sev-snp-guest' capability from one of
our test cases as Peter's machine he uses to refresh capabilities
is not SEV capable. But that's okay. It's consistent with
'sev-guest' capability.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemuxmlconftest; Explicitly enable QEMU_CAPS_SEV_SNP_GUEST for "launch-security-sev...
Michal Privoznik [Tue, 25 Jun 2024 07:58:43 +0000 (09:58 +0200)]
qemuxmlconftest; Explicitly enable QEMU_CAPS_SEV_SNP_GUEST for "launch-security-sev-snp"

Soon, QEMU_CAPS_SEV_SNP_GUEST is going to be dependant on more
than plain presence of "sev-snp-guest" object in QEMU. Explicitly
enable the capability for "launch-security-sev-snp" test so that
we can continue testing cmd line and xml2xml.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agolibvirt_private.syms: Export virDomainLaunchSecurity enum handlers
Michal Privoznik [Tue, 25 Jun 2024 08:52:55 +0000 (10:52 +0200)]
libvirt_private.syms: Export virDomainLaunchSecurity enum handlers

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemu_block: Validate number of hosts for iSCSI disk device
Rayhan Faizel [Thu, 6 Jun 2024 14:27:51 +0000 (19:57 +0530)]
qemu_block: Validate number of hosts for iSCSI disk device

An iSCSI device with zero hosts will result in a segmentation fault. This patch
adds a check for the number of hosts, which must be one in the case of iSCSI.

Minimal reproducing XML:

<domain type='qemu'>
    <name>MyGuest</name>
    <uuid>4dea22b3-1d52-d8f3-2516-782e98ab3fa0</uuid>
    <os>
        <type arch='x86_64'>hvm</type>
    </os>
    <memory>4096</memory>
    <devices>
        <disk type='network'>
            <source name='dummy' protocol='iscsi'/>
            <target dev='vda'/>
        </disk>
    </devices>
</domain>

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
10 months agoqemu: add support for qemu switchover-ack
Jon Kohler [Mon, 24 Jun 2024 17:38:51 +0000 (10:38 -0700)]
qemu: add support for qemu switchover-ack

Add plumbing for QEMU's switchover-ack migration capability, which
helps lower the downtime during VFIO migrations. This capability is
enabled by default as long as both the source and destination support
it.

Note: switchover-ack depends on the return path capability, so this may
not be used when VIR_MIGRATE_TUNNELLED flag is set.

Extensive details about the qemu switchover-ack implementation are
available in the qemu series v6 cover letter [1] where the highlight is
the extreme reduction in guest visible downtime. In addition to the
original test results below, I saw a roughly ~20% reduction in downtime
for VFIO VGPU devices at minimum.

  === Test results ===

  The below table shows the downtime of two identical migrations. In the
  first migration swithcover ack is disabled and in the second it is
  enabled. The migrated VM is assigned with a mlx5 VFIO device which has
  300MB of device data to be migrated.

  +----------------------+-----------------------+----------+
  |    Switchover ack    | VFIO device data size | Downtime |
  +----------------------+-----------------------+----------+
  |       Disabled       |         300MB         |  1900ms  |
  |       Enabled        |         300MB         |  420ms   |
  +----------------------+-----------------------+----------+

  Switchover ack gives a roughly 4.5 times improvement in downtime.
  The 1480ms difference is time that is used for resource allocation for
  the VFIO device in the destination. Without switchover ack, this time is
  spent when the source VM is stopped and thus the downtime is much
  higher. With switchover ack, the time is spent when the source VM is
  still running.

[1] https://patchwork.kernel.org/project/qemu-devel/cover/20230621111201.29729-1-avihaih@nvidia.com/

Signed-off-by: Jon Kohler <jon@nutanix.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Avihai Horon <avihaih@nvidia.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: YangHang Liu <yanghliu@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
10 months agoqemu: Fix migration with disabled vmx-* CPU features
Jiri Denemark [Wed, 12 Jun 2024 14:44:28 +0000 (16:44 +0200)]
qemu: Fix migration with disabled vmx-* CPU features

When starting a domain on a host which lacks a vmx-* CPU feature which
is expected to be enabled by the CPU model specified in the domain XML,
libvirt properly marks such feature as disabled in the active domain
XML. But migrating the domain to a similar host which lacks the same
vmx-* feature will fail with libvirt reporting the feature as missing.
This is because of a bug in the hack ensuring backward compatibility
libvirt running on the destination thinks the missing feature is
expected to be enabled.

https://issues.redhat.com/browse/RHEL-40899

Fixes: v10.1.0-85-g5fbfa5ab8a
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
10 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Mon, 24 Jun 2024 12:47:17 +0000 (14:47 +0200)]
Translated using Weblate (Swedish)

Currently translated at 77.1% (8062 of 10454 strings)

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

Translated using Weblate (Swedish)

Currently translated at 76.9% (8042 of 10454 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>
10 months agoqemu: Don't specify vfio-pci.ramfb when ramfb is false
Jonathon Jongsma [Wed, 12 Jun 2024 17:18:49 +0000 (12:18 -0500)]
qemu: Don't specify vfio-pci.ramfb when ramfb is false

Commit 7c8e606b64c73ca56d7134cb16d01257f39c53ef attempted to fix
the specification of the ramfb property for vfio-pci devices, but it
failed when ramfb is explicitly set to 'off'. This is because only the
'vfio-pci-nohotplug' device supports the 'ramfb' property. Since we use
the base 'vfio-pci' device unless ramfb is enabled, attempting to set
the 'ramfb' parameter to 'off' this will result in an error like the
following:

  error: internal error: QEMU unexpectedly closed the monitor
  (vm='rhel'): 2024-06-06T04:43:22.896795Z qemu-kvm: -device
  {"driver":"vfio-pci","host":"0000:b1:00.4","id":"hostdev0","display":"on
  ","ramfb":false,"bus":"pci.7","addr":"0x0"}: Property 'vfio-pci.ramfb'
  not found.

This also more closely matches what is done for mdev devices.

Resolves: https://issues.redhat.com/browse/RHEL-28808

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agonetwork: add more firewall test cases
Laine Stump [Fri, 21 Jun 2024 12:17:58 +0000 (08:17 -0400)]
network: add more firewall test cases

This patch adds some previously missing test cases that test for
proper firewall rule creation when the following are included in the
network definition:

* <forward dev='blah'>
* no forward element (an "isolated" network)
* nat port range when only ipv4 is nat-ed
* nat port range when both ipv4 & ipv6 are nated

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Laine Stump <laine@redhat.com>
10 months agotests: fix broken nftables test data so that individual tests are successful
Laine Stump [Wed, 12 Jun 2024 19:25:46 +0000 (15:25 -0400)]
tests: fix broken nftables test data so that individual tests are successful

When the chain names and table name used by the nftables firewall
backend were changed in commit
958aa7f274904eb8e4678a43eac845044f0dcc38, I forgot to change the test
data file base.nftables, which has the extra "list" and "add
chain/table" commands that are generated for the first test case of
networkxml2firewalltest.c. When the full set of tests is run, the
first test will be an iptables test case, so those extra commands
won't be added to any of the nftables cases, and so the data in
base.nftables never matches, and the tests are all successful.

However, if the test are limited with, e.g. VIR_TEST_RANGE=2 (test #2
will be the nftables version of the 1st test case), then the commands
to add nftables table/chains *will* be generated in the test output,
and so the test will fail. Because I was only running the entire test
series after the initial commits of nftables tests, I didn't notice
this. Until now.

base.nftables has now been updated to reflect the current names for
chains/table, and running individual test cases is once again
successful.

Fixes: 958aa7f274904eb8e4678a43eac845044f0dcc38
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Laine Stump <laine@redhat.com>
10 months agoqemuDomainDiskChangeSupported: Fill in missing check
Adam Julis [Fri, 21 Jun 2024 16:16:55 +0000 (18:16 +0200)]
qemuDomainDiskChangeSupported: Fill in missing check

The attribute 'discard_no_unref' of <disk/> is not allowed to be
changed while the virtual machine is running.

Resolves: https://issues.redhat.com/browse/RHEL-37542
Signed-off-by: Adam Julis <ajulis@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agonetwork: allow for forward dev to be a transient interface
Laine Stump [Fri, 7 Jun 2024 16:46:34 +0000 (12:46 -0400)]
network: allow for forward dev to be a transient interface

A user reported that if they set <forward mode='nat|route' dev='blah'>
starting the network would fail if the device 'blah' didn't already
exist.

This is caused by using "iif" and "oif" in nftables rules to check for
the forwarding device - these two commands work by saving the named
interface's ifindex (an unsigned integer) when the rule is added, and
comparing it to the ifindex associated with the packet's path at
runtime. This works great if the interface both 1) exists when the
rule is added, and 2) is never deleted and re-created after the rule
is added (since it would end up with a different ifindex).

When checking for the network's bridge device, it is okay for us to
use "iif" and "oif", because the bridge device is created before the
firewall rules are added, and will continue to exist until just after
the firewall rules are deleted when the network is shutdown.

But since the forward device might be deleted/re-added during the
lifetime of the network's firewall rules, we must instead us "oifname"
and "iifname" - these are much less efficient than "Xif" because they
do a string compare of the interface's name rather than just comparing
two integers (ifindex), but they don't require the interface to exist
when the rule is added, and they can properly cope with the named
interface being deleted and re-added later.

Fixes: a4f38f6ffe6a9edc001d18890ccfc3f38e72fb94
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agodomain_validate: Add missing 'break' in virDomainDefLaunchSecurityValidate()
Michal Privoznik [Fri, 21 Jun 2024 08:37:35 +0000 (10:37 +0200)]
domain_validate: Add missing 'break' in virDomainDefLaunchSecurityValidate()

A few commits ago (v10.4.0-101-gc65eba1f57) I've introduced
virDomainDefLaunchSecurityValidate() and a switch() statement in
it. Some cases are empty but are lacking 'break' statement which
is not valid. Provide missing 'break' statement.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemu_firmware: Pick the right firmware for SEV-SNP guests
Michal Privoznik [Thu, 13 Jun 2024 12:35:57 +0000 (14:35 +0200)]
qemu_firmware: Pick the right firmware for SEV-SNP guests

The firmware descriptors have 'amd-sev-snp` feature which
describes whether firmware is suitable for SEV-SNP guests.
Provide necessary implementation to detect the feature and pick
the right firmware if guest is SEV-SNP enabled.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemu: Build cmd line for SEV-SNP
Michal Privoznik [Wed, 12 Jun 2024 13:22:00 +0000 (15:22 +0200)]
qemu: Build cmd line for SEV-SNP

Pretty straightforward as qemu has 'sev-snp-guest' object which
attributes maps pretty much 1:1 to our XML model. Except for
@vcek where QEMU has 'vcek-disabled`, an inverted boolean, while
we model it as virTristateBool. But that's easy to map too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoconf: Introduce SEV-SNP support
Michal Privoznik [Tue, 11 Jun 2024 09:58:41 +0000 (11:58 +0200)]
conf: Introduce SEV-SNP support

SEV-SNP is an enhancement of SEV/SEV-ES and thus it shares some
fields with it. Nevertheless, on XML level, it's yet another type
of <launchSecurity/>.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemu_capabilities: Introduce QEMU_CAPS_SEV_SNP_GUEST
Michal Privoznik [Wed, 12 Jun 2024 07:04:16 +0000 (09:04 +0200)]
qemu_capabilities: Introduce QEMU_CAPS_SEV_SNP_GUEST

This capability tracks sev-snp-guest object availability.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemu: Report snp-policy in virDomainGetLaunchSecurityInfo()
Michal Privoznik [Tue, 11 Jun 2024 09:53:43 +0000 (11:53 +0200)]
qemu: Report snp-policy in virDomainGetLaunchSecurityInfo()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemu_monitor: Allow querying SEV-SNP state in 'query-sev'
Michal Privoznik [Mon, 10 Jun 2024 14:17:26 +0000 (16:17 +0200)]
qemu_monitor: Allow querying SEV-SNP state in 'query-sev'

In QEMU commit v9.0.0-1155-g59d3740cb4 the return type of
'query-sev' monitor command changed to accommodate SEV-SNP. Even
though we currently support launching plain SNP guests, this will
soon change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agosrc: Convert some _virDomainSecDef::sectype checks to switch()
Michal Privoznik [Wed, 12 Jun 2024 07:29:59 +0000 (09:29 +0200)]
src: Convert some _virDomainSecDef::sectype checks to switch()

In a few instances there is a plain if() check for
_virDomainSecDef::sectype. While this works perfectly for now,
soon there'll be another type and we can utilize compiler to
identify all the places that need adaptation. Switch those if()
statements to switch().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoDrop needless typecast to virDomainLaunchSecurity
Michal Privoznik [Wed, 12 Jun 2024 08:06:57 +0000 (10:06 +0200)]
Drop needless typecast to virDomainLaunchSecurity

The sectype member of _virDomainSecDef struct is already declared
as of virDomainLaunchSecurity type. There's no need to typecast
it to the very same type when passing it to switch().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoconf: Separate SEV formatting into a function
Michal Privoznik [Tue, 11 Jun 2024 11:00:58 +0000 (13:00 +0200)]
conf: Separate SEV formatting into a function

To avoid convolution of switch() inside of virDomainSecDefFormat() even
more (as new sectypes are added), move formatting into a separate
function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoconf: Move some members of virDomainSEVDef into virDomainSEVCommonDef
Michal Privoznik [Tue, 11 Jun 2024 10:12:08 +0000 (12:12 +0200)]
conf: Move some members of virDomainSEVDef into virDomainSEVCommonDef

Some parts of SEV are to be shared with SEV SNP. In order to
reuse XML parsing / formatting code cleanly, let's move those
common bits into a new struct (virDomainSEVCommonDef) and adjust
rest of the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemu_monitor_json: Report error in error paths in SEV related code
Michal Privoznik [Tue, 11 Jun 2024 08:44:24 +0000 (10:44 +0200)]
qemu_monitor_json: Report error in error paths in SEV related code

While working on qemuMonitorJSONGetSEVMeasurement() and
qemuMonitorJSONGetSEVInfo() I've noticed that if these functions
fail, they do so without appropriate error set. Fill in error
reporting.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
10 months agoqemu: migration: Preserve error across qemuDomainSetMaxMemLock() on error paths
Peter Krempa [Thu, 13 Jun 2024 15:02:15 +0000 (17:02 +0200)]
qemu: migration: Preserve error across qemuDomainSetMaxMemLock() on error paths

When a VM terminates itself while it's being migrated in running state
libvirt would report wrong error:

 error: cannot get locked memory limit of process 2502057: No such file or directory

rather than the proper error:

 error: operation failed: domain is not running

Remember the error on error paths in qemuMigrationSrcConfirmPhase and
qemuMigrationSrcPerformPhase.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemuMigrationSrcRun: Re-check whether VM is active before accessing job data
Peter Krempa [Thu, 13 Jun 2024 14:21:47 +0000 (16:21 +0200)]
qemuMigrationSrcRun: Re-check whether VM is active before accessing job data

'qemuProcessStop()' clears the 'current' job data. While the code under
the 'error' label in 'qemuMigrationSrcRun()' does check that the VM is
active before accessing the job, it also invokes multiple helper
functions to clean up the migration including
'qemuMigrationSrcNBDCopyCancel()' which calls 'qemuDomainObjWait()'
invalidating the result of the liveness check as it unlocks the VM.

Duplicate the liveness check and explain why. The rest of the code e.g.
accessing the monitor is safe as 'qemuDomainEnterMonitorAsync()'
performs a liveness check. The cleanup path just ignores the return
values of those functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemu: migration: Inline 'qemuMigrationDstFinishResume()'
Peter Krempa [Thu, 13 Jun 2024 14:19:37 +0000 (16:19 +0200)]
qemu: migration: Inline 'qemuMigrationDstFinishResume()'

The function is a pointless wrapper on top of
qemuMigrationDstWaitForCompletion.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemu: migration: Properly check for live VM after qemuDomainObjWait()
Peter Krempa [Thu, 13 Jun 2024 14:15:58 +0000 (16:15 +0200)]
qemu: migration: Properly check for live VM after qemuDomainObjWait()

Similarly to the one change in commit 4d1a1fdffda19a62d62fa2457d162362
we should be checking that the VM is not being yet destroyed if we've
invoked qemuDomainObjWait().

Use the new helper qemuDomainObjIsActive().

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemu: domain: Introduce qemuDomainObjIsActive helper
Peter Krempa [Thu, 6 Jun 2024 16:17:29 +0000 (18:17 +0200)]
qemu: domain: Introduce qemuDomainObjIsActive helper

The helper checks whether VM is active including the internal qemu
state. This helper will become useful in situations when an async job
is in use as VIR_JOB_DESTROY can run along async jobs thus both checks
are necessary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemu: process: Ensure that 'beingDestroyed' gets cleared only after VM id is reset
Peter Krempa [Thu, 6 Jun 2024 15:43:12 +0000 (17:43 +0200)]
qemu: process: Ensure that 'beingDestroyed' gets cleared only after VM id is reset

Prevent the possibility that a VM could be considered as alive while
inside qemuProcessStop.

A recently fixed bug which unlocked the domain object while inside
qemuProcessStop showed that there's possibility to confuse the state of
the VM to be considered active while 'qemuProcessStop' is processing
shutdown of the VM. Ensure that this doesn't happen by clearing the
'beingDestroyed' flag only after the VM id is cleared.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemuProcessStop: Move code not depending on 'vm->def->id' after reset of the ID
Peter Krempa [Wed, 12 Jun 2024 13:54:24 +0000 (15:54 +0200)]
qemuProcessStop: Move code not depending on 'vm->def->id' after reset of the ID

There are few function calls done while cleaning up a stopped VM which
do require the old VM id, to e.g. clean up paths containing the 'short'
domain name in the path.

Anything else, which doesn't strictly require it can be moved after
clearing the 'id' in order to decrease likelyhood of potential bugs.

This patch moves all the code which does not require the 'id' (except
for the log entry and closing the monitor socket) after the statement
clearing the id and adds a comment explaining that anything in the
section must not unlock the VM object.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemuProcessStop: Prevent crash when qemuDomainObjStopWorker() unlocks the VM
Peter Krempa [Mon, 10 Jun 2024 16:12:16 +0000 (18:12 +0200)]
qemuProcessStop: Prevent crash when qemuDomainObjStopWorker() unlocks the VM

'qemuDomainObjStopWorker()' which is meant to dispose of the event loop
thread for the monitor unlocks the VM object while disposing the thread
to prevent possible deadlocks with events waiting on the monitor thread.

Unfortunately 'qemuDomainObjStopWorker()' is called *before* the VM is
marked as inactive by clearing 'vm->def->id', but at the same time it's
no longer marked as 'beingDestroyed' when we're inside
'qemuProcessStop()'.

If 'vm' would be kept locked this wouldn't be a problem. Same way it's
not a problem for anything that uses non-ASYNC VM jobs, or when the
monitor is accessed in an async job, as the 'destroy' job interlocks
with those.

It is a problem for code inside an async job which uses
'qemuDomainObjWait()' though. The API contract of qemuDomainObjWait()
ensures the caller that the VM on successful return from it, but in this
specific reason it's not the case, as both 'beingDestroyed' is already
false, and 'vm->def->id' is not yet cleared.

To fix the issue move the 'qemuDomainObjStopWorker()' call *after*
clearing 'vm->def->id' and also add a note stating what the function is
doing.

Fixes: 860a999802d3c82538373bb3f314f92a2e258754
Closes: https://gitlab.com/libvirt/libvirt/-/issues/640
Reported-by: luzhipeng <luzhipeng@cestc.cn>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemuDomainObjWait: Add documentation
Peter Krempa [Thu, 6 Jun 2024 16:04:57 +0000 (18:04 +0200)]
qemuDomainObjWait: Add documentation

Document why this function exists and meaning of return values.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemuDomainDeviceBackendChardevForeach: Fix typo in comment
Peter Krempa [Thu, 6 Jun 2024 16:04:28 +0000 (18:04 +0200)]
qemuDomainDeviceBackendChardevForeach: Fix typo in comment

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemuDomainDiskPrivateDispose: Prevent dangling 'disk' pointer in blockjob data
Peter Krempa [Tue, 11 Jun 2024 13:50:52 +0000 (15:50 +0200)]
qemuDomainDiskPrivateDispose: Prevent dangling 'disk' pointer in blockjob data

Clear the 'disk' member of 'blockjob' as we're freeing the disk object
at this point. While this should not normally happen it was observed
when other bug allowed the VM to be cleared while other threads didn't
yet finish.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agoqemuBlockJobProcessEventConcludedBackup: Handle potentially NULL 'job->disk'
Peter Krempa [Tue, 11 Jun 2024 15:14:16 +0000 (17:14 +0200)]
qemuBlockJobProcessEventConcludedBackup: Handle potentially NULL 'job->disk'

Similarly to other blockjob handlers, if there's no disk associated with
the blockjob the handler needs to behave correctly. This is needed as
the disk might have been de-associated on unplug or other operations.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agonodedev: add ccw device state and remove fencing
Boris Fiuczynski [Wed, 19 Jun 2024 12:29:17 +0000 (14:29 +0200)]
nodedev: add ccw device state and remove fencing

Instead of fencing offline ccw devices add the state to the ccw
capability.

Resolves: https://issues.redhat.com/browse/RHEL-39497
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agonodedev: prevent invalid DASD node object creation
Boris Fiuczynski [Wed, 19 Jun 2024 12:29:16 +0000 (14:29 +0200)]
nodedev: prevent invalid DASD node object creation

Prevent the creation of a new DASD node object when the device does not
exist.

Resolves: https://issues.redhat.com/browse/RHEL-39497
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agonodedev: improve DASD detection
Boris Fiuczynski [Wed, 19 Jun 2024 12:29:15 +0000 (14:29 +0200)]
nodedev: improve DASD detection

In newer DASD driver versions the ID_TYPE tag is supported. This tag is
missing after a system reboot but when the ccw device is set offline and
online the tag is included. To fix this version independently we need to
check if devices detected as type disk is actually a DASD to maintain
the node object consistency and not end up with multiple node objects
for DASDs.

Resolves: https://issues.redhat.com/browse/RHEL-39497
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 months agonodedev: refactor storage type fixup
Boris Fiuczynski [Wed, 19 Jun 2024 12:29:14 +0000 (14:29 +0200)]
nodedev: refactor storage type fixup

Refactor the storage type fixup into a reusable method.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>