]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
2 years agoTranslated using Weblate (Japanese)
Jiri Denemark [Wed, 22 Mar 2023 15:20:49 +0000 (16:20 +0100)]
Translated using Weblate (Japanese)

Currently translated at 99.5% (10368 of 10416 strings)

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

Co-authored-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoTranslated using Weblate (French)
grimst [Wed, 22 Mar 2023 15:20:48 +0000 (16:20 +0100)]
Translated using Weblate (French)

Currently translated at 99.9% (10410 of 10416 strings)

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

Co-authored-by: grimst <grimaitres@gmail.com>
Signed-off-by: grimst <grimaitres@gmail.com>
2 years agoTranslated using Weblate (Finnish)
Jan Kuparinen [Wed, 22 Mar 2023 15:20:48 +0000 (16:20 +0100)]
Translated using Weblate (Finnish)

Currently translated at 22.5% (2349 of 10416 strings)

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

Co-authored-by: Jan Kuparinen <copper_fin@hotmail.com>
Signed-off-by: Jan Kuparinen <copper_fin@hotmail.com>
2 years agoqemu_shim: Require absolute path for root directory
Michal Privoznik [Wed, 22 Mar 2023 11:39:21 +0000 (12:39 +0100)]
qemu_shim: Require absolute path for root directory

The virConnectOpen(), well virConnectOpenInternal() reports an
error if embed root is not an absolute path. This is a fair
requirement, but our qemu_shim doesn't check this requirement and
passes the path to mkdir(), only to fail later on, leaving the
empty directory behind:

  $ ls -d asd
  ls: cannot access 'asd': No such file or directory

  $ virt-qemu-run -r asd whatever.xml
  virt-qemu-run: cannot open qemu:///embed?root=asd: unsupported configuration: root path must be absolute

  $ ls -d asd
  asd

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2 years agoqemu_domain: Drop ATTRIBUTE_NONNULL() for non-existent arguments
Michal Privoznik [Wed, 22 Mar 2023 10:07:50 +0000 (11:07 +0100)]
qemu_domain: Drop ATTRIBUTE_NONNULL() for non-existent arguments

After cleanup done in v8.2.0-rc1~47 the
qemuDomainObjExitMonitor() and after v8.7.0-rc1~176 the
qemuDomainObjEnterMonitor() lost the @driver argument. But
corresponding ATTRIBUTE_NONNULL() annotation was not removed and
both functions are still annotated as ATTRIBUTE_NONNULL(2) even
though they accept just one argument (@obj).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2 years agoqemu_shim: set system identity
Ján Tomko [Wed, 15 Mar 2023 15:21:49 +0000 (16:21 +0100)]
qemu_shim: set system identity

Otherwise looking up a secret fails when we try to elevate the identity
in qemuDomainSecretInfoSetupFromSecret.

https://bugzilla.redhat.com/show_bug.cgi?id=2000410

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Move validation check out of postparse
Andrea Bolognani [Fri, 17 Mar 2023 10:19:04 +0000 (11:19 +0100)]
qemu: Move validation check out of postparse

Suggested-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: Move validation check out of postparse
Andrea Bolognani [Fri, 17 Mar 2023 11:00:39 +0000 (12:00 +0100)]
conf: Move validation check out of postparse

The reason why it was in postparse in the first place was so
that we could could automatically enable the secure-boot feature
in some cases, but that no longer happens so we can finally move
it to the proper location.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: Don't explicitly set the secure-boot feature
Andrea Bolognani [Wed, 15 Mar 2023 19:23:58 +0000 (20:23 +0100)]
conf: Don't explicitly set the secure-boot feature

Now that we're adding information obtained from the firmware
descriptor to the domain XML, this will happen automatically
whenever a firmware that has the enrolled-keys feature ends up
being selected.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Automatically add firmware type/features information
Andrea Bolognani [Wed, 15 Mar 2023 16:53:02 +0000 (17:53 +0100)]
qemu: Automatically add firmware type/features information

Even when the user is not taking advantage of firmware
autoselection and instead manually providing all the necessary
information, in most cases they're still going to use firmware
builds that are provided by the OS vendor, are installed in
standard paths and come with a corresponding firmware
descriptor.

Similarly, even when the user is not guiding the autoselection
process by specifying the desired status of certain features
and instead is relying on the system-level descriptor priority
being set up correctly, libvirt will still ultimately decide to
use a specific descriptor, which includes information about the
firmware's features.

In both these cases, take the additional information that were
obtained from the firmware descriptor and reflect them back into
the domain XML, where they can be conveniently inspected by the
user and management applications alike.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Don't drop firmware type/features information
Andrea Bolognani [Tue, 14 Mar 2023 22:08:29 +0000 (23:08 +0100)]
qemu: Don't drop firmware type/features information

Now that we no longer reject configurations that include both
this information and explicit firmware details, as long of
course as everything is internally consistent, and that we've
ensured that we produce maximally compatible XML on migration,
we can stop stripping this information at the end of the
firmware selection process.

There are several advantages to keeping this information around:

  * if the user wants to change the firmware configuration for
    an existing VM, they can simply drop the <loader> and
    <nvram> elements, tweak the firmware autoselection parameters
    and let libvirt pick a firmware that matches on the new
    requirements;

  * management applications can inspect the XML and easily
    figure out firmware-related information without having to
    reverse-engineer them based on some opaque paths.

Overall, this change makes things more transparent and easier to
understand. The improvement is so significant that, in a
follow-up commit, we're going to ensure that this information is
available in even more cases.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: Don't format firmware type/features when migrating
Andrea Bolognani [Fri, 17 Mar 2023 10:12:31 +0000 (11:12 +0100)]
conf: Don't format firmware type/features when migrating

The combination of explicit firmware paths, which we now
produce in all cases, and firmware autoselection knobs is
explicitly rejected by libvirt 8.6.0 and newer.

Right now we produce inherently migratable XML in all cases,
since we always strip those bits, but that's going to change
soon. To prepare for that, make sure that we always skip the
problematic elements and attributes when preparing a
migratable XML.

