]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
15 months agovirPCIVPDParseVPDLargeResourceFields: Merge logic conditions
Peter Krempa [Tue, 30 Jan 2024 14:02:39 +0000 (15:02 +0100)]
virPCIVPDParseVPDLargeResourceFields: Merge logic conditions

Merge the pre-checks with the 'switch' statement which is operating on
the same values to simplify further refactoring.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirPCIVPDParseVPDLargeResourceString: Properly report errors
Peter Krempa [Mon, 29 Jan 2024 22:42:22 +0000 (23:42 +0100)]
virPCIVPDParseVPDLargeResourceString: Properly report errors

Replace VIR_INFO being used as form of error reporting with proper
virReportError and the usual return values.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirPCIVPDReadVPDBytes: Refactor error handling
Peter Krempa [Mon, 29 Jan 2024 22:33:07 +0000 (23:33 +0100)]
virPCIVPDReadVPDBytes: Refactor error handling

Each caller was checking that the function read as many bytes as it
expected. Move the check inside virPCIVPDReadVPDBytes and make it report
a proper error rather than just a combination of VIR_DEBUG inside the
function and a random VIR_INFO in the caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirPCIDeviceGetVPD: Handle errors in callers
Peter Krempa [Mon, 29 Jan 2024 21:32:33 +0000 (22:32 +0100)]
virPCIDeviceGetVPD: Handle errors in callers

Until now 'virPCIDeviceGetVPD' couldn't reallistically raise an error,
but that will change. Handle the errors by either resetting it if we'd
be ignoring it or forward it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirPCIDeviceGetVPD: Fix multiple error handling bugs
Peter Krempa [Mon, 29 Jan 2024 15:59:20 +0000 (16:59 +0100)]
virPCIDeviceGetVPD: Fix multiple error handling bugs

- fix passing of 'errno' to 'virReportSystemError'

 The 'open' syscall returns '-1' and sets 'errno' on failure. The code
 passed '-fd' as 'errno' rather than errno itself, thus always reporting
 EPERM.

- don't overwrite errors when closing FD

 Use VIR_AUTOCLOSE to avoid overwriting the errors from virPCIVPDParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirPCIDeviceHasVPD: Refactor "debug" messages
Peter Krempa [Mon, 29 Jan 2024 15:53:27 +0000 (16:53 +0100)]
virPCIDeviceHasVPD: Refactor "debug" messages

A checker function should not raise VIR_INFO or VIR_WARN messages
especially if they contain information useful only for debugging.

Turn the message into a VIR_DEBUG with universal meaning.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoutil: virpcivpd: Remove return value from virPCIVPDResourceUpdateKeyword
Peter Krempa [Wed, 24 Jan 2024 16:15:10 +0000 (17:15 +0100)]
util: virpcivpd: Remove return value from virPCIVPDResourceUpdateKeyword

The function always succeeded and after the removal of programing error
checks doesn't even have a 'return false' case. Additionally one of the
tests in 'virpcivpdtest' tested that this function never failed on wrong
data. Embrace this logic and remove the return value and adjust logging
to VIR_DEBUG level to avoid spamming logs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirNodeDeviceCapVPDParseXML: Fix error reporting
Peter Krempa [Tue, 30 Jan 2024 16:41:44 +0000 (17:41 +0100)]
virNodeDeviceCapVPDParseXML: Fix error reporting

Don't overwrite already reported errors and improve parsing of
attributes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoconf: node_device: Refactor 'virNodeDeviceCapVPDParseCustomFields' to fix error reporting
Peter Krempa [Mon, 29 Jan 2024 17:26:29 +0000 (18:26 +0100)]
conf: node_device: Refactor 'virNodeDeviceCapVPDParseCustomFields' to fix error reporting

The errors raised in virNodeDeviceCapVPDParseCustomFields were actually
ignored by continuing the parse rather than raised.

Rather than just replace 'continue' by 'return -1' this patch refactors
the whole parser to simplify it as well as report reasonable errors.

Parsing of individual fields is done without XPath and is extracted into
a common helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoutil: virPCIVPDResourceUpdateKeyword: Remove impossible checks
Peter Krempa [Wed, 24 Jan 2024 15:42:45 +0000 (16:42 +0100)]
util: virPCIVPDResourceUpdateKeyword: Remove impossible checks

All callers satisfy these checks as they are just for programming
errors.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirpcivpdtest: testPCIVPDResourceBasic: Remove tests for uninitialized 'ro'/'rw'...
Peter Krempa [Wed, 24 Jan 2024 16:13:51 +0000 (17:13 +0100)]
virpcivpdtest: testPCIVPDResourceBasic: Remove tests for uninitialized 'ro'/'rw' section

This is a synthetic case which tests the behaviour if the 'ro' or 'rw'
struct members are uninitialized, basically excercising only a pointless
programming-error NULL check in 'virPCIVPDResourceUpdateKeyword' as real
usage does always pass a proper pointer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoconf: virNodeDeviceCapVPDParse*: Remove pointless NULL checks
Peter Krempa [Wed, 24 Jan 2024 15:27:35 +0000 (16:27 +0100)]
conf: virNodeDeviceCapVPDParse*: Remove pointless NULL checks

The function are never called with NULL argument so the checks can be
removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoutil: virpcivpd: Remove return value from virPCIVPDResourceCustomUpsertValue
Peter Krempa [Wed, 24 Jan 2024 15:11:24 +0000 (16:11 +0100)]
util: virpcivpd: Remove return value from virPCIVPDResourceCustomUpsertValue

None of the callers pass NULL, so the NULL check is pointless. Remove it
an remove the return value.

The function is exported only for use in 'virpcivpdtest' thus marking
the arguments as NONNULL is unnecessary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirPCIVPDResourceGetKeywordPrefix: Fix logging
Peter Krempa [Wed, 24 Jan 2024 14:13:16 +0000 (15:13 +0100)]
virPCIVPDResourceGetKeywordPrefix: Fix logging

