Commit Graph

389 Commits

Author SHA1 Message Date
Jiri Denemark
ce7d0a7db4 Post-release version bump to 10.0.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-12-01 16:24:28 +01:00
Laine Stump
9231566146 build: suppress "ignoring duplicate libraries" warning on macOS
Xcode 15, which provides the compiler toolchain for building libvirt
on macOS has switched to a new linker that warns about duplicated
"-lblah" options on the ld commandline. In practice this is impossible
to prevent in a large project, and also harmless.

Fortunately the new ld command also has an option,
-no_warn_duplicate_libraries, that supresses this harmless/pointless
warning, meson has a simple way to check if that option is supported,
and libvirt's meson.build files already have examples of adding an
option to the ld commandline if it's available.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-11-03 15:56:37 -04:00
Daniel P. Berrangé
a62486b95f build: switch over to new rpc generator code
This replaces use of 'rpcgen' with our new python impl of
the RPC code generator. Since the new impl generates code
that matches our style/coding rules, and does not contain
long standing bugs, we no longer need to post-process the
output.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2023-11-03 14:06:35 -04:00
Daniel P. Berrangé
8c8b97685b 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>
2023-11-03 14:06:35 -04:00
Daniel P. Berrangé
a24ab56da8 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>
2023-11-03 14:06:35 -04:00
Jiri Denemark
bfcf4be172 Post-release version bump to 9.10.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-11-01 10:42:48 +01:00
Andrea Bolognani
4242a94816 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>
2023-10-26 11:31:25 +02:00
Andrea Bolognani
87f14badd0 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>
2023-10-26 11:31:24 +02:00
Andrea Bolognani
8ce0decc37 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>
2023-10-26 11:31:22 +02:00
Andrea Bolognani
5904228f92 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>
2023-10-26 11:31:21 +02:00
Andrea Bolognani
44711485b1 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>
2023-10-26 11:31:19 +02:00
Andrea Bolognani
03785fef92 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>
2023-10-25 12:19:32 +02:00
Andrea Bolognani
7cbd8c4230 meson: Improve nbdkit configurability
Currently, nbdkit support will automatically be enabled as long as
the pidfd_open(2) syscall is available. Optionally, libnbd is used
to generate more user-friendly error messages.

In theory this is all good, since use of nbdkit is supposed to be
transparent to the user. In practice, however, there is a problem:
if support for it is enabled at build time and the necessary
runtime components are installed, nbdkit will always be preferred,
with no way for the user to opt out.

This will arguably be fine in the long run, but right now none of
the platforms that we target ships with a SELinux policy that
allows libvirt to launch nbdkit, and the AppArmor policy that we
maintain ourselves hasn't been updated either.

So, in practice, as of today having nbdkit installed on the host
makes network disks completely unusable unless you're willing to
compromise the overall security of the system by disabling
SELinux/AppArmor.

In order to make the transition smoother, provide a convenient
way for users and distro packagers to disable nbdkit support at
compile time until SELinux and AppArmor are ready.

In the process, detection is completely overhauled. libnbd is
made mandatory when nbdkit support is enabled, since availability
across operating systems is comparable and offering users the
option to make error messages worse doesn't make a lot of sense;
we also make sure that an explicit request from the user to
enable/disable nbdkit support is either complied with, or results
in a build failure when that's not possible. Last but not least,
we avoid linking against libnbd when nbdkit support is disabled.

At the RPM level, we disable the feature when building against
anything older than Fedora 40, which still doesn't have the
necessary SELinux bits but will hopefully gain them by the time
it's released. We also allow nbdkit support to be disabled at
build time the same way as other optional features, that is, by
passing "--define '_without_nbdkit 1'" to rpmbuild. Finally, if
nbdkit support has been disabled, installing libvirt will no
longer drag it in as a (weak) dependency.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2023-10-05 22:49:14 +02:00
Jiri Denemark
bd011ff818 Post-release version bump to 9.9.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-10-02 09:33:28 +02:00
Jonathon Jongsma
40935b395c qemu: try to connect to nbdkit early to detect errors
When using nbdkit to serve a network disk source, the nbdkit process
will start and wait for an nbd connection before actually attempting to
connect to the (remote) disk location. Because of this, nbdkit will not
report an error until after qemu is launched and tries to read from the
disk. This results in a fairly user-unfriendly error saying that qemu
was unable to start because "Requested export not available".