The destination will simply receive a fully specified firmware
configuration, which is indistinguishable from one that was
manually provided by the user and is thus accepted by any old
version of libvirt, regardless of whether or not firmware
autoselection was used on the source host.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoconf: Remove some firmware validation checks
Andrea Bolognani [Tue, 14 Mar 2023 22:02:46 +0000 (23:02 +0100)]
conf: Remove some firmware validation checks

libvirt 8.6.0 introduced these checks and very clearly delineated
two possible firmware selection scenarios: manual firmware
selection, where the user is responsible for providing all
information, and firmware autoselection, where a list of desired
features is provided and everything else is handled by libvirt.

In the interest of maintaining the clear separation between these
two scenarios, setting most attributes when firmware autoselection
is active will result in the configuration being rejected.

This works fine, but is unnecessarily restrictive: in most cases,
the additional information that the user has provided matches
the information that libvirt would have discovered on its own by
looking at firmware descriptors, and asking the user to scrub it
from the XML only result in pointless friction.

Remove these checks entirely.

Unsurprisingly, this results in a few test cases that were
rejected until now to suddenly start working and producing
sensible results.

The firmware-auto-efi-loader-path-nonstandard test case is
notable: while we can now enable the xml2xml part of the test,
the xml2argv part is still failing, although in a slightly
different way. This is expected: since the firmware binary is a
non-standard one, libvirt is unable to figure out the missing
information from a firmware descriptor, and the configuration
is still ultimately an invalid one. However, if we were to find
such a configuration on disk at daemon startup, we would not
ignore it completely and instead would offer the user a chance
to fix it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Always go through firmware autoselection
Andrea Bolognani [Wed, 15 Mar 2023 16:32:43 +0000 (17:32 +0100)]
qemu: Always go through firmware autoselection

Right now there are a few scenarios in which we skip ahead, and
removing these exceptions will make for more consistent and
predictable behavior.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Discard requires-smm firmware when loader.secure=no
Andrea Bolognani [Thu, 16 Mar 2023 18:42:56 +0000 (19:42 +0100)]
qemu: Discard requires-smm firmware when loader.secure=no

The requires-smm feature being present in a firmware descriptor
causes loader.secure=yes to be automatically chosen for the
domain, so we have to avoid this situation or the user's choice
will be silently subverted.

Note that we can't actually encounter loader.secure=no in this
function at the moment because of earlier checks, but that's
going to change soon.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Introduce qemuFirmwareMatchesPaths()
Andrea Bolognani [Wed, 15 Mar 2023 17:12:58 +0000 (18:12 +0100)]
qemu: Introduce qemuFirmwareMatchesPaths()

Right now we have checks in place that ensure that explicit
paths are not provided when firmware autoselection has been
enabled, but that's going to change soon.

To prepare for that, take into account user-provided paths
during firmware autoselection if present, and discard all
firmware descriptors that don't contain matching information.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agotests: Fix firmware descriptor masking test
Andrea Bolognani [Wed, 15 Mar 2023 19:51:51 +0000 (20:51 +0100)]
tests: Fix firmware descriptor masking test

Right now we're checking that firmware descriptor masking works
as intended by creating an empty file matching 60-ovmf-sb.json
in name.

However, that firmware descriptors contains the details for a
perfectly valid and quite common situation: Secure Boot being
supported by the firmware build, but being effectively disabled
by the lack of certificates in the NVRAM template.

Unmask that firmware descriptor, and instead create a dummy one
that has higher priority than all other OVMF builds and points
to paths that are obviously incorrect, which should make it
easy to notice it getting accidentally unmasked in the future.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agotests: Add more tests for manual Secure Boot configuration
Andrea Bolognani [Wed, 15 Mar 2023 18:39:06 +0000 (19:39 +0100)]
tests: Add more tests for manual Secure Boot configuration

These cover the same scenarios as the matching test cases for
autoselection.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agotests: Add firmware-auto-efi-loader-path
Andrea Bolognani [Thu, 16 Mar 2023 18:10:29 +0000 (19:10 +0100)]
tests: Add firmware-auto-efi-loader-path

This is identical to the existing
firmware-auto-efi-loader-path-nonstandard test case, but uses
a standard firmware path.

Right now the two test cases behave identically, but that's
going to change in the future.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agotests: Fix firmware-auto-efi-loader-path-nonstandard
Andrea Bolognani [Thu, 16 Mar 2023 17:59:52 +0000 (18:59 +0100)]
tests: Fix firmware-auto-efi-loader-path-nonstandard

This test is intended to simulate the use of an OVMF firmware
image installed under a non-standard path. In order to make
such a configuration work, the user would have to provide
additional information.

Right now it doesn't matter, because the configuration is
rejected anyway, but the behavior is going to change slightly
in the future. Prepare by making the configuration more
complete and realistic.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agotests: Rename a few firmware tests
Andrea Bolognani [Thu, 16 Mar 2023 16:36:45 +0000 (17:36 +0100)]
tests: Rename a few firmware tests

This unifies the naming between the manual and automatic
selection cases, clarifies the contents of the tests and makes
room for more tests being added in the future.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: Fix memory leaks in firmware selection code
Andrea Bolognani [Tue, 21 Mar 2023 23:22:43 +0000 (00:22 +0100)]
qemu: Fix memory leaks in firmware selection code

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agomeson: Stop detecting -Wl,--version-script=
Michal Privoznik [Mon, 20 Mar 2023 12:38:27 +0000 (13:38 +0100)]
meson: Stop detecting -Wl,--version-script=

With its version 16.0, the LLVM's linker turned on
--no-undefined-version by default [1]. This breaks how we detect
--version-script= detection, because at the compile time there's
no library built yet that we can use to make --version-script=
happy. Unfortunately, meson does not provide a way to detect this
either [2].

But there's not much sense in detecting the argument either. We
already special case some systems (windows, darwin) and do the
check for others, which are expected to support versioned
symbols, because of ELF. Worst case scenario - the error is
reported during compile time rather than configure time.

