]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
18 months agorpcgen: add a C code generator for XDR protocol specs
Daniel P. Berrangé [Mon, 19 Dec 2022 19:08:09 +0000 (14:08 -0500)]
rpcgen: add a C code generator for XDR protocol specs

This implements a C code generator that emits code that is
(almost) identical to the classic 'rpcgen' program. The
key differences are:

 - Skip inlining of calls for struct fields
 - Skip K&R style function prototypes in headers
 - Use int64_t instead of quad_t for OS portability
 - Saner whitespace / indentation

The tests/demo.c and tests/demo.h files were created using
the traditional 'rpcgen' program, and then editted to cut
out the leading boilerplate, and the differences mentioned
above.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpcgen: define a visitor API for XDR protocol specs
Daniel P. Berrangé [Mon, 19 Dec 2022 19:06:30 +0000 (14:06 -0500)]
rpcgen: define a visitor API for XDR protocol specs

The visitor API defines an interface for visiting each element
in the XDR protocol spec abstract syntax tree.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpcgen: add an XDR protocol parser
Daniel P. Berrangé [Mon, 19 Dec 2022 17:52:29 +0000 (12:52 -0500)]
rpcgen: add an XDR protocol parser

This adds a parser capable of handling the XDR protocol files.

The parsing grammar requirements are detailed in

  https://www.rfc-editor.org/rfc/rfc4506#section-6.3

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpcgen: add an XDR protocol abstract syntax tree
Daniel P. Berrangé [Mon, 19 Dec 2022 17:52:29 +0000 (12:52 -0500)]
rpcgen: add an XDR protocol abstract syntax tree

This introduces classes needed to form an abstract syntax
tree representing the XDR protocol language.

The syntax requirements are detailed in

  https://www.rfc-editor.org/rfc/rfc4506#section-6.3

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpcgen: add an XDR protocol lexer
Daniel P. Berrangé [Mon, 19 Dec 2022 17:48:06 +0000 (12:48 -0500)]
rpcgen: add an XDR protocol lexer

This adds a lexer capable of handling the XDR protocol files.

The lexical rquirements are detailed in

  https://www.rfc-editor.org/rfc/rfc4506#section-6.2

pytest is introduced as a build dependancy for testing python
code.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agobuild-aux: introduce 'black' tool for python formatting
Daniel P. Berrangé [Wed, 1 Feb 2023 16:19:16 +0000 (11:19 -0500)]
build-aux: introduce 'black' tool for python formatting

The 'black' tool is intended to be an opinionated formatting
tool for python code. It is complementary to flake8 which
validates coding bad practices, but (mostly) ignores code
layout issues.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agobuild-aux: skip E203 and W503 flake8 checks
Daniel P. Berrangé [Tue, 17 Jan 2023 18:01:59 +0000 (13:01 -0500)]
build-aux: skip E203 and W503 flake8 checks

The flake8 check W503 does not want a line break before
binary operator. This is contrary to the style that the
'black' formatting tool wants to use. Defer to 'black'
as it is intended to be an opinionated formatting tool
standardizing python code style, and thus not to be
customized per project.

The flake8 check E203 does not want whitespace before
a ':'. This is, however, desirable when indexing array
slices eg

   self.lookahead[skip : skip + 1]

which is a format that 'black' produces.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpcgen: drop type-puning workarounds
Daniel P. Berrangé [Tue, 20 Dec 2022 17:14:07 +0000 (12:14 -0500)]
rpcgen: drop type-puning workarounds

The current RPC code is post-processed to introduce an
intermediate variable, rather than casting directly
to char ** at time of use. This is said to be a workaround
for type-puning warnings that the compiler emitted.

Neither GCC or CLang emit any warnings for the code in
question today, across any of the architectures we
test in CI. Thus it is presumed that somewhere in the
15 years since the workaround was done, the compilers
have got smarter and do the right thing.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agotests: ignore $__CF_USER_TEXT_ENCODING in env during commandtest
Laine Stump [Fri, 3 Nov 2023 03:55:27 +0000 (23:55 -0400)]
tests: ignore $__CF_USER_TEXT_ENCODING in env during commandtest

This environment variable is supposedly set according to the contents
of ~/.CFUserTextEncoding, and certainly on MacOS 14 (Sonoma) it is set
in the environment of child processes created by execve() (used by
virCommand()), causing commandtest to fail. (However, the value that is
shown in $__CF_USER_TEXT_ENCODING during the test 1) is not in the
environment of the shell the test is run from, and 2) doesn't match
the contents of ~/.CFUserTextEncoding.)

It is true, though, that filtering out this environment setting from
the test results permits commandtest to pass on macOS 14 (Sonoma).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
18 months agoqemu_process: fix crash in qemuSaveImageDecompressionStart
Pavel Hrdina [Fri, 3 Nov 2023 13:03:55 +0000 (14:03 +0100)]
qemu_process: fix crash in qemuSaveImageDecompressionStart

Commit changing the code to allow passing NULL as @data into
qemuSaveImageDecompressionStart() was not correct as it left the
original call into the function as well.

Introduced-by: 2f3e582a1ac1008eba8d43c751cdba8712dd1614
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2247754
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agorpc: Make rpcgen produce ANSI C code
Andrea Bolognani [Thu, 2 Nov 2023 23:04:29 +0000 (00:04 +0100)]
rpc: Make rpcgen produce ANSI C code

This is the default for the version of rpcgen shipped with
Linux distributions, but the one in macOS and possibly others
default to K&R C, which modern compilers don't appreciate.

