]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 months agoutil: change name of virFirewallRule to virFirewallCmd
Laine Stump [Sat, 20 Apr 2024 02:19:42 +0000 (22:19 -0400)]
util: change name of virFirewallRule to virFirewallCmd

These objects aren't rules, they are commands that are executed that
may create a firewall rule, delete a firewall rule, or simply list the
existing firewall rules. It's confusing for the objects to be called
"Rule" (especially in the case of the function
virFirewallRemoveRule(), which doesn't remove a rule from the
firewall, it takes one of the objects out of the list of commands to
execute! In order to remove a rule from the host's firewall, you have
to Add a "rule" (now "cmd" aka command) to the list that will, when
applied/run, remove a rule from the host firewall.)

Changing the name to virFirewallCmd makes it all much less confusing.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agoutil: #define the names used for private packet filter chains
Laine Stump [Sat, 20 Apr 2024 02:19:42 +0000 (22:19 -0400)]
util: #define the names used for private packet filter chains

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agonetwork: make all iptables functions used only in network_iptables.c static
Laine Stump [Sat, 20 Apr 2024 02:19:42 +0000 (22:19 -0400)]
network: make all iptables functions used only in network_iptables.c static

Now that the toplevel iptables functions have been moved out of the
linux bridge driver into network_iptables.c, all of the utility
functions are used only within that same file, so simplify it.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agonetwork: move all functions manipulating iptables rules into network_iptables.c
Laine Stump [Sat, 20 Apr 2024 02:19:42 +0000 (22:19 -0400)]
network: move all functions manipulating iptables rules into network_iptables.c

Although initially we will add exactly the same rules for the nftables
backend, the two may (hopefully) soon diverge as we take advantage of
nftables features that weren't available in iptables. When we do that,
there will need to be a different version of these functions (currently in
bridge_driver_linux.c) for each backend:

  networkAddFirewallRules()
  networkRemoveFirewallRules()
  networkSetupPrivateChains()

Although it will mean duplicating some amount of code (with just the
function names changed) for the nftables backend, this patch moves all
of the rule-related code in the above three functions into iptables*()
functions in network_iptables.c, and changes the functions in
bridge_driver_linux.c to call the iptables*() functions. When we make
a different backend, it will only need to make equivalents of those 3
functions publicly available to the upper layer.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agoutil/network: move viriptables.[ch] from util to network directory
Laine Stump [Sat, 20 Apr 2024 02:19:42 +0000 (22:19 -0400)]
util/network: move viriptables.[ch] from util to network directory

These functions are only ever used by the network driver, and are so
specific to the network driver's usage of iptables that they likely
won't ever be used elsewhere. The files are renamed to
network_iptables.[ch] to be more in line with driver-specific file
naming conventions.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agosrc: Fix return types of .stateInitialize callbacks
Michal Privoznik [Wed, 22 May 2024 07:31:50 +0000 (09:31 +0200)]
src: Fix return types of .stateInitialize callbacks

The virStateDriver struct has .stateInitialize callback which is
declared to return virDrvStateInitResult enum. But some drivers
return a plain int in their implementation which is UB.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agodocs: Fix broken links
Han Han [Tue, 21 May 2024 09:07:28 +0000 (17:07 +0800)]
docs: Fix broken links

For the links of drvinterface, drvnetwork, drvnwfilter, and Nagios-virt,
there are no alternative docs. Just remove them directly.

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
11 months agoqemu: fix qemu command for pci hostdevs and ramfb='off'
Jonathon Jongsma [Thu, 16 May 2024 21:46:04 +0000 (16:46 -0500)]
qemu: fix qemu command for pci hostdevs and ramfb='off'

There was no test for this and we mistakenly used 'B' rather than 'T'
when constructing the json value for this parameter. Thus, a value of
'off' was VIR_TRISTATE_SWITCH_OFF=2, which was translated to a boolean
value of 'true'.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
11 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sun, 19 May 2024 20:36:18 +0000 (22:36 +0200)]
Translated using Weblate (Swedish)

Currently translated at 71.2% (7423 of 10423 strings)

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

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
11 months agoqemuhotplugtest: Add testcases for hotplugging evdev input devices
Rayhan Faizel [Wed, 15 May 2024 10:27:54 +0000 (15:57 +0530)]
qemuhotplugtest: Add testcases for hotplugging evdev input devices

This patch adds testcases to exercise hotplugging/hotunplugging
evdev input devices.

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
11 months agoqemu: Implement support for hotplugging evdev input devices
Rayhan Faizel [Wed, 15 May 2024 10:27:53 +0000 (15:57 +0530)]
qemu: Implement support for hotplugging evdev input devices

Unlike other input types, evdev is not a true device since it's backed by
'-object'. We must use object-add/object-del monitor commands instead of
device-add/device-del in this particular case.

This patch adds support for handling live attachment and
detachment of evdev type devices.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/529
Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
11 months agorpm: Drop with_ssh_proxy define
Andrea Bolognani [Wed, 15 May 2024 15:55:49 +0000 (17:55 +0200)]
rpm: Drop with_ssh_proxy define

As a general rule, we use defines for features that can only be
enabled on a subset of the platforms that we target, and we
don't offer fine-grained control over every single possible
meson configuration knob at the RPM level.

In the case of ssh-proxy, we are enabling it everywhere already,
so having a define for it is unnecessary.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agorpm: Drop weak dependency on ssh-proxy from client
Andrea Bolognani [Wed, 15 May 2024 15:39:12 +0000 (17:39 +0200)]
rpm: Drop weak dependency on ssh-proxy from client

The ssh-proxy feature works independently of the clients,
just like the NSS plugin does.

Moreover, ssh-proxy only works for local VMs, while clients
are routinely used to manage remote hypervisors.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agoNEWS: Mention '--help' bug in virsh and virt-admin
Peter Krempa [Wed, 15 May 2024 06:59:18 +0000 (08:59 +0200)]
NEWS: Mention '--help' bug in virsh and virt-admin

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
11 months agovirshtest: Add tests for '--help'
Peter Krempa [Wed, 15 May 2024 06:53:08 +0000 (08:53 +0200)]
virshtest: Add tests for '--help'

Add test cases for help handling.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
11 months agovsh: Fix '--help' option for virsh/virt-admin
Peter Krempa [Wed, 15 May 2024 06:42:57 +0000 (08:42 +0200)]
vsh: Fix '--help' option for virsh/virt-admin

The refactor of the libvirt tools command parser introduced a bug where
the '--help' option would cause an error:

 $ virsh list --help
 error: command 'list' doesn't support option --help

rather than printing the help for the command as the help option is
supposed to be handled separately from the real options.

Re-introduce the separate handling to the new parser code.