1: https://reviews.llvm.org/D135402
2: https://github.com/mesonbuild/meson/issues/3047

Resolves: https://bugs.gentoo.org/902211
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agovbox: unify "unable to get hard disk id" message
Ján Tomko [Sat, 18 Mar 2023 13:23:13 +0000 (14:23 +0100)]
vbox: unify "unable to get hard disk id" message

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agoUnify error message when namespaces are unsupported
Ján Tomko [Sat, 18 Mar 2023 12:17:22 +0000 (13:17 +0100)]
Unify error message when namespaces are unsupported

Some helpers used a period at the end, others did not.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agoutil: xml: remove function names from error messages
Ján Tomko [Sat, 18 Mar 2023 11:47:18 +0000 (12:47 +0100)]
util: xml: remove function names from error messages

The function name is already logged, and these can happen only as a
result of a programmer error.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agovbox: remove unreachable error in virVBoxSnapshotConfSaveVboxFile
Ján Tomko [Sat, 18 Mar 2023 11:34:47 +0000 (12:34 +0100)]
vbox: remove unreachable error in virVBoxSnapshotConfSaveVboxFile

Both callers in the VirtualBox driver handle the error and only
call this function with a non-NULL argument.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agovbox: remove unreachable error in virVBoxSnapshotConfLoadVboxFile
Ján Tomko [Sat, 18 Mar 2023 11:33:17 +0000 (12:33 +0100)]
vbox: remove unreachable error in virVBoxSnapshotConfLoadVboxFile

Both callers in the VirtualBox driver error out if the path
can't be fetched via VirtualBox APIs and abort on conversion error
from UTF-16 to UTF-8.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agobhyve: unify error message for UUID generation
Ján Tomko [Fri, 17 Mar 2023 21:57:42 +0000 (22:57 +0100)]
bhyve: unify error message for UUID generation

All the other places spell UUID in all caps.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agosrc: unify symlink creation error message
Ján Tomko [Fri, 17 Mar 2023 21:56:19 +0000 (22:56 +0100)]
src: unify symlink creation error message

In some places, one quote got dropped by accident.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agobhyve: fix typo in error message
Ján Tomko [Fri, 17 Mar 2023 21:43:51 +0000 (22:43 +0100)]
bhyve: fix typo in error message

Use the same string as in qemu_process.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agocapabilities: reduce scope in virCapabilitiesInitCaches()
Shaleen Bathla [Mon, 20 Mar 2023 10:39:56 +0000 (16:09 +0530)]
capabilities: reduce scope in virCapabilitiesInitCaches()

over-writing a variable in inner while-loop without freeing previous memory
leaks it over time.
To fix this, we can just change scope of bank variable to the inner loop.

Signed-off-by: Shaleen Bathla <shaleen.bathla@oracle.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Fixes: 5c84485439ee63f40002c04914e111395c598db0
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agomanpages: fix secret injection example for SEV
Daniel P. Berrangé [Thu, 16 Mar 2023 08:57:34 +0000 (08:57 +0000)]
manpages: fix secret injection example for SEV

The --disk-password argument was present in early impls of the patch but
replaced by the more generic --inject-secret argument.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agorpc: fix typo in admin code generation
Ján Tomko [Thu, 16 Mar 2023 12:13:25 +0000 (13:13 +0100)]
rpc: fix typo in admin code generation

An extra '&' introduced a crash.

https://bugzilla.redhat.com/show_bug.cgi?id=2178866

Fixes: 778c3004609ede0a9df4cf3e01c031047530efb7
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoTranslated using Weblate (French)
Ludek Janda [Thu, 16 Mar 2023 14:26:18 +0000 (15:26 +0100)]
Translated using Weblate (French)

Currently translated at 100.0% (10416 of 10416 strings)

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

Co-authored-by: Ludek Janda <ljanda@redhat.com>
Signed-off-by: Ludek Janda <ljanda@redhat.com>
2 years agoTranslated using Weblate (Czech)
Ján Tomko [Thu, 16 Mar 2023 14:26:18 +0000 (15:26 +0100)]
Translated using Weblate (Czech)

Currently translated at 83.5% (8706 of 10416 strings)

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

Co-authored-by: Jan Tomko <jtomko@redhat.com>
Co-authored-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Jan Tomko <jtomko@redhat.com>
2 years agoTranslated using Weblate (Chinese (Simplified) (zh_CN))
Jiri Denemark [Thu, 16 Mar 2023 14:26:17 +0000 (15:26 +0100)]
Translated using Weblate (Chinese (Simplified) (zh_CN))

Currently translated at 99.5% (10373 of 10416 strings)

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

Translated using Weblate (Chinese (Simplified) (zh_CN))

Currently translated at 99.5% (10373 of 10416 strings)

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

Translated using Weblate (Japanese)

Currently translated at 99.5% (10368 of 10416 strings)

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

Translated using Weblate (Japanese)

Currently translated at 99.5% (10369 of 10416 strings)

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

Co-authored-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2 years agoTranslated using Weblate (Czech)
Daniel P. Berrangé [Thu, 16 Mar 2023 14:26:16 +0000 (15:26 +0100)]
Translated using Weblate (Czech)

Currently translated at 83.5% (8706 of 10416 strings)

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

Co-authored-by: Daniel P. Berrange <berrange@redhat.com>
Co-authored-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2 years agomeson: stop CLang doing inter-procedural analysis
Daniel P. Berrangé [Thu, 16 Mar 2023 12:50:56 +0000 (12:50 +0000)]
meson: stop CLang doing inter-procedural analysis

The virNumaNodeIsAvailable function is stubbed out when building
without libnuma, such that it just returns a constant value. When
CLang is optimizing, it does inter-procedural analysis across
function calls. When it sees that the call to virNumaNodeIsAvailable
returns a fixed constant, it elides the conditional check for errors
in the callers such as virNumaNodesetIsAvailable.

This is a valid optimization as the C standard declares that there
must only be one implementation of each function in a binary. This
is normally the case, but ELF allows for function overrides when
linking or at runtime with LD_PRELOAD, which is technically outside
the mandated C language behaviour.