Luckily, all versions of rpcgen shipped with our target
platforms seem to support the -C option.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agoqemu: block: Remove unused flags QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_ flags
Peter Krempa [Thu, 19 Oct 2023 15:39:15 +0000 (17:39 +0200)]
qemu: block: Remove unused flags QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_ flags

QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP is no longer
referenced inside the code.

QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY is passed from
various code paths to the qemuBlockStorageSourceGetBackendProps helper,
but it's no longer used.

Both thus can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuBlockStorageSourceGetBackendProps: Remove unused logic for (auto-)read-only flags
Peter Krempa [Thu, 19 Oct 2023 15:37:14 +0000 (17:37 +0200)]
qemuBlockStorageSourceGetBackendProps: Remove unused logic for (auto-)read-only flags

The code was refactored to format the 'read-only' and 'auto-read-only'
flags via the common helper, so the logic determining their values can
be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuBlockStorageSourceGetBackendProps: Use qemuBlockStorageSourceAddBlockdevCommonProps
Peter Krempa [Thu, 19 Oct 2023 14:23:23 +0000 (16:23 +0200)]
qemuBlockStorageSourceGetBackendProps: Use qemuBlockStorageSourceAddBlockdevCommonProps

Use the qemuBlockStorageSourceAddBlockdevCommonProps helper when
formatting protocol layer both when it's used as backing for a format
node and when it's used as the effective node.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuBuildHostdevSCSIAttachPrepare: Use "effective node" mode for getting blockdev...
Peter Krempa [Thu, 19 Oct 2023 14:13:43 +0000 (16:13 +0200)]
qemuBuildHostdevSCSIAttachPrepare: Use "effective node" mode for getting blockdev props

The resulting properties are identical, as the hostdev backend code
doesn't set any of the extra properties.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuBlockStorageSourceGetBackendProps: Introduce QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PR...
Peter Krempa [Thu, 19 Oct 2023 14:12:38 +0000 (16:12 +0200)]
qemuBlockStorageSourceGetBackendProps: Introduce QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_EFFECTIVE_NODE

Introduce a mode where the protocol layer -blockdev will be formatted
so that it can be used as the effective node (used to access data from
the device). For this new mode we'll use
qemuBlockStorageSourceAddBlockdevCommonProps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: block: Use qemuBlockStorageSourceAddBlockdevCommonProps for storage slice
Peter Krempa [Tue, 24 Oct 2023 10:38:57 +0000 (12:38 +0200)]
qemu: block: Use qemuBlockStorageSourceAddBlockdevCommonProps for storage slice

Use the new helper in qemuBlockStorageSourceGetBlockdevStorageSliceProps
to format the common bits.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: block: Add helper to add common properties for -blockdev configuration
Peter Krempa [Thu, 19 Oct 2023 14:04:11 +0000 (16:04 +0200)]
qemu: block: Add helper to add common properties for -blockdev configuration

The new helper replaces qemuBlockStorageSourceGetBlockdevFormatCommonProps
and the two inline instances generating the common properties for a
blockdev layer.

The new helper is to be used for both the format layer and the storage
backing layer, thus a new parameter 'effective' switches between the
modes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuBlockStorageSourceGetBackendProps: Unify ordering of fields
Peter Krempa [Tue, 24 Oct 2023 13:19:39 +0000 (15:19 +0200)]
qemuBlockStorageSourceGetBackendProps: Unify ordering of fields

Use the same ordering of the relevant fields as we do for the format
layer -blockdev so that later they can be refactored without test
fallout.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agovirDomainDiskGetDetectZeroesMode: Return proper type
Peter Krempa [Thu, 19 Oct 2023 13:11:15 +0000 (15:11 +0200)]
virDomainDiskGetDetectZeroesMode: Return proper type

Change the return value type to 'virDomainDiskGetDetectZeroes'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuBlockStorageSourceGetBackendProps: Unify cases for '!onlytarget' and '!legacy'
Peter Krempa [Wed, 18 Oct 2023 11:58:29 +0000 (13:58 +0200)]
qemuBlockStorageSourceGetBackendProps: Unify cases for '!onlytarget' and '!legacy'

At this point only a single code path (for formatting -drive for legacy
SD cards) uses the 'legacy' output and that code path doesn't populate
the node name. Thus we can unify the code block and simplify the JSON
formatters.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agosrc: Remove duplicated VIR_REQUIRE_FLAG_GOTO() call
Andrea Bolognani [Tue, 31 Oct 2023 10:07:49 +0000 (11:07 +0100)]
src: Remove duplicated VIR_REQUIRE_FLAG_GOTO() call

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agologging: lockdown the systemd service configuration
Daniel P. Berrangé [Fri, 4 Mar 2022 11:59:23 +0000 (11:59 +0000)]
logging: lockdown the systemd service configuration

The 'systemd-analyze security' command looks at the unit file
configuration and reports on any settings which increase the
attack surface for the daemon. Since most systemd units are
fairly minimalist, this is generally informing us about settings
that we never put any thought into using before.

In its current configuration it reports

  # systemd-analyze security virtlogd.service
  ...snip...
  → Overall exposure level for virtlogd.service: 9.6 UNSAFE 😨

which is pretty terrible as a score.

If we apply all of the recommendations that appear possible
without (knowingly) breaking functionality it reports:

  # systemd-analyze security virtlogd.service
  ...snip...
  → Overall exposure level for virtlogd.service: 2.2 OK 🙂

which is a pretty decent improvement.