Use VIR_DEBUG instead of VIR_INFO as that's more appropriate and report
relevant information for debugging.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoutil: virpcivpd: Unexport 'virPCIVPDParseVPDLargeResourceString'
Peter Krempa [Mon, 29 Jan 2024 16:58:17 +0000 (17:58 +0100)]
util: virpcivpd: Unexport 'virPCIVPDParseVPDLargeResourceString'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: virpcivpd: Remove 'testVirPCIVPDParseVPDStringResource' case
Peter Krempa [Mon, 29 Jan 2024 16:55:06 +0000 (17:55 +0100)]
tests: virpcivpd: Remove 'testVirPCIVPDParseVPDStringResource' case

The test case excercises 'virPCIVPDParseVPDLargeResourceString' which is
also tested by other cases which parse the whole VPD block. Remove the
specific test case as it's not adding any additional value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoutil: pcivpd: Unexport virPCIVPDParseVPDLargeResourceFields
Peter Krempa [Wed, 24 Jan 2024 13:40:38 +0000 (14:40 +0100)]
util: pcivpd: Unexport virPCIVPDParseVPDLargeResourceFields

The function is not used in other files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoutil: virpcivpd: Unexport 'virPCIVPDReadVPDBytes'
Peter Krempa [Wed, 24 Jan 2024 13:58:52 +0000 (14:58 +0100)]
util: virpcivpd: Unexport 'virPCIVPDReadVPDBytes'

The function is no longer used outside of virpcivpd.c

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: virpcivpdtest: Remove 'testVirPCIVPDReadVPDBytes' case
Peter Krempa [Wed, 24 Jan 2024 13:55:47 +0000 (14:55 +0100)]
tests: virpcivpdtest: Remove 'testVirPCIVPDReadVPDBytes' case

The case checks only the 'virPCIVPDReadVPDBytes' which is also tested
multiple times via 'virPCIVPDParse' as it's used to read the data, thus
having a special case for this is pointless.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoDon't overwrite error message from 'virXPathNodeSet'
Peter Krempa [Mon, 29 Jan 2024 14:50:27 +0000 (15:50 +0100)]
Don't overwrite error message from 'virXPathNodeSet'

'virXPathNodeSet' returns -1 only when 'ctxt' or 'xpath' are NULL or
when the 'xpath' string is invalid. Both are programming errors. It
doesn't make sense for the code to overwrite the error message for
anything supposedly more relevant.

The majority of calls to 'virXPathNodeSet' already didn't do this, so
this patch fixes the rest to prevent it from spreading again.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Test the previously mishandled PCI VPD characters
Peter Krempa [Tue, 23 Jan 2024 15:40:34 +0000 (16:40 +0100)]
tests: Test the previously mishandled PCI VPD characters

Modify the test data to validate '<>' and other characters.
Unfortunately the test suite doesn't have a proper end-to-end test, thus
we just add a XML->XML variant and also add data to the binary parser.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoschema: nodedev: Adjust allowed characters in 'vpdFieldValueFormat'
Peter Krempa [Mon, 29 Jan 2024 15:12:09 +0000 (16:12 +0100)]
schema: nodedev: Adjust allowed characters in 'vpdFieldValueFormat'

The check in 'virPCIVPDResourceIsValidTextValue' allows any printable
characters, thus the XML schema should do the same.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirNodeDeviceCapVPDFormat: Properly escape system-originated strings
Peter Krempa [Tue, 30 Jan 2024 16:11:37 +0000 (17:11 +0100)]
virNodeDeviceCapVPDFormat: Properly escape system-originated strings

Similarly to previous commit other specific fields which come from the
system data and aren't sanitized enough to be safe for XML were also
formatted via virBufferAsprintf.

Other static and safe strings used virBufferEscapeString instead of
virBufferAddLit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirNodeDeviceCapVPDFormatCustom*: Escape unsanitized strings
Peter Krempa [Mon, 29 Jan 2024 14:15:03 +0000 (15:15 +0100)]
virNodeDeviceCapVPDFormatCustom*: Escape unsanitized strings

The custom field data is taken from PCI device data which can contain
any printable characters, and thus must be escaped when putting into
XML.

Originally, based on the comment and XML schema which was fixed in
previous commits the idea seemed to be that the parser would validate
that only characters which don't break the XML would be present but that
didn't seem to materialize.

Switch to proper escaping of the XML.

Fixes: 3954378d06a
Resolves: https://issues.redhat.com/browse/RHEL-22314
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoutil: pcivpd: Refactor virPCIVPDResourceIsValidTextValue
Peter Krempa [Wed, 24 Jan 2024 14:53:39 +0000 (15:53 +0100)]
util: pcivpd: Refactor virPCIVPDResourceIsValidTextValue

The function is never called with NULL argument. Remove the check and
refactor the rest including the debug statement.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirPCIVPDResourceIsValidTextValue: Adjust comment to reflect actual code
Peter Krempa [Wed, 24 Jan 2024 14:24:27 +0000 (15:24 +0100)]
virPCIVPDResourceIsValidTextValue: Adjust comment to reflect actual code

The function does not reject '&', '<', '>' contrary to what it actually
states. Move and adjust the comment.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuMigrationDstStartNBDServer: Refactor cleanup
Peter Krempa [Tue, 16 Jan 2024 15:22:03 +0000 (16:22 +0100)]
qemuMigrationDstStartNBDServer: Refactor cleanup

There's nothing under the 'cleanup:' label thus the whole code can be
simplified.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agoqemu: migration: Properly handle reservation of manually specified NBD port
Peter Krempa [Tue, 16 Jan 2024 14:52:25 +0000 (15:52 +0100)]
qemu: migration: Properly handle reservation of manually specified NBD port

Originally the migration code didn't register the NBD disk port with the
port allocator when it was manually specified. Later when commit
e74d627bb3bc2684cbe3 refactored the code and started registering it, the
old logic which was clearing 'priv->nbdPort' in case when it was manually
specified was not removed.

This caused following problems:
 - the port was not released after successful migration
 - the port was released even when it was not allocated on failures
   regarding the NBD server start
 - the port was not released on other failures of the migration after
   NBD server startup

To address this we remove the assumption that 'priv->nbdPort' is used
only for auto-allocated port and fill it only once the port is
allocated and make the caller of qemuMigrationDstStartNBDServer
responsible for releasing it.