Fixes: 5540c3d2415c194b206f8946cf74b13648163332
Resolves: https://issues.redhat.com/browse/RHEL-36565
Reported-by: Lili Zhu <lizhu@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
11 months agotests: Link some mocks with libtest_qemu_driver.so
Michal Privoznik [Mon, 13 May 2024 10:34:09 +0000 (12:34 +0200)]
tests: Link some mocks with libtest_qemu_driver.so

I've noticed some tests fail to run under valgrind with the
following error:

  $ valgrind --leak-check=full --trace-children=yes ./qemuxmlconftest
  valgrind: symbol lookup error: libvirt.git/_build/tests/libdomaincapsmock.so: undefined symbol: virQEMUCapsGet

But without valgrind the test passes just fine. While we usually
don't want to change our code just to adhere to random tools, in
this case we ought to make an exception because valgrind helps us
to detect memory leaks.

NB, the --trace-children=yes is needed whenever a test
re-executes itself, i.e. when it uses mocks. Otherwise we'd just
get (boring) result for the first invocation of main() which does
nothing more than sets up the environment and calls exec().

When running the test binary without valgrind I can see the
libtest_qemu_driver.so being loaded even after exec:

$ LD_DEBUG=libs ./qemuxmlconftest 2>&1 | grep -e libtest_qemu_driver.so -e virQEMUCapsGet
      6439:     find library=libtest_qemu_driver.so [0]; searching
      6439:       trying file=libvirt.git/_build/tests/../src/libtest_qemu_driver.so
      6439:       trying file=libvirt.git/_build/tests/glibc-hwcaps/x86-64-v3/libtest_qemu_driver.so
      6439:       trying file=libvirt.git/_build/tests/glibc-hwcaps/x86-64-v2/libtest_qemu_driver.so
      6439:       trying file=libvirt.git/_build/tests/libtest_qemu_driver.so
      6439:     calling init: libvirt.git/_build/tests/libtest_qemu_driver.so
      6439:     find library=libtest_qemu_driver.so [0]; searching
      6439:       trying file=libvirt.git/_build/tests/libtest_qemu_driver.so
      6439:     calling init: libvirt.git/_build/tests/libtest_qemu_driver.so
      6439:     calling fini: libvirt.git/_build/tests/libtest_qemu_driver.so [0]

But running the same under valgrind:

$ LD_DEBUG=libs valgrind --leak-check=full --trace-children=yes ./qemuxmlconftest 2>&1 | grep -e libtest_qemu_driver.so -e virQEMUCapsGet
      6515:     find library=libtest_qemu_driver.so [0]; searching
      6515:       trying file=libvirt.git/_build/tests/../src/libtest_qemu_driver.so
      6515:       trying file=libvirt.git/_build/tests/glibc-hwcaps/x86-64-v3/libtest_qemu_driver.so
      6515:       trying file=libvirt.git/_build/tests/glibc-hwcaps/x86-64-v2/libtest_qemu_driver.so
      6515:       trying file=libvirt.git/_build/tests/libtest_qemu_driver.so
      6515:     calling init: libvirt.git/_build/tests/libtest_qemu_driver.so
      6515:     libvirt.git/_build/tests/libdomaincapsmock.so: error: symbol lookup error: undefined symbol: virQEMUCapsGet (fatal)
valgrind: symbol lookup error: libvirt.git/_build/tests/libdomaincapsmock.so: undefined symbol: virQEMUCapsGet

To me, it looks like valgrind forced linker to lookup symbols
"sooner", as individual libraries are loaded. But I must admit I
have no idea how valgrind does that (or if that's even valgrind's
'fault').

But fix is pretty simple: link mocks that rely on symbols from
the QEMU driver with the QEMU driver, well, its test suite
suitable version (libtest_qemu_driver.so).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
11 months agogithub: Update lockdown message when opening a PR
Michal Privoznik [Fri, 10 May 2024 07:54:59 +0000 (09:54 +0200)]
github: Update lockdown message when opening a PR

The message that's thrown at users when they try to open a pull
request on github suggests opening the MR on gitlab instead.
While this works for other libvirt subprojects, for the main
libvirt.git we still use e-mail workflow. Update the message to
reflect this fact.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
11 months agoqemuxmlconftest: Test 'page_per_vq' config option for 'vhostuser' backed disk
Peter Krempa [Thu, 9 May 2024 08:16:23 +0000 (10:16 +0200)]
qemuxmlconftest: Test 'page_per_vq' config option for 'vhostuser' backed disk

Add a missing option for the test to prove that we parse/format this
option.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agoTranslated using Weblate (English (United Kingdom))
Andi Chandler [Tue, 14 May 2024 20:36:09 +0000 (22:36 +0200)]
Translated using Weblate (English (United Kingdom))

Currently translated at 48.0% (5005 of 10423 strings)

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

Co-authored-by: Andi Chandler <andi@gowling.com>
Signed-off-by: Andi Chandler <andi@gowling.com>
11 months agodocs: formatsnapshot: add docs for snapshotDeleteInProgress
Abhiram Tilak [Mon, 13 May 2024 15:07:53 +0000 (20:37 +0530)]
docs: formatsnapshot: add docs for snapshotDeleteInProgress

Adds documentation for the <snapshotDeleteInProgress/> element to
the libvirt snapshot format XML reference. The <snapshotDeleteInProgress/>
element, introduced at commit 565bcb5d79, ensures the consistency of qcow2
images during snapshot deletion operations by marking disks in snapshot
metadata as invalid until deletion is successfully completed.

The commit was merged but the related documentation was missing.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/609
Signed-off-by: Abhiram Tilak <atp.exp@gmail.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
11 months agogitlab-ci: Switch coverity job to AlmaLinux 9
Michal Privoznik [Tue, 14 May 2024 13:36:59 +0000 (15:36 +0200)]
gitlab-ci: Switch coverity job to AlmaLinux 9

It's currently running against AlmaLinux 8 which went out of
support.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agogitlab-ci: Switch potfile job to AlmaLinux 9
Michal Privoznik [Tue, 14 May 2024 13:35:36 +0000 (15:35 +0200)]
gitlab-ci: Switch potfile job to AlmaLinux 9

It's currently running against AlmaLinux 8 which went out of
support.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agoci: Introduce Ubuntu 24.04
Michal Privoznik [Fri, 3 May 2024 13:58:20 +0000 (15:58 +0200)]
ci: Introduce Ubuntu 24.04

Ubuntu 24.04 was released recently. Add it to our CI. Also, to be
able to run ASAN/UBSAN builds on Ubuntu 24.04 libclang-rt-dev
needs to be installed (because clang's runtime was moved into a
separate package). Hence so many seemingly unrelated changes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agomeson: Bump glib version to 2.58.0
Michal Privoznik [Fri, 3 May 2024 13:48:54 +0000 (15:48 +0200)]
meson: Bump glib version to 2.58.0