So while CLang's optimization works fine at runtime, it breaks in our
test suite which aims to mock the virNumaNodeIsAvailable function so
that it has specific semantics regardless of whether libnuma is built
or not. The return value check optimization though means our mock
override won't have the right effect. The mock will be invoked, but
its return value is not used.

Potentially the same problem could be exhibited with GCC if certain
combinations of optimizations are enabled, though thus far we've
not seen it.

To be robust on both CLang and GCC we need to make it more explicit
that we want to be able to replace functions and thus optimization
of calls must be limited. Currently we rely on 'noinline' which
does successfully prevent inlining of the function, but it cannot
stop the eliding of checks based on the constant return value.
Thus we need a bigger hammer.

There are a couple of options to disable this optimization:

 * Annotate a symbol as 'weak'. This is tells the compiler
   that the symbol is intended to be overridable at linktime
   or runtime, and thus it will avoid doing inter-procedural
   analysis for optimizations. This was tried previously but
   have to be reverted as it had unintended consequences
   when linking .a files into our final .so, resulting in all
   the weak symbol impls being lost. See commit
   407a281a8e2b6c5078ba1148535663ea64fd9314

 * Annotate a symbol with 'noipa'. This tells the compiler
   to avoid inter-procedural analysis for calls to just this
   function. This would be ideal match for our scenario, but
   unfortunately it is only implemented for GCC currently:

     https://reviews.llvm.org/D101011

 * The '-fsemantic-interposition' argument tells the optimizer
   that any functions may be replaced with alternative
   implementations that have different semantics. It thus
   blocks any optimizations across function calls. This is
   quite a harsh block on the optimizer, but it appears to be
   the only one that is viable with CLang.

Out of those choices option (3) is the only viable option for
CLang. We don't want todo it for GCC though as it is such a
big hammer. Probably we should apply (2) for GCC, should we
experiance a problem in future.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu: use correct formatting string for size_t
Ján Tomko [Fri, 17 Mar 2023 13:58:23 +0000 (14:58 +0100)]
qemu: use correct formatting string for size_t

Otherwise the build on armv7l breaks:
error: format ‘%lu’ expects argument of type
‘long unsigned int’, but argument 4 has type
‘size_t’ {aka ‘unsigned int’} [-Werror=format=]

Fixes: 1992ae40fac90c315d0d8d1a9c6f880bd0a39b57
Fixes: e239f7d0a86ebddf9aab3f8c8e6b6e66351485b2
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agotests: qemublocktest: fix memory leak
Ján Tomko [Fri, 17 Mar 2023 14:34:02 +0000 (15:34 +0100)]
tests: qemublocktest: fix memory leak

Set enccount to 1, so the cleanup function knows
there is something to be cleaned up.

Fixes: 1992ae40fac90c315d0d8d1a9c6f880bd0a39b57
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2 years agoqemu: add luks-any encryption support for RBD images
Or Ozeri [Mon, 13 Mar 2023 09:50:23 +0000 (04:50 -0500)]
qemu: add luks-any encryption support for RBD images

The newly added luks-any rbd encryption format in qemu
allows for opening both LUKS and LUKS2 encryption formats.
This commit enables libvirt uses to use this wildcard format.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: capabilities: Introduce QEMU_CAPS_RBD_ENCRYPTION_LUKS_ANY capability
Or Ozeri [Mon, 13 Mar 2023 09:50:22 +0000 (04:50 -0500)]
qemu: capabilities: Introduce QEMU_CAPS_RBD_ENCRYPTION_LUKS_ANY capability

This capability represents that qemu supports the "luks-any" encryption
format for RBD images.
Both LUKS and LUKS2 formats can be parsed using this wildcard format.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: add support for librbd layered encryption
Or Ozeri [Mon, 13 Mar 2023 09:50:21 +0000 (04:50 -0500)]
qemu: add support for librbd layered encryption

This commit enables libvirt users to use layered encryption
of RBD images, using the librbd encryption engine.
This allows opening of an encrypted cloned image
whose parent is encrypted with a possibly different encryption key.
To open such images, multiple encryption secrets are expected
to be defined under the encryption XML tag.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: add multi-secret support in _qemuDomainStorageSourcePrivate
Or Ozeri [Mon, 13 Mar 2023 09:50:20 +0000 (04:50 -0500)]
qemu: add multi-secret support in _qemuDomainStorageSourcePrivate

This commit changes the _qemuDomainStorageSourcePrivate struct
to support multiple secrets (instead of a single one before this commit).
This will useful for storage encryption requiring more than a single secret.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: add multi-secret support in qemuBlockStorageSourceAttachData
Or Ozeri [Mon, 13 Mar 2023 09:50:19 +0000 (04:50 -0500)]
qemu: add multi-secret support in qemuBlockStorageSourceAttachData

This commit changes the qemuBlockStorageSourceAttachData struct
to support multiple secrets (instead of a single one before this commit).
This will useful for storage encryption requiring more than a single secret.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: add support for multiple secret aliases
Or Ozeri [Mon, 13 Mar 2023 09:50:18 +0000 (04:50 -0500)]
qemu: add support for multiple secret aliases

Change secret aliases from %s-%s-secret0 to %s-%s-secret%lu,
which will later be used for storage encryption requiring more
than a single secret.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agoqemu: capabilities: Introduce QEMU_CAPS_RBD_ENCRYPTION_LAYERING capability
Or Ozeri [Mon, 13 Mar 2023 09:50:17 +0000 (04:50 -0500)]
qemu: capabilities: Introduce QEMU_CAPS_RBD_ENCRYPTION_LAYERING capability

This capability represents that qemu supports the layered encryption
of RBD images, where a cloned image is encrypted with a possible
different encryption than its parent image.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agodocs: clarify --timeout description for virtsecretd
Ján Tomko [Wed, 15 Mar 2023 10:15:01 +0000 (11:15 +0100)]
docs: clarify --timeout description for virtsecretd