Fixes: e74d627bb3bc2684cbe3edc1e2f7cc745b4e1ff3
Resolves: https://issues.redhat.com/browse/RHEL-21543
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agoutil: virtportallocator: Add VIR_DEBUG statements for port allocations and release
Peter Krempa [Tue, 16 Jan 2024 14:10:55 +0000 (15:10 +0100)]
util: virtportallocator: Add VIR_DEBUG statements for port allocations and release

Add a few debug statements to be able to trace lifetime of a
reserved/allocated port.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agoremoteDispatchAuthPolkit: Fix lock ordering deadlock if client closes connection...
Peter Krempa [Wed, 17 Jan 2024 14:55:35 +0000 (15:55 +0100)]
remoteDispatchAuthPolkit: Fix lock ordering deadlock if client closes connection during auth

Locks in following text:
A: virNetServer
B: virNetServerClient
C: daemonClientPrivate

'virNetServerSetClientAuthenticated' locks A then B

'remoteDispatchAuthPolkit' calls 'virNetServerSetClientAuthenticated'
while holding C.

If a client closes its connection 'virNetServerProcessClients' with the
lock A and B locked will call 'virNetServerClientCloseLocked' which will
try to dispose of the 'client' private data by:

  ref(b);
  unlock(b);
  remoteClientFreePrivateCallbacks();
  lock(b);
  unref(b);

Unfortunately remoteClientFreePrivateCallbacks() tries lock C.

Thus the locks are held in the following order:

 polkit auth: C -> A
 connection close: A -> C

causing a textbook-example deadlock. To resolve it we can simply drop
lock 'C' before calling 'virNetServerSetClientAuthenticated' as the lock
is not needed any more.

Resolves: https://issues.redhat.com/browse/RHEL-20337
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
15 months agoapparmor: Add user session path for PID and socket files used by passt
Stefano Brivio [Tue, 30 Jan 2024 18:15:51 +0000 (19:15 +0100)]
apparmor: Add user session path for PID and socket files used by passt