Now that we don't have any distro stuck with glib-2.56.0, we can
bump the glib version. In fact, this is needed, because of
g_clear_pointer. Since v7.4.0-rc1~301 we declare at compile time
what version of glib APIs we want to use (by setting
GLIB_VERSION_MIN_REQUIRED = GLIB_VERSION_MAX_ALLOWED = 2.56.0),
regardless of actual glib version in the host.

And since we currently require glib-2.56.0 and force glib to use
APIs of that version, some newer bits are slipping from us. For
instance: regular function version of g_clear_pointer() is used
instead of a fancy macro. So what? Well, g_clear_pointer()
function typecasts passed free function to void (*)(void *) and
then calls it. Well, this triggers UBSAN, understandably. But
with glib-2.58.0 the g_clear_pointer() becomes a macro which
calls the free function directly, with no typecasting and thus no
undefined behavior.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agoci: Drop Ubuntu 20.04
Michal Privoznik [Fri, 3 May 2024 13:43:47 +0000 (15:43 +0200)]
ci: Drop Ubuntu 20.04

It's now more than two years since Ubuntu 22.04 was released and
per our support policy, Ubuntu 20.04 (the previous major release)
is now not supported. Remove it from our CI testing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agoci: Switch from Fedora 38 to Fedora 40
Michal Privoznik [Fri, 3 May 2024 17:48:28 +0000 (19:48 +0200)]
ci: Switch from Fedora 38 to Fedora 40

Since Fedora 40 was released recently, Fedora 38 is now
unsupported. Drop Fedora 38 and introduce Fedora 40 to our CI.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agoci: Switch from AlmaLinux 8 to AlmaLinux 9
Michal Privoznik [Fri, 3 May 2024 17:52:58 +0000 (19:52 +0200)]
ci: Switch from AlmaLinux 8 to AlmaLinux 9

By the time of release, it's going to be more than two years
since AlmaLinux 9 was released and per our support policy,
AlmaLinux 8 (the previous major release) will be not supported.
Switch from AlmaLinux 8 to AlmaLinux 9.

This also means the website_job which depends on AlmaLinux 8
needs to be moved to newer AlmaLinux.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agomeson: Disable -fsanitize=function
Michal Privoznik [Fri, 3 May 2024 15:58:05 +0000 (17:58 +0200)]
meson: Disable -fsanitize=function

Strictly speaking, xdrproc_t is declared as following:

  typedef bool_t (*xdrproc_t)(XDR *, ...);

But our rpcgen generates properly typed functions, e.g.:

  bool_t xdr_virNetMessageError(XDR *xdrs, virNetMessageError *objp)

Now, these functions of ours are passed around as callbacks (via
an argument of xdrproc_t type), for instance in
virNetMessageEncodePayload(). But these two types are strictly
different. We silence the compiler by typecasting the callbacks
when passing them, but strictly speaking - calling such callback
later, when a function of xdrproc_t is expected is an undefined
behavior.

Ideally, we would fix our rpcgen to generate proper function
headers, but: a) my brain is too small to do that, and b) we
would lose compiler protection if an xdr_*() function is called
directly but argument of a wrong type is passed.

Silence UBSAN for now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agosecurity: Fix return types of .probe callbacks
Michal Privoznik [Fri, 3 May 2024 14:32:05 +0000 (16:32 +0200)]
security: Fix return types of .probe callbacks

The .probe member of virSecurityDriver struct is declared to
return virSecurityDriverStatus enum. But there are two instances
(AppArmorSecurityManagerProbe() and
virSecuritySELinuxDriverProbe()) where callbacks are defined to
return an integer. This is an undefined behavior because integer
has strictly bigger space of possible values than the enum.

Defined those aforementioned callbacks so that they return the
correct enum instead of int.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agotestutilsqemu: Don't leak struct testQemuArgs::vdpafds
Michal Privoznik [Fri, 3 May 2024 12:37:23 +0000 (14:37 +0200)]
testutilsqemu: Don't leak struct testQemuArgs::vdpafds

Allocated in testQemuInfoSetArgs(), the vdpafds member of
testQemuArgs is never freed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agoqemu_hotplug: Properly assign USB address to hotplugged usb-net device
Rayhan Faizel [Mon, 13 May 2024 13:55:03 +0000 (19:25 +0530)]
qemu_hotplug: Properly assign USB address to hotplugged usb-net device

Previously, the network device hotplug logic would try to ensure only CCW or
PCI addresses. With recent support for the usb-net model, this patch will
ensure USB addresses for usb-net network devices.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/14
Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
11 months agovmx: Do not require DVS Port ID
Martin Kletzander [Mon, 13 May 2024 10:24:19 +0000 (12:24 +0200)]
vmx: Do not require DVS Port ID

It can be safely removed from the VMX, VMWare will still boot the
machine and once another ethernet is added it is updated in the VMX to
zero.  So do not require it and default to zero too since this part of
the XML is done as best effort and it is mentioned even in our
documentation.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agoNEWS: Announce virtio sound model support
Rayhan Faizel [Fri, 10 May 2024 11:16:22 +0000 (16:46 +0530)]
NEWS: Announce virtio sound model support

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
11 months agoNEWS: Document SSH proxy feature
Michal Privoznik [Thu, 18 Apr 2024 11:00:11 +0000 (13:00 +0200)]
NEWS: Document SSH proxy feature

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agodocs: Document SSH proxy
Michal Privoznik [Thu, 18 Apr 2024 08:39:18 +0000 (10:39 +0200)]
docs: Document SSH proxy

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agotools: Introduce SSH proxy
Michal Privoznik [Tue, 16 Apr 2024 14:32:26 +0000 (16:32 +0200)]
tools: Introduce SSH proxy

This allows users to SSH into a domain with a VSOCK device:

  ssh user@qemu/machineName

So far, only QEMU domains are supported AND qemu:///system is
looked for the first for 'machineName' followed by
qemu:///session. I took an inspiration from Systemd's ssh proxy
[1] [2].

To just work out of the box, it requires (yet unreleased) systemd
to be running inside the guest to set up a socket activated SSHD
on the VSOCK. Alternatively, users can set up the socket
activation themselves, or just run a socat that'll forward vsock
<-> TCP communication.

1: https://github.com/systemd/systemd/blob/main/src/ssh-generator/ssh-proxy.c
2: https://github.com/systemd/systemd/blob/main/src/ssh-generator/20-systemd-ssh-proxy.conf.in

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/579
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agoqemu_capabilities: Remove unused struct
Dr. David Alan Gilbert [Sun, 12 May 2024 00:24:57 +0000 (01:24 +0100)]
qemu_capabilities: Remove unused struct