As of commit 9e3cc0ff5 the virtsecretd daemon does not timeout
while it keeps any ephemeral secrets.

https://bugzilla.redhat.com/show_bug.cgi?id=2035985

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agodocs: clarify --timeout description for split daemons
Ján Tomko [Wed, 15 Mar 2023 10:08:29 +0000 (11:08 +0100)]
docs: clarify --timeout description for split daemons

Remove the reference to "running domains" for daemons that happily
exit while domains are running.

https://bugzilla.redhat.com/show_bug.cgi?id=2035985

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoutil: virXMLValidatorInit: improve translatable errors
Ján Tomko [Wed, 8 Mar 2023 13:00:18 +0000 (14:00 +0100)]
util: virXMLValidatorInit: improve translatable errors

In some translations, the RNG initials were mistranslated
as a random number generator.

Spell it out as RelaxNG to make it clearer.
Include the word 'schema' and quotes around the filename.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2 years agocpu_map: Add missing feature "fsrc"
Tim Wiederhake [Thu, 9 Mar 2023 13:18:18 +0000 (14:18 +0100)]
cpu_map: Add missing feature "fsrc"

Introduced in qemu 58794f644e.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agocpu_map: Add missing feature "fsrs"
Tim Wiederhake [Thu, 9 Mar 2023 13:18:18 +0000 (14:18 +0100)]
cpu_map: Add missing feature "fsrs"

Introduced in qemu 58794f644e.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agocpu_map: Add missing feature "fzrm"
Tim Wiederhake [Thu, 9 Mar 2023 13:18:18 +0000 (14:18 +0100)]
cpu_map: Add missing feature "fzrm"

Introduced in qemu 58794f644e.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agocpu_map: Add missing feature "sgx-aex-notify"
Tim Wiederhake [Thu, 9 Mar 2023 13:18:18 +0000 (14:18 +0100)]
cpu_map: Add missing feature "sgx-aex-notify"

Introduced in qemu d45f24fe75.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agocpu_map: Add missing feature "sgx-edeccssa"
Tim Wiederhake [Thu, 9 Mar 2023 13:18:18 +0000 (14:18 +0100)]
cpu_map: Add missing feature "sgx-edeccssa"

Introduced in qemu d45f24fe75.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agosync_qemu_features_i386: Ignore xen-vapic
Tim Wiederhake [Thu, 9 Mar 2023 13:18:18 +0000 (14:18 +0100)]
sync_qemu_features_i386: Ignore xen-vapic

Not a cpu-feature.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agosync_qemu_models_i386.py: Add missing features
Tim Wiederhake [Thu, 9 Mar 2023 13:18:18 +0000 (14:18 +0100)]
sync_qemu_models_i386.py: Add missing features

This brings the tool's list of features in sync with qemu
commit 9832009d9dd2386664c15cc70f6e6bfe062be8bd.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agosync_qemu_models_i386.py: Sort features
Tim Wiederhake [Thu, 9 Mar 2023 13:18:17 +0000 (14:18 +0100)]
sync_qemu_models_i386.py: Sort features

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoNEWS: Document recent thread-context bug fix
Michal Privoznik [Wed, 8 Mar 2023 10:59:39 +0000 (11:59 +0100)]
NEWS: Document recent thread-context bug fix

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agodocs: Document memory allocation and emulator pinning limitation
Michal Privoznik [Wed, 8 Mar 2023 10:53:37 +0000 (11:53 +0100)]
docs: Document memory allocation and emulator pinning limitation

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoqemuBuildThreadContextProps: Prune .node-affinity wrt <emulatorpin/>
Michal Privoznik [Tue, 7 Mar 2023 13:05:54 +0000 (14:05 +0100)]
qemuBuildThreadContextProps: Prune .node-affinity wrt <emulatorpin/>

When a thread-context object is specified on the cmd line, then
QEMU spawns a thread and sets its affinity to the list of NUMA
nodes specified in .node-affinity attribute. And this works just
fine, until the main QEMU thread itself is not restricted.

Because of v5.3.0-rc1~18 we restrict the main emulator thread
even before QEMU is executed and thus then it tries to set
affinity of a thread-context thread, it inevitably fails with:

  Setting CPU affinity failed: Invalid argument

Now, we could lift the pinning temporarily, let QEMU spawn all
thread-context threads, and enforce pinning again, but that would
require some form of communication with QEMU (maybe -preconfig?).
But that would still be wrong, because it would circumvent
<emulatorpin/>.

Technically speaking, thread-context is an internal
implementation detail of QEMU, and if it weren't for it, the main
emulator thread would be doing the allocation. Therefore, we
should honor the pinning and prune the list of node so that
inaccessible ones are dropped.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2154750
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoqemu: Add @nodemask argument to qemuBuildThreadContextProps()
Michal Privoznik [Tue, 7 Mar 2023 11:39:47 +0000 (12:39 +0100)]
qemu: Add @nodemask argument to qemuBuildThreadContextProps()

When building a thread-context object (inside of
qemuBuildThreadContextProps()) we look at given memory-backend-*
object and look for .host-nodes attribute. This works, as long as
we need to just copy the attribute value into another
thread-context attribute. But soon we will need to adjust it.
That's the point where having the value in virBitmap comes handy.
Utilize the previous commit, which made
qemuBuildMemoryBackendProps() set the argument and pass it into
qemuBuildThreadContextProps().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoqemu: Add @nodemaskRet argument to qemuBuildMemoryBackendProps()
Michal Privoznik [Tue, 7 Mar 2023 11:02:11 +0000 (12:02 +0100)]
qemu: Add @nodemaskRet argument to qemuBuildMemoryBackendProps()

While it's true that anybody who's interested in getting
.host-nodes attribute value can just use
virJSONValueObjectGetArray() (and that's exactly what
qemuBuildThreadContextProps() is doing, btw), if somebody is
interested in getting the actual virBitmap, they would have to
parse the JSON array.