Some of the settings we would like to enable require a systemd
version that is newer than that available in our oldest distro
target - RHEL-8 at v239.

NB, RestrictSUIDSGID is technically newer than 239, but RHEL-8
backported it, and other distros we target have it by default.

Remaining recommendations are

✗ CapabilityBoundingSet=~CAP_(DAC_*|FOWNER|IPC_OWNER)

  We block FOWNER/IPC_OWNER, but can't block the two DAC
  capabilities. Historically apps/users might point QEMU
  to log files in $HOME, pre-created with their own user
  ID.

✗ IPAddressDeny=

  Not required since RestrictAddressFamilies blocks IP
  usage. Ignoring this avoids the overhead of creating
  a traffic filter than will never be used.

✗ NoNewPrivileges=

  Highly desirable, but cannot enable it yet, because it
  will block the ability to transition to the virtlogd_t
  SELinux domain during execve. The SELinux policy needs
  fixing to permit this transition under NNP first.

✗ PrivateTmp=

  There is a decent chance people have VMs configured
  with a serial port logfile pointing at /tmp. We would
  cause a regression to use private /tmp for logging

✗ PrivateUsers=

  This would put virtlogd inside a user namespace where
  its root is in fact unprivileged. Same problem as the
  User= setting below

✗ ProcSubset=

  Libraries we link to might read certain non-PID related
  files from /proc

✗ ProtectClock=

  Requires v245

✗ ProtectHome=

  Same problem as PrivateTmp=. There's a decent chance
  that someone has a VM configured to write a logfile
  to /home

✗ ProtectHostname=

  Requires v241

✗ ProtectKernelLogs

  Requires v244

✗ ProtectProc

  Requires v247

✗ ProtectSystem=

  We only set it to 'full', as 'strict' is not viable for
  our required usage

✗ RootDirectory=/RootImage=

  We are not capable of running inside a custom chroot
  given needs to write log files to arbitrary places

✗ RestrictAddressFamilies=~AF_UNIX

  We need AF_UNIX to communicate with other libvirt daemons

✗ SystemCallFilter=~@resources

  We link to libvirt.so which links to libnuma.so which has
  a constructor that calls set_mempolicy. This is highly
  undesirable todo during a constructor.

✗ User=/DynamicUser=

  This is highly desirable, but we currently read/write
  logs as root, and directories we're told to write into
  could be anywhere. So using a non-root user would have
  a major risk of regressions for applications and also
  have upgrade implications

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agoPost-release version bump to 9.10.0
Jiri Denemark [Wed, 1 Nov 2023 09:42:48 +0000 (10:42 +0100)]
Post-release version bump to 9.10.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
18 months agoRelease of libvirt-9.9.0
Jiri Denemark [Wed, 1 Nov 2023 10:22:09 +0000 (11:22 +0100)]
Release of libvirt-9.9.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
18 months agodocs: update search form to use hyperkitty search
Daniel P. Berrangé [Fri, 27 Oct 2023 11:24:26 +0000 (12:24 +0100)]
docs: update search form to use hyperkitty search

The hyperkitty search facility does a massively better job
than google docs for mailing lists.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agogitpublish: update for new devel mailing list address
Daniel P. Berrangé [Fri, 27 Oct 2023 10:05:58 +0000 (11:05 +0100)]
gitpublish: update for new devel mailing list address

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agodocs: update docs pointing to old mailing list addrs
Daniel P. Berrangé [Fri, 27 Oct 2023 09:59:02 +0000 (10:59 +0100)]
docs: update docs pointing to old mailing list addrs

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agosrc: update log/error messages pointing to old mailing list addr
Daniel P. Berrangé [Fri, 27 Oct 2023 09:59:02 +0000 (10:59 +0100)]
src: update log/error messages pointing to old mailing list addr

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agoqemu: Setup host side of VDPA device for block copy
Peter Krempa [Thu, 26 Oct 2023 13:44:34 +0000 (15:44 +0200)]
qemu: Setup host side of VDPA device for block copy

Setup the VDPA bits of the appropriate part of the image chain for block
copy.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: hotplug: Setup host side of VDPA device for disk hotplug
Peter Krempa [Thu, 26 Oct 2023 13:12:35 +0000 (15:12 +0200)]
qemu: hotplug: Setup host side of VDPA device for disk hotplug

The code which opens the VDPA device and prepares it for FD passing was
not called in the hotplug code path, preventing hotplug of VDPA disks
with:

 error: internal error: argument key 'path' must not have null value

Use the new helper qemuProcessPrepareHostStorageDisk to setup the VDPA
definition.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/539
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: process: Extract host setup of disk device into helpers
Peter Krempa [Thu, 26 Oct 2023 13:05:41 +0000 (15:05 +0200)]
qemu: process: Extract host setup of disk device into helpers

Currently the code sets up only VDPA backends but will be used later in
hotplug code too.

This patch also uses normal forward iteration in the loop in
qemuProcessPrepareHostStorage as we don't need to remove disks from the
disk list at that point.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agodocs: formatdomain: Clarify that the SLIC ACPI table config is available for all...
Peter Krempa [Thu, 26 Oct 2023 11:56:46 +0000 (13:56 +0200)]
docs: formatdomain: Clarify that the SLIC ACPI table config is available for all modes

Move the docs for the <acpi><table> element under a common section as
it's not specific for direct kernel boot. In fact the original use was
for Windows activation.