'virQEMUCapsSearchData' has been unused since
commit bc33b8c63911 ("qemu: capabilities: Drop the
virQEMUCapsCacheLookupByArch function")
Remove it.

Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
11 months agoTranslated using Weblate (English (United Kingdom))
Andi Chandler [Wed, 8 May 2024 15:56:42 +0000 (17:56 +0200)]
Translated using Weblate (English (United Kingdom))

Currently translated at 47.3% (4937 of 10423 strings)

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

Translated using Weblate (English (United Kingdom))

Currently translated at 47.1% (4913 of 10423 strings)

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

Co-authored-by: Andi Chandler <andi@gowling.com>
Signed-off-by: Andi Chandler <andi@gowling.com>
11 months agonetwork: Register dnsmasq with resolved only when really requested
Jiri Denemark [Thu, 9 May 2024 14:16:57 +0000 (16:16 +0200)]
network: Register dnsmasq with resolved only when really requested

An incorrect check for domainRegister caused the DNS server for a
virtual domain to be registered with systemd-resolved even if
register='no' attribute was present. Only omitting the attribute
completely would disable the registration.

Reported-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agodocs: ensure HTML/images are built before running reference tests
Daniel P. Berrangé [Tue, 7 May 2024 12:04:24 +0000 (13:04 +0100)]
docs: ensure HTML/images are built before running reference tests

The 'check-html-references' test will process the built HTML files,
so they must exist before it is run, along with any images that
they point to.

If using the older 'configure_file' command, no changes are needed
since that always gets executed at 'meson setup' time, rather than
at 'meson compile' time.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agosrc/node_device: don't overwrite error messages
Daniel P. Berrangé [Tue, 7 May 2024 13:35:39 +0000 (14:35 +0100)]
src/node_device: don't overwrite error messages

The nodedev code unhelpfully reports

  couldn't convert node device def to mdevctl JSON

which hides the actual error message

  No JSON parser implementation is available

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agotests: don't run mdevctl test if lacking YAJL
Daniel P. Berrangé [Tue, 7 May 2024 13:35:04 +0000 (14:35 +0100)]
tests: don't run mdevctl test if lacking YAJL

The mdev code requires YAJL in order to convert from node dev XML to
mdev's config format.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agotest: drop bogus check for YAJL from libxl test/mock
Daniel P. Berrangé [Tue, 7 May 2024 13:26:55 +0000 (14:26 +0100)]
test: drop bogus check for YAJL from libxl test/mock

The libxlmock.c conditionalizes on WITH_YAJL, but this mock is
used from other tests which only conditionalize on WITH_LIBXL.
The libxl code does not have any dependancy on YAJL, so the
bogus condition can be removed from the mock and also from
libxlxml2domconfigtest.c

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agotests: always build securityselinuxhelper if libselinux is present
Daniel P. Berrangé [Tue, 7 May 2024 13:17:36 +0000 (14:17 +0100)]
tests: always build securityselinuxhelper if libselinux is present

The securityselinuxhelper build is conditionalized on the SELinux
security driver feature. It is also needed, however, by viridentitytest
whenever libselinux is present.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agotest: conditionalize 'virsh-auth' on test driver
Daniel P. Berrangé [Tue, 7 May 2024 13:05:12 +0000 (14:05 +0100)]
test: conditionalize 'virsh-auth' on test driver

The 'virsh-auth' test is mistakenly conditionalized on the libvirtd
daemon build, however, it just uses the 'test:///default' driver
URI, so does not require a daemon.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agotests: build driver modules before virdrivermoduletest
Daniel P. Berrangé [Tue, 7 May 2024 12:23:39 +0000 (13:23 +0100)]
tests: build driver modules before virdrivermoduletest

The virdrivermoduletest will attempt to dlopen() each driver module,
so they must be build before the test can run.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agotests: build 'virsh' before running virsh-auth test
Daniel P. Berrangé [Tue, 7 May 2024 12:16:26 +0000 (13:16 +0100)]
tests: build 'virsh' before running virsh-auth test

The 'virsh-auth' test needs to be able to invoke the 'virsh' binary

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agosrc: ensure augeas test file is generated before running test
Daniel P. Berrangé [Tue, 7 May 2024 12:10:59 +0000 (13:10 +0100)]
src: ensure augeas test file is generated before running test

We fail to express an ordering between the custom target that
generates the combined augeas test input file, and the meson
test command.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agomeson: record which other options are a pre-requisite
Daniel P. Berrangé [Tue, 7 May 2024 10:38:07 +0000 (11:38 +0100)]
meson: record which other options are a pre-requisite

Several meson options cannot be enabled, without first enabling another
option. This adds a small comment prior to an option to record its
mandatory dependencies.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agotests: fix tests when test driver is disabled
Daniel P. Berrangé [Tue, 7 May 2024 09:40:15 +0000 (10:40 +0100)]
tests: fix tests when test driver is disabled

Various tests try to open a connection to 'test:///default' and
must be skipped when the test driver is disabled.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agoscripts/rpcgen: skip tests if tirpc is not present
Daniel P. Berrangé [Tue, 7 May 2024 09:38:59 +0000 (10:38 +0100)]
scripts/rpcgen: skip tests if tirpc is not present

This skips building tests which rely on tirpc when it is not
present.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agotests: fix two off-by-1 errors in read-big-pipe test
Daniel P. Berrangé [Wed, 8 May 2024 12:03:20 +0000 (13:03 +0100)]
tests: fix two off-by-1 errors in read-big-pipe test

When testPipeFeeder copies the XML document into the padded buffer, it
tells virStrcpy that 'xmlsize' bytes are available. This is under
reporting size by 1 byte, and as a result it fails to copy the trailing
'\n' replacing it with '\0'. The return value of virStrcpy wasn't
checked, but was reporting this truncation.

When testPipeFeeder then sends the padded buffer down the pipe, it asks
to send 'emptyspace + xmlsize + 1' bytes, which means it sends the data,
as well as the trailing '\0' terminator.

Both bugs combined mean it is sending '\0\0' as the last bytes, instead
of '\n' which was intended. When virFileReadAll reads data from the
pipe, it ends up adding another '\0' resulting in a very NUL terminated
string ('\0\0\0'). This is all harmless, but should be fixed regardless.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
11 months agotests: fix hang in virshtest 'read-big-pipe' case
Daniel P. Berrangé [Wed, 8 May 2024 10:50:09 +0000 (11:50 +0100)]
tests: fix hang in virshtest 'read-big-pipe' case

The virshtest program testPipeFeeder method is doing this:

  mkfifo("test.fifo", 0600) ;

  int fd = open("test.fifo", O_RDWR);

  char buf[...];
  memset(buf, 'a', sizeof(buf));
  write(fd, buf, sizeof(buf)) == sizeof(buf));
  close(fd);

