]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
14 months agosecret_conf: Simplify calling of virSecretDefParseUsage()
Michal Privoznik [Fri, 9 Feb 2024 11:07:03 +0000 (12:07 +0100)]
secret_conf: Simplify calling of virSecretDefParseUsage()

The virSecretDefParseUsage() function is called conditionally.
Call it unconditionally and keep pointer to the <usage/> node as
it'll come handy soon.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
14 months agoviraccessdriverpolkit: Add missing vtpm case
Michal Privoznik [Fri, 9 Feb 2024 08:03:29 +0000 (09:03 +0100)]
viraccessdriverpolkit: Add missing vtpm case

When adding vtpm virSecret usage type (in v5.6.0-rc1~61) we
forgot to update polkit access check. This limited user's ability
to match secrets in their rules. Add missing case into switch in
virAccessDriverPolkitCheckSecret().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
14 months agoqemu: handle adding/removing nbdkit-backed disk sources
Jonathon Jongsma [Thu, 25 Jan 2024 17:51:51 +0000 (11:51 -0600)]
qemu: handle adding/removing nbdkit-backed disk sources

Previously we were only starting or stopping nbdkit when the guest was
started or stopped or when hotplugging/unplugging a disk. But when doing
block operations, the disk backing store sources can also be be added or
removed independently of the disk device. When this happens the nbdkit
backend was not being handled properly. For example, when doing a
blockcopy from a nbdkit-backed disk to a new disk and pivoting to that
new location, the nbdkit process did not get cleaned up properly. Add
some functionality to qemuDomainStorageSourceAccessModify() to handle
this scenario.

Since we're now starting nbdkit from the ChainAccessAllow/Revoke()
functions, we no longer need to explicitly start nbdkit in hotplug code
paths because the hotplug functions already call these allow/revoke
functions and will start/stop nbdkit if necessary.

Add a check to qemuNbdkitProcessStart() to report an error if we
are trying to start nbdkit for a disk source that already has a running
nbdkit process. This shouldn't happen, and if it does it indicates an
error in another part of our code.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
14 months agoqemu: roll back if not all nbdkit backends are successful
Jonathon Jongsma [Thu, 25 Jan 2024 20:02:16 +0000 (14:02 -0600)]
qemu: roll back if not all nbdkit backends are successful

When starting nbdkit processes for the backing store of a disk, we were
returning an error if any backing store failed, but we were not cleaning
up processes that succeeded higher in the chain. Make sure that if we
return a failure status from qemuNbdkitStartStorageSource() that we roll
back any processes that had been started.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
14 months agoqemu: add a 'chain' parameter to nbdkit start/stop
Jonathon Jongsma [Thu, 25 Jan 2024 17:30:02 +0000 (11:30 -0600)]
qemu: add a 'chain' parameter to nbdkit start/stop

This will allow us to start or stop nbdkit for just a single disk source
or for every source in the backing chain. This will be used in following
patches.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
14 months agotests: Add capabilities for QEMU 8.2.0 on s390x
Andrea Bolognani [Fri, 9 Feb 2024 15:25:43 +0000 (16:25 +0100)]
tests: Add capabilities for QEMU 8.2.0 on s390x

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
14 months agotests: Update capabilities for QEMU 8.1.0 on s390x
Andrea Bolognani [Fri, 9 Feb 2024 15:44:09 +0000 (16:44 +0100)]
tests: Update capabilities for QEMU 8.1.0 on s390x

The existing capabilities were generated against a build made
quite early in the QEMU 8.1.0 development cycle. Update them
to match the final release.

A notable effect of this is that the recently introduced
s390-usb-model test now passes instead of failing: QEMU 8.1.0
enables several new devices on s390x, including the qemu-xhci
USB controller.

There's a small amount of additional churn caused by the fact
that the machine on which I have generated these capabilities
is apparently slightly less fancy than the one used originally.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
14 months agotests: Add s390-usb-model
Andrea Bolognani [Fri, 9 Feb 2024 16:15:10 +0000 (17:15 +0100)]
tests: Add s390-usb-model

Show what happens when trying to use a specific type of USB
controller. This currently fails because the QEMU binary doesn't
include the necessary device.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
14 months agotests: Minimize s390-usb-*
Andrea Bolognani [Fri, 9 Feb 2024 14:08:49 +0000 (15:08 +0100)]
tests: Minimize s390-usb-*

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
14 months agotests: Rename s390-usb-*
Andrea Bolognani [Fri, 9 Feb 2024 16:09:26 +0000 (17:09 +0100)]
tests: Rename s390-usb-*

These tests currently cover the scenarios in which the guest
can end up with no USB controller, one of which is specific
to s390x. We are going to add more USB on s390x scenarios, so
a different naming convention is needed.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
14 months agoqemu: fix nbdkit command test for backing chains
Jonathon Jongsma [Fri, 26 Jan 2024 16:41:58 +0000 (10:41 -0600)]
qemu: fix nbdkit command test for backing chains

Previously this test only tested the generated nbdkit command for the
top level disk source. Update it to test the generated commmands for all
sources in the chain.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
14 months agoci: regenerate
Ján Tomko [Thu, 8 Feb 2024 15:33:38 +0000 (16:33 +0100)]
ci: regenerate

Regenerate the ci files using the latest libvirt-ci:
commit 5b9b11261fa28cae964fd91638056318f270e300
    examples: illustrate use of remote project reference

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
14 months agoci: lcitool: sync dependencies with libvirt-ci repo
Ján Tomko [Thu, 8 Feb 2024 15:13:50 +0000 (16:13 +0100)]
ci: lcitool: sync dependencies with libvirt-ci repo

libvirt commit 120a674f25aa6e9e1ff7c2e9527f890f48f0340e
    ci: lcitool: Maintain project package deps lists here

added an override file for lcitool in August, but nobody regenerating
libvirt's ci files from the manifest seemed to use the override dir.

libvirt-ci commit 1f4184edfdd541964a187810b34ac4c7702b6577
    commandline: set --extra-data-dir default path
from January made $PWD/ci/lcitool the default.

Reflect the changes made in libvirt-ci's repo here too.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
14 months agodocs: Improve documentation for dies and clusters
Andrea Bolognani [Tue, 6 Feb 2024 17:56:39 +0000 (18:56 +0100)]
docs: Improve documentation for dies and clusters

I've seen examples in the wild of the cluster attribute having
non-zero value on x86_64.

This is obviously quite confusing, but it's the information that
Linux exposes to userspace and we don't really have a way to tell
apart a valid die/cluster ID from a dummy one.

What ultimately matters is that the underlying assumptions about
topology are respected, which they are: in the x86_64 cases that
I have analyzed, for example, each "cluster" contained exactly
one core, so any program that would use this information to
influence guest topology decisions would be unaffected by the
additional level showing up in the hierarchy.

In an attempt to reduce confusion, remove any reference to any
specific value for the attributes having any special meaning
attached to it.

In fact, since there are plans to make it possible to create
guests with multiple CPU clusters on x86_64, rework the note
into a more generic warning cautioning users that an attribute
showing up here does not imply that the same attribute can be
used when defining a guest CPU topology.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
14 months agodocs: page.xsl: Split up 'href_base' for assets and links
Peter Krempa [Wed, 7 Feb 2024 16:05:49 +0000 (17:05 +0100)]
docs: page.xsl: Split up 'href_base' for assets and links

To allow reuse of this template as-is in libvirt-wiki, we need to be
able to specify a distinct asset_href_base and link_href_base. Adjust
the template to allow that.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
14 months agodocs: xsl: Properly propagate 'href_base' as XSL template parameter
Peter Krempa [Wed, 7 Feb 2024 16:30:55 +0000 (17:30 +0100)]
docs: xsl: Properly propagate 'href_base' as XSL template parameter

Propagate it as a parameter both from site.xsl and from newapi.xsl, the
latter of which declared it as a variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
14 months agodocs: Move 'html including' from page.xsl to site.xsl
Peter Krempa [Wed, 7 Feb 2024 14:08:16 +0000 (15:08 +0100)]
docs: Move 'html including' from page.xsl to site.xsl

Strip down the main template as much as possible.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
14 months agocss: Move generic styles to 'generic.css'
Peter Krempa [Wed, 7 Feb 2024 13:27:43 +0000 (14:27 +0100)]
css: Move generic styles to 'generic.css'

Move the few generic styles to the appropriate document. 'libvirt.css'
will now be a compilation of styles related only to libvirt.org.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
14 months agocss: Move styles for the generated API documents to libvirt-api.css
Peter Krempa [Wed, 7 Feb 2024 13:23:24 +0000 (14:23 +0100)]
css: Move styles for the generated API documents to libvirt-api.css

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
14 months agocss: Remove unused CSS for migration support matrix table
Peter Krempa [Wed, 7 Feb 2024 13:18:23 +0000 (14:18 +0100)]
css: Remove unused CSS for migration support matrix table

The 'table tbody td.y' and 'table tbody td.n' selectors don't exist
since commit 8841302e3d46b2de0227dc2f97e4e647580e3d88 which converted
the table to rST.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
14 months agocss: Split out page templated styles to 'libvirt-template.css'
Peter Krempa [Wed, 7 Feb 2024 12:59:30 +0000 (13:59 +0100)]
css: Split out page templated styles to 'libvirt-template.css'

Separate the styles related to the main page template and the build
process specifics (docutils-originated) into a separate CSS file.

Hint: Best viewed with 'git show --color-moved=blocks'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
14 months agocss: mobile: Split up libvirt.org specific styles from main template style
Peter Krempa [Wed, 7 Feb 2024 09:45:17 +0000 (10:45 +0100)]
css: mobile: Split up libvirt.org specific styles from main template style

Separate the libvirt.org specific stuff from the main template style so
that the latter can be reused in libvirt-wiki without modification.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
14 months agojs: Separate the virt-tools blog planet loader code
Peter Krempa [Wed, 7 Feb 2024 09:31:02 +0000 (10:31 +0100)]
js: Separate the virt-tools blog planet loader code

In order to promote simple assets sharing between main libvirt web and
the libvirt-wiki separate the virt tools blog feed loader from the main
code used for search.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
14 months agodocs: page.xsl: Fix headerlinks with new docutils
Peter Krempa [Wed, 7 Feb 2024 15:54:22 +0000 (16:54 +0100)]
docs: page.xsl: Fix headerlinks with new docutils

New docutils generates a <section> element rather than a <div
class='section'> as it did before thus breaking our headerlink
generator.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
14 months agogitlab_pages: Fix 'maven' redirect
Peter Krempa [Wed, 7 Feb 2024 13:28:28 +0000 (14:28 +0100)]
gitlab_pages: Fix 'maven' redirect

The redirect to the 'maven' repository of libvirt doesn't work currently
for libvirt pages as the ':splat' replacement doesn't match due to a
missing '/'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoexamples: Define _GNU_SOURCE for more examples
Michal Privoznik [Wed, 7 Feb 2024 12:28:15 +0000 (13:28 +0100)]
examples: Define _GNU_SOURCE for more examples

Some of our examples use GNU/Linux extensions functions/variables:

1) domtop.c uses usleep(3),
2) logging.c uses getopt(3).

Put _GNU_SOURCE definition at the top of corresponding files so
that users can just grab the code and compile it (in contrast
with the rest of the code where _GNU_SOURCE is declared in
meson-config.h).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirsh-domain: Fix return of virshGetDBusDisplay() in one error path
Michal Privoznik [Wed, 7 Feb 2024 12:28:31 +0000 (13:28 +0100)]
virsh-domain: Fix return of virshGetDBusDisplay() in one error path

The virshGetDBusDisplay() function is declared to return a
pointer and yet, in one error path false is returned. Switch the
statement to return NULL, which is what other error paths use to
indicate an error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Wed, 7 Feb 2024 10:36:47 +0000 (11:36 +0100)]
Translated using Weblate (Swedish)

Currently translated at 67.2% (7022 of 10447 strings)

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

Translated using Weblate (Swedish)

Currently translated at 67.0% (7002 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 agoNEWS: Mention systemd-resolved support in network driver
Jiri Denemark [Thu, 1 Feb 2024 20:56:45 +0000 (21:56 +0100)]
NEWS: Mention systemd-resolved support in network driver

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agonetwork: Make virtual domains resolvable from the host
Jiri Denemark [Wed, 31 Jan 2024 11:20:54 +0000 (12:20 +0100)]
network: Make virtual domains resolvable from the host

This patch adds a new attribute "register" to the <domain> element. If
set to "yes", the DNS server created for the virtual network is
registered with systemd-resolved as a name server for the associated
domain. The names known to the dnsmasq process serving DNS and DHCP
requests for the virtual network will then be resolvable from the host
by appending the domain name to them.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Add tests for virSystemdResolvedRegisterNameServer
Jiri Denemark [Thu, 25 Jan 2024 15:22:24 +0000 (16:22 +0100)]
tests: Add tests for virSystemdResolvedRegisterNameServer

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoutil: Introduce virSystemdResolvedRegisterNameServer
Jiri Denemark [Wed, 31 Jan 2024 11:20:41 +0000 (12:20 +0100)]
util: Introduce virSystemdResolvedRegisterNameServer

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoutil: Introduce virSocketAddrBytes
Jiri Denemark [Wed, 31 Jan 2024 10:58:47 +0000 (11:58 +0100)]
util: Introduce virSocketAddrBytes

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoutil: Introduce virSystemdHasResolved
Jiri Denemark [Thu, 25 Jan 2024 11:45:26 +0000 (12:45 +0100)]
util: Introduce virSystemdHasResolved

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoutil: Unify virSystemdHas{Machined,Logind}
Jiri Denemark [Thu, 25 Jan 2024 11:38:00 +0000 (12:38 +0100)]
util: Unify virSystemdHas{Machined,Logind}

When checking for machined we do not really care whether systemd itself
is running, we just need machined to be either running or socket
activated by systemd. That is, exactly the same we do for logind.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu_monitor: Simplify qemuMonitorIOWriteWithFD()
Michal Privoznik [Fri, 2 Feb 2024 12:08:58 +0000 (13:08 +0100)]
qemu_monitor: Simplify qemuMonitorIOWriteWithFD()

After previous cleanups, qemuMonitorIOWriteWithFD() is but a thin wrapper
over virSocketSendMsgWithFDs(). Replace the body of the former
with a call to the latter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirsocket: Simplify virSocketSendFD()
Michal Privoznik [Fri, 2 Feb 2024 12:05:20 +0000 (13:05 +0100)]
virsocket: Simplify virSocketSendFD()

After previous cleanups, virSocketSendFD() is but a thin wrapper
over virSocketSendMsgWithFDs(). Replace the body of the former
with a call to the latter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirSocketSendMsgWithFDs: Introduce @payload_len argument
Michal Privoznik [Fri, 2 Feb 2024 12:05:08 +0000 (13:05 +0100)]
virSocketSendMsgWithFDs: Introduce @payload_len argument

Instead of using strlen() to calculate length of payload we're
sending, let caller specify the size: they may want to send just
a portion of a buffer (even though the only current user
doesn't).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirSocketSendMsgWithFDs: Don't report errors, just set errno
Michal Privoznik [Fri, 2 Feb 2024 11:56:04 +0000 (12:56 +0100)]
virSocketSendMsgWithFDs: Don't report errors, just set errno

Currently, virSocketSendMsgWithFDs() reports two errors:

1) if CMSG_FIRSTHDR() fails,
2) if sendmsg() fails.

Well, the latter sets an errno, so caller can just use
virReportSystemError(). And the former - it is very unlikely to
fail because memory for whole control message was allocated just
a few lines above.

The motivation is to unify behavior of virSocketSendMsgWithFDs()
and virSocketSendFD() because the latter is just a subset of the
former (will be addressed later).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sun, 4 Feb 2024 21:36:00 +0000 (22:36 +0100)]
Translated using Weblate (Swedish)

Currently translated at 66.6% (6962 of 10447 strings)

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

Translated using Weblate (Swedish)

Currently translated at 66.0% (6902 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 agovirt-admin: Add warning when connection to default daemon fails
Peter Krempa [Thu, 1 Feb 2024 09:40:41 +0000 (10:40 +0100)]
virt-admin: Add warning when connection to default daemon fails

The admin connection defaults to the system-wide 'libvirtd' daemon to
manage (libvirtd:///system). As we've now switched to modular daemons
this will not work for most users out of the box:

 $ virt-admin version
 error: Failed to connect to the admin server
 error: no valid connection
 error: Failed to connect socket to '/run/user/1000/libvirt/libvirt-admin-sock': No such file or directory

As we don't want to assume which daemon the user wants to manage in the
modular topology there's no reasonable default to pick.

Give a hint to the users to use the '-c' if the connection to the
default URI fails:

 $ virt-admin version
 NOTE: Connecting to default daemon. Specify daemon using '-c' (e.g. virtqemud:///system)
 error: Failed to connect to the admin server
 error: no valid connection
 error: Failed to connect socket to '/run/user/1000/libvirt/libvirt-admin-sock': No such file or directory

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
15 months agoqemuBlockStorageSourceNeedsFormatLayer: Stop formatting 'raw' driver when not needed
Peter Krempa [Thu, 19 Oct 2023 20:07:49 +0000 (22:07 +0200)]
qemuBlockStorageSourceNeedsFormatLayer: Stop formatting 'raw' driver when not needed

The 'raw' driver without any special configuration is not needed and
creates overhead in qemu.

Stop using the 'raw' format driver in cases when it's not needed. A
special case when it is needed is for FD passed images with only a
single writable FD passed, where we need an overlay driver to properly
reflect the 'read-only' flag.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: monitor: Use 'backing-mask-protocol' for blockjobs when available
Peter Krempa [Fri, 24 Nov 2023 14:38:11 +0000 (15:38 +0100)]
qemu: monitor: Use 'backing-mask-protocol' for blockjobs when available

Store whether qemu supports the appropriate option for block-stream and
block-commit commands and always use it if available.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: capabilities: Introduce QEMU_CAPS_BLOCKJOB_BACKING_MASK_PROTOCOL
Peter Krempa [Fri, 24 Nov 2023 14:19:35 +0000 (15:19 +0100)]
qemu: capabilities: Introduce QEMU_CAPS_BLOCKJOB_BACKING_MASK_PROTOCOL

The capability is asserted when both block-stream and block-commit QMP
commands support the 'backing-mask-protocol' argument.

The argument causes qemu to record 'raw' as the backing file format in
case when a protocol node is used directly. This is needed to preserve
compatibility of images after a block-commit or block-pull libvirt
operation with older libvirt versions in case when we'll want to remove
the unneded 'raw' format drivers from the block graph.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: qemucapabilitiesdata: Update 'caps_9.0.0_x86_64.replies'
Peter Krempa [Thu, 1 Feb 2024 11:57:29 +0000 (12:57 +0100)]
tests: qemucapabilitiesdata: Update 'caps_9.0.0_x86_64.replies'

Update to 'v8.2.0-952-g14639717bf'.

Notable changes:
 - 'backing-mask-protocol' feature added for block-commit and block-stream
 - 'singlestep' mode dropped
 - 'cmpccxadd' cpu feature became available

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirsocket: Drop unused #include and #define
Michal Privoznik [Fri, 2 Feb 2024 11:49:22 +0000 (12:49 +0100)]
virsocket: Drop unused #include and #define

Inside of virsocket.c there is an include of poll.h and
PKT_TIMEOUT_MS macro definition. Neither of these is really
needed and in fact it's a leftover after I reworked one of
previously merged commits during review.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoch: Enable ETHERNET Network mode support
Praveen K Paladugu [Tue, 16 Jan 2024 21:25:43 +0000 (15:25 -0600)]
ch: Enable ETHERNET Network mode support

enable VIR_DOMAIN_NET_TYPE_ETHERNET network support for ch guests.

Tested with following interface config:

    <interface type='ethernet'>
      <target dev='chtap0' managed="yes"/>
      <model type='virtio'/>
      <driver queues='2'/>
    <interface>

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
15 months agoch: Introduce version based cap for network support
Praveen K Paladugu [Tue, 16 Jan 2024 21:25:42 +0000 (15:25 -0600)]
ch: Introduce version based cap for network support

This capability checks if ch can receive multiple fds along with net-add
api. This capability is required to enable multiple queues for
domain/guest interfaces.

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
15 months agoutil: Add util methods required by ch networking
Praveen K Paladugu [Tue, 16 Jan 2024 21:25:41 +0000 (15:25 -0600)]
util: Add util methods required by ch networking

virSocketSendMsgWithFDs method send fds along with payload using
SCM_RIGHTS. virSocketRecv method polls, receives and sends the response
to callers.

These methods are required to add network suppport in ch driver.

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
15 months agohypervisor: Move domain interface mgmt methods
Praveen K Paladugu [Tue, 16 Jan 2024 21:25:40 +0000 (15:25 -0600)]
hypervisor: Move domain interface mgmt methods

Move domain interface management methods from qemu to hypervisor. This
refactoring allows the domain management methods to be shared between CH and
qemu drivers.

This commit does not introduce any functional changes.

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
15 months agoconf: Drop unused parameter
Praveen K Paladugu [Tue, 16 Jan 2024 21:25:39 +0000 (15:25 -0600)]
conf: Drop unused parameter

Drop unused parameter from virDomainNetReleaseActualDevice method.

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
15 months agodocs: Fix typo in network XML documentation
Jiri Denemark [Thu, 1 Feb 2024 20:55:49 +0000 (21:55 +0100)]
docs: Fix typo in network XML documentation

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
15 months agoconf: Fix error message in virNetworkForwardDefParseXML
Jiri Denemark [Thu, 1 Feb 2024 10:32:35 +0000 (11:32 +0100)]
conf: Fix error message in virNetworkForwardDefParseXML

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu-replies-tool: Dump 'device-list-properties'
Peter Krempa [Thu, 4 Jan 2024 12:22:34 +0000 (13:22 +0100)]
qemu-replies-tool: Dump 'device-list-properties'

The order of properties in 'device-list-properties' can hange
arbitrarily and git is not great at picking the contexts in JSON to help
seeing what changed.

The new --dump-device-list-properties produces a stable order of
properties and dumps also the type and default value mainly useful for
comparing two .replies files.

Example output:

$ ./scripts/qemu-replies-tool.py tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies --dump-device-list-properties
(dev) ICH9-LPC acpi-index uint32 (0)
(dev) ICH9-LPC acpi-pci-hotplug-with-bridge-support bool
(dev) ICH9-LPC acpi_disable_cmd uint8
(dev) ICH9-LPC acpi_enable_cmd uint8
(dev) ICH9-LPC addr int32 (-1)
(dev) ICH9-LPC cpu-hotplug-legacy bool
(dev) ICH9-LPC disable_s3 uint8
(dev) ICH9-LPC disable_s4 uint8

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 agoqemu-replies-tool: Dump 'qom-list-types'
Peter Krempa [Thu, 4 Jan 2024 12:22:34 +0000 (13:22 +0100)]
qemu-replies-tool: Dump 'qom-list-types'

The order of entries in 'qom-list-types' sometimes changes arbitrarily.

The --dump-qom-list-types produces a stable order and drops the for
libvirt unneeded 'parent' information.

Sample output:

$ ./scripts/qemu-replies-tool.py tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies --dump-qom-list-types
(qom) 486-v1-x86_64-cpu
(qom) 486-x86_64-cpu
(qom) AC97
(qom) AMDVI-PCI
(qom) Broadwell-IBRS-x86_64-cpu
(qom) Broadwell-noTSX-IBRS-x86_64-cpu
(qom) Broadwell-noTSX-x86_64-cpu
(qom) Broadwell-v1-x86_64-cpu
(qom) Broadwell-v2-x86_64-cpu
(qom) Broadwell-v3-x86_64-cpu

[...]

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 agoqemu-replies-tool: Add mode to dump all QMP schema query strings
Peter Krempa [Mon, 15 Jan 2024 20:56:39 +0000 (21:56 +0100)]
qemu-replies-tool: Add mode to dump all QMP schema query strings

Make the tool useful also for non-testing purposes by adding 'dump'
mode, which will process the data and output information about the qemu
version.

The first 'dump' mode produces all possible valid query strings per
virQEMUQAPISchemaPathGet/virQEMUCapsQMPSchemaQueries. This is useful for
users to look up a query string via 'grep' rather than trying to come up
with it manually.

Additionally the data as represented by qemu changes naming very often
and that makes it un-reviewable to find changes between two qemu builds.
By using the dump mode, which produces results in stable order we can
use it to 'diff' two .replies file without churn.

Sample output '[...]' denotes an arbitrary trim:

$ ./scripts/qemu-replies-tool.py tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies --dump-qmp-query-strings
[...]
(qmp) blockdev-add
(qmp) blockdev-add/arg-type/auto-read-only
(qmp) blockdev-add/arg-type/auto-read-only/!bool
(qmp) blockdev-add/arg-type/cache
(qmp) blockdev-add/arg-type/cache/direct
(qmp) blockdev-add/arg-type/cache/direct/!bool
(qmp) blockdev-add/arg-type/cache/no-flush
(qmp) blockdev-add/arg-type/cache/no-flush/!bool
(qmp) blockdev-add/arg-type/detect-zeroes
(qmp) blockdev-add/arg-type/detect-zeroes/^off
(qmp) blockdev-add/arg-type/detect-zeroes/^on
(qmp) blockdev-add/arg-type/detect-zeroes/^unmap
[...]
(qmp) blockdev-add/arg-type/driver
(qmp) blockdev-add/arg-type/driver/^blkdebug
(qmp) blockdev-add/arg-type/driver/^blklogwrites
(qmp) blockdev-add/arg-type/driver/^blkreplay
(qmp) blockdev-add/arg-type/driver/^blkverify
(qmp) blockdev-add/arg-type/driver/^bochs
(qmp) blockdev-add/arg-type/driver/^cloop
[...]
(qmp) blockdev-add/arg-type/+blkdebug
(qmp) blockdev-add/arg-type/+blkdebug/align
(qmp) blockdev-add/arg-type/+blkdebug/align/!int
(qmp) blockdev-add/arg-type/+blkdebug/config
(qmp) blockdev-add/arg-type/+blkdebug/config/!str
(qmp) blockdev-add/arg-type/+blkdebug/image
(qmp) blockdev-add/arg-type/+blkdebug/image (recursion)
(qmp) blockdev-add/arg-type/+blkdebug/image/!str
(qmp) blockdev-add/arg-type/+blkdebug/inject-error

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 agoqemu-replies-tool: Add validation of known fields in 'query-qmp-schema'
Peter Krempa [Mon, 15 Jan 2024 16:07:51 +0000 (17:07 +0100)]
qemu-replies-tool: Add validation of known fields in 'query-qmp-schema'

If the schema itself is extended in qemu we need to have a notification
to add appropriate handling to ensure that we have full coverage of all
fields.

Add validation that only fields that libvirt currently knows about are
present in the schema.

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 agoqemumonitortestutils: Unexport 'qemuMonitorTestProcessFileEntries'
Peter Krempa [Mon, 15 Jan 2024 14:47:02 +0000 (15:47 +0100)]
qemumonitortestutils: Unexport 'qemuMonitorTestProcessFileEntries'

Unexport the function and 'struct qemuMonitorTestCommandReplyTuple' as
they are currently used only in tests/qemumonitortestutils.c

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 agoutil: json: Remove 'virJSONValueObjectReplaceValue'
Peter Krempa [Mon, 15 Jan 2024 14:42:14 +0000 (15:42 +0100)]
util: json: Remove 'virJSONValueObjectReplaceValue'

The helper was used only in 'qemucapabilitiesnumbering' test which was
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 agotests: Remove 'qemucapabilitiesnumbering' test
Peter Krempa [Mon, 15 Jan 2024 14:37:30 +0000 (15:37 +0100)]
tests: Remove 'qemucapabilitiesnumbering' test

The test case was completely replaced by the 'qemu-replies-tool.py'
script in default mode.

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 agoscripts: Add 'qemu-replies-tool' script for testing and modifying data for qemucapabi...
Peter Krempa [Thu, 18 May 2023 14:12:09 +0000 (16:12 +0200)]
scripts: Add 'qemu-replies-tool' script for testing and modifying data for qemucapabilitiestest

The tool in the current shape functionally replaces
tests/qemucapabilitiesnumbering.c

It validates that the output '.replies' files conform to how we generate
them from qemu and also allows programmatic modification of the
'.replies' files if re-generation is not feasible any more.

The main advantage is that JSON objects are parsed into native python
types and thus the programatic modification is much more convenient.

The tool will be later extended to also do validation that we properly
handle the whole of QMP schema as well as help in reviewing the
differences in the .replies file after qemu updates.

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 agotests: qemucaps: Make JSON output identical to python's 'json.dump' method
Peter Krempa [Wed, 3 Jan 2024 21:02:43 +0000 (22:02 +0100)]
tests: qemucaps: Make JSON output identical to python's 'json.dump' method

YAJL formats empty objects and arrays in a weird way:

 {
   "emptyarray": [

   ],
   "emptyobject": {

   }
 }

We want to use empty lines to separate commands and replies as well as
be compatible with python's 'json.dump' method, thus we drop any
whitespace between array/object braces.

Adjust the two formatters which are used for capabilities and fix all
output files.

Note that the code is duplicated in qemucapabilitiesnumbering.c and
qemucapsprobemock.c, but later patches will replace
qemucapabilitiesnumbering.c by a python tool.

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 agoqemu: Use virDomainControllerDefNew() more
Andrea Bolognani [Fri, 26 Jan 2024 18:56:06 +0000 (19:56 +0100)]
qemu: Use virDomainControllerDefNew() more

Instead of open-coding a partial version of it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
15 months agoqemu: Handle MODEL_SCSI_{AUTO,DEFAULT} appropriately
Andrea Bolognani [Fri, 26 Jan 2024 18:40:12 +0000 (19:40 +0100)]
qemu: Handle MODEL_SCSI_{AUTO,DEFAULT} appropriately

The qemuDomainGetSCSIControllerModel() function, which is
responsible for choosing a model for a SCSI controller that
didn't have one provided by the user, considers values >0 to
mean "model has been set".

Since MODEL_SCSI_AUTO == 0, this means that such a value is
considered the same as MODEL_SCSI_DEFAULT (-1). This makes
sense, as not specifying a model name or explicitly asking for
one to be automatically chosen intuitively should result in
the same behavior.

Specifically, there is no case in which a value of
MODEL_SCSI_AUTO or MODEL_SCSI_DEFAULT is encountered after the
initial controller creation: it is either replaced with an
actual model, or an error is raised.

Despite this, there are a few places in the QEMU driver where
we incorrectly treat these values as if they were actual
model names. To reduce confusion, make sure that no longer
happens.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
15 months agotests: Add controller-scsi-auto
Andrea Bolognani [Fri, 26 Jan 2024 18:37:31 +0000 (19:37 +0100)]
tests: Add controller-scsi-auto

The "auto" SCSI controller model was introduced for use in the
ESX driver, but the QEMU driver doesn't reject the value.

Add a test case showing the behavior when such a configuration
is encountered.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
15 months agovirPCIVPDParse: Do reasonable error reporting
Peter Krempa [Mon, 29 Jan 2024 16:12:43 +0000 (17:12 +0100)]
virPCIVPDParse: Do reasonable error reporting

Remove the wannabe error reporting via 'VIR_DEBUG/VIR_INFO' in favor of
proper errors.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirPCIVPDParseVPDLargeResourceFields: Report proper errors
Peter Krempa [Tue, 30 Jan 2024 15:55:50 +0000 (16:55 +0100)]
virPCIVPDParseVPDLargeResourceFields: Report proper errors

The code abused 'VIR_INFO' as an attempt at error reporting. Rework the
code to return the usual 0/-1 and raise proper errors.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirPCIVPDParseVPDLargeResourceFields: Refactor return logic
Peter Krempa [Tue, 30 Jan 2024 15:45:39 +0000 (16:45 +0100)]
virPCIVPDParseVPDLargeResourceFields: Refactor return logic

Rewrite the conditions after exiting the parser so that they are easier
to understand. This partially decreases the granularity of "error"
messages as they are not strictly necessary albeit for debugging.

As it was already observed in this code the logic itself often does
something else than the comment claims, thus the code logic is
preserved.

Changes:
 - any case when not all data was processed is aggregated together and
   gets a common "error" message
 - absence of 'checksum' field is checked separately
 - helper variables are removed as they are no longer needed

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirPCIVPDParseVPDLargeResourceFields: Refactor processing of read data
Peter Krempa [Tue, 30 Jan 2024 14:14:49 +0000 (15:14 +0100)]
virPCIVPDParseVPDLargeResourceFields: Refactor processing of read data

Use a 'switch' statement instead of a bunch of if/elseif statements.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirPCIVPDParseVPDLargeResourceFields: Remove impossible 'default' switch case
Peter Krempa [Tue, 30 Jan 2024 14:05:20 +0000 (15:05 +0100)]
virPCIVPDParseVPDLargeResourceFields: Remove impossible 'default' switch case

The 'fieldFormat' variable is guaranteed to have only the proper enum
values by virPCIVPDResourceGetFieldValueFormat.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
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>