]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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>
12 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sat, 27 Apr 2024 08:02:43 +0000 (08:02 +0000)]
Translated using Weblate (Swedish)

Currently translated at 70.7% (7378 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 07:57:59 +0000 (09:57 +0200)]
Translated using Weblate (Romanian)

Currently translated at 0.1% (3 of 10423 strings)

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

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

Currently translated at 0.1% (3 of 10423 strings)

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

Co-authored-by: Remus-Gabriel Chelu <remusgabriel.chelu@disroot.org>
Signed-off-by: Remus-Gabriel Chelu <remusgabriel.chelu@disroot.org>
12 months agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Sat, 27 Apr 2024 07:57:58 +0000 (09:57 +0200)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10423 of 10423 strings)

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

Co-authored-by: Yuri Chornoivan <yurchor@ukr.net>
Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
12 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sat, 27 Apr 2024 07:57:57 +0000 (09:57 +0200)]
Translated using Weblate (Swedish)

Currently translated at 70.6% (7363 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 agoTranslated using Weblate (Korean)
김인수 [Sat, 27 Apr 2024 07:57:57 +0000 (09:57 +0200)]
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/

Co-authored-by: 김인수 <simmon@nplob.com>
Signed-off-by: 김인수 <simmon@nplob.com>
12 months agoUpdate translation files
Weblate [Sat, 27 Apr 2024 07:57:55 +0000 (09:57 +0200)]
Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

Co-authored-by: Weblate <noreply@weblate.org>
Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
12 months agopo: Refresh potfile for v10.3.0
Jiri Denemark [Fri, 26 Apr 2024 08:19:09 +0000 (10:19 +0200)]
po: Refresh potfile for v10.3.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
12 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Thu, 25 Apr 2024 19:48:00 +0000 (21:48 +0200)]
Translated using Weblate (Swedish)