while the the 'virsh' child process then ends up doing:

  fd = open("test.fifo", O_RDONLY);
  read(fd, buf, sizeof(buf)) == sizeof(buf));
  close(fd);

The 'virsh' code hangs on open() on at least ppc64 and some other
arches. It can be provoked to hang even on x86 by reducing the size of
the buffer. It can be prevented from hanging on ppc64 by increasing the
size of the buffer.

What is happening is a result of differing page sizes, altering the
overall pipe capacity size, since pipes on linux default to 16 pages
in size and thus have architecture specific capacity when measured
in bytes.

 * On x86, testPipeFeeder opens R+W, tries to write 140kb and
   write() blocks because the pipe is full. This gives time for
   virsh to start up, and it can open the pipe for O_RDONLY
   since testPipeFeeder still has it open for write. Everything
   works as intended.

 * On ppc64,  testPipeFeeder opens R+W, tries to write 140kb
   and write() succeeds because the larger 64kb page size
   resulted in greater buffer capacity for the pipe. It thus
   quickly closes the pipe, removing the writer, and triggering
   discard of all the unread data. Now virsh starts up, tries
   to open the pipe for O_RDONLY and blocks waiting for a new
   writer to open it, which will never happen. Meson kills
   the test after 30 seconds.

   NB, every now & then, it will not block because virsh starts
   up quickly enough that testPipeFeeder has not yet closed the
   write end of the pipe, giving the illusion of correctness.

The key flaw here is that it should not have been using O_RDWR
in testPipeFeeder. Synchronization is required such that both
virsh and testPipeFeeder have their respective ends of the pipe
open before any data is sent. This is trivially arranged by
using O_WRONLY in testPipeFeeder.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
12 months agoudevListInterfacesByStatus: Don't try to return NULL names
Peter Krempa [Mon, 6 May 2024 15:44:42 +0000 (17:44 +0200)]
udevListInterfacesByStatus: Don't try to return NULL names

In case when the interface is being detached/reattached it may happen
that udev will return NULL from 'udev_device_get_sysname()'.

As the RPC code requires nonnull strings in the return array it fails to
serialize such reply:

 libvirt: XML-RPC error : Unable to encode message payload

Fix this by simply ignoring such interfaces as there's nothing we can
report in such case.

A similar fix was done to 'udevConnectListAllInterfaces' in commit
2ca94317ac6.

Resolves: https://issues.redhat.com/browse/RHEL-34615
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agointerface_udev: Replace udevNumOfInterfacesByStatus by udevListInterfacesByStatus
Peter Krempa [Mon, 6 May 2024 15:41:02 +0000 (17:41 +0200)]
interface_udev: Replace udevNumOfInterfacesByStatus by udevListInterfacesByStatus

Make the array-filling operation of udevListInterfacesByStatus optional
and replace the completely redundant udevNumOfInterfacesByStatus by it.

Further patches fixing the listing will not need to be duplicated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agodatatypes: Declare g_autoptr cleanup functions for more public objects
Michal Privoznik [Thu, 18 Apr 2024 07:19:52 +0000 (09:19 +0200)]
datatypes: Declare g_autoptr cleanup functions for more public objects

Some public objects (like virDomain, virInterface, and so on) are
missing g_autoptr() cleanup functions. Provide missing
declarations. Note, this is only for our internal use - hence
datatypes.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
12 months agoqemu: Substract isolcpus from all online affinity
Michal Privoznik [Mon, 22 Apr 2024 09:55:46 +0000 (11:55 +0200)]
qemu: Substract isolcpus from all online affinity

When starting a domain and there's no vCPU/emulator pinning set,
we query the list of all online physical CPUs and set affinity of
the child process (which eventually becomes QEMU) to that list.
We can't assume libvirtd itself had affinity to all online CPUs
and since affinity of the child process is inherited, we should
fix it afterwards. But that's not necessarily correct. Users
might isolate some physical CPUs and we should avoid touching
them unless explicitly told so (i.e. vCPU/emulator pinning told
us so).

Therefore, when attempting to set affinity to all online CPUs
subtract the isolated ones.

Before this commit:

  root@localhost:~# cat /sys/devices/system/cpu/isolated
  19,21,23
  root@virtlab414:~# taskset -cp $(pgrep qemu)
  pid 14835's current affinity list: 0-23

After:

  root@virtlab414:~# taskset -cp $(pgrep qemu)
  pid 17153's current affinity list: 0-18,20,22

Resolves: https://issues.redhat.com/browse/RHEL-33082
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
12 months agovirhostcpu: Introduce virHostCPUGetIsolated()
Michal Privoznik [Mon, 22 Apr 2024 09:07:13 +0000 (11:07 +0200)]
virhostcpu: Introduce virHostCPUGetIsolated()

This is a helper that parses /sys/devices/system/cpu/isolated
into a virBitmap. It's going to be needed soon.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
12 months agovirfile: Introduce virFileReadValueBitmapAllowEmpty()
Michal Privoznik [Tue, 23 Apr 2024 08:41:50 +0000 (10:41 +0200)]
virfile: Introduce virFileReadValueBitmapAllowEmpty()

Some sysfs files contain either string representation of a bitmap
or just a newline character. An example of such file is:
/sys/devices/system/cpu/isolated. Our current implementation of
virFileReadValueBitmap() fails in the latter case, unfortunately.
Introduce a slightly modified version that accepts empty files.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
12 months agovirbitmap: Introduce virBitmapParseUnlimitedAllowEmpty()
Michal Privoznik [Tue, 23 Apr 2024 07:17:51 +0000 (09:17 +0200)]
virbitmap: Introduce virBitmapParseUnlimitedAllowEmpty()

Some sysfs files contain either string representation of a bitmap
or just a newline character. An example of such file is:
/sys/devices/system/cpu/isolated. Our current implementation of
virBitmapParseUnlimited() fails in the latter case,
unfortunately. Introduce a slightly modified version that accepts
empty files.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
12 months agoqemu_saveimage: add zstd to supported compression formats
Adam Julis [Fri, 26 Apr 2024 18:28:47 +0000 (20:28 +0200)]
qemu_saveimage: add zstd to supported compression formats