Commit 7a39b04d683f ("apparmor: Enable passt support") grants
passt(1) read-write access to /{,var/}run/libvirt/qemu/passt/* if
started by the libvirt daemon. That's the path where passt creates
PID and socket files only if the guest is started by the root user.

If the guest is started by another user, though, the path is more
commonly /var/run/user/$UID/libvirt/qemu/run/passt: add it as
read-write location. Otherwise, passt won't be able to start, as
reported by Andreas.

While at it, replace /{,var/}run/ in the existing rule by its
corresponding tunable variable, @{run}.

Fixes: 7a39b04d683f ("apparmor: Enable passt support")
Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1061678
Reported-by: Andreas B. Mundt <andi@debian.org>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
15 months agomeson: Adjust -fstack-protector use
Andrea Bolognani [Sat, 20 Jan 2024 16:06:38 +0000 (17:06 +0100)]
meson: Adjust -fstack-protector use

Back in 2014, -fstack-protector was reported not to work on
aarch64, so fe881ae086ec disabled it on that target. OS-wise,
its use is currently limited to just Linux, FreeBSD and Windows.

Looking at the situation today, it seems that whatever issue was
affecting aarch64 a decade ago has been resolved; moreover,
macOS can also use the feature these days.

I haven't checked any of the other BSDs, but since the feature
works on FreeBSD it's pretty safe to assume that they can use
it too. If we get reports that it's not the case, we can always
further restrict its usage accordingly.

Best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Wed, 31 Jan 2024 07:36:49 +0000 (08:36 +0100)]
Translated using Weblate (Swedish)

Currently translated at 65.8% (6882 of 10447 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>
15 months agoscripts: Make check-symfile.py work on alpha
Andrea Bolognani [Sat, 20 Jan 2024 17:20:21 +0000 (18:20 +0100)]
scripts: Make check-symfile.py work on alpha

The script expects each of the symbols that it looks for to
be in one of three sections, which in nm(1) are described as
follows:

  T - The symbol is in the text (code) section.
  B - The symbol is in the BSS data section. This section
      typically contains zero-initialized or uninitialized
      data, although the exact behavior is system dependent.
  D - The symbol is in the initialized data section.

When building on alpha, however, some of the symbols show up
in one of two additional sections, specifically:

  S - The symbol is in an uninitialized or zero-initialized
      data section for small objects.
  G - The symbol is in an initialized data section for small
      objects.

In other words, S is the same as B and G is the same as D,
except with some optimization for small objects that for some
reason is applied on alpha but not on other architectures.

I have confirmed that, for all the symbols that the script
complained about being missing on alpha, the section is the
expected one, that is, symbols that are reported as B on x86
are reported as S on alpha, and symbols that are reported as
D on x86 are reported as G on alpha.

Note that, while the B section doesn't seem to be used at all
on alpha, at least in our case, the D section still is.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
15 months agoqemu_snapshot: create: don't require disk-only flag for offline external snapshot
Pavel Hrdina [Tue, 30 Jan 2024 11:13:32 +0000 (12:13 +0100)]
qemu_snapshot: create: don't require disk-only flag for offline external snapshot

Historically creating offline external snapshot required disk-only flag
as well. Now when user requests new snapshot for offline VM and at least
one disk is specified to use external snapshot we will no longer require
disk-only flag as all other not specified disk will use external
snapshots as well.

Resolves: https://issues.redhat.com/browse/RHEL-22797
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_snapshot: create: refactor external snapshot detection
Pavel Hrdina [Tue, 30 Jan 2024 10:33:23 +0000 (11:33 +0100)]
qemu_snapshot: create: refactor external snapshot detection

Introduce new function qemuSnapshotCreateUseExternal() that will return
true if we will use external snapshots as default location.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_snapshot: fix detection if non-leaf snapshot isn't in active chain
Pavel Hrdina [Tue, 30 Jan 2024 12:05:22 +0000 (13:05 +0100)]
qemu_snapshot: fix detection if non-leaf snapshot isn't in active chain

The condition was completely wrong. As per the comment for function
virDomainMomentIsAncestor() it checks that the first argument is
descendant of the second argument.

Consider the following snapshot tree for VM:

  s1
    |
    +- s2
    |   |
    |   +- s3
    |
    +- s4
        |
        +- s5 (current)

When deleting s2 with the original code we checked if
virDomainMomentIsAncestor(s2, s5) which would return false basically for
any snapshot as s5 is leaf snapshot so no children.

When deleting s2 with fixed code we check if
virDomainMomentIsAncestor(s5, s2) which still returns false but when
deleting s4 it will correctly return true.

Before this fix it fails with the following error:

    error: Failed to delete snapshot s2
    error: invalid argument: could not find base disk source in disk source chain

After the fix it fails with correct error:

    error: Failed to delete snapshot s2
    error: unsupported configuration: deletion of non-leaf external snapshot that is not in active chain is not supported

Resolves: https://issues.redhat.com/browse/RHEL-23212
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoch_driver: fix condition in virCHDomainRemoveInactive()
Purna Pavan Chandra Aekkaladevi [Mon, 29 Jan 2024 12:38:21 +0000 (12:38 +0000)]
ch_driver: fix condition in virCHDomainRemoveInactive()

Rectify the condition to remove a domain only if it is not persistent.

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
15 months agoqemu: Move qemuDomainGetSCSIControllerModel()
Andrea Bolognani [Fri, 19 Jan 2024 14:54:06 +0000 (15:54 +0100)]
qemu: Move qemuDomainGetSCSIControllerModel()

It has nothing to do with assigning addresses, so it makes more
sense to have it in qemu_domain.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: Add missing error handling
Andrea Bolognani [Mon, 22 Jan 2024 17:50:17 +0000 (18:50 +0100)]
qemu: Add missing error handling

qemuDomainGetSCSIControllerModel() can return -1 on failure,
but qemuDomainFindOrCreateSCSIDiskController() didn't implement
any handling for this scenario.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: Drop qemuDomainSetSCSIControllerModel()
Andrea Bolognani [Fri, 19 Jan 2024 15:04:39 +0000 (16:04 +0100)]
qemu: Drop qemuDomainSetSCSIControllerModel()

It only has a single caller.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: Drop qemuDomainFindSCSIControllerModel()
Andrea Bolognani [Fri, 19 Jan 2024 14:46:06 +0000 (15:46 +0100)]
qemu: Drop qemuDomainFindSCSIControllerModel()

It only has a single caller.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: Clean up qemuDomainDefaultNetModel()
Andrea Bolognani [Fri, 19 Jan 2024 14:27:32 +0000 (15:27 +0100)]
qemu: Clean up qemuDomainDefaultNetModel()

Group things together where it makes sense, avoid unnecessary
uses of 'else if', plus other tweaks.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: Default to no USB and no memballoon for new architectures
Andrea Bolognani [Tue, 16 Jan 2024 18:14:56 +0000 (19:14 +0100)]
qemu: Default to no USB and no memballoon for new architectures

The current defaults, that can be altered on a per-architecture
basis, are derived from the historical x86 behavior.

Every time support for a new architecture is added to libvirt,
care must be taken to override these default: if that doesn't
happen, guests will end up with additional hardware, which is
something that's generally undesirable.

Turn things around, and require architectures to explicitly
ask for the devices to be created by default instead. The
behavior for existing architectures is preserved.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: Fix a few comments
Andrea Bolognani [Wed, 24 Jan 2024 17:17:09 +0000 (18:17 +0100)]
qemu: Fix a few comments

They reference functions that have since been renamed.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Add default-models cases for many architectures
Andrea Bolognani [Wed, 17 Jan 2024 18:01:35 +0000 (19:01 +0100)]
tests: Add default-models cases for many architectures

These are similar to the minimal cases that we just introduced,
but are intended to demonstrate what device or controller model
libvirt will choose when one is not provided by the user.

Note that we want both regular and ABI_UPDATE variants of the
various test cases because, in some cases, the behavior for new
guests is not the same as that for existing ones due to backward
compatibility concerns.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Drop minimal
Andrea Bolognani [Wed, 17 Jan 2024 17:55:42 +0000 (18:55 +0100)]
tests: Drop minimal

We have just added a number of test cases that supersede it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Add minimal cases for many architectures
Andrea Bolognani [Wed, 17 Jan 2024 17:44:58 +0000 (18:44 +0100)]
tests: Add minimal cases for many architectures

We currently have a single test case called "minimal", which
suffers from two big flaws:

  * it's limited to the x86_64/pc machine type;
  * it explicitly enables a number of devices.

Add several test cases, one for each of the architectures and
machine types that we have good support for.

Unlike the existing one, they're *really* minimal: no devices
or controllers at all are present in the input XML. So the new
test cases demonstrate exactly what devices and controller
libvirt will decide to add automatically.

Note that we want both regular and ABI_UPDATE variants of the
various test cases because, in some cases, the behavior for new
guests is not the same as that for existing ones due to backward
compatibility concerns.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Rename and minimize no-memory
Andrea Bolognani [Wed, 17 Jan 2024 17:40:36 +0000 (18:40 +0100)]
tests: Rename and minimize no-memory

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Add aarch64-panic-no-model
Andrea Bolognani [Wed, 24 Jan 2024 09:31:25 +0000 (10:31 +0100)]
tests: Add aarch64-panic-no-model

This demonstrates that on aarch64, where a native panic device
doesn't exist, it's necessary for the user to specify the model
explicitly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Add usb-controller-automatic-unavailable-q35
Andrea Bolognani [Wed, 24 Jan 2024 10:25:56 +0000 (11:25 +0100)]
tests: Add usb-controller-automatic-unavailable-q35

For q35 guests, we normally add a USB controller by default,
but there's a scenario in which we can decide to skip it. Add
test coverage for it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Drop existing <title> and <description> tags
Andrea Bolognani [Wed, 17 Jan 2024 17:34:57 +0000 (18:34 +0100)]
tests: Drop existing <title> and <description> tags

Now that we have an explicit test case for the feature in
genericxml2xmltest, we can drop a bunch of duplicated accidental
coverage from qemuxmlconftest.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Add title-and-description
Andrea Bolognani [Fri, 26 Jan 2024 10:31:26 +0000 (11:31 +0100)]
tests: Add title-and-description

We have a few cases in qemuxmlconftest that cover the ability
to set <title> and <description> for a guest as a side effect.

Introduce an explicit case for the functionality in
genericxml2xmltest, as it's not specific to the QEMU driver.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_command: Generate cmd line for virtio-mem dynamicMemslots
Michal Privoznik [Thu, 4 Jan 2024 09:49:06 +0000 (10:49 +0100)]
qemu_command: Generate cmd line for virtio-mem dynamicMemslots

This is pretty straightforward.

Resolves: https://issues.redhat.com/browse/RHEL-15316
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_validate: Check capability for virtio-mem dynamicMemslots
Michal Privoznik [Thu, 4 Jan 2024 10:04:51 +0000 (11:04 +0100)]
qemu_validate: Check capability for virtio-mem dynamicMemslots

The QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI_DYNAMIC_MEMSLOTS reflects
whether QEMU is capable of .dynamic-memslots for virtio-mem.
Use it when validating domain configuration.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_capabilities: Add QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI_DYNAMIC_MEMSLOTS capability
Michal Privoznik [Thu, 4 Jan 2024 09:57:12 +0000 (10:57 +0100)]
qemu_capabilities: Add QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI_DYNAMIC_MEMSLOTS capability

Starting from v8.2.0-rc0~74^2~2 QEMU has .dynamic-memslots
attribute for virtio-mem-pci device. Introduce a capability which
reflects that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoconf: Introduce dynamicMemslots attribute for virtio-mem
Michal Privoznik [Thu, 4 Jan 2024 09:03:36 +0000 (10:03 +0100)]
conf: Introduce dynamicMemslots attribute for virtio-mem

Introduced in v8.2.0-rc0~74^2~2, QEMU now allows setting
.dynamic-memslots attribute for virtio-mem-pci devices. When
turned on, it allows memory exposed to guest to be split into
multiple memslots and thus smaller memory footprint (see the
original commit for detailed explanation).

Therefore, introduce new <target/> attribute which will control
that QEMU knob.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Mon, 29 Jan 2024 15:36:25 +0000 (16:36 +0100)]
Translated using Weblate (Swedish)

Currently translated at 65.4% (6842 of 10447 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>
15 months agoTranslated using Weblate (Korean)
김인수 [Mon, 29 Jan 2024 15:36:25 +0000 (16:36 +0100)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10433 of 10433 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>
15 months agoremote_driver: Restore special behavior of remoteDomainGetBlockIoTune()
Michal Privoznik [Mon, 29 Jan 2024 09:07:05 +0000 (10:07 +0100)]
remote_driver: Restore special behavior of remoteDomainGetBlockIoTune()

In v9.10.0-rc1~103 the remote driver was switched to g_auto() for
client RPC return parameters. But whilst doing so a small bug
slipped in: previously, when virDomainGetBlockIoTune() was called
with *nparams == 0, the function set *nparams to the number of
supported params and zero was returned (so that client can
allocate memory and call the API second time). IOW - the usual,
old style of APIs where we didn't want to allocate memory on
caller's behalf. But because of this bug, a negative one is
returned instead.

Fixes: 501825011c1fe80f458820c7efe5a198e0af9be5
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Improve ABI_UPDATE macros
Andrea Bolognani [Fri, 26 Jan 2024 10:57:21 +0000 (11:57 +0100)]
tests: Improve ABI_UPDATE macros

There are a number of cases in which we want to test both the
normal behavior and the ABI_UPDATE behavior for the same input
XML.

The way this is currently implemented is ad-hoc, and involves
symlinking the input XML as well as coming up with an
alternative name for the ABI_UPDATE variant: in most cases the
-abi-update suffix is added, but since this is not enforced
there are a couple of cases where we do something else instead.

To make things simpler and more consistent, implement the
naming convention at the macro level. This way, we no longer
need to create any symlinks for the input file, and the output
files are automatically named correctly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Use ABI_UPDATE macros more
Andrea Bolognani [Fri, 26 Jan 2024 10:56:54 +0000 (11:56 +0100)]
tests: Use ABI_UPDATE macros more

In one case, the macro was open-coded.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Drop ppc64-usb-controller-legacy
Andrea Bolognani [Fri, 26 Jan 2024 11:16:39 +0000 (12:16 +0100)]
tests: Drop ppc64-usb-controller-legacy

The input file is a symlink for the ppc64-usb-controller input
file, so the output files are identical as well. It's just an
unnecessary duplicate.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: block: fix error when blockcopy target is librbd encrypted
Or Ozeri [Thu, 12 Jan 2023 09:04:01 +0000 (03:04 -0600)]
qemu: block: fix error when blockcopy target is librbd encrypted

Encryption secrets are considered a format dependency, even
when being used by the storage node itself, as in the case of
using encryption engine=librbd.
Currently, the storage node is created (blockdev-add) before
creating the format dependencies (including encryption secrets).
As a result, when trying to perform a blockcopy when the target
disk uses librbd encryption, an error of this form is returned:

  "error: internal error: unable to execute QEMU command 'blockdev-add': No secret with id 'libvirt-5-format-encryption-secret0'"

To overcome this error, we change the order of commands so that
format dependencies are created BEFORE creating the storage node.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_hotplug: Don't lose 'created' flag in qemuDomainChangeNet()
Michal Privoznik [Wed, 24 Jan 2024 17:43:21 +0000 (18:43 +0100)]
qemu_hotplug: Don't lose 'created' flag in qemuDomainChangeNet()

After v9.1.0-rc1~116 we track whether it's us who created a
macvtap or not. But when updating a vNIC its definition might be
replaced with a new one (though, ifname is not allowed to
change), e.g. to reflect new QoS, link state, etc.

Now, the fact whether we created macvtap for given vNIC is stored
in net->privateData->created. And replacing definition is done by
simply freeing the old definition and making the pointer point to
the new one. But this does not preserve the 'created' flag, which
in turn means when a domain is shutting off, the macvtap is not
removed (see loop inside of qemuProcessStop()).

Copy this flag into new definition and leave a note in
_qemuDomainNetworkPrivate struct.

Fixes: 61d1b9e6592660121aeda66bf7adbcd39de06aa8
Resolves: https://issues.redhat.com/browse/RHEL-22714
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovmx: Separate disk target name generation into a function
Michal Privoznik [Fri, 15 Dec 2023 13:48:25 +0000 (14:48 +0100)]
vmx: Separate disk target name generation into a function

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovmx2xmltest: Add another test case
Michal Privoznik [Fri, 15 Dec 2023 12:55:53 +0000 (13:55 +0100)]
vmx2xmltest: Add another test case

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovmx: Accept empty fileName for cdrom-image
Michal Privoznik [Fri, 15 Dec 2023 13:12:42 +0000 (14:12 +0100)]
vmx: Accept empty fileName for cdrom-image

Turns out, there are two ways to specify an empty CD-ROM drive in
a .vmx file:

  1) .fileName = "emptyBackingString"
  2) .fileName = ""

While we do parse 1) successfully, the code does not accept 2)
and an error is reported. Modify the code to treat both cases the
same.

Resolves: https://issues.redhat.com/browse/RHEL-19380
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoAdd explanation about the attribute "delay"
Yalan Zhang [Wed, 10 Jan 2024 04:58:58 +0000 (12:58 +0800)]
Add explanation about the attribute "delay"

The libvirt created linux bridge has a configurable value "delay",
the default value is "0", but it will not take effect. That's because
kernel has a minimum value for linux bridge. Add some explanation
about it in the document.

Signed-off-by: Yalan Zhang <yalzhang@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoNEWS: Document recent rx-filter bugfix
Michal Privoznik [Thu, 25 Jan 2024 13:19:06 +0000 (14:19 +0100)]
NEWS: Document recent rx-filter bugfix

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_process: Skip over non-virtio non-TAP NIC models when refreshing rx-filter
Michal Privoznik [Tue, 23 Jan 2024 16:20:42 +0000 (17:20 +0100)]
qemu_process: Skip over non-virtio non-TAP NIC models when refreshing rx-filter

After guest is started, or we are reconnecting to already running
one (after daemon restart), qemuProcessRefreshRxFilters() is
called to refresh rx-filters (basically MAC addresses of guest
NICs) as they might have changed while we were not running (for
the case when reconnecting to an already running guest), or we
need to enable them by running a command (for freshly started
guest - see processNicRxFilterChangedEvent()).

Now, our XML parser allowed trustGuestRxFilters attribute for all
types and models of <interface/> while in reality, only virtio
model AND TUN/TAP based types can see MAC address changes. For
other combinations, QEMU reports an error.

This all means that when the daemon is restarted and it
reconnects to a guest with, well invalid configuration, or when
such guest is restored from a saved image, or migrated then we
issue the monitor command, to which QEMU replies with an error
which is then propagated to users:

  error: internal error: unable to execute QEMU command 'query-rx-filter': invalid net client name: hostdev0

While on one hand users should fix their configuration (and after
v10.0.0-rc1~123 they can do that even on live domains), libvirt
can also has some logic built in that prevent issuing the command
in the first place (for obviously wrong cases).

Fixes: 060d4c83ef436cf56abfad51a4d64c39448e199d
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agobuild: Make daemons depend on generated *_protocol.[ch]
Jiri Denemark [Wed, 24 Jan 2024 18:23:54 +0000 (19:23 +0100)]
build: Make daemons depend on generated *_protocol.[ch]

This should fix build failures when a daemon code is compiled before the
included *_protocol.h headers are ready, such as:

    FAILED: src/virtqemud.p/remote_remote_daemon_config.c.o
    ../src/remote/remote_daemon_config.c: In function ‘daemonConfigNew’:
    ../src/remote/remote_daemon_config.c:111:30: error:
        ‘REMOTE_AUTH_POLKIT’ undeclared (first use in this function)
      111 |         data->auth_unix_rw = REMOTE_AUTH_POLKIT;
          |                              ^~~~~~~~~~~~~~~~~~
    ../src/remote/remote_daemon_config.c:111:30: note: each undeclared
        identifier is reported only once for each function it appears in
    ../src/remote/remote_daemon_config.c:115:30: error:
        ‘REMOTE_AUTH_NONE’ undeclared (first use in this function)
      115 |         data->auth_unix_rw = REMOTE_AUTH_NONE;
          |                              ^~~~~~~~~~~~~~~~
    ../src/remote/remote_daemon_config.c: In function
        ‘daemonConfigLoadOptions’:
    ../src/remote/remote_daemon_config.c:252:31: error:
        ‘REMOTE_AUTH_POLKIT’ undeclared (first use in this function)
      252 |     if (data->auth_unix_rw == REMOTE_AUTH_POLKIT) {
          |                               ^~~~~~~~~~~~~~~~~~

or

    FAILED: src/virtqemud.p/remote_remote_daemon_dispatch.c.o
    In file included from ../src/remote/remote_daemon.h:28,
                     from ../src/remote/remote_daemon_dispatch.c:26:
    src/remote/lxc_protocol.h:13:5: error:
        unknown type name ‘remote_nonnull_domain’
       13 |     remote_nonnull_domain dom;
          |     ^~~~~~~~~~~~~~~~~~~~~
    In file included from ../src/remote/remote_daemon.h:29,
                     from ../src/remote/remote_daemon_dispatch.c:26:
    src/remote/qemu_protocol.h:13:5: error:
        unknown type name ‘remote_nonnull_domain’
       13 |     remote_nonnull_domain dom;
          |     ^~~~~~~~~~~~~~~~~~~~~
    src/remote/qemu_protocol.h:14:5: error:
        unknown type name ‘remote_nonnull_string’
       14 |     remote_nonnull_string cmd;
          |     ^~~~~~~~~~~~~~~~~~~~~
    ...

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
15 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Wed, 24 Jan 2024 09:36:12 +0000 (10:36 +0100)]
Translated using Weblate (Swedish)

Currently translated at 64.5% (6741 of 10447 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>
15 months agotests: Remove readahead and timeout from ssh tests
Jonathon Jongsma [Fri, 19 Jan 2024 21:18:21 +0000 (15:18 -0600)]
tests: Remove readahead and timeout from ssh tests

These values are currently unsupported for ssh disks, and in fact aren't
even parsed for ssh disks. So while this didn't result in any test
errors, we can remove them from the test input files.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
15 months agoqemu: Fix bug in nbdkit-backed backing chains
Jonathon Jongsma [Thu, 18 Jan 2024 23:17:07 +0000 (17:17 -0600)]
qemu: Fix bug in nbdkit-backed backing chains

When trying to start nbdkit-backed disks in backing chains, we were
accidentally always checking the private data of the top of the chain
instead of using the loop variable.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
15 months agoExplicitly convert type to double to avoid losing precision
Egor Makrushin [Tue, 23 Jan 2024 09:28:34 +0000 (12:28 +0300)]
Explicitly convert type to double to avoid losing precision

Division between integers will also be integer.
Thus, to preserve fractional part explicitly
convert first operand to double.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 28d54aab05 ("examples: Introduce domtop")
Signed-off-by: Egor Makrushin <emakrushin@astralinux.ru>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
15 months agoconf: make virNetDevVPortProfileFormat() void
Alexandra Diupina [Wed, 17 Jan 2024 16:04:58 +0000 (19:04 +0300)]
conf: make virNetDevVPortProfileFormat() void

Since commit 4af3cbafdd0e the function always returns 0, so it is
possible to make this function void and remove return value checks.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru>
15 months agoqemuxmlconftest: Move 'qemuxml2xmloutdata' into 'qemuxmlconfdata'
Peter Krempa [Mon, 22 Jan 2024 15:49:18 +0000 (16:49 +0100)]
qemuxmlconftest: Move 'qemuxml2xmloutdata' into 'qemuxmlconfdata'

Unify the output directory. Symlinks needed to be adapted to work
properly, but the 'qemuxml2argvdata' symlink can now be removed.

The virschematest exceptions needed to be moved to the proper directory
once the files are moved.

The unification of the output directory now also ensures that files
won't be forgotten once tests are removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agoqemuxmlconftest: Move data directory 'qemuxml2argvdata' to 'qemuxmlconfdata'
Peter Krempa [Mon, 22 Jan 2024 12:18:56 +0000 (13:18 +0100)]
qemuxmlconftest: Move data directory 'qemuxml2argvdata' to 'qemuxmlconfdata'

Unify the naming of the data directory with the test name.

'tests/qemuxml2argvdata' is for the time converted to a symlink to
'qemuxmlconfdata', to preserve the symlinks in
'tests/qemuxml2xmloutdata'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agoqemuxml2xmloutdata: Drop unused output files
Peter Krempa [Tue, 23 Jan 2024 13:29:01 +0000 (14:29 +0100)]
qemuxml2xmloutdata: Drop unused output files

Remove leftover output files. The list of files was identified by
temporarily hacking testConfXMLEnumerate to also enumerate
'tests/qemuxml2xmloutdata' directory.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agoqemuxmlconftest: Check also output files for usage
Peter Krempa [Tue, 23 Jan 2024 12:44:50 +0000 (13:44 +0100)]
qemuxmlconftest: Check also output files for usage

Include also the output files in the validation of used files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agoqemuxmlconftest: Populate output/error file only when needed
Peter Krempa [Tue, 23 Jan 2024 12:35:39 +0000 (13:35 +0100)]
qemuxmlconftest: Populate output/error file only when needed

Populate the output filename strings only when the files are expected to
exist, so that other logic can be based on the presence of the strings
rather than having to re-check the test flags for expected state.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agovirschematest: Don't bother checking symlinked XMLs
Peter Krempa [Tue, 23 Jan 2024 12:59:11 +0000 (13:59 +0100)]
virschematest: Don't bother checking symlinked XMLs

There's plenty symlinks in qemuxml2argvdata and qemuxml2xmlout
directories pointing to other files in the same directory. It makes no
sense to check those files twice, thus we can simply skip symlinks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agodomain_validate: Check for domain address conflicts fully
Michal Privoznik [Fri, 19 Jan 2024 07:22:13 +0000 (08:22 +0100)]
domain_validate: Check for domain address conflicts fully

Current implementation of virDomainMemoryDefCheckConflict() does
only a one way comparison, i.e. if there's a memory device within
def->mems[] which address falls in [mem->address, mem->address +
mem->size] range (mem is basically an iterator within
def->mems[]). And for static XML this works just fine. Problem is
with hot/cold plugging of a memory device. Then mem points to
freshly parsed memory device and these half checks are
insufficient. Not only we must check whether an existing memory
device doesn't clash with freshly parsed memory device, but also
whether freshly parsed memory device does not fall into range of
already existing memory device.

Resolves: https://issues.redhat.com/browse/RHEL-4452
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agomeson: drop explicit python interpreter
Biswapriyo Nath [Sun, 21 Jan 2024 06:25:57 +0000 (06:25 +0000)]
meson: drop explicit python interpreter

meson wraps python scripts already on win32, so we end up with these
failing commands:

[185/868] Generating src/rpc/virnetprotocol.h with a custom command
FAILED: src/rpc/virnetprotocol.h
"sh" "libvirt/scripts/meson-python.sh" "F:/msys64/ucrt64/bin/python3.EXE" "F:/msys64/ucrt64/bin/python.exe" "libvirt/scripts/rpcgen/main.py" "--mode=header" "../src/rpc/virnetprotocol.x" "src/rpc/virnetprotocol.h"
SyntaxError: Non-UTF-8 code starting with '\x90' in file F:/msys64/ucrt64/bin/python.exe on line 1, but no encoding declared; see https://peps.python.org/pep-0263/ for details

The issue was introduced in a62486b95feed2cf17ce4adbe794a1ecff9ef22a commit.
These changes are similar as e06beacec2f8e57bbc5cd8f6eb9d44a1f291966d commit.

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
15 months agoTranslated using Weblate (Georgian)
Mariam Low-Ghelaghutashvili [Fri, 19 Jan 2024 13:51:07 +0000 (14:51 +0100)]
Translated using Weblate (Georgian)

Currently translated at 4.4% (461 of 10433 strings)

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

Co-authored-by: Mariam Low-Ghelaghutashvili <mariamlow@zusmail.xyz>
Signed-off-by: Mariam Low-Ghelaghutashvili <mariamlow@zusmail.xyz>
15 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Fri, 19 Jan 2024 13:51:06 +0000 (14:51 +0100)]
Translated using Weblate (Swedish)

Currently translated at 63.5% (6641 of 10447 strings)

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

Translated using Weblate (Swedish)

Currently translated at 63.3% (6621 of 10447 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>
15 months agodocs: Add redirects configuration for gitlab pages
Peter Krempa [Mon, 3 Apr 2023 14:18:54 +0000 (16:18 +0200)]
docs: Add redirects configuration for gitlab pages

Adapt the configuration of redirects from the server hosting libvirt.org

The redirect to the 'libvirt-console-proxy' Golang module is not adapted
as it doesn't exist on the current server.

NOTES:
 - The redirects are currently configured for hosting via the
   'gitlab.io/libvirt' URI. For hosting via custom domain it will need
   to be rewritten to drop the '/libvirt' prefixes.

 - gitlab pages doesn't currently support redirects to outside content,
   thus most of the redirects don't actually work:

     https://gitlab.com/gitlab-org/gitlab-pages/-/issues/601

 - The redirects file is only installed in the webpage job but is not
   actually distributed.

 - The validity of the redirects can be checked by visiting:

     https://libvirt.gitlab.io/_redirects

   Having them installed allows us to validate them before we'll be
   switching to use gitlab pages completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
15 months agogitlab-ci: Configure website build to be published via gitlab pages
Peter Krempa [Mon, 3 Apr 2023 14:02:05 +0000 (16:02 +0200)]
gitlab-ci: Configure website build to be published via gitlab pages

On pushes to master publish the webpage (built in the 'website_job' job)
via gitlab pages. The 'pages' job uses the default image that gitlab
assumes as it's consuming artifacts from an existing job and naming
them properly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
15 months agoci: Regenerate with latest 'lcitool' and fix manual job definitions
Peter Krempa [Thu, 18 Jan 2024 15:20:14 +0000 (16:20 +0100)]
ci: Regenerate with latest 'lcitool' and fix manual job definitions

The latest lcitool merged the 'prebuilt-env' and 'local-env' jobs into
one which use variables to pick up the right environment and steps
rather than duplicating everything.

Regenerate the generated job definitions, fix the helper definitions
and also fix the manually defined jobs (website-job).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
15 months agonews: document my changes for 10.0.0
Ján Tomko [Wed, 17 Jan 2024 14:30:13 +0000 (15:30 +0100)]
news: document my changes for 10.0.0

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: Improve qemuDomainSupportsPCIMultibus()
Andrea Bolognani [Wed, 17 Jan 2024 08:53:19 +0000 (09:53 +0100)]
qemu: Improve qemuDomainSupportsPCIMultibus()

Rewrite the function so that it's more compact and easier to
extend as new architectures, which will likely come with
multibus support right out the gate, are introduced.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: Move qemuDomainSupportsPCIMultibus()
Andrea Bolognani [Wed, 17 Jan 2024 08:39:48 +0000 (09:39 +0100)]
qemu: Move qemuDomainSupportsPCIMultibus()

It belongs next to qemuDomainSupportsPCI().

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: Improve qemuDomainSupportsPCI()
Andrea Bolognani [Tue, 16 Jan 2024 15:42:18 +0000 (16:42 +0100)]
qemu: Improve qemuDomainSupportsPCI()

The way the function is currently written sort of obscures this
fact, but ultimately we already unconditionally assume PCI
support on most architectures.

Arm and RISC-V need some additional checks to maintain
compatibility with existing configurations but for all future
architectures, such as the upcoming LoongArch64, we expect PCI
support to come out of the box.

Last but not least, the functions is made const-correct.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: Retire QEMU_CAPS_OBJECT_GPEX
Andrea Bolognani [Tue, 16 Jan 2024 15:36:58 +0000 (16:36 +0100)]
qemu: Retire QEMU_CAPS_OBJECT_GPEX

It's no longer used anywhere.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: Stop checking QEMU_CAPS_OBJECT_GPEX
Andrea Bolognani [Tue, 16 Jan 2024 15:36:46 +0000 (16:36 +0100)]
qemu: Stop checking QEMU_CAPS_OBJECT_GPEX

For all versions of QEMU that we support, the virt machine type
has a hard dependency on this device, so we can stop checking
whether the capability is present and just use it unconditionally.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Request virtio-mmio for balloon-mmio-deflate
Andrea Bolognani [Tue, 16 Jan 2024 14:44:44 +0000 (15:44 +0100)]
tests: Request virtio-mmio for balloon-mmio-deflate

For all supported QEMU version, the virt machine type has a hard
dependency on PCI support, so if we want to test virtio-balloon
together with virtio-mmio we have to either request that
explicitly or trick libvirt by masking capabilities. Do the
former instead of the latter.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Simplify balloon-mmio-deflate
Andrea Bolognani [Tue, 16 Jan 2024 14:45:53 +0000 (15:45 +0100)]
tests: Simplify balloon-mmio-deflate

Drop everything that's not directly related to the scenario
being tested.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Drop various redundant tests
Andrea Bolognani [Tue, 16 Jan 2024 14:52:52 +0000 (15:52 +0100)]
tests: Drop various redundant tests

All of these are either a subset of other tests, or provide
coverage for scenarios that are not really possible: for all
versions of QEMU that we support, the virt machine type has a
hard dependency on the generic PCIe controller, which means
that we will never need to fall back to virtio-mmio.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Add {aarch64,riscv64}-virt-headless-mmio
Andrea Bolognani [Tue, 16 Jan 2024 14:51:31 +0000 (15:51 +0100)]
tests: Add {aarch64,riscv64}-virt-headless-mmio

Even though virtio-mmio is no longer the default on either
architecture, and likely nobody is using it at this point, we
still provide a way to opt into virtio-mmio usage and want to
keep existing guests working. Add explicit test suite coverage
for this scenario.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>