Fixes: 72f652da63255c7f1a9914625cce617dde9128d0
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemublocktest: testBackingXMLjsonXML: Drop 'legacy' mode
Peter Krempa [Wed, 18 Oct 2023 14:55:13 +0000 (16:55 +0200)]
qemublocktest: testBackingXMLjsonXML: Drop 'legacy' mode

Legacy mode used to be needed for use with -drive, which was almost
completely deleted. We now have qemuxml2argvtest test cases checking a
few cases and the rest uses the modern mode only. Thus we don't need to
test the legacy mode any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemublocktest: Fix logical bug in TEST_JSON_FORMAT macro
Peter Krempa [Wed, 18 Oct 2023 14:55:41 +0000 (16:55 +0200)]
qemublocktest: Fix logical bug in TEST_JSON_FORMAT macro

Condition handling failure of the first virTestRun was lacking the 'ret
= -1' line thus the subsequent line was taken as it's body rendering the
first invocation useless.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemublocktest: Drop 'sheepdog' and 'vxhs' test cases
Peter Krempa [Wed, 18 Oct 2023 15:23:46 +0000 (17:23 +0200)]
qemublocktest: Drop 'sheepdog' and 'vxhs' test cases

QEMU deprecated and removed support for those protocols, but due to a
logic bug in the tests it was not caught. Remove the test cases first.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemucapabilitiestest: Update capabilities data for 8.2 dev cycle on x86_64
Peter Krempa [Thu, 26 Oct 2023 08:02:27 +0000 (10:02 +0200)]
qemucapabilitiestest: Update capabilities data for 8.2 dev cycle on x86_64

Update to v8.1.0-2161-ga95260486a

Notable changes:
 - new CPU topology parameters: 'books', 'drawers'
 - new migration parameter 'avail-switchover-bandwidth'
 - new s390x CPU properties: 'dedicated', 'entitlement'
 - new 'hostmem' parameter for 'virtio-gpu'
 - new device 'piix4-isa'
 - new property 'dynamic-memslots' of 'virtio-mem' device
 - new 'gsi*' parameters of 'ICH9-LPC'
 - new experimental 'x-south-bridge' machine option

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
18 months agopo: Refresh potfile for v9.9.0
Jiri Denemark [Thu, 26 Oct 2023 10:03:18 +0000 (12:03 +0200)]
po: Refresh potfile for v9.9.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
18 months agomeson: Rename build_tests -> tests_enabled
Andrea Bolognani [Tue, 3 Oct 2023 13:39:02 +0000 (15:39 +0200)]
meson: Rename build_tests -> tests_enabled

Given that this variable now controls not just whether C tests
are built, but also whether any test at all is executed, the new
name is more appropriate.

Update the description for the corresponding meson option
accordingly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
18 months agomeson: Disable all tests when tests are disabled
Andrea Bolognani [Tue, 3 Oct 2023 12:58:56 +0000 (14:58 +0200)]
meson: Disable all tests when tests are disabled

Currently, passing -Dtests=disabled only disables a subset of
tests: those that are written in C and thus require compilation.
Other tests, such as the syntax-check ones and those that are
implemented as scripts, are always enabled.

There's a potentially dangerous consequence of this behavior:
when tests are disabled, 'meson test' will succeed as if they
had been enabled. No indication of this will be shown, so the
user will likely make the reasonable assumption that everything
is fine when in fact the significantly reduced coverage might
be hiding failures.

To solve this issues, disable *all* tests when asked to do so,
and inject an intentionally failing test to ensure that 'meson
test' doesn't succeed.

Best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
18 months agomeson: Make -Dexpensive_tests depend on -Dtests
Andrea Bolognani [Tue, 3 Oct 2023 12:53:08 +0000 (14:53 +0200)]
meson: Make -Dexpensive_tests depend on -Dtests

It only makes sense to enable expensive tests when tests are
enabled. Disallow invalid configurations.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
18 months agomeson: Handle -Dtests=enabled with Clang
Andrea Bolognani [Tue, 3 Oct 2023 12:52:45 +0000 (14:52 +0200)]
meson: Handle -Dtests=enabled with Clang

There are some cases in which we automatically disable tests when
using Clang as the compiler. If the user has explicitly asked for
tests to be enabled, however, we should error out instead of
silently disabling things.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
18 months agomeson: Move all handling of test options together
Andrea Bolognani [Tue, 3 Oct 2023 12:46:56 +0000 (14:46 +0200)]
meson: Move all handling of test options together

This will make future patches nicer.

Note that we need to handle these somewhat late because of the
dependency on information about the compiler and the flags it
supports.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
18 months agomeson: Do less when not building from git
Andrea Bolognani [Tue, 3 Oct 2023 12:57:05 +0000 (14:57 +0200)]
meson: Do less when not building from git

As explained in the comment, the syntax-check machinery uses git
to figure out the list of files it should operate on, so we can
only enable it when building from git.

Despite only registering the various tests with meson in that
case, however, we unconditionally perform a bunch of preparation
that is only useful for the purpose of registering and running
the tests. If we're not going to do that, we can skip a few steps
and save a bit of time.

Best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
18 months agoci: Disable optimizations on macOS
Andrea Bolognani [Wed, 25 Oct 2023 15:33:49 +0000 (17:33 +0200)]
ci: Disable optimizations on macOS

Clang can be too aggressive at optimizations, which can end up
breaking our test suite. See f9f5ab57189b for details.

As a result of this, since 7944700b4037 we are automatically
disabling tests when Clang is used unless it supports the
-fsemantic-interposition compiler flag.