Extend the list of supported formats, update and clarify comment
in qemu.conf.in (removed misleading sentence about the order of
compression format types).

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/589
Signed-off-by: Adam Julis <ajulis@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agoNEWS: document qemu: ras as a new feature
Kristina Hanicova [Fri, 3 May 2024 11:49:30 +0000 (13:49 +0200)]
NEWS: document qemu: ras as a new feature

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
12 months agovsh: Don't init history in cmdComplete()
Michal Privoznik [Sat, 4 May 2024 03:12:54 +0000 (05:12 +0200)]
vsh: Don't init history in cmdComplete()

Recent rework of virshtest uncovered a subtle bug that was
dormant in now vsh but before that even in monolithic virsh.

In vsh.c there's this vshReadlineInit() function that's supposed
to initialize readline library, i.e. set those global rl_*
pointers.  But it also initializes history library. Then, when
virsh/virt-admin quits, vshReadlineDeinit() is called which
writes history into a file (ensuring the parent directory
exists). So far no problem.

Problem arises when cmdComplete() is called (from a bash
completer, for instance). It does not guard call to
vshReadlineInit() with check for interactive shell (and it should
not), but it sets ctl->historyfile which signals to
vshReadlineDeinit() the history should be written.

Now, no real history is written, because nothing was entered on
the stdin, but the parent directory is created nevertheless. With
recent movement in virshtest.c this means some test cases might
create virsh history file which breaks our promise of not
touching user's data in test suite.

Resolves: https://bugs.gentoo.org/931109
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agohyperv: prevent potential NULL dereference
Oleg Sviridov [Fri, 3 May 2024 09:26:51 +0000 (12:26 +0300)]
hyperv: prevent potential NULL dereference

Return value of a function 'virDomainChrDefNew' is dereferenced
at hyperv_driver.c without checking for NULL, which can lead to
NULL dereference immediately after.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Oleg Sviridov <oleg.sviridov@red-soft.ru>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
12 months agolibxl: Fix domxml-to-native conversion
Jim Fehlig [Mon, 29 Apr 2024 20:50:07 +0000 (14:50 -0600)]
libxl: Fix domxml-to-native conversion

Similar to commit 57d084febe, another case of the libxl driver not
adapting to modular daemons. When converting configuration that
contains a type='network' interface, the converter calls
virNetworkLookupByName, passing the hypervisor connection object
instead of a connection to virtnetworkd. E.g.

> cat dom.xml
...
    <interface type='network'>
      <source network='default'/>
    </interface>
...
> virsh net-info default
Name:           default
UUID:           25a5b089-1e71-4956-99aa-df2213bbb407
Active:         yes
Persistent:     no
Autostart:      no
Bridge:         virbr0
> virsh domxml-to-native xen-xl dom.xml
error: Network not found: default

Acquire a connection to virtnetworkd and use it when calling
virNetwork* APIs.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agocpu_map: Drop 'mpx' from x86 cpu models
Tim Wiederhake [Fri, 9 Feb 2024 10:52:56 +0000 (11:52 +0100)]
cpu_map: Drop 'mpx' from x86 cpu models

The mpx feature was removed from the corresponding qemu cpu models.
With mpx in the libvirt cpu models, libvirt believes the feature
to be implicitly enabled when creating qemu VMs, while in fact it is
disabled.

This became an issue when commit 94eacd5a5f introduced new vmx-*
features, of which some are dependent on mpx (see "feature_dependencies"
table in qemu target/i386/cpu.c), e.g. vmx-exit-clear-bndcfgs and
vmx-entry-load-bndcfgs. These features cannot be enabled by qemu
without also mpx being enabled, leading to the error message

    error: Failed to create domain from testdomain.xml
    error: operation failed: guest CPU doesn't match
    specification: missing features: mpx,vmx-exit-clear-bndcfgs,
    vmx-entry-load-bndcfgs

when trying to create a VM with a "host-model" cpu on a host that
does support mpx and the mentioned vmx-* features:

    <domain>
      ...
      <cpu mode='host-model' check='full' />
      ...
    </domain>

Resolve the issue by removing mpx from libvirt's cpu models as well.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agoqemu: Enable removing features from CPU models
Jiri Denemark [Fri, 26 Apr 2024 14:32:16 +0000 (16:32 +0200)]
qemu: Enable removing features from CPU models

Features removed from a CPU model are marked with "removed='yes'"
attribute in the CPU map. Such features will always be present in a CPU
definition produced by libvirt regardless on their state. In other words
a running domain (even saved in a file) will always explicitly contain
states of all features removed from the specified CPU model. This
enables migration to older libvirt which would otherwise think the
affected features should be enabled as they are still included in the
CPU model in the older version of CPU map. Migration from an old libvirt
to a new one would be broken as the new libvirt would think the removed
features should be disabled (because they are not included in the CPU
model anymore), which might not be the case on the source host. Thus we
were refusing to remove CPU features unless they were never working and
no domain could even be running with those features enabled.

This patch removes the limitation. When handling CPU definitions with
missing features marked as removed in the specified CPU model, we know
whether it comes from a running domain, in which case it must have been
created by older libvirt where the missing CPU features were not removed
yet. This means the features must have been enabled on the source and we
can automatically fix the definition by adding the missing features with
correct states.

We can safely remove any CPU feature from our CPU models now, but it
should only be used for features removed from all versions of a given
CPU model in QEMU because unversioned models correspond to v1.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agocpu: Add removedPolicy parameter to virCPUUpdate
Jiri Denemark [Fri, 26 Apr 2024 07:57:31 +0000 (09:57 +0200)]
cpu: Add removedPolicy parameter to virCPUUpdate

virCPUUpdate check the CPU definition for features that were marked as
removed in the specified CPU model and explicitly adds those that were
not mentioned in the definition. So far such features were added with
VIR_CPU_FEATURE_DISABLE policy, but the caller may want to use a
different policy in some situations, which is now possible via the
removedPolicy parameter.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agoconf: Change return value of some CPU feature APIs
Jiri Denemark [Thu, 25 Apr 2024 13:35:06 +0000 (15:35 +0200)]
conf: Change return value of some CPU feature APIs

The virCPUDefAddFeatureInternal helper function only fails if it is
called with VIR_CPU_ADD_FEATURE_MODE_EXCLUSIVE, which is only used in
virCPUDefAddFeature. The other callers (virCPUDefUpdateFeature and
virCPUDefAddFeatureIfMissing) will never get anything but 0 from
virCPUDefAddFeatureInternal and their return type can be changed to
void.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agovmx: Check serialX.vspc before serialX.fileName
Martin Kletzander [Thu, 25 Apr 2024 10:34:21 +0000 (12:34 +0200)]
vmx: Check serialX.vspc before serialX.fileName

When using vSPC (Virtual Serial Port Concentrator) in vSphere the actual
address for it is saved in serialX.vspc in which case the
serialX.fileName is most probably something we can't get any useful
information from and we also fail during the parsing rendering any
dumpxml and similar tries unsuccessful.