Currently translated at 70.3% (7345 of 10438 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 agovsh: Refactor logic in vshCommandParse
Peter Krempa [Thu, 7 Mar 2024 16:06:18 +0000 (17:06 +0100)]
vsh: Refactor logic in vshCommandParse

Refactor the existing logic using two nested loops with a jump into the
middle of both with 3 separate places fetching next token to a single
loop using a state machine with one centralized place to fetch next
tokens and add explanation comments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agovsh: Move option assignment debugging from vshCommandParse to vshCmdOptAssign
Peter Krempa [Wed, 17 Apr 2024 12:06:38 +0000 (14:06 +0200)]
vsh: Move option assignment debugging from vshCommandParse to vshCmdOptAssign

As we now have a centralized point to assign values to options move the
debugging logic there.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agovshCmddefCheckInternals: Remove check for "too many options"
Peter Krempa [Thu, 18 Apr 2024 14:32:44 +0000 (16:32 +0200)]
vshCmddefCheckInternals: Remove check for "too many options"

This check was needed due to the use "unsigned long long" as bitmap
which was refactored recently.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agovsh: Refactor parsed option and command assignment
Peter Krempa [Mon, 15 Apr 2024 14:55:18 +0000 (16:55 +0200)]
vsh: Refactor parsed option and command assignment

Refactor the very old opaque logic (using multiple bitmaps) by
fully-allocating vshCmdOpt for each possible argument and then filling
them as they go rather than allocating them each time after it's parsed.

This simplifies the checkers and removes the need to cross-reference
multiple arrays.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agovsh: Unexport command lookup helpers 'vshCmddefSearch', 'vshCmdGrpSearch', 'vshCmdGrp...
Peter Krempa [Mon, 15 Apr 2024 12:09:04 +0000 (14:09 +0200)]
vsh: Unexport command lookup helpers 'vshCmddefSearch', 'vshCmdGrpSearch', 'vshCmdGrpHelp'

Neither of them is used outside of vsh.c. 'vshCmddefSearch' needed to be
rearranged as it was called earlier in vsh.c than it was defined.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agovsh: Remove unused infrastructure for command completion
Peter Krempa [Mon, 15 Apr 2024 09:45:14 +0000 (11:45 +0200)]
vsh: Remove unused infrastructure for command completion

Remove the old helpers which were used previously to pick which field to
complete.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agovirsh: Introduce new 'VSH_OT_ARGV' accessors
Peter Krempa [Wed, 6 Mar 2024 16:26:56 +0000 (17:26 +0100)]
virsh: Introduce new 'VSH_OT_ARGV' accessors

In preparation for internal parser refactor introduce new accessors for
the VSH_OT_ARGV type which will return a NULL-terminated string list or
even a concatenated string for the given argument.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agovsh: Rework logic for picking which argument is to be completed
Peter Krempa [Tue, 12 Mar 2024 07:29:00 +0000 (08:29 +0100)]
vsh: Rework logic for picking which argument is to be completed

Currently the code decides which option to complete by looking into the
input string and trying to infer it based on whether we are at the
end position as we truncate the string to complete to the current cursor
position.

That basically means that only the last-parsed option will be up for
completion.

Replace the logic by remembering which is the last option rather than
using two different position checks and base the completion decision on
that and the actual value of the last argument (see comment).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agovirshtest: Add test cases for command completion helper
Peter Krempa [Tue, 12 Mar 2024 16:03:56 +0000 (17:03 +0100)]
virshtest: Add test cases for command completion helper

Add both single invocations as well as a script containing the same
commands.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agovsh: Add a VSH_OT_STRING argument for 'virsh echo'
Peter Krempa [Wed, 3 Apr 2024 05:07:57 +0000 (07:07 +0200)]
vsh: Add a VSH_OT_STRING argument for 'virsh echo'

The argument will be used for testing the command/option completer
function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agovsh: Fix 'stdin' closing in 'cmdComplete'
Peter Krempa [Tue, 26 Mar 2024 15:28:33 +0000 (16:28 +0100)]
vsh: Fix 'stdin' closing in 'cmdComplete'

While the 'complete' command is meant to be hidden and used only for
the completion script, there's nothing preventing it being used in all
virsh modes.

This poses a problem as the command tries to close 'stdin' to avoid the
possibility that an auth callback would want to read the password.

In interactive mode this immediately terminates virsh and in
non-interactive mode it attempts to close it multiple times if you use
virsh in batch mode.

Fix the issues by using virOnce() to close it exactly once and do so
only in non-interactive mode.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agotools: Rename vshCommandOptStringReq to vshCommandOptString
Peter Krempa [Mon, 11 Mar 2024 14:55:11 +0000 (15:55 +0100)]
tools: Rename vshCommandOptStringReq to vshCommandOptString

Shorten the function name as there isn't any vshCommandOptString.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agomeson: tests: Add 'virsh' as dependency of 'virshtest'
Peter Krempa [Mon, 8 Apr 2024 13:55:38 +0000 (15:55 +0200)]
meson: tests: Add 'virsh' as dependency of 'virshtest'

Ensure that virsh is rebuilt if needed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agovshReadlineInit: Initialize only once
Peter Krempa [Thu, 25 Apr 2024 08:15:53 +0000 (10:15 +0200)]
vshReadlineInit: Initialize only once

'vshReadlineInit' is called when interactive virsh is started but also
on each call to 'cmdComplete'. Calling it repeatedly (using the
'complete' command interactively, or multiple times in batch mode) leaks
the buffers for history file configuration.

Avoid multiple setups of this function by returning success in case the
history file config is already present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agovsh: cmdComplete: Don't leak buffer for completion
Peter Krempa [Thu, 25 Apr 2024 08:05:42 +0000 (10:05 +0200)]
vsh: cmdComplete: Don't leak buffer for completion

The buffer which we assign to the 'rl_line_buffer' variable of readline
would be overwritten and thus leaked on multiple invocations of
cmdComplete in one session.

Free/clear it after it's used.

Hitting this leak was until recenly possible only in non-interactive
batch mode and recently also in interactive mode as 'complete' can be
used multiple times now interactively.

Fixes: a0e1ada63c0afdc2af3b9405cbf637d8bd28700c
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agovirnetdevbandwidth.c: Put a limit to "quantum"
Michal Privoznik [Wed, 24 Apr 2024 14:55:34 +0000 (16:55 +0200)]
virnetdevbandwidth.c: Put a limit to "quantum"

The "quantum" attribute of HTB is documented as:

  Number of bytes to serve from this class before the scheduler
  moves to the next class.

Since v1.3.2-rc1~225 we compute what we think is the appropriate
value and pass it on the TC command line. But kernel and
subsequently TC use uint32_t to store this value. If we compute
value outside of this type then TC fails and prints usage which
we then interpret as an error message. Needlessly long error
message. While there's not much we can do about the latter, we
can put a cap on the value and stop tickling this behavior of TC.

Fixes: 065054daa71f645fc83aff0271f194d326208616
Resolves: https://issues.redhat.com/browse/RHEL-34112
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
12 months agotest: nodedev: fill active_config at driver startup time
Cole Robinson [Sat, 6 Apr 2024 19:13:40 +0000 (15:13 -0400)]
test: nodedev: fill active_config at driver startup time

Commit v10.0.0-265-ge67bca23e4 added a `active_config` and
`defined_config` to nodedev mdev internal XML handling.
`defined_config` can be filled at XML parse time, but `active_config`
must be filled in by nodedev driver. This wasn't implemented for the
test driver however, which caused virt-manager test suite regressions.

Working example:

```
$ virsh --connect test:///home/crobinso/src/virt-manager/tests/data/testdriver/testdriver.xml nodedev-dumpxml mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110
<device>
  <name>mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110</name>
  <path>/sys/devices/css0/0.0.0023/8e37ee90-2b51-45e3-9b25-bf8283c03110</path>
  <parent>css_0_0_0023</parent>
  <capability type='mdev'>
    <type id='vfio_ccw-io'/>
    <iommuGroup number='0'/>
  </capability>
</device>
```

Broken example:

```
$ virsh --connect test:///home/crobinso/src/virt-manager/tests/data/testdriver/testdriver.xml nodedev-dumpxml mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110
<device>
  <name>mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110</name>
  <path>/sys/devices/css0/0.0.0023/8e37ee90-2b51-45e3-9b25-bf8283c03110</path>
  <parent>css_0_0_0023</parent>
  <capability type='mdev'>
    <iommuGroup number='0'/>
  </capability>
</device>
```

There's already code that does what we want in the test suite.
Move it to a shared function, and call it in test driver when
creating a nodedev from driver startup XML.

Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
12 months agotest: Sync GetXML INACTIVE behavior with live driver
Cole Robinson [Wed, 17 Apr 2024 15:07:14 +0000 (11:07 -0400)]
test: Sync GetXML INACTIVE behavior with live driver

- Error if INACTIVE requested for transient object
- Force dumping INACTIVE XML when object is inactive

Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
12 months agotest: make parsed nodedevs active and persistent
Cole Robinson [Fri, 22 Mar 2024 14:45:48 +0000 (10:45 -0400)]
test: make parsed nodedevs active and persistent

This was the implied default before nodedevs gained a notion of
being inactive and transient. It also matches the implied default
when parsing other object types

Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
12 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Wed, 24 Apr 2024 07:36:08 +0000 (09:36 +0200)]
Translated using Weblate (Swedish)