Since the version of Clang included in macOS doesn't support that
compiler flag, we end up always disabling the test suite on that
platform.

This is already far from ideal, considering that it was just last
year when we finally managed to get the test suite to successfully
pass on macOS, and it would be a real shame if the situation
regressed again.

With the upcoming changes, which will turn running 'meson test'
into a hard failure if tests are disabled, this behavior will
result in every single pipeline failing.

Work around the problem the only way we can: disabling
optimizations entirely for the macOS CI jobs.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
18 months agotests: Fix some test cases on macOS
Andrea Bolognani [Wed, 25 Oct 2023 14:48:18 +0000 (16:48 +0200)]
tests: Fix some test cases on macOS

Test cases that depend on duplicating fds are using fairly big
values as targets.

This works fine on Linux, where RLIMIT_NOFILE is 1024 by
default, but fails on macOS which uses 256 as the default.

Decrease the values so that they're valid across all platforms.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
18 months agoqemublocktest: Use "target only" mode in 'testJSONtoJSON' and 'testBackingXMLjsonXML'
Peter Krempa [Wed, 18 Oct 2023 14:18:40 +0000 (16:18 +0200)]
qemublocktest: Use "target only" mode in 'testJSONtoJSON' and 'testBackingXMLjsonXML'

Both tests pass a disk source definition which didn't go through the
preparation steps and thus contains only the target information that
were originally present, thus we should be using the
QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_TARGET_ONLY flag.

For the same reason QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUTO_READONLY
used in 'testJSONtoJSON' doesn't make sense.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuBlockStorageSourceGetBlockdevGetCacheProps: Return the cache object rather than...
Peter Krempa [Wed, 18 Oct 2023 11:51:09 +0000 (13:51 +0200)]
qemuBlockStorageSourceGetBlockdevGetCacheProps: Return the cache object rather than appending it

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuDomainDiskCachemodeFlags: Simplify usage
Peter Krempa [Wed, 18 Oct 2023 11:19:08 +0000 (13:19 +0200)]
qemuDomainDiskCachemodeFlags: Simplify usage

Return whether a relevant cachemode was presented rather than returning
an error, so that callers can be simplified. Use the proper enum type as
argument rather than typecasting in the switch statement.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agovirStorageSource: Use proper type for shadow copies of iomode/cachemode/discard/detec...
Peter Krempa [Wed, 18 Oct 2023 07:55:19 +0000 (09:55 +0200)]
virStorageSource: Use proper type for shadow copies of iomode/cachemode/discard/detect_zeroes

The aforementioned fields in virStorageSource struct are copies of the
disk properties, but were not converted to the proper type yet.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoconf: Move definition of some disk type enums to a common header
Peter Krempa [Wed, 18 Oct 2023 10:56:04 +0000 (12:56 +0200)]
conf: Move definition of some disk type enums to a common header

Certain disk config fields are mirrored between the disk and storage
source definitions, but the proper types are not available for use in
the virStorageSource definition. Move them so they can be used properly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuBlockStorageSourceGetBackendProps: Remove unnecessary indent for non-nbdkit code...
Peter Krempa [Wed, 18 Oct 2023 07:38:56 +0000 (09:38 +0200)]
qemuBlockStorageSourceGetBackendProps: Remove unnecessary indent for non-nbdkit code path

Formatting of the 'nbdkit' driven backend breaks out of the switch
statement so we don't need to have an unnecessary block and indentation
level for the case when nbdkit is not in use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuBuildDriveSourceStr: Absorb only use of qemuDiskSourceGetProps
Peter Krempa [Wed, 18 Oct 2023 07:34:27 +0000 (09:34 +0200)]
qemuBuildDriveSourceStr: Absorb only use of qemuDiskSourceGetProps

'qemuBuildDriveSourceStr' used to build the legacy -drive commandline
for SD cards is the only user of qemuDiskSourceGetProps. Move the helper
directly inline.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: migration: No longer avoid 'auto-read-only' option for migration
Peter Krempa [Tue, 17 Oct 2023 14:10:47 +0000 (16:10 +0200)]
qemu: migration: No longer avoid 'auto-read-only' option for migration

The 'auto-read-only' blockdev option is available in all supported qemu
versions so we can remove the migration hack which disabled it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuxml2(argv|xml)test: Add network backed disk type='sd'
Peter Krempa [Wed, 18 Oct 2023 07:16:40 +0000 (09:16 +0200)]
qemuxml2(argv|xml)test: Add network backed disk type='sd'

Add a few examples of SD cards backed with network storage to capture
the current state as the formatter code is about to be refactored.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agonews: document `virsh console --resume` and `virsh (start|create) --console` osstest/frozen/xen-4.18-testing
Marc Hartmayer [Wed, 25 Oct 2023 09:03:54 +0000 (11:03 +0200)]
news: document `virsh console --resume` and `virsh (start|create) --console`

Document the following changes:
 + added `virsh console --resume` subcommand option
 + improved `virsh start --console` behavior
 + improved `virsh create --console` behavior

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
18 months agomeson: Fix XDR check for GNU/Hurd
Andrea Bolognani [Mon, 9 Oct 2023 21:17:10 +0000 (23:17 +0200)]
meson: Fix XDR check for GNU/Hurd

The situation is the same as Linux: since glibc no
longer includes the RPC functionality, libtirpc must
be used to complement it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agosystemd: Tweak service definitions
Andrea Bolognani [Fri, 29 Sep 2023 13:56:17 +0000 (15:56 +0200)]
systemd: Tweak service definitions