Instead, introduce an argument to qemuBuildMemoryBackendProps()
which is set to corresponding value used when formatting the
attribute.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoqemuBuildMemoryBackendProps: Join two conditions
Michal Privoznik [Tue, 14 Mar 2023 16:19:27 +0000 (17:19 +0100)]
qemuBuildMemoryBackendProps: Join two conditions

There are two compound conditions in
qemuBuildMemoryBackendProps() and each one checks for nodemask
for NULL first. Join them into one bigger block.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoqemu: Fix qemuDomainGetEmulatorPinInfo()
Michal Privoznik [Tue, 7 Mar 2023 11:31:08 +0000 (12:31 +0100)]
qemu: Fix qemuDomainGetEmulatorPinInfo()

The order of pinning priority (at least for emulator thread) was
set by v1.2.15-rc1~58 (for cgroup code). But later, when
automatic placement was implemented into
qemuDomainGetEmulatorPinInfo(), the priority was not honored.

Now that we have this priority code in a separate function, we
can just call that and avoid this type of error.

Fixes: 776924e37649f2d47acd805746d5fd9325212ea5
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoqemu: Move cpuset preference evaluation into a separate function
Michal Privoznik [Tue, 7 Mar 2023 11:27:05 +0000 (12:27 +0100)]
qemu: Move cpuset preference evaluation into a separate function

The set of if()-s that determines the preference in cpumask used
for setting things like emulatorpin, vcpupin, etc. is going to be
re-used. Separate it out into a function.

You may think that this changes behaviour, but
qemuProcessPrepareDomainNUMAPlacement() ensures that
priv->autoCpuset is set for VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoqemuxml2argvmock: Drop virNuma* mocks
Michal Privoznik [Tue, 7 Mar 2023 15:06:14 +0000 (16:06 +0100)]
qemuxml2argvmock: Drop virNuma* mocks

Since qemuxml2argvtest is now using virnumamock, there's no need
for qemuxml2argvmock to offer reimplementation of virNuma*()
functions. Also, the comment about CLang and FreeBSD (introduced
in v4.3.0-40-g77ac204d14) is no longer true. Looks like noinline
attribute was the missing culprit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoqemuxml2argvdata: Extend vCPUs placement in memory-hotplug-dimm-addr.xml
Michal Privoznik [Tue, 7 Mar 2023 14:36:47 +0000 (15:36 +0100)]
qemuxml2argvdata: Extend vCPUs placement in memory-hotplug-dimm-addr.xml

So far, the memory-hotplug-dimm-addr.xml test case pins its vCPUs
onto CPUs 0-1 which correspond to NUMA node #0 (per
tests/vircaps2xmldata/linux-basic/system/node/node0). Place vCPUs
onto nodes #1 and #2 too so that DIMM <memory/> device can
continue using thread-context after future patches. This
configuration, as-is currently, would make QEMU error out anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoqemuxml2argvdata: Adjust maximum NUMA node used
Michal Privoznik [Tue, 7 Mar 2023 15:06:03 +0000 (16:06 +0100)]
qemuxml2argvdata: Adjust maximum NUMA node used

We have couple of qemuxml2argvtest cases where up to 8 NUMA nodes
are assumed. These are used to check whether disjoint ranges of
host-nodes= is generated properly. Without prejudice to the
generality, we can rewrite corresponding XML files to use up to 4
NUMA nodes and still have disjoint ranges.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoqemuxml2argvtest: Use virnuma mock
Michal Privoznik [Tue, 7 Mar 2023 14:36:35 +0000 (15:36 +0100)]
qemuxml2argvtest: Use virnuma mock

While no part of cmd line building process currently depends on a
host NUMA configuration, this will change soon. Use freshly
changed virnumamock from qemuxml2argvtest and make the mock read
NUMA data from vircaps2xmldata which seems to have the most rich
NUMA configuration.

This also means, we have to start building virnumamock
unconditionally. But this is not a problem, since nothing inside
of the mock relies on Linux specificity. The whole mock is merely
just reading files and parsing them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agovirnumamock: Introduce virNumaGetNodeOfCPU() mock
Michal Privoznik [Tue, 7 Mar 2023 14:44:41 +0000 (15:44 +0100)]
virnumamock: Introduce virNumaGetNodeOfCPU() mock

Introduce a mock of virNumaGetNodeOfCPU() because soon we will
need virNumaCPUSetToNodeset() to return predictable results.
Also, fill in missing symlinks in vircaps2xmldata/.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agovirnuma: Introduce virNumaCPUSetToNodeset()
Michal Privoznik [Tue, 7 Mar 2023 13:05:27 +0000 (14:05 +0100)]
virnuma: Introduce virNumaCPUSetToNodeset()

So far, we have a function that expands given list of NUMA nodes
into list of CPUs. But soon, we are going to need the inverse -
expand list of CPUs into list of NUMA nodes. Introduce
virNumaCPUSetToNodeset() for that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agovirnuma: Move virNumaNodesetToCPUset() out of WITH_NUMACTL
Michal Privoznik [Wed, 8 Mar 2023 09:10:00 +0000 (10:10 +0100)]
virnuma: Move virNumaNodesetToCPUset() out of WITH_NUMACTL

Technically, there's nothing libnuma specific about
virNumaNodesetToCPUset(). It just implements a generic algorithm
over virNumaGetNodeCPUs() (which is then libnuma dependant).
Nevertheless, there's no need to have this function living inside
WITH_NUMACTL block. Any error returned from virNumaGetNodeCPUs()
(including the one that !WITH_NUMACTL stub returns) is propagated
properly.

Move the function out of the block into a generic one and drop
the !WITH_NUMACTL stub.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoqemu_alias: Fix backcompat console alias generation
Michal Privoznik [Tue, 14 Mar 2023 10:03:50 +0000 (11:03 +0100)]
qemu_alias: Fix backcompat console alias generation

We have this crazy backwards compatibility when it comes to
serial and console devices. Basically, in same cases the very
first <console/> is just an alias to the very first <serial/>
device. This is to be seen at various places:

1) virDomainDefFormatInternalSetRootName() - when generating
   domain XML, the <console/> configuration is basically ignored
   and corresponding <serial/> config is formatted,