Ideally we'd like to be able to tell the user *why* the export is not
available, but this sort of information is only available to nbdkit, not
qemu. It could be because the url was incorrect, or because of an
authentication failure, or one of many other possibilities.

To make this friendlier for users and easier to detect
misconfigurations, try to connect to nbdkit immediately after starting
nbdkit and before we try to start qemu. This requires adding a
dependency on libnbd. If an error occurs when connecting to nbdkit, read
back from the nbdkit error log and provide that information in the error
report from qemuNbdkitProcessStart().

User-visible change demonstrated below:
Previous error:

    $ virsh start nbdkit-test
    2023-01-18 19:47:45.778+0000: 30895: error : virNetClientProgramDispatchError:172 : internal
    error: process exited while connecting to monitor: 2023-01-18T19:47:45.704658Z
    qemu-system-x86_64: -blockdev {"driver":"nbd","server":{"type":"unix",
    "path":"/var/lib/libvirt/qemu/domain-1-nbdkit-test/nbdkit-libvirt-1-storage.socket"},
    "node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}: Requested export not
    available
    error: Failed to start domain 'nbdkit-test'
    error: internal error: process exited while connecting to monitor: 2023-01-18T19:47:45.704658Z
    qemu-system-x86_64: -blockdev {"driver":"nbd","server":{"type":"unix",
    "path":"/var/lib/libvirt/qemu/domain-1-nbdkit-test/nbdkit-libvirt-1-storage.socket"},
    "node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}: Requested export not
    available

After this change:

    $ virsh start nbdkit-test
    2023-01-18 19:44:36.242+0000: 30895: error : virNetClientProgramDispatchError:172 : internal
    error: Failed to connect to nbdkit for 'http://localhost:8888/nonexistent.iso': nbdkit: curl[1]:
    error: problem doing HEAD request to fetch size of URL [http://localhost:8888/nonexistent.iso]:
    HTTP response code said error: The requested URL returned error: 404
    error: Failed to start domain 'nbdkit-test'
    error: internal error: Failed to connect to nbdkit for 'http://localhost:8888/nonexistent.iso]:
    error: problem doing HEAD request to fetch size of URL [http://localhost:8888/nonexistent.iso]:
    HTTP response code said error: The requested URL returned error: 404

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-09-19 14:28:50 -05:00
Jonathon Jongsma
447e09dfdb qemu: Monitor nbdkit process for exit
Adds the ability to monitor the nbdkit process so that we can take
action in case the child exits unexpectedly.

When the nbdkit process exits, we pause the vm, restart nbdkit, and then
resume the vm. This allows the vm to continue working in the event of a
nbdkit failure.

Eventually we may want to generalize this functionality since we may
need something similar for e.g. qemu-storage-daemon, etc.

The process is monitored with the pidfd_open() syscall if it exists
(since linux 5.3). Otherwise it resorts to checking whether the process
is alive once a second. The one-second time period was chosen somewhat
arbitrarily.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2023-09-19 14:28:50 -05:00
Peter Krempa
c2e6897e54 build: Fix logic bug determining whether running with optimization
The conversion from ternary to a 'if' clause was wrong and thus didn't
properly increase the stack size where needed but only where not
actually needed.

Fixes: b68faa99d9
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2023-09-04 14:30:48 +02:00
Peter Krempa
d9c04cdc34 build: Fix assignment into 'stack_frame_size' when sanitizer is enabled
Instead of an assignment into the 'stack_frame_size' variable when
sanitizers are enabled I've accidentally compared the value against the
requested size.

Fix the typo.

Fixes: b68faa99d9
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2023-09-04 14:07:31 +02:00
Peter Krempa
b68faa99d9 build: Work around clang's stack size calculation without optimization
When building without optimization on clang, certain big functions trip
the stack size limit despite not actually reaching it. Relax the stack
limit size for clang without optimization.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2023-09-04 13:32:28 +02:00
Peter Krempa
42bc76cdb8 build: Decrease maximum stack frame size to 2048
After recent cleanups we can now restrict the maximum stack frame size
to 2k.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2023-09-04 10:31:53 +02:00
Jiri Denemark
32d1543ae9 Post-release version bump to 9.8.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-09-01 13:04:19 +02:00
Jiri Denemark
b185dce64e Post-release version bump to 9.7.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-08-01 11:49:29 +02:00
Jim Fehlig
5f7f6ceb47 Revert "meson: attr_dep switch to dependency()"
openSUSE Leap 15.{4,5} are supported under libvirt's distro support
statement, but they only contain attr version 2.4.47.

Reverts: dffeef89ef
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2023-07-07 08:37:14 -06:00
Andrea Bolognani
4a779f21bd meson: Detect AppArmor 3.x
We will soon need to base some decisions on whether AppArmor 3.x
or 2.x is present on the system.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2023-07-03 14:55:31 +02:00
Jiri Denemark
6742edff2e Post-release version bump to 9.6.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-07-03 12:17:17 +02:00
Michal Privoznik
063e8b9d62 meson: Use dependency().found() instead of conf.has()
So far this change alone doesn't make much sense, but prepares
code for upcoming change. Unfortunately, some conf.has()
statements have to stay, because there's no corresponding
dependency(). But that's okay.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2023-06-12 12:21:02 +02:00
Michal Privoznik
2ef5876e2b meson: numactl_dep switch to dependency()
The pkg-config file to libnuma was introduced in 2.0.12 release
(though the comment mistakenly claims 2.0.14 version). Every
supported distro ships at least this version, and thus we can
switch meson detection to dependency().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2023-06-12 12:20:55 +02:00
Michal Privoznik
dffeef89ef meson: attr_dep switch to dependency()
The pkg-config file to libattr was introduced in 2.4.48 release.
Now that every supported distro ships at least this version, we
can switch meson detection to dependency().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2023-06-12 12:08:18 +02:00
Michal Privoznik
63ca3e656c meson: acl_dep switch to dependency()
The pkg-config file to libacl was introduced in 2.2.53 release.
Now that every supported distro ships at least this version, we
can switch meson detection to dependency().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2023-06-12 11:58:26 +02:00
Jiri Denemark
68545ed21b Post-release version bump to 9.5.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-06-01 11:50:19 +02:00
Andrea Bolognani
4400f63636 meson: Stop looking for dbus-daemon
Now that we're performing the lookup at runtime, doing it at
build time is no longer necessary.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-05-11 15:04:54 +02:00
Andrea Bolognani
b134a9bd2a meson: Stop looking for QEMU helpers
Now that we're performing the lookup at runtime, doing it at
build time is no longer necessary.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-10 18:54:12 +02:00
Andrea Bolognani
d18572b4b7 meson: Improve initconfdir defaults
Keep /etc/sysconfig as the fallback, but pick more suitable
values for various Linux distros.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-05 15:08:31 +02:00
Andrea Bolognani
6f42d9610c meson: Move definition of os_release
We're about to introduce another user of the value in a
different scope.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-05 15:08:29 +02:00
Andrea Bolognani
9850b37e39 meson: Introduce initconfdir option
Right now we expect the configuration files for init scripts
to live in /etc/sysconfig, but that location is only used by
RHEL- and SUSE-derived distros.

This means that packagers for other distros have to patch
things as part of the build process, while people building
from source will get wonky integration.

This new option will provide a convenient way to override
the default location at build time that is usable by distro
packagers and people building from source alike.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-05-05 15:08:19 +02:00
Andrea Bolognani
2f197ab695 meson: Fix qemu_{user,group} defaults for Arch
The current values might have been accurate at the time
when the logic was introduced, but these days Arch is
using the same ones as Debian.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat>
2023-05-03 10:15:09 +02:00
Jiri Denemark
30403ef1d6 Post-release version bump to 9.4.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-05-02 14:18:37 +02:00
Andrea Bolognani
0324adb647 meson: Check header usability
This fixes cross-building in some scenarios.

Specifically, when building for armv7l on x86_64, has_header()
will see the x86_64 version of the linux/kmv.h header and
consider it to be usable. Later, when an attempt is made to
actually include it, the compiler will quickly realize that
things can't quite work.

The reason why we haven't hit this in our CI is that we only ever
install the foreign version of header files. When building the
Debian package, however, some of the Debian-specific tooling will
bring in the native version of the Linux headers in addition to
the foreign one, causing meson to misreport the header's
availability status.

Checking for actual usability, as opposed to mere presence, of
headers is enough to make things work correctly in all cases.

The meson documentation recommends using has_header() instead of
check_header() whenever possible for performance reasons, but
while testing this change on fairly old and underpowered hardware
I haven't been able to measure any meaningful slowdown.

https://bugs.debian.org/1024504

Suggested-by: Helmut Grohne <helmut@subdivi.de>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-27 15:29:10 +02:00
Michal Privoznik
ac7f3667f2 meson: Work around configure_file(copy:true) deprecation
In our meson scripts, we use configure_file(copy:true) to copy
files from srcdir into builddir. However, as of meson-0.64.0,
this is deprecated [1] in favor of using:

  fs = import('fs')
  fs.copyfile(in, out)

Except, the submodule's new method wasn't introduced until
0.64.0. And since we can't bump the minimal meson version we
require, we have to work with both: new and old versions.

Now, the fun part: fs.copyfile() is not a drop in replacement as
it returns different type (a custom_target object). This is
incompatible with places where we store the configure_file()
retval in a variable to process it further.

While we could just replace 'copy:true' with a dummy
'configuration:...' (say 'configuration: configmake_conf') we
can't do that for binary files (like src/fonts/ or src/images/).

Therefore, places where we are not interested in the retval can
be switched to fs.copyfile() and places where we are interested
in the retval will just use a dummy 'configuration:'.

Except, src/network/meson.build. In here we not just copy the
file but also specify alternative install dir and that's not
something that fs.copyfile() can handle. Yet, using 'copy: true'
is viewed wrong [2].

1: https://mesonbuild.com/Release-notes-for-0-64-0.html#fscopyfile-to-replace-configure_filecopy-true
2: https://github.com/mesonbuild/meson/pull/10042

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-04-20 15:30:18 +02:00
Marc-André Lureau
883b427acf Move src/keycodemapdb -> subprojects/keycodemapdb
Follow better meson build system conventions. This allows to find
keymap-gen or CSV without explicitly setting the paths.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-17 15:02:38 +02:00
Marc-André Lureau
c69bbd14fa meson: don't look for unix paths on win32
Or meson will complain with:
../meson.build:770:2: ERROR: Search directory /sbin is not an absolute path.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-04-17 15:02:22 +02:00
Jiri Denemark
cc7058996d Post-release version bump to 9.3.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-04-01 09:52:31 +02:00
Michal Privoznik
7944700b40 meson: Don't build tests when CLang lacks -fsemantic-interposition
There are some CLang versions that do not support
-fsemantic-interposition. If that's the case, the code is
optimized so much that our mocking no longer works.

Therefore, disable tests and produce a warning.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-03-24 11:15:23 +01:00
Michal Privoznik
743fdb97c8 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>
2023-03-21 11:54:52 +01:00
Daniel P. Berrangé
f9f5ab5718 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
   407a281a8e

 * 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>
2023-03-17 14:43:46 +00:00
Jiri Denemark
3b7d109a17 Post-release version bump to 9.2.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-03-01 11:15:06 +01:00
Jiri Denemark
666bc8ee4f Post-release version bump to 9.1.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2023-01-16 11:59:42 +01:00
Laine Stump
a56f0168d5 qemu: hook up passt config to qemu domains
This consists of (1) adding the necessary args to the qemu commandline
netdev option, and (2) starting a passt process prior to starting
qemu, and making sure that it is terminated when it's no longer
needed. Under normal circumstances, passt will terminate itself as
soon as qemu closes its socket, but in case of some error where qemu
is never started, or fails to startup completely, we need to terminate
passt manually.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-01-10 01:19:25 -05:00
Michal Privoznik
53369ad062 virnuma: Allow multiple nodes for preferred policy
In the past, the preferred policy
(VIR_DOMAIN_NUMATUNE_MEM_PREFERRED) required exactly one (host)
NUMA node. This made sense because:

  1) the libnuma API - numa_set_preferred() allowed exactly one
     node, because
  2) corresponding kernel syscall (__NR_set_mempolicy) accepted
     exactly one node (for MPOL_PREFERRED mode).

But things have changed since then. Firstly, kernel introduced
new MPOL_PREFERRED_MANY mode (v5.15-rc1~107^2~21) which was then
exposed in libnuma as numa_set_preferred_many() (v2.0.15~24).

Fortunately, libnuma also exposes numa_has_preferred_many() which
returns whether the kernel has support for the new mode (1) or
not (0).

Putting this all together, we can lift our check for sufficiently
new kernel and libnuma.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2151064
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-12-14 16:07:04 +01:00
Daniel P. Berrangé
77b9617cd7 util: implement secure erase with explicit_bzero
This is available on at least FreeBSD and GLibc >= 2.25.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-12-13 04:46:59 -05:00