Use a consistent style everywhere.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agosystemd: Make service_extra_in/socket_extra_in required
Andrea Bolognani [Fri, 29 Sep 2023 13:59:34 +0000 (15:59 +0200)]
systemd: Make service_extra_in/socket_extra_in required

We want at least one file to always be present, so that it can
serve as a pointer for users. Ensure that this is the case by
unconditionally using the value of the respective keys.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agosystemd: Set service_extra_in/socket_extra_in everywhere
Andrea Bolognani [Fri, 29 Sep 2023 13:20:07 +0000 (15:20 +0200)]
systemd: Set service_extra_in/socket_extra_in everywhere

It's somewhat confusing that some of the services have a
corresponding foo.service.extra.in and foo.socket.extra.in, some
have just one of the two, and some have neither.

In order to make things more approachable, make sure that both
files exists for each service.

In most cases the extra units are currently unused, so they will
just contain a comment briefly explaining their purpose and
pointing users to meson.build, where they can find more
information. The same comment is also added to the top of
extra units that already have some contents in them for
consistency.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agosystemd: Allow comments at the top of units
Andrea Bolognani [Fri, 29 Sep 2023 13:28:25 +0000 (15:28 +0200)]
systemd: Allow comments at the top of units

Currently the script will reject any type of contents outside
of a section, but we want to be able to have some useful
comments at the top of each file to help users understand how
they are processed.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agosystemd: Introduce systemd_service_oomscoreadjust_extra_in
Andrea Bolognani [Thu, 28 Sep 2023 10:17:58 +0000 (12:17 +0200)]
systemd: Introduce systemd_service_oomscoreadjust_extra_in

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agosystemd: Introduce systemd_service_limitmemlock_extra_in
Andrea Bolognani [Thu, 28 Sep 2023 10:14:45 +0000 (12:14 +0200)]
systemd: Introduce systemd_service_limitmemlock_extra_in

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agosystemd: Introduce systemd_service_tasksmax_extra_in
Andrea Bolognani [Thu, 28 Sep 2023 10:07:15 +0000 (12:07 +0200)]
systemd: Introduce systemd_service_tasksmax_extra_in

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agosystemd: Introduce systemd_service_limitnofile_extra_in
Andrea Bolognani [Thu, 28 Sep 2023 09:51:16 +0000 (11:51 +0200)]
systemd: Introduce systemd_service_limitnofile_extra_in

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agosystemd: Accept multiple files for service_extra_in/socket_extra_in
Andrea Bolognani [Thu, 28 Sep 2023 09:43:31 +0000 (11:43 +0200)]
systemd: Accept multiple files for service_extra_in/socket_extra_in

Now that the underlying script is able to merge an arbitrary
number of units into the base template, expose this possibility
in the build system.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agosystemd: Support merging multiple units
Andrea Bolognani [Thu, 28 Sep 2023 09:39:23 +0000 (11:39 +0200)]
systemd: Support merging multiple units

In order to further deduplicate the contents of the various unit
files, we need to be able to merge multiple additional units
into the initial one.

Luckily the merge logic is in no way constrained to working with
just two units, so achieving this is pretty much just a matter
of lifting the existing limitation on the number of arguments
that the script accepts.

As a special case, it's now also possible to call the script
with just the base unit as argument. No merging will be performed
in that case, obviously, but we'll still go through the basic
validation and cleanup steps.

This also fixes a bug in the check for the number of arguments:
sys.argv also contains the name of the script, so we should have
checked that its size was at least 3. The check is now written in
a way that's less prone to misunderstandings.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agosystemd: libvirtd doesn't need @sockprefix@
Andrea Bolognani [Fri, 29 Sep 2023 13:20:58 +0000 (15:20 +0200)]
systemd: libvirtd doesn't need @sockprefix@

It uses custom templates which already hardcode the correct
value.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agoImprove `virsh create --console` behavior
Marc Hartmayer [Thu, 28 Sep 2023 15:37:10 +0000 (17:37 +0200)]
Improve `virsh create --console` behavior

When starting a guest via libvirt (`virsh create --console`), early
console output was missed because the guest was started first and then
the console was attached. This patch changes this to the following
sequence:

1. create a paused transient guest
2. attach the console
3. resume the guest

Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agoImprove `virsh start --console` behavior
Marc Hartmayer [Thu, 28 Sep 2023 15:37:09 +0000 (17:37 +0200)]
Improve `virsh start --console` behavior

When starting a guest via libvirt (`virsh start --console`), early
console output was missed because the guest was started first and then
the console was attached. This patch changes this to the following
sequence:

1. create a paused guest
2. attach the console
3. resume the guest

Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agovirsh: add `console --resume` support
Marc Hartmayer [Thu, 28 Sep 2023 15:37:08 +0000 (17:37 +0200)]
virsh: add `console --resume` support

This patch adds the command line flag `--resume` to the `virsh console`
command. This resumes a paused guest after connecting to the console.
This might be handy since it's a "common" pattern to start a guest
paused, connect to the console, and then resume it so as not to miss any
console messages.

Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agospecfile: use correct option for nbdkit in mingw build
Laine Stump [Mon, 23 Oct 2023 02:34:52 +0000 (22:34 -0400)]
specfile: use correct option for nbdkit in mingw build

commit v9.8.0-40-g7cbd8c4230 changed the name of the option that
enables/disables nbdkit support in the build from "libnbd" to
"nbdkit", but one use of "libnbd=disabled" was missed in
libvirt.specfile.in - the meson commandline for mingw.