Currently translated at 70.1% (7325 of 10438 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 agovirDomainDeviceIsUSB: Handle all USB devices and simplify the code
Peter Krempa [Wed, 3 Apr 2024 10:13:55 +0000 (12:13 +0200)]
virDomainDeviceIsUSB: Handle all USB devices and simplify the code

Rework 'virDomainUSBDeviceDefForeach' to use virDomainDeviceInfoIterate
instead of open-coding all iterators. To achieve this
'virDomainDeviceIsUSB' needs to be fixed as it didn't properly handle
'sound', 'fs', 'chr', 'ccid', and 'net' usb devices.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
12 months agodocs: Rewrite documentation for network device models
Peter Krempa [Wed, 3 Apr 2024 10:49:09 +0000 (12:49 +0200)]
docs: Rewrite documentation for network device models

Since libvirt now tries to interpret network device models (unless an
unknow model is used) the documentation didn't make a good job
specifying what is supported.

Rewrite the docs to explicitly list the models which we do parse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
12 months agoqemucapabilitiestest: Update qemu capability dump for qemu-9.0 release
Peter Krempa [Wed, 24 Apr 2024 08:25:08 +0000 (10:25 +0200)]
qemucapabilitiestest: Update qemu capability dump for qemu-9.0 release

qemu-9.0 was released so update the capability dump to the final
version.

Notable changes:
 - the 'vdpa' simulator support was reverted for now

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
12 months agotests: qemucapsprobe: Fix construction of path to libqemucapsprobemock.so
Peter Krempa [Wed, 24 Apr 2024 08:06:28 +0000 (10:06 +0200)]
tests: qemucapsprobe: Fix construction of path to libqemucapsprobemock.so

Prior to commit eac646ea490e66 VIR_TEST_MOCK included the path to the
build directory, but the code was not fixed after VIR_TEST_MOCK was
changed resulting in the following failure when attempting to probe
capaibilities:

 $ ./tests/qemucapsprobe /path/to/qemu/qemu-system-x86_64 > out
 libqemucapsprobemock.so: No such file or directory

Fix the construction of the path to the mock library by concatenating it
back with the absolute path to the build directory.

Fixes: eac646ea490e66500609585047f0d800e3645d6b
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
12 months agoqemu: migration: Don't use empty string for 'tls-hostname' NBD blockdev
Peter Krempa [Fri, 19 Apr 2024 13:51:35 +0000 (15:51 +0200)]
qemu: migration: Don't use empty string for 'tls-hostname' NBD blockdev

While QEMU accepts and interprets an empty string in the tls-hostname
field in migration parametes as if it's unset, the same does not apply
for the 'tls-hostname' field when 'blockdev-add'-ing a NBD backend for
non-shared storage migration.

When libvirt sets up migation with TLS in 'qemuMigrationParamsEnableTLS'
the QEMU_MIGRATION_PARAM_TLS_HOSTNAME migration parameter will be set to
empty string in case when the 'hostname' argument is passed as NULL.

Later on when setting up the NBD connections for non-shared storage
migration 'qemuMigrationParamsGetTLSHostname', which fetches the value
of the aforementioned TLS parameter.

This bug was mostly latent until recently as libvirt used
MIGRATION_DEST_CONNECT_HOST mode in most cases which required the
hostname to be passed, thus the parameter was set properly.

This changed with 8d693d79c40 for post-copy migration, where libvirt now
instructs qemu to connect and thus passes NULL hostname to
qemuMigrationParamsEnableTLS, which in turn causes libvirt to try to
add NBD connection with empty string as tls-hostname resulting in:

  error: internal error: unable to execute QEMU command 'blockdev-add': Certificate does not match the hostname

To address this modify 'qemuMigrationParamsGetTLSHostname' to undo the
weird semantics the migration code uses to handle TLS hostname and make
it return NULL if the hostname is an empty string.

Fixes: e8fa09d66bc
Resolves: https://issues.redhat.com/browse/RHEL-32880
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
12 months agovirnetdevopenvswitch: Create OVS ports as transient
Michal Privoznik [Fri, 19 Apr 2024 13:45:48 +0000 (15:45 +0200)]
virnetdevopenvswitch: Create OVS ports as transient

Since OVS keeps desired state in a DB, upon sudden crash of the
host we may leave a port behind. There's no problem on VM
shutdown or NIC hotunplug as we call corresponding del-port
function (virNetDevOpenvswitchRemovePort()). But if the host
suddenly crashes we won't ever do that. What happens next, is
when OVS starts it finds desired state in its DB and creates a
stale port.

OVS added support for transient ports in v2.5.0 (Feb 2016) and
since its v2.9.0 it even installs a systemd service
(ovs-delete-transient-ports) that automatically deletes transient
ports on system startup. If we mark a port as transient then OVS
won't restore its state on restart after crash.

This change may render "--may-exist" argument redundant, but I'm
not sure about all the implications if it was removed. Let's keep
it for now.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/615
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
12 months agoqemu_validate: Reject virtiofs with bootindex on s390x with CCW
Peter Krempa [Mon, 22 Apr 2024 13:21:37 +0000 (15:21 +0200)]
qemu_validate: Reject virtiofs with bootindex on s390x with CCW

The CCW variant of the 'vhost-user-fs' device in qemu doesn't
deliberately support the 'bootindex' attribute as the machine is unable
to boot from such device.

Reject '<boot order' on non-PCI virtiofs, add tests validating that it's
rejected as well as that virtiofs on PCI-based hosts but without address
specified will be accepted.

Resolves: https://issues.redhat.com/browse/RHEL-22728
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
12 months agoqemuxmlconftest: Decouple input and output files of 'vhost-user-fs-hugepage' case
Peter Krempa [Mon, 22 Apr 2024 14:49:28 +0000 (16:49 +0200)]
qemuxmlconftest: Decouple input and output files of 'vhost-user-fs-hugepage' case

Replace symlink by a real output file so that we can also test updates
to input file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
12 months agoqemuxmlconftest: Add test case for virtiofs on s390 using 'ccw' addresses
Peter Krempa [Mon, 22 Apr 2024 13:15:45 +0000 (15:15 +0200)]
qemuxmlconftest: Add test case for virtiofs on s390 using 'ccw' addresses

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
12 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Mon, 22 Apr 2024 17:36:06 +0000 (19:36 +0200)]
Translated using Weblate (Swedish)

Currently translated at 69.9% (7305 of 10438 strings)

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

Translated using Weblate (Swedish)

Currently translated at 69.6% (7265 of 10438 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 agoTranslated using Weblate (English (United Kingdom))
Andi Chandler [Mon, 22 Apr 2024 17:36:05 +0000 (19:36 +0200)]
Translated using Weblate (English (United Kingdom))

Currently translated at 46.9% (4902 of 10438 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>
12 months agoqemu_command: Generate mem-reserve for controllers
Michal Privoznik [Mon, 11 Sep 2023 13:59:53 +0000 (15:59 +0200)]
qemu_command: Generate mem-reserve for controllers

Pretty straightforward. Just put mem-reserve attribute whenever
it's set. Previous commit ensures it's set only for valid
controller models.

Resolves: https://issues.redhat.com/browse/RHEL-7461
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
12 months agoqemu_validate: Restrict setting @memReserve only to some controllers
Michal Privoznik [Mon, 11 Sep 2023 13:59:44 +0000 (15:59 +0200)]
qemu_validate: Restrict setting @memReserve only to some controllers

Only two controller models allow setting mem-reserve:
pcie-root-port and pci-bridge. Reflect this fact during
validation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
12 months agoconf: Introduce @memReserve to <controller/>
Michal Privoznik [Mon, 11 Sep 2023 12:33:18 +0000 (14:33 +0200)]
conf: Introduce @memReserve to <controller/>

There are PCI devices with pretty large non-prefetchable memory,
for instance:

  Memory at 9d800000 (64-bit, non-prefetchable) [size=8M]
  Memory at a6800000 (64-bit, non-prefetchable) [size=16K]

For cold plugged devices this is not a problem, because firmware
sets PCI controllers in a way that make devices behind them just
work. Problem arises if such PCI device is to be hot plugged.
Since the PCI device wasn't present at cold boot, firmware could
not take it into calculations and the amount of reserved memory
is not sufficient.

Introduce a know that allows users overriding value computed by
FW and thus allow hot plug of such PCI devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
12 months agolibvirt_nss: Fix ERROR() macro
Michal Privoznik [Thu, 18 Apr 2024 07:25:07 +0000 (09:25 +0200)]
libvirt_nss: Fix ERROR() macro

The purpose of ERROR() macro in our NSS module is to print error
message provided as arguments followed by error string
corresponding to errno. Historically, we've used strerror_r() for
that (please note, we want our NSS module to be free of libvirt
internal functions, or glib even - hence, g_strerror() is off the
table).

Now strerror_r() is documented as:

  Returns ... a pointer to a string that the function stores in
  buf, or a pointer to some (immutable) static string (in which
  case buf is unused).

Therefore, we can't rely the string being stored in the buf and
really need to store the retval and print that instead.

While touching this area, decrease the ebuf size, since its
current size (1KiB) is triggering our stack limit (2KiB) in some
cases.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
12 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Wed, 17 Apr 2024 19:36:08 +0000 (21:36 +0200)]
Translated using Weblate (Swedish)

Currently translated at 69.4% (7245 of 10438 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 agoqemu: Change return type of qemuDomainFixupCPUs to void
Jiri Denemark [Wed, 17 Apr 2024 12:28:24 +0000 (14:28 +0200)]
qemu: Change return type of qemuDomainFixupCPUs to void

The function never fails.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
12 months agoqemu: Change return type of qemuDomainUpdateCPU to void
Jiri Denemark [Wed, 17 Apr 2024 12:24:38 +0000 (14:24 +0200)]
qemu: Change return type of qemuDomainUpdateCPU to void

The function never fails.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
12 months agoNEWS: Mention migration bug with custom XML
Jiri Denemark [Tue, 16 Apr 2024 15:38:37 +0000 (17:38 +0200)]
NEWS: Mention migration bug with custom XML

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
12 months agoqemu: Fix migration with custom XML
Jiri Denemark [Tue, 16 Apr 2024 10:57:22 +0000 (12:57 +0200)]
qemu: Fix migration with custom XML

Ages ago origCPU in domain private data was introduced to provide
backward compatibility when migrating to an old libvirt, which did not
support fetching updated CPU definition from QEMU. Thus origCPU will
contain the original CPU definition before such update. But only if the
update actually changed anything. Let's always fill origCPU with the
original definition when starting a domain so that we can rely on it
being always set, even if it matches the updated definition.

This fixes migration or save operations with custom domain XML after
commit v10.1.0-88-g14d3517410, which expected origCPU to be always set
to the CPU definition from inactive XML to check features explicitly
requested by a user.

https://issues.redhat.com/browse/RHEL-30622

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
12 months agotest: Implement virNodeDeviceIsPersistent
Cole Robinson [Fri, 22 Mar 2024 14:36:00 +0000 (10:36 -0400)]
test: Implement virNodeDeviceIsPersistent

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
12 months agotest: Implement virNodeDeviceIsActive
Cole Robinson [Fri, 22 Mar 2024 14:33:20 +0000 (10:33 -0400)]
test: Implement virNodeDeviceIsActive

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
12 months agotest: Fix `virsh nodedev-list`
Cole Robinson [Thu, 21 Mar 2024 22:50:22 +0000 (18:50 -0400)]
test: Fix `virsh nodedev-list`

$ virsh --connect test:///default nodedev-list
error: Failed to list node devices
error: unsupported flags (0x80000000) in function testConnectListAllNodeDevices

The test driver handles the nodedev state flags, we just need to
allow them

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
12 months agonetwork: ensure nparams is non-NULL and non-negative
Daniel P. Berrangé [Fri, 15 Mar 2024 10:47:07 +0000 (10:47 +0000)]
network: ensure nparams is non-NULL and non-negative

The typed parameter array length must be non-NULL and either 0, or a
positive number.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
12 months agoqemu: Use g_autoptr in qemuProcessInit
Jiri Denemark [Tue, 16 Apr 2024 13:11:02 +0000 (15:11 +0200)]
qemu: Use g_autoptr in qemuProcessInit

The only thing we need to free in the cleanup code is virCPUDef and for
that we already have g_autoptr handler.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Tue, 16 Apr 2024 13:35:57 +0000 (15:35 +0200)]
Translated using Weblate (Swedish)

Currently translated at 69.2% (7225 of 10438 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 agoTranslated using Weblate (English (United Kingdom))
Andi Chandler [Tue, 16 Apr 2024 13:35:56 +0000 (15:35 +0200)]
Translated using Weblate (English (United Kingdom))

Currently translated at 46.7% (4880 of 10438 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>
12 months agotests: Allow spaces in path to virt-aa-helper
Michal Privoznik [Mon, 25 Mar 2024 11:42:50 +0000 (12:42 +0100)]
tests: Allow spaces in path to virt-aa-helper

The virt-aa-helper bash script constructs a path to itself when
it runs. But it isn't prepared for the case when there is a space
in the path leading to the script (something, something, double
quotes, something).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agotests: mock: Accept spaces in build path
Michal Privoznik [Fri, 22 Mar 2024 15:57:44 +0000 (16:57 +0100)]
tests: mock: Accept spaces in build path

If path to the build directory contains spaces (e.g. meson setup
'a b') then our mocks don't work. The problem is in glibc where
not just a colon but also a space character is a delimiter for
LD_PRELOAD [1]. Hence, a test using mock tries to preload
something like libvirt.git/a b/libsomethingmock.so which is
interpreted by glibc as two separate strings: "libvirt.git/a",
"b/libsomethingmock.so".

One trick to get around this is to set LD_PRELOAD to just the
shared object file (without path) and let glibc find the mock in
paths specified in LD_LIBRARY_PATH (where only a colon or a
semicolon are valid separators [1]). This can be seen in action
by running say:

  LD_DEBUG=libs ./virpcitest

1: https://man7.org/linux/man-pages/man8/ld.so.8.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
12 months agodomain_interface: Fix build on FreeBSD
Michal Privoznik [Mon, 15 Apr 2024 06:51:23 +0000 (08:51 +0200)]
domain_interface: Fix build on FreeBSD

In one of my recent commits I've chopped just too much and moved
a variable declaration into a function not realizing it's still
used on FreeBSD. Bring it back but only for the FreeBSD case.

Fixes: f8b5bd855f8312457fd9ad8a68fb044982bd3cc6
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
12 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sat, 13 Apr 2024 12:18:20 +0000 (12:18 +0000)]
Translated using Weblate (Swedish)

Currently translated at 69.1% (7223 of 10438 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 (Swedish)
Weblate [Sat, 13 Apr 2024 12:17:45 +0000 (14:17 +0200)]
Translated using Weblate (Swedish)

Currently translated at 69.1% (7219 of 10438 strings)

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

Co-authored-by: Weblate <noreply-mt-weblate@weblate.org>
Signed-off-by: Weblate <noreply-mt-weblate@weblate.org>
12 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sat, 13 Apr 2024 12:17:45 +0000 (14:17 +0200)]
Translated using Weblate (Swedish)

Currently translated at 69.1% (7219 of 10438 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 agovbox: Drop needless g_new0(..., 0) in vbox_snapshot_conf.c
Michal Privoznik [Fri, 12 Apr 2024 15:45:16 +0000 (17:45 +0200)]
vbox: Drop needless g_new0(..., 0) in vbox_snapshot_conf.c

clang on Fedora started to complain about some calls to g_new0()
we're making in vbox_snapshot_conf.c. Specifically, we're passing
zero as number of elements to allocate. And while usually SA
tools are not clever, in this specific case clang is right.
There are three cases where such call is made, but all of them
later use VIR_EXPAND_N() to allocate more memory (if needed). But
VIR_EXPAND_N() accepts a variable set to NULL happily.

Therefore, just drop those three calls to g_new0(..., 0) and let
VIR_EXPAND_N() allocate memory.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
12 months agodomain_interface: Introduce and use virDomainInterfaceClearQoS()
Michal Privoznik [Fri, 12 Apr 2024 07:26:20 +0000 (09:26 +0200)]
domain_interface: Introduce and use virDomainInterfaceClearQoS()

In QEMU and LXC drivers in a few places only
virNetDevBandwidthClear() is called. This means that if an
interface is of openvswitch vport profile, its QoS is not
removed. And to make matters worse - OVS is designed to remember
state even when corresponding interface is gone. This leads to
stale QoS settings piling up in OVS database.

To resolve this, introduce virDomainInterfaceClearQoS() which
looks at given interface and calls corresponding QoS clear
function. Then, basically replace virNetDevBandwidthClear() calls
in those hypervisor drivers with this new function.

Resolves: https://issues.redhat.com/browse/RHEL-30373
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
12 months agoconf: Move virDomainClearNetBandwidth() to src/hypervisor/
Michal Privoznik [Fri, 12 Apr 2024 08:05:10 +0000 (10:05 +0200)]
conf: Move virDomainClearNetBandwidth() to src/hypervisor/

The reason virDomainClearNetBandwidth() exists in src/conf/ is
that at the time its introduction we did not have a better place.
But now we do. Firstly, virDomainClearNetBandwidth() is
hypervisor agnostic code, but really has nothing to do with
domain configuration (it doesn't parse/format XML). Secondly, in
near future it'll call another function from src/hypervisor/ and
that's not really allowed from src/conf/.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
12 months agovirnetdevopenvswitch: Drop @brname arg from virNetDevOpenvswitchRemovePort()
Michal Privoznik [Thu, 11 Apr 2024 10:37:23 +0000 (12:37 +0200)]
virnetdevopenvswitch: Drop @brname arg from virNetDevOpenvswitchRemovePort()

The @brname argument of virNetDevOpenvswitchRemovePort() is and
was unused ever since its introduction in v0.9.11-rc1~257. Just
remove it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
12 months agohypervisor: Introduce and use virDomainInterfaceVportRemove()
Michal Privoznik [Thu, 11 Apr 2024 12:12:37 +0000 (14:12 +0200)]
hypervisor: Introduce and use virDomainInterfaceVportRemove()

Both LXC and QEMU drivers have the same code to remove vport when
removing a domain's interface. Instead of repeating the same
pattern in both drivers, move the code into hypervisor agnostic
location (src/hypervisor/) and switch to calling this new
function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
12 months agovirnetdevopenvswitch: Fix comment to virNetDevOpenvswitchInterfaceGetMaster()
Michal Privoznik [Fri, 12 Apr 2024 10:16:26 +0000 (12:16 +0200)]
virnetdevopenvswitch: Fix comment to virNetDevOpenvswitchInterfaceGetMaster()

The comment to virNetDevOpenvswitchInterfaceGetMaster() contains
wrong function name. Fix this.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
12 months agovsh: Drop fwd declaration of a nonexistent function
Michal Privoznik [Fri, 12 Apr 2024 10:29:34 +0000 (12:29 +0200)]
vsh: Drop fwd declaration of a nonexistent function

The vshFindTypedParamByName() function no longer exists (as of
v1.0.2-rc1~82), but its header file declaration was still kept
around. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
12 months agoqemusecuritytest: Call real virFileExists in mock
Michal Privoznik [Tue, 9 Apr 2024 08:17:11 +0000 (10:17 +0200)]
qemusecuritytest: Call real virFileExists in mock

When I suggested to Jim to call real virFileExists() I forgot to
also suggest calling init_syms(). Without it, real_virFileExists
pointer might be left unset. And indeed, that's what we were
seeing on FreeBSD.

This effectively reverts commit 4b5cc57ed35dc24d11673dd3f04bfb8073c0340d.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>