Instead of parsing the vspc URL with something along the lines of
`virURIParse(vspc ? vspc : fileName)`, which could lead to us reporting
information that is very prune to misuse (the vSPC seemingly has a
protocol on top of the telnet connection; redefining the domain would
change the behaviour; the URL might have a fragment we are not saving;
etc.) or adding more XML knobs to indicate vSPC usage (which we would
not be able to configure; we'd have to properly error out everywhere;
etc.) let's just report dummy serial port that leads to nowhere (i.e.
type="null").

Resolves: https://issues.redhat.com/browse/RHEL-32182
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agorpc: ensure temporary GSource is removed from client event loop
Daniel P. Berrangé [Tue, 30 Apr 2024 10:51:15 +0000 (11:51 +0100)]
rpc: ensure temporary GSource is removed from client event loop

Users are seeing periodic segfaults from libvirt client apps,
especially thread heavy ones like virt-manager. A typical
stack trace would end up in the virNetClientIOEventFD method,
with illegal access to stale stack data. eg

==238721==ERROR: AddressSanitizer: stack-use-after-return on address 0x75cd18709788 at pc 0x75cd3111f907 bp 0x75cd181ff550 sp 0x75cd181ff548
WRITE of size 4 at 0x75cd18709788 thread T11
    #0 0x75cd3111f906 in virNetClientIOEventFD /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:1634:15
    #1 0x75cd3210d198  (/usr/lib/libglib-2.0.so.0+0x5a198) (BuildId: 0a2311dfbbc6c215dc36f4b6bdd2b4b6fbae55a2)
    #2 0x75cd3216c3be  (/usr/lib/libglib-2.0.so.0+0xb93be) (BuildId: 0a2311dfbbc6c215dc36f4b6bdd2b4b6fbae55a2)
    #3 0x75cd3210ddc6 in g_main_loop_run (/usr/lib/libglib-2.0.so.0+0x5adc6) (BuildId: 0a2311dfbbc6c215dc36f4b6bdd2b4b6fbae55a2)
    #4 0x75cd3111a47c in virNetClientIOEventLoop /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:1722:9
    #5 0x75cd3111a47c in virNetClientIO /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:2002:10
    #6 0x75cd3111a47c in virNetClientSendInternal /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:2170:11
    #7 0x75cd311198a8 in virNetClientSendWithReply /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:2198:11
    #8 0x75cd31111653 in virNetClientProgramCall /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclientprogram.c:318:9
    #9 0x75cd31241c8f in callFull /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/remote/remote_driver.c:6054:10
    #10 0x75cd31241c8f in call /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/remote/remote_driver.c:6076:12
    #11 0x75cd31241c8f in remoteNetworkGetXMLDesc /usr/src/debug/libvirt/libvirt-10.2.0/build/src/remote/remote_client_bodies.h:5959:9
    #12 0x75cd31410ff7 in virNetworkGetXMLDesc /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/libvirt-network.c:952:15

The root cause is a bad assumption in the virNetClientIOEventLoop
method. This method is run by whichever thread currently owns the
buck, and is responsible for handling I/O. Inside a for(;;) loop,
this method creates a temporary GSource, adds it to the event loop
and runs g_main_loop_run(). When I/O is ready, the GSource callback
(virNetClientIOEventFD) will fire and call g_main_loop_quit(), and
return G_SOURCE_REMOVE which results in the temporary GSource being
destroyed. A g_autoptr() will then remove the last reference.

What was overlooked, is that a second thread can come along and
while it can't enter virNetClientIOEventLoop, it will register an
idle source that uses virNetClientIOWakeup to interrupt the
original thread's 'g_main_loop_run' call. When this happens the
virNetClientIOEventFD callback never runs, and so the temporary
GSource is not destroyed. The g_autoptr() will remove a reference,
but by virtue of still being attached to the event context, there
is an extra reference held causing GSource to be leaked. The
next time 'g_main_loop_run' is called, the original GSource will
trigger its callback, and access data that was allocated on the
stack by the previous thread, and likely SEGV.

To solve this, the thread calling 'g_main_loop_run' must call
g_source_destroy, immediately upon return, to guarantee that
the temporary GSource is removed.

CVE-2024-4418
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Martin Shirokov <shirokovmartin@gmail.com>
Tested-by: Martin Shirokov <shirokovmartin@gmail.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
12 months agoqemu: Generate command line for sound devices with model 'virtio'
Rayhan Faizel [Thu, 11 Apr 2024 20:12:44 +0000 (01:42 +0530)]
qemu: Generate command line for sound devices with model 'virtio'

Allow generation of command line for virtio-sound-pci and virtio-sound-device
devices along with additional virtio options.

A new testcase is added to test virtio-sound-pci. The
arm-vexpressa9-virtio testcase is also extended to test virtio-sound-device.

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agoconf: Introduce support for virtio-sound devices
Rayhan Faizel [Thu, 11 Apr 2024 20:12:43 +0000 (01:42 +0530)]
conf: Introduce support for virtio-sound devices

This patch adds parsing of the virtio sound model, along with parsing
of virtio options and PCI/virtio-mmio address assignment.

A new 'streams' attribute is added for configuring number of PCM streams
(default is 2) in virtio sound devices. QEMU additionally has jacks and chmaps
parameters but these are currently stubbed, hence they are excluded in this
patch series.

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agoqemu_capabilities: Add QEMU_CAPS_DEVICE_VIRTIO_SOUND capability
Rayhan Faizel [Thu, 11 Apr 2024 20:12:42 +0000 (01:42 +0530)]
qemu_capabilities: Add QEMU_CAPS_DEVICE_VIRTIO_SOUND capability

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agoci: drop CentOS 8 Stream and refresh
Daniel P. Berrangé [Thu, 25 Apr 2024 13:40:30 +0000 (14:40 +0100)]
ci: drop CentOS 8 Stream and refresh

This drops the CentOS 8 Stream distro target, since that is going EOL
at the end of May, at which point it will cease to be installable
due to package repos being archived.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
12 months agoci: refresh with latest lcitool manifest
Daniel P. Berrangé [Thu, 25 Apr 2024 13:42:32 +0000 (14:42 +0100)]
ci: refresh with latest lcitool manifest

This brings in a fix to the job rules which solves a problem with
jobs getting skipped in merge requests in some scenarios. It also
changes the way Cirrus CI vars are set, which involves a weak to
the way $PATH is set in build.yml.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
12 months agoscripts/meson-dist.py: Get builddir from env too
Michal Privoznik [Mon, 29 Apr 2024 07:49:17 +0000 (09:49 +0200)]
scripts/meson-dist.py: Get builddir from env too

When meson runs a dist script it sets both MESON_BUILD_ROOT and
MESON_DIST_ROOT envvars [1]. But for some reason, we took the
former as an argument and obtained the latter via env. Well,
obtain both via env.

1: https://mesonbuild.com/Reference-manual_builtin_meson.html#mesonadd_dist_script
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agoqemu: format machine virt ras feature and test it
Kristina Hanicova [Tue, 30 Apr 2024 14:32:39 +0000 (16:32 +0200)]
qemu: format machine virt ras feature and test it

Resolves: https://issues.redhat.com/browse/RHEL-7489
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agoqemu: validate machine virt ras feature
Kristina Hanicova [Tue, 30 Apr 2024 14:32:38 +0000 (16:32 +0200)]
qemu: validate machine virt ras feature

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agoconf: parse and format machine virt ras feature
Kristina Hanicova [Tue, 30 Apr 2024 14:32:37 +0000 (16:32 +0200)]
conf: parse and format machine virt ras feature

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agoqemu: introduce QEMU_CAPS_MACHINE_VIRT_RAS capability
Kristina Hanicova [Tue, 30 Apr 2024 14:32:36 +0000 (16:32 +0200)]
qemu: introduce QEMU_CAPS_MACHINE_VIRT_RAS capability

The capability can be used to detect if the qemu binary already
supports 'ras' feature for 'virt' machine type.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agoPost-release version bump to 10.4.0
Jiri Denemark [Thu, 2 May 2024 09:10:01 +0000 (11:10 +0200)]
Post-release version bump to 10.4.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
12 months agoRelease of libvirt-10.3.0
Jiri Denemark [Thu, 2 May 2024 09:07:09 +0000 (11:07 +0200)]
Release of libvirt-10.3.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
12 months agoNEWS: Document my contributions for upcoming release
Michal Privoznik [Tue, 30 Apr 2024 13:12:43 +0000 (15:12 +0200)]
NEWS: Document my contributions for upcoming release

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
12 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Thu, 2 May 2024 05:56:27 +0000 (07:56 +0200)]
Translated using Weblate (Swedish)

Currently translated at 71.0% (7403 of 10423 strings)

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

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
12 months agoNEWS: Document TLS migration bug, usb-net support and two fixes
Peter Krempa [Tue, 30 Apr 2024 08:15:04 +0000 (10:15 +0200)]
NEWS: Document TLS migration bug, usb-net support and two fixes

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
12 months agoNEWS: Fix marking of 'path' as inline literal
Peter Krempa [Tue, 30 Apr 2024 08:11:58 +0000 (10:11 +0200)]
NEWS: Fix marking of 'path' as inline literal

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
12 months agoTranslated using Weblate (Korean)
김인수 [Mon, 29 Apr 2024 04:40:28 +0000 (04:40 +0000)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10423 of 10423 strings)

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

Signed-off-by: 김인수 <simmon@nplob.com>
12 months agoTranslated using Weblate (Romanian)
Remus-Gabriel Chelu [Sat, 27 Apr 2024 23:27:35 +0000 (23:27 +0000)]
Translated using Weblate (Romanian)

Currently translated at 0.8% (89 of 10423 strings)

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

Signed-off-by: Remus-Gabriel Chelu <remusgabriel.chelu@disroot.org>
12 months agoTranslated using Weblate (Romanian)
Weblate [Sat, 27 Apr 2024 23:23:56 +0000 (23:23 +0000)]
Translated using Weblate (Romanian)

Currently translated at 0.7% (74 of 10423 strings)

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

Signed-off-by: Weblate <noreply-mt-weblate@weblate.org>
12 months agoTranslated using Weblate (Romanian)
Remus-Gabriel Chelu [Sat, 27 Apr 2024 23:23:01 +0000 (23:23 +0000)]
Translated using Weblate (Romanian)

Currently translated at 0.7% (74 of 10423 strings)

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

Signed-off-by: Remus-Gabriel Chelu <remusgabriel.chelu@disroot.org>
12 months agoTranslated using Weblate (Romanian)
Weblate [Sat, 27 Apr 2024 23:08:09 +0000 (23:08 +0000)]
Translated using Weblate (Romanian)

Currently translated at 0.6% (69 of 10423 strings)

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

Signed-off-by: Weblate <noreply-mt-weblate@weblate.org>
12 months agoTranslated using Weblate (Romanian)
Remus-Gabriel Chelu [Sat, 27 Apr 2024 23:07:23 +0000 (23:07 +0000)]
Translated using Weblate (Romanian)

Currently translated at 0.6% (69 of 10423 strings)

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

Signed-off-by: Remus-Gabriel Chelu <remusgabriel.chelu@disroot.org>
12 months agoTranslated using Weblate (Romanian)
Remus-Gabriel Chelu [Sat, 27 Apr 2024 08:16:02 +0000 (08:16 +0000)]
Translated using Weblate (Romanian)

Currently translated at 0.4% (43 of 10423 strings)

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

Signed-off-by: Remus-Gabriel Chelu <remusgabriel.chelu@disroot.org>
12 months agoTranslated using Weblate (Romanian)
Weblate [Sat, 27 Apr 2024 08:15:34 +0000 (08:15 +0000)]
Translated using Weblate (Romanian)

Currently translated at 0.3% (32 of 10423 strings)

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

Signed-off-by: Weblate <noreply-mt-weblate@weblate.org>
12 months agoTranslated using Weblate (Romanian)
Remus-Gabriel Chelu [Sat, 27 Apr 2024 08:05:30 +0000 (08:05 +0000)]
Translated using Weblate (Romanian)

Currently translated at 0.3% (32 of 10423 strings)

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

Signed-off-by: Remus-Gabriel Chelu <remusgabriel.chelu@disroot.org>
12 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sat, 27 Apr 2024 08:05:10 +0000 (08:05 +0000)]
Translated using Weblate (Swedish)

Currently translated at 70.8% (7383 of 10423 strings)

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

Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
12 months agoTranslated using Weblate (Romanian)
Weblate [Sat, 27 Apr 2024 08:03:59 +0000 (08:03 +0000)]
Translated using Weblate (Romanian)

Currently translated at 0.1% (11 of 10423 strings)

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

Signed-off-by: Weblate <noreply-mt-weblate@weblate.org>
12 months agoTranslated using Weblate (Romanian)
Remus-Gabriel Chelu [Sat, 27 Apr 2024 08:02:10 +0000 (08:02 +0000)]
Translated using Weblate (Romanian)

Currently translated at 0.1% (11 of 10423 strings)

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

Signed-off-by: Remus-Gabriel Chelu <remusgabriel.chelu@disroot.org>