This patch changes that line to "-Dnbdkit=disabled", thus unbreaking
the rpm build.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/550
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
18 months agoch: support serial and console devices in parallel
Praveen K Paladugu [Tue, 10 Oct 2023 21:42:58 +0000 (16:42 -0500)]
ch: support serial and console devices in parallel

Starting v18, cloud-hypervisor supports serial and console devices in
parallel. Drop related check based on ch version.

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agoch: use payload api to send kernel details
Praveen K Paladugu [Tue, 10 Oct 2023 21:42:57 +0000 (16:42 -0500)]
ch: use payload api to send kernel details

Starting with v28.0 cloud-hypervisor requires the use of "payload" api to pass
kernel, initramfs and cmdline options. Extend ch driver to use the new
api based on ch version.

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agoutil:hostcpu: Report physical address size based on Architecture
Narayana Murty N [Wed, 4 Oct 2023 05:58:41 +0000 (01:58 -0400)]
util:hostcpu: Report physical address size based on Architecture

The function virHostCPUGetPhysAddrSize was introduced with commit be1b7d5b18e
fails on architectures other than x86 and SuperH. The commit 8417c1394cd4d
fixed the issue only for s390 but the problem is still seen on other
architectures like ppc which does not report Physical address size in their
cpuinfo output.

command:
systemctl restart libvirtd.service
Output :
<snip>
dnsmasq[2377]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0
addresses
dnsmasq-dhcp[2377]: read /var/lib/libvirt/dnsmasq/default.hostsfile
libvirtd[3163]: libvirt version: 9.8.0
libvirtd[3163]: hostname: xxxxxxxxxx
libvirtd[3163]: internal error: Missing or invalid CPU address size in
/proc/cpuinfo
 libvirtd.service: Deactivated successfully.
 </snip>

This patch fixes this issue by returning the size=0 for architectures
other than x86 and SuperH.

Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agolxc: fix lxcContainerMountAllFS() DEREF_BEFORE_CHECK
Dmitry Frolov [Thu, 7 Sep 2023 09:04:57 +0000 (12:04 +0300)]
lxc: fix lxcContainerMountAllFS() DEREF_BEFORE_CHECK

vmDef->fss[i]->src->path may be NULL,
so check is needed before passing it to VIR_DEBUG.
Also removed checking vmDef->fss[i]->src for NULL, since it may not be NULL.

Fixes: 57487085dc ("lxc: don't try to reference NULL when mounting filesystems")
Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agoqemu: Send event on persistent config modification
Fima Shevrin [Thu, 19 Oct 2023 14:20:36 +0000 (17:20 +0300)]
qemu: Send event on persistent config modification

Currently, libvirt doesn't send events when devices are attached,
detached or updated. Thus, any services that listen to events are
unaware of the change to persistent config.

Signed-off-by: Fima Shevrin <efim.shevrin@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agoselinux: Drop dead code in virSecuritySELinuxSetImageLabelInternal()
Sergey Mironov [Wed, 11 Oct 2023 14:31:55 +0000 (17:31 +0300)]
selinux: Drop dead code in virSecuritySELinuxSetImageLabelInternal()

Considering that at the virSecuritySELinuxSetFilecon() function can only
return 0 or -1 and so does the virSecuritySELinuxFSetFilecon(), the check
for '1' at the end of virSecuritySELinuxSetImageLabelInternal() is
effectively a dead code. Drop it.

Co-developed-by: sdl.qemu <sdl.qemu@linuxtesting.org>
Signed-off-by: Sergey Mironov <mironov@fintech.ru>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
18 months agoexamples: Fix printf format string in event-test.c
zhujun2 [Tue, 17 Oct 2023 06:43:50 +0000 (23:43 -0700)]
examples: Fix printf format string in event-test.c

Inside of myDomainEventMemoryFailureCallback() arguments are
printed via printf but '%d' is used to print @flags (of type
uint). Use '0x%x' instead, just like we do everywhere else.

Signed-off-by: zhujun2 <zhujun2@cmss.chinamobile.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agoconf: Rename 'nodeformat' field of virStorageSource to 'nodenameformat'
Peter Krempa [Thu, 17 Aug 2023 13:36:51 +0000 (15:36 +0200)]
conf: Rename 'nodeformat' field of virStorageSource to 'nodenameformat'

While the name itself doesn't matter, this rename is done to prove that
all places using 'nodeformat' were converted to the appropriate
accessors.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: driver: Use 'format' nodename accessors for disk resize
Peter Krempa [Mon, 16 Oct 2023 14:48:17 +0000 (16:48 +0200)]
qemu: driver: Use 'format' nodename accessors for disk resize

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: migration: Use 'format' nodename accessors in dirty bitmap migration
Peter Krempa [Mon, 16 Oct 2023 14:44:20 +0000 (16:44 +0200)]
qemu: migration: Use 'format' nodename accessors in dirty bitmap migration

The persistent bitmaps are stored in the format layer, using 'effective'
bitmap name is the most reasonable approach in this case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: Convert migration setup code to use 'format' layer node name accessors
Peter Krempa [Mon, 16 Oct 2023 14:42:16 +0000 (16:42 +0200)]
qemu: Convert migration setup code to use 'format' layer node name accessors

The blockjob, NBD export and setup of the cookie data all care about the
effective nodename.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: command: Use 'format' nodename accessors for 'pflash' backend setup
Peter Krempa [Mon, 16 Oct 2023 14:39:46 +0000 (16:39 +0200)]
qemu: command: Use 'format' nodename accessors for 'pflash' backend setup

The frontend device needs to access the blocks directly so it cares
about the effective nodename.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: Use 'format' nodename accessors for block dirty bitmap operations
Peter Krempa [Mon, 16 Oct 2023 14:20:27 +0000 (16:20 +0200)]
qemu: Use 'format' nodename accessors for block dirty bitmap operations

In most cases the bitmap operations are relevant only on qcow2 images
thus the 'format' layer will be present. Although in certain specific
cases temporary bitmaps can be created on top of other images as well,
thus we use the 'effective' bitmap name in all cases for bitmap
operations.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: driver: Convert disk stats code to use 'format' nodename accessors
Peter Krempa [Mon, 16 Oct 2023 14:12:40 +0000 (16:12 +0200)]
qemu: driver: Convert disk stats code to use 'format' nodename accessors

I case of statistics we're interested in the statistics of the effective
bitmap whatever it happens to be.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: Convert disk backend setup code to use 'format' nodename accessors
Peter Krempa [Mon, 16 Oct 2023 14:09:55 +0000 (16:09 +0200)]
qemu: Convert disk backend setup code to use 'format' nodename accessors

The disk backend setup code is concerned only about the effective
nodename. Doing this conversion will also simplify further changes
needed to drop the 'raw' layer in cases when it's not really needed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agotests: Use 'format' layer nodename accessors in test code
Peter Krempa [Mon, 16 Oct 2023 13:55:25 +0000 (15:55 +0200)]
tests: Use 'format' layer nodename accessors in test code

The test code cares mostly about the actual layer nodenames thus,
appropriate accessors are used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: domain: Use 'format' layer node name accessors for nodename setup code
Peter Krempa [Mon, 16 Oct 2023 13:54:17 +0000 (15:54 +0200)]
qemu: domain: Use 'format' layer node name accessors for nodename setup code

The code setting the nodenames needs to use the 'true' nodename of the
format layer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: block: Use 'format' nodename accessors in '-blockdev' setup code
Peter Krempa [Thu, 4 Mar 2021 13:54:00 +0000 (14:54 +0100)]
qemu: block: Use 'format' nodename accessors in '-blockdev' setup code

Convert the main -blockdev JSON object setup code to use the new
accessors. In these we use mainly the real 'format' layer node name.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: blockjob: Use 'format' nodename accessors for job naming
Peter Krempa [Mon, 16 Oct 2023 13:41:12 +0000 (15:41 +0200)]
qemu: blockjob: Use 'format' nodename accessors for job naming

Use the effective nodename for naming the job as we use that one now.
It doesn't matter too much which one we pick, because it's used just for
the name of the job, which we preserve in the status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: backup: Use format nodename accessors
Peter Krempa [Mon, 16 Oct 2023 13:36:47 +0000 (15:36 +0200)]
qemu: backup: Use format nodename accessors

Both modified cases in this patch require the effective nodename as they
deal with the data being backed up.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuBlockStorageSourceGetFormatProps: Use new frontend name accessor
Peter Krempa [Tue, 12 Sep 2023 14:53:01 +0000 (16:53 +0200)]
qemuBlockStorageSourceGetFormatProps: Use new frontend name accessor

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: block: Add accessors for storage source effective nodename
Peter Krempa [Wed, 20 Sep 2023 13:47:51 +0000 (15:47 +0200)]
qemu: block: Add accessors for storage source effective nodename

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: block: Add accessors for format layer node names
Peter Krempa [Wed, 20 Sep 2023 13:24:14 +0000 (15:24 +0200)]
qemu: block: Add accessors for format layer node names

Introduce a set of accessors, which return node names based on
semantics. This will allow to us to modify how we setup the backing
chain in cases when e.g. the format driver can be omitted, without
breaking all the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoconf: Rename 'nodestorage' field of virStorageSource to 'nodenamestorage'
Peter Krempa [Mon, 11 Sep 2023 13:46:33 +0000 (15:46 +0200)]
conf: Rename 'nodestorage' field of virStorageSource to 'nodenamestorage'

While the name itself doesn't matter, this rename is done to prove that
all places using 'nodestorage' were converted to the appropriate
accessors.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuDomainSetBlockThreshold: Use 'storage' node name accessor
Peter Krempa [Mon, 25 Sep 2023 15:14:55 +0000 (17:14 +0200)]
qemuDomainSetBlockThreshold: Use 'storage' node name accessor

We need to keep setting the block threshold on the real storage layer
per semantics of the API. Use the appropriate accessor.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemuDomainGetStatsBlockExportDisk: Use 'storage' node name accessors
Peter Krempa [Mon, 25 Sep 2023 15:07:27 +0000 (17:07 +0200)]
qemuDomainGetStatsBlockExportDisk: Use 'storage' node name accessors

In all cases we want to probe stats from the 'storage' layer as we're
interested in the 'threshold' value, which we set there.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: Refactor storage backend 'storage' layer helepr object setup
Peter Krempa [Mon, 25 Sep 2023 15:02:20 +0000 (17:02 +0200)]
qemu: Refactor storage backend 'storage' layer helepr object setup

Use the new nodename accessors for any storage layer helper object.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agoqemu: Refactor storage backend attach/detach setup code to use 'storage' nodename...
Peter Krempa [Mon, 25 Sep 2023 15:00:36 +0000 (17:00 +0200)]
qemu: Refactor storage backend attach/detach setup code to use 'storage' nodename accessors

Refactor the code settin up data structures used to attach/detach disks
and SCSI hostdevs.

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