2) virDomainDefAddConsoleCompat() - which adds a copy of
   <serial/> or <console/> into virDomainDef in post parse.

And when talking to QEMU we need a special handling too, because
while <serial/> is generated on the cmd line, the <console/> is
not. And in a lot of place we get it right. Except for generating
device aliases. On domain startup the 'expected' happens and
devices get "serial0" and "console0" aliases, correspondingly.
This ends up in the status XML too. But due to aforementioned
trick when formatting domain XML, "serial0" ends up in both
'virsh dumpxml' and the status XML. But internally, both devices
have different alias. Therefore, detaching the device using
<console/> fails as qemuDomainDetachDeviceChr() tries to detach
"console0".

After the daemon is restarted and status XML is parsed, then
everything works suddenly. This is because in the status XML both
devices have the same alias.

Let's generate correct alias from the beginning.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2156300
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agoqemu_migration: Use VIR_DOMAIN_PAUSED_API_ERROR
Jiri Denemark [Wed, 1 Mar 2023 11:55:18 +0000 (12:55 +0100)]
qemu_migration: Use VIR_DOMAIN_PAUSED_API_ERROR

Other APIs that internally use QEMU migration and need to temporarily
suspend a domain already report failure to resume vCPUs by setting
VIR_DOMAIN_PAUSED_API_ERROR state reason and emitting
VIR_DOMAIN_EVENT_SUSPENDED event with
VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR.

Let's do the same in qemuMigrationSrcRestoreDomainState for consistent
behavior.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoIntroduce VIR_DOMAIN_PAUSED_API_ERROR
Jiri Denemark [Tue, 28 Feb 2023 15:53:29 +0000 (16:53 +0100)]
Introduce VIR_DOMAIN_PAUSED_API_ERROR

Some APIs (migration, save/restore, snapshot, ...) require a domain to
be suspended temporarily. In case resuming the domain fails, the domain
will be unexpectedly left paused when the API finishes. This situation
is reported via VIR_DOMAIN_EVENT_SUSPENDED event with
VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR detail. But we do not have a
corresponding reason for VIR_DOMAIN_PAUSED state and the reason would
remain set to the value used when the domain was paused. So the state
reason would suggest the operation is still running.

This patch changes the state reason to a new VIR_DOMAIN_PAUSED_API_ERROR
to make it clear the API that paused the domain already finished, but
failed to resume the domain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoClarify VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR semantics
Jiri Denemark [Tue, 28 Feb 2023 14:49:29 +0000 (15:49 +0100)]
Clarify VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR semantics

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoNEWS: Mention support for custom UEFI firmwar paths in Xen
Jim Fehlig [Mon, 13 Mar 2023 20:37:49 +0000 (14:37 -0600)]
NEWS: Mention support for custom UEFI firmwar paths in Xen

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: remove unused argument
Ján Tomko [Mon, 13 Mar 2023 13:42:58 +0000 (14:42 +0100)]
qemu: remove unused argument

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoqemu: relax shared memory check for vhostuser daemons
Ján Tomko [Mon, 13 Mar 2023 12:56:47 +0000 (13:56 +0100)]
qemu: relax shared memory check for vhostuser daemons

For some vhostuser daemons, we validate that the guest memory is shared
with the host.

With earlier versions of QEMU, it was only possible to mark memory
as shared by defining an explicit NUMA topology.  Later, QEMU exposed
the name of the default memory backend (defaultRAMid) so we can mark
that memory as shared.

Since libvirt commit:
  commit bff2ad5d6b1f25da02802273934d2a519159fec7
    qemu: Relax validation for mem->access if guest has no NUMA
we already check for the case when user requests shared memory,
but QEMU did not expose defaultRAMid.

Drop the duplicit check from vhostuser device validation, to make
it pass on hotplug even after libvirtd restart.

This avoids the need to store the defaultRAMid, since we don't really
need it for anything after the VM has been already started.

https://bugzilla.redhat.com/show_bug.cgi?id=2078693
https://bugzilla.redhat.com/show_bug.cgi?id=2177701

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agonews: Update for passt on SELinux/AppArmor support
Andrea Bolognani [Tue, 14 Mar 2023 09:44:38 +0000 (10:44 +0100)]
news: Update for passt on SELinux/AppArmor support

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agorpm: Recommend passt-selinux
Andrea Bolognani [Tue, 14 Mar 2023 09:41:46 +0000 (10:41 +0100)]
rpm: Recommend passt-selinux

Now that we have SELinux support for passt, we want things to
work out of the box and that requires having the passt-specific
SELinux bits installed.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2 years agodocs: downloads: Point to pkg.go.dev for go module releases
Peter Krempa [Tue, 14 Mar 2023 09:11:33 +0000 (10:11 +0100)]
docs: downloads: Point to pkg.go.dev for go module releases

Currently the 'Releases' column pointed to the generic page about the
specific go module. Change the link to point to the respective
pkg.go.dev page for the module.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agodocs: downloads: Don't mention releases directory of libvirt-csharp
Peter Krempa [Tue, 14 Mar 2023 12:01:59 +0000 (13:01 +0100)]
docs: downloads: Don't mention releases directory of libvirt-csharp

The releases directory is empty. Don't advertise it on our downloads
page.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agodocs: downloads: Drop link to sources of 'consoleproxy'
Peter Krempa [Tue, 14 Mar 2023 08:47:35 +0000 (09:47 +0100)]
docs: downloads: Drop link to sources of 'consoleproxy'

The directory doesn't exist. The project also doesn't have any releases
on gitlab so there's nothing to replace it with.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agospec: Use 'download.libvirt.org' as source server
Peter Krempa [Tue, 14 Mar 2023 08:32:30 +0000 (09:32 +0100)]
spec: Use 'download.libvirt.org' as source server

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agodocs: downloads: Replace 'libvirt.org/sources' by 'download.libvirt.org'
Peter Krempa [Tue, 14 Mar 2023 08:30:25 +0000 (09:30 +0100)]
docs: downloads: Replace 'libvirt.org/sources' by 'download.libvirt.org'

We split off the downloads into a new subdomain. Link directly to it
instead of relying on redirects.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agodocs: java: Clean up links to source code
Peter Krempa [Tue, 14 Mar 2023 08:26:11 +0000 (09:26 +0100)]
docs: java: Clean up links to source code

 - drop the link to the FTP server which doesn't exist any more
 - change links to libvirt.org/source to download.libvirt.org
 - change link to the maven repository to point to download.libvirt.org
 - change link to javadoc to the documentation generated via gitlab job
   in the libvirt-java project

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2 years agodocs: Fix searching in the wiki
Peter Krempa [Mon, 13 Mar 2023 12:10:17 +0000 (13:10 +0100)]
docs: Fix searching in the wiki

Conversion of the wiki to static pages means that the integrated search
no longer functions. Use the same approach we have for other search to
simply defer to google.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agorpc: genprotocol: Always apply fixups to rpcgen's output
Peter Krempa [Wed, 8 Mar 2023 08:51:05 +0000 (09:51 +0100)]
rpc: genprotocol: Always apply fixups to rpcgen's output

The platform check which determines when to apply the fixups mentions
all officially supported build targets (per docs/platforms.rst) thus
it's not really necessary.

Additionally while not explicitly written as supported the check does
not work properly when building with the MinGW toolchain on Windows as
it does not apply the needed transformations. They are necessary
there the same way as with MinGW on Linux.

https://gitlab.com/libvirt/libvirt/-/issues/453

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2 years agoUse G_N_ELEMENTS() more
Michal Privoznik [Mon, 13 Mar 2023 09:43:50 +0000 (10:43 +0100)]
Use G_N_ELEMENTS() more

In a few places we still use the good old:

  sizeof(var) / sizeof(var[0])
  sizeof(var) / sizeof(int)

The G_N_ELEMENTS() macro is preferred though. In a few places we
don't link with glib, so provide the macro definition.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2 years agoremote: fix typo in error message string
Daniel P. Berrangé [Mon, 13 Mar 2023 12:21:32 +0000 (12:21 +0000)]
remote: fix typo in error message string

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2 years agoqemu: set SELinux label of passt process to its own binary's label
Laine Stump [Wed, 1 Mar 2023 20:58:24 +0000 (15:58 -0500)]
qemu: set SELinux label of passt process to its own binary's label

set useBinarySpecificLabel = true when calling qemuSecurityCommandRun
for the passt process, so that the new process context will include
the binary-specific label that should be used for passt (passt_t)
rather than svirt_t (as would happen if useBinarySpecificLabel was
false). (The MCS part of the label, which is common to all child
processes related to a particular qemu domain instance, is also set).

Resolves: https://bugzilla.redhat.com/2172267
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agosecurity: make it possible to set SELinux label of child process from its binary
Laine Stump [Wed, 1 Mar 2023 20:34:32 +0000 (15:34 -0500)]
security: make it possible to set SELinux label of child process from its binary

Normally when a child process is started by libvirt, the SELinux label
of that process is set to virtd_t (plus an MCS range). In at least one
case (passt) we need for the SELinux label of a child process label to
match the label that the binary would have transitioned to
automatically if it had been run standalone (in the case of passt,
that label is passt_t).

This patch modifies virSecuritySELinuxSetChildProcessLabel() (and all
the functions above it in the call chain) so that the toplevel
function can set a new argument "useBinarySpecificLabel" to true. If
it is true, then virSecuritySELinuxSetChildProcessLabel() will call
the new function virSecuritySELinuxContextSetFromFile(), which uses
the selinux library function security_compute_create() to determine
what would be the label of the new process if it had been run
standalone (rather than being run by libvirt) - the MCS range from the
normally-used label is added to this newly derived label, and that is
what is used for the new process rather than whatever is in the
domain's security label (which will usually be virtd_t).

In order to easily verify that nothing was broken by these changes to
the call chain, all callers currently set useBinarySpecificPath =
false, so all behavior should be completely unchanged. (The next
patch will set it to true only for the case of running passt.)

https://bugzilla.redhat.com/2172267
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agosecurity: make args to virSecuritySELinuxContextAddRange() const
Laine Stump [Wed, 8 Mar 2023 17:50:38 +0000 (12:50 -0500)]
security: make args to virSecuritySELinuxContextAddRange() const

Neither of these are modified anywhere in the function, and the
function will soon be called with an arg that actually is a const.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoutil: add an API to retrieve the resolved path to a virCommand's binary
Laine Stump [Wed, 1 Mar 2023 16:34:24 +0000 (11:34 -0500)]
util: add an API to retrieve the resolved path to a virCommand's binary

The binary to be exec'ed by virExec() is stored in
virCommand::args[0], and is resolved to a full absolute path (stored
in a local of virExec() just prior to execve().

Since we will have another use for the full absolute path, lets make
an API to resolve/retrieve the absolute path, and cache it in
virCommand::binaryPath so we only have to do the resolution once.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agolibxl: Add support for custom firmware path in config converter
Jim Fehlig [Mon, 13 Feb 2023 21:30:31 +0000 (14:30 -0700)]
libxl: Add support for custom firmware path in config converter

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agolibxl: Support specifying a custom firmware path
Jim Fehlig [Fri, 10 Feb 2023 21:22:19 +0000 (14:22 -0700)]
libxl: Support specifying a custom firmware path

libxl added support for specifying custom firmware paths long ago. The
functionality exists in all Xen version supported by libvirt. This patch
adds support for user-specified efi firmware paths in the libxl driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2 years agoapparmor: Enable passt support
Andrea Bolognani [Tue, 7 Mar 2023 18:20:09 +0000 (19:20 +0100)]
apparmor: Enable passt support

passt provides an AppArmor abstraction that covers all the
inner details of its operation, so we can simply import that
and add the libvirt-specific parts on top: namely, passt
needs to be able to create a socket and pid file, while
the libvirt daemon needs to be able to kill passt.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>