]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
14 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>
14 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>
14 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>
14 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>
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>