]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
17 months agoTranslated using Weblate (Russian)
Ján Tomko [Fri, 24 Nov 2023 08:52:44 +0000 (09:52 +0100)]
Translated using Weblate (Russian)

Currently translated at 88.4% (9215 of 10415 strings)

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

Co-authored-by: Jan Tomko <jtomko@redhat.com>
Co-authored-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Jan Tomko <jtomko@redhat.com>
17 months agoNEWS: Document pipewire audio backend
Michal Privoznik [Thu, 11 May 2023 11:31:27 +0000 (13:31 +0200)]
NEWS: Document pipewire audio backend

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agoqemu: Generate cmd line for pipewire audio backend
Michal Privoznik [Wed, 10 May 2023 10:58:44 +0000 (12:58 +0200)]
qemu: Generate cmd line for pipewire audio backend

This is mostly straightforward, except for a teensy-weensy
detail: usually, there's no system wide daemon running, no system
wide available socket that anybody could connect to. PipeWire
uses a per user daemon approach instead. But this in turn means,
that the socket location floats between various locations and is
derived from various environment variables (just like the actual
socket name) and thus we must pass the variables to QEMU.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/560
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agoconf: Introduce pipewire audio backend
Michal Privoznik [Wed, 10 May 2023 10:29:54 +0000 (12:29 +0200)]
conf: Introduce pipewire audio backend

QEMU gained support for PipeWire audio backend (see QEMU commit
of v8.0.0-403-gc2d3d1c294). Its configuration knobs are basically
the same as pulseaudio's, except for PA's server name. Therefore,
a lot of code is copied over from pulseadio and fixed by
s/Pulse/Pipewire/ or s/pulseaudio/pipewire/.

There's one ley difference to PA though: pipewire daemon is
usually on per user basis (just like our qemu:///session).
Therefore, introduce this 'runtimeDir' attribute, which allows
specifying path to pipewire daemon socket (useful for
qemu:///system for instance).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agovirnuma: Avoid integer overflow in virNumaGetPages()
Michal Privoznik [Fri, 24 Nov 2023 10:59:32 +0000 (11:59 +0100)]
virnuma: Avoid integer overflow in virNumaGetPages()

On systems with humongous pages (16GiB) and 32bit int it's easy
to hit integer overflow in virNumaGetPages(). What happens is,
inside of virNumaGetPages() as we process hugepages for given
NUMA node (e.g. in order to produce capabilities XML), we keep a
sum of sizes of pools in an ULL variable (huge_page_sum). In each
iteration, the variable is incremented by 1024 * page_size *
page_avail. Now, page_size is just an uint, so we have:

  ULL += U * U * ULL;

and because of associativity, U * U is computed first and since
we have two operands of the same type, no type expansion happens.
But this means, for humongous pages (like 16GiB) the
multiplication overflows.

Therefore, move the multiplication out of the loop. This helps in
two ways:

1) now we have ULL += U * ULL; which expands the uint in
   multiplication,

2) it saves couple of CPU cycles.

Resolves: https://issues.redhat.com/browse/RHEL-16749
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agoqemu: block: Don't try to merge bitmaps into 'raw' images
Peter Krempa [Thu, 23 Nov 2023 12:43:36 +0000 (13:43 +0100)]
qemu: block: Don't try to merge bitmaps into 'raw' images

If any of the images in a chain above a raw image have bitmaps, libvirt
would attempt to merge them when doing a block commit or block copy
operation, which would result into a error in the logs as creating
persistent bitmaps in a raw image is not supported.

Since libvirt cares only about persistent bitmaps we can simply skip the
operation if the target of a block copy or block commit is a raw image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agoqemu: hotplug: Detect disk backing images before setting up security access
Peter Krempa [Thu, 23 Nov 2023 13:07:48 +0000 (14:07 +0100)]
qemu: hotplug: Detect disk backing images before setting up security access

The VM will require access also to the detected images. Unfortunately a
recent reordering of the code introduced a bug where the backing chain
was probed after setting up cgroups/selinux/namespaces, which caused
that any detected images were not allowed/added and qemu was then not
able to use them.

Fixes: 9b8bb536ff999fa61e41869bd98a026b8e23378f
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agoqemu_domain: Drop qemuCheckMemoryDimmConflict()
Michal Privoznik [Fri, 3 Nov 2023 09:15:58 +0000 (10:15 +0100)]
qemu_domain: Drop qemuCheckMemoryDimmConflict()

The virDomainMemoryDefCheckConflict() already does the same set
of checks. There's no need to duplicate them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
17 months agovirDomainMemoryDefCheckConflict: Validate dimm slot too
Michal Privoznik [Thu, 2 Nov 2023 15:35:00 +0000 (16:35 +0100)]
virDomainMemoryDefCheckConflict: Validate dimm slot too

Since we're iterating over def->mems array, might as well check
for dimm slot duplicates.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
17 months agovirDomainMemoryDefCheckConflict: Check dimm & nvdimm models too
Michal Privoznik [Thu, 2 Nov 2023 15:06:00 +0000 (16:06 +0100)]
virDomainMemoryDefCheckConflict: Check dimm & nvdimm models too

So far we check whether virtio-mem and/or virtio-pmem memory
devices do not overlap with each other. But we allow specifying
address where dimm and nvdimm memory devices are mapped too. And
there are left out from this collision check. Not anymore.

This leaves just sgx model out, but that's expected since it
can't have any address (see virDomainMemoryDefValidate()).

Resolves: https://issues.redhat.com/browse/RHEL-4452
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
17 months agodomain_validate: Move memdevice address conflict check into a separate function
Michal Privoznik [Thu, 2 Nov 2023 15:05:46 +0000 (16:05 +0100)]
domain_validate: Move memdevice address conflict check into a separate function

At the end of virDomainMemoryDefValidate() there's a code that
checks whether two virtio-mem/virtio-pmem devices don't overlap.
Separate this code into its own function
(virDomainMemoryDefCheckConflict()).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
17 months agoFix cpu-host-model test data
Tim Wiederhake [Fri, 24 Nov 2023 10:05:13 +0000 (11:05 +0100)]
Fix cpu-host-model test data

This was broken by the recent addition of vmx-* features.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
17 months agocpu_map: Add missing vmx features from MSR 0x491
Tim Wiederhake [Thu, 9 Nov 2023 13:42:10 +0000 (14:42 +0100)]
cpu_map: Add missing vmx features from MSR 0x491

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
17 months agocpu_map: Add missing vmx features from MSR 0x490
Tim Wiederhake [Thu, 9 Nov 2023 13:41:35 +0000 (14:41 +0100)]
cpu_map: Add missing vmx features from MSR 0x490

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
17 months agocpu_map: Add missing vmx features from MSR 0x48F
Tim Wiederhake [Thu, 9 Nov 2023 13:39:59 +0000 (14:39 +0100)]
cpu_map: Add missing vmx features from MSR 0x48F

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
17 months agocpu_map: Add missing vmx features from MSR 0x48E
Tim Wiederhake [Thu, 9 Nov 2023 13:39:17 +0000 (14:39 +0100)]
cpu_map: Add missing vmx features from MSR 0x48E

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
17 months agocpu_map: Add missing vmx features from MSR 0x48D
Tim Wiederhake [Thu, 9 Nov 2023 13:38:10 +0000 (14:38 +0100)]
cpu_map: Add missing vmx features from MSR 0x48D

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
17 months agocpu_map: Add missing vmx features from MSR 0x48C
Tim Wiederhake [Thu, 9 Nov 2023 13:37:19 +0000 (14:37 +0100)]
cpu_map: Add missing vmx features from MSR 0x48C

Differences from qemu:

* "vmx-ept-uc" (bit 8) and "vmx-ept-wb" (bit 14) are not added to
qemu's list of named features yet, but used in several qemu cpu
models never the less. Add to libvirt regardless.

* "vmx-invvpid-single-context" (bit 41) is erroneously called
"vmx-invept-single-context" in qemu. This is the name of the
feature associated with bit 25 in both libvirt and qemu.

* "vmx-invvpid-single-context-noglobals" (bit 43) is erroneously
called "vmx-invept-single-context-noglobals". Use the correct name.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
17 months agocpu_map: Add missing vmx features from MSR 0x48B
Tim Wiederhake [Thu, 9 Nov 2023 13:36:30 +0000 (14:36 +0100)]
cpu_map: Add missing vmx features from MSR 0x48B

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
17 months agocpu_map: Add missing vmx features from MSR 0x485
Tim Wiederhake [Thu, 9 Nov 2023 13:35:39 +0000 (14:35 +0100)]
cpu_map: Add missing vmx features from MSR 0x485

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
17 months agocpu_map: Add missing vmx features from MSR 0x480
Tim Wiederhake [Thu, 9 Nov 2023 13:33:38 +0000 (14:33 +0100)]
cpu_map: Add missing vmx features from MSR 0x480

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
17 months agocpu_map: No longer ignore vmx- features in sync_qemu_features_i386.py
Tim Wiederhake [Thu, 9 Nov 2023 12:19:41 +0000 (13:19 +0100)]
cpu_map: No longer ignore vmx- features in sync_qemu_features_i386.py

Some guest OSes require cpu features from the vmx-* family,
e.g. vmx-xsaves. Up to now, libvirt ignored these features as they
were not required yet. qemu does not automatically enable e.g.
"vmx-xsaves" when requesting "xsaves":

    qmp="qemu-kvm -machine accel=kvm -nodefaults -nographic -qmp stdio"
    $(qmp) <<-EOF | jq | grep "xsaves"
    { "execute": "qmp_capabilities" }
    {
      "execute": "query-cpu-model-expansion",
      "arguments": {
        "type": "full",
        "model": {
          "name": "Skylake-Client-v1",
          "props": { "xsaves": true }   `# set to "true" or "false"`
        }
      }
    }
    { "execute": "quit" }
    EOF

with xsaves "false":
    "xsaves": false,
    "vmx-xsaves": false,

with xsaves "true":
    "xsaves": true,
    "vmx-xsaves": false,

Stop ignoring vmx-* features and begin adding them to libvirt's
database.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
17 months agocpu_map: Add missing feature "amx-complex"
Tim Wiederhake [Thu, 9 Nov 2023 12:18:50 +0000 (13:18 +0100)]
cpu_map: Add missing feature "amx-complex"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
17 months agocpu_map: Add missing feature "gds-no"
Tim Wiederhake [Thu, 9 Nov 2023 12:17:11 +0000 (13:17 +0100)]
cpu_map: Add missing feature "gds-no"

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
17 months agosyntax-check: Forbid use of qsort()
Michal Privoznik [Thu, 23 Nov 2023 09:54:57 +0000 (10:54 +0100)]
syntax-check: Forbid use of qsort()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
17 months agolib: Replace qsort() with g_qsort_with_data()
Michal Privoznik [Wed, 22 Nov 2023 13:58:49 +0000 (14:58 +0100)]
lib: Replace qsort() with g_qsort_with_data()

While glibc provides qsort(), which usually is just a mergesort,
until sorting arrays so huge that temporary array used by
mergesort would not fit into physical memory (which in our case
is never), we are not guaranteed it'll use mergesort. The
advantage of mergesort is clear - it's stable. IOW, if we have an
array of values parsed from XML, qsort() it and produce some
output based on those values, we can then compare the output with
some expected output, line by line.

But with newer glibc this is all history. After [1], qsort() is
no longer mergesort but introsort instead, which is not stable.
This is suboptimal, because in some cases we want to preserve
order of equal items. For instance, in ebiptablesApplyNewRules(),
nwfilter rules are sorted by their priority. But if two rules
have the same priority, we want to keep them in the order they
appear in the XML. Since it's hard/needless work to identify
places where stable or unstable sorting is needed, let's just
play it safe and use stable sorting everywhere.

Fortunately, glib provides g_qsort_with_data() which indeed
implement mergesort and it's a drop in replacement for qsort(),
almost. It accepts fifth argument (pointer to opaque data), that
is passed to comparator function, which then accepts three
arguments.

We have to keep one occurance of qsort() though - in NSS module
which deliberately does not link with glib.

1: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=03bf8357e8291857a435afcc3048e0b697b6cc04
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
17 months agobuild-aux: Refresh list of nonreentrant functions
Michal Privoznik [Thu, 23 Nov 2023 09:11:19 +0000 (10:11 +0100)]
build-aux: Refresh list of nonreentrant functions

There's a new twalk() function that has a reentrant variant. Add
the former onto list of nonreentrant functions.

Also, refresh the comment on how to get the list, because it's
outdated a bit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
17 months agoci: Build RPMs on MinGW
Andrea Bolognani [Thu, 2 Nov 2023 10:16:20 +0000 (11:16 +0100)]
ci: Build RPMs on MinGW

Now that the spec file supports selectively disabling the native,
mingw32 and mingw64 parts, we can add coverage for the MinGW RPM
builds.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
17 months agorpm: Introduce with_native
Andrea Bolognani [Thu, 2 Nov 2023 15:56:54 +0000 (16:56 +0100)]
rpm: Introduce with_native

The new _without_native knob makes it possible to skip the native
build completely and build for MinGW only.

Best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
17 months agorpm: Introduce with_mingw32/with_mingw64
Andrea Bolognani [Thu, 2 Nov 2023 11:24:21 +0000 (12:24 +0100)]
rpm: Introduce with_mingw32/with_mingw64

These replace the existing with_mingw but offer additional
granularity.

The existing _without_mingw knob retains its behavior of
disabling all MinGW builds at once for convenience, while the
newly introduced _without_mingw32/_without_mingw64 knobs make
it possible to disable only one of them.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
17 months agorpm: Split call to mingw_debug_package
Andrea Bolognani [Thu, 2 Nov 2023 15:10:35 +0000 (16:10 +0100)]
rpm: Split call to mingw_debug_package

This is functionally equivalent and will make future patches
nicer.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
17 months agorpm: Shuffle BuildRequires around
Andrea Bolognani [Thu, 2 Nov 2023 15:45:11 +0000 (16:45 +0100)]
rpm: Shuffle BuildRequires around

Move all dependencies that are needed both for native builds and
for MinGW ones near the top of the list. This will make future
patches nicer.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
17 months agoqemu: hotplug: Don't try to setup disk image when hotplugging empty cdrom drive
Peter Krempa [Tue, 21 Nov 2023 13:59:37 +0000 (14:59 +0100)]
qemu: hotplug: Don't try to setup disk image when hotplugging empty cdrom drive

Originally the disk hotplug code didn't know how to attach a CD-ROM
drive, thus didn't have the necessary logic to handle empty cdroms.

Other disks can't be empty which is enforced by the parser validation
logic.

When support for hotplugging cdroms was added the code was not adjusted
to deal with empty drives thus attempted to setup the blockdev backend
for it.

Fixes: 3078799fef82d45ac10624e3bacded7a285d8a4f
Resolves: https://issues.redhat.com/browse/RHEL-16870
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agoqemuDomainAttachDeviceDiskLiveInternal: Add missing jump to 'cleanup' on error
Peter Krempa [Tue, 21 Nov 2023 15:51:12 +0000 (16:51 +0100)]
qemuDomainAttachDeviceDiskLiveInternal: Add missing jump to 'cleanup' on error

Commit allowing hotplug of CDROMs moved the logic forbidding the hotplug
to the appropriate blocks based on the disk frontend but forgot to
actually bail out on such error.

Fixes: 3078799fef82d45ac10624e3bacded7a285d8a4f
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agoqemuDomainAttachDeviceDiskLiveInternal: Fix jumps on error
Peter Krempa [Tue, 21 Nov 2023 16:17:38 +0000 (17:17 +0100)]
qemuDomainAttachDeviceDiskLiveInternal: Fix jumps on error

When I've originally refactored the function in commit 0d981bcefcb5defa2
the logic was still correct, but then later in commit 52f865543920b0
I've moved most of the image setup logic into the function neglecting to
add the 'goto cleanup;' needed to skip over the setup of the disk
images.

Fixes: 52f865543920b0cc5ba93f4407c1b2efdffb8ddc
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agoqemu: validate: Reword error message when CCW addresses are not supported for a machine
Peter Krempa [Tue, 21 Nov 2023 08:42:16 +0000 (09:42 +0100)]
qemu: validate: Reword error message when CCW addresses are not supported for a machine

Reword the error message to clearly state that the machine type doesn't
support the address type. It doesn't matter which device it's for.

Additionally the alias may be still NULL at the point when the error is
being reported misleading users that they have something wrong with a
specific device.

Resolves: https://issues.redhat.com/browse/RHEL-16878
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
17 months agogitlab: adjust url to Coverity tools
Daniel P. Berrangé [Tue, 21 Nov 2023 17:31:40 +0000 (17:31 +0000)]
gitlab: adjust url to Coverity tools

The URL to the Coverity tools download has changed; the old one points
to an obsolete version that is not supported anymore.  Adjust to point
to the correct and supported tools.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
17 months agosrc: reject empty string for 'dname' in migrate APIs
Daniel P. Berrangé [Wed, 8 Nov 2023 16:20:35 +0000 (16:20 +0000)]
src: reject empty string for 'dname' in migrate APIs

A domain name is expected to be non-empty, and we validate this when
parsing XML, or accepting a new name during renames. We fail to
enforce this property, however, when performing a migration. This
was discovered when a user complained about inaccessible VMs after
migrating with the Rust APIs which mistakenly hardcoded 'dname' to
the empty string.

Fixes: https://gitlab.com/libvirt/libvirt-rust/-/issues/11
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
17 months agoconf: virDomainDiskSourceFormat: check for srcpool presence correctly
Ján Tomko [Wed, 1 Nov 2023 14:18:24 +0000 (15:18 +0100)]
conf: virDomainDiskSourceFormat: check for srcpool presence correctly

As a guard against programming errors, one part of the condition
only dereferences srcpool if it exists, other one does not.

Move the check up one level so that it actually has a chance to do
something useful.

Fixes: 19b1c0d31988a3a10c4694c10c27eb15c018f450
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
17 months agolib: Replace xmlKeepBlanksDefault() with virXMLParseWithIndent()
Michal Privoznik [Mon, 20 Nov 2023 15:20:51 +0000 (16:20 +0100)]
lib: Replace xmlKeepBlanksDefault() with virXMLParseWithIndent()

Now that we have virXMLParseWithIndent() and
virXMLParseStringCtxtWithIndent(), we can use them directly and
drop calls to xmlKeepBlanksDefault().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agovirxml: Introduce parsing APIs that keep indentation
Michal Privoznik [Tue, 21 Nov 2023 09:39:58 +0000 (10:39 +0100)]
virxml: Introduce parsing APIs that keep indentation

When parsing an XML it may be important to keep indentation to
produce a better looking result when formatting the XML back.
Just look at all those xmlKeepBlanksDefault() calls just before
virXMLParse() is called.

Anyway, as of libxml2 commit v2.12.0~108 xmlKeepBlanksDefault()
is deprecated. Therefore, introduce virXMLParse...WithIndent()
variants which would do exactly xmlKeepBlanksDefault() did but
with non-deprecated APIs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agovirXMLParseHelper: Store XML parsing flags in a variable
Michal Privoznik [Sat, 18 Nov 2023 03:17:47 +0000 (04:17 +0100)]
virXMLParseHelper: Store XML parsing flags in a variable

The virXMLParseHelper() can work in two modes: either it parses a
file or a string. Either way, the same set of flags is specified
in call of corresponding function. Save flags in a local variable
instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agovirxml: include <libxml/xmlsave.h> for xmlIndentTreeOutput declaration
Michal Privoznik [Mon, 20 Nov 2023 02:18:12 +0000 (03:18 +0100)]
virxml: include <libxml/xmlsave.h> for xmlIndentTreeOutput declaration

After libxml2's commit of v2.12.0~101 we no longer get
xmlIndentTreeOutput declaration by us including just
libxml/xpathInternals.h and libxml2's header files leakage.

Resolves: https://bugs.gentoo.org/917516
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agovbox_snapshot_conf: Keep indent in snapshot XML
Michal Privoznik [Tue, 21 Nov 2023 09:40:36 +0000 (10:40 +0100)]
vbox_snapshot_conf: Keep indent in snapshot XML

As mentioned in previous commit, VirtualBox has its own snapshot
XML which we parse, change and then format back. During this, we
ought to keep the indentation to produce better looking result
(especially when we want to compare the output in tests later on,
like we do in vboxsnapshotxmltest).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agovbox_snapshot_conf: Parse XMLs without net access
Michal Privoznik [Mon, 20 Nov 2023 03:49:53 +0000 (04:49 +0100)]
vbox_snapshot_conf: Parse XMLs without net access

When working with VirtualBox's snapshots, the snapshot XML is
firstly parsed, stored in memory (with some parts being stored as
verbatim XML snippets, strings), requested changes are made and
then this modified XML is formatted via
virVBoxSnapshotConfSaveVboxFile() which calls
xmlParseInNodeContext() to format those previously stored XML
snippets.

The first parse of whole VirtualBox snapshot file is done using
virXMLParse() (in virVBoxSnapshotConfLoadVboxFile()) and thus
with XML_PARSE_NONET specified.

But those ad-hoc parsings when formatting the XML back pass zero
flags mask: xmlParseInNodeContext(..., options = 0, ...);

This is potentially dangerous.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agokbase: More info on firmware change for existing VMs
Andrea Bolognani [Thu, 16 Nov 2023 16:01:44 +0000 (17:01 +0100)]
kbase: More info on firmware change for existing VMs

The need to remove the <loader> and <nvram> elements in order
to make the firmware autoselection process kick in again is
not exactly intuitive, so document it explicitly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agorpc: Pass GPG_TTY and TERM environment variables
Andrea Bolognani [Thu, 16 Nov 2023 18:12:34 +0000 (19:12 +0100)]
rpc: Pass GPG_TTY and TERM environment variables

gpg-agent can be used instead of ssh-agent to authenticate
against an SSH server, but in order to do so the GPG_TTY and
TERM environment variables need to be passed through.

For obvious reasons, we avoid doing that when no_tty=1 is found
in the connection URI.

https://bugs.debian.org/843863
https://gitlab.com/libvirt/libvirt/-/merge_requests/290

Thanks: Guilhem Moulin <guilhem@guilhem.org>
Thanks: Kunwu Chan <chentao@kylinos.cn>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
17 months agoqemu_snapshot: fix reverting to inactive snapshot
Pavel Hrdina [Wed, 1 Nov 2023 13:01:32 +0000 (14:01 +0100)]
qemu_snapshot: fix reverting to inactive snapshot

When reverting to inactive snapshot updating the domain definition needs
to happen after the new overlays are created otherwise qemu-img will
correctly fail with error:

    Trying to create an image with the same filename as the backing file

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
17 months agoqemu_snapshot: fix snapshot deletion that had multiple children
Pavel Hrdina [Wed, 1 Nov 2023 09:12:22 +0000 (10:12 +0100)]
qemu_snapshot: fix snapshot deletion that had multiple children

When we revert to non-leaf snapshot and create new branch or branches
the overlay in snapshot metadata is no longer usable as a disk source
for deletion of that snapshot. We need to use other places to figure out
the correct storage source.

Fixes: https://gitlab.com/libvirt/libvirt/-/issues/534
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
17 months agovirDomainDeviceInfoCheckABIStability: Implement proper check for CCW addresses
Peter Krempa [Thu, 2 Nov 2023 15:08:57 +0000 (16:08 +0100)]
virDomainDeviceInfoCheckABIStability: Implement proper check for CCW addresses

CCW addresses need to be also checked for ABI stability.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
17 months agoqemucapabilitiestest: Update capabilities data for 8.2 dev cycle on x86_64
Peter Krempa [Wed, 8 Nov 2023 13:29:36 +0000 (14:29 +0100)]
qemucapabilitiestest: Update capabilities data for 8.2 dev cycle on x86_64

Update to v8.1.0-3111-gad6ef0a42e

Notable changes:
 - migration:
    - multichannel migration added
        - 'channels' array argument of migrate/migrate-incomming added
    - legacy block migration deprecated
        - 'blk', 'inc' arguments of 'migrate' command
        - 'block' migration capability
        - 'block-incremental' migration parameter
    - legacy migration compression deprecated
        - 'compress' migration capability
        - 'compress-level', 'compress-threads', 'compress-wait-thread',
          'decompress-threads' migration paramters
    - migration parameter 'mode' with 'normal' and 'cpr-reboot' options
      added

 - new formats for 'dump-guest-memory'
    - 'dump-raw-lzo', 'kdump-raw-snappy', 'kdump-raw-zlib' added

 - 'block-job-change' command added

 - 'HV_BALLOON_STATUS_REPORT' event and
   'query-hv-balloon-status-report' command added

 - deprecated old i440fx machine types:
    - 'pc-i440fx-2.0', 'pc-i440fx-2.1', 'pc-i440fx-2.2', 'pc-i440fx-2.3'

 - 'sha-ni' and few other ring 0 instruction are now exposed to tcg
   guests

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agoqemuxml2argvtest: Add '8.1.0' variants of 'cpu-host-model*' tests
Peter Krempa [Thu, 9 Nov 2023 14:28:22 +0000 (15:28 +0100)]
qemuxml2argvtest: Add '8.1.0' variants of 'cpu-host-model*' tests

Upcoming test bump will cause some changes thus preserve the existing
state.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agoqemuxml2argvtest: Add complementary 'kvm/tcg' test cases for cpu-host-model*
Peter Krempa [Thu, 9 Nov 2023 14:20:38 +0000 (15:20 +0100)]
qemuxml2argvtest: Add complementary 'kvm/tcg' test cases for cpu-host-model*

CPU host model expansion depends on the CPU data from the capabilities
and can change based on emulation type. Add complementary tests to the
ones we already have to ensure full coverage.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agoqemuxml2argvtest: Rename 'cpu-host-model' tests according to emulation type
Peter Krempa [Thu, 9 Nov 2023 14:15:39 +0000 (15:15 +0100)]
qemuxml2argvtest: Rename 'cpu-host-model' tests according to emulation type

The cpu-host-model.xml test case uses 'kvm' whereas the
fallback/nofallback cases use tcg in the definition. Rename them
accordingly so that the complement cases can be added later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agotests: qemumigparamsdata: Drop deprecated fields
Peter Krempa [Wed, 8 Nov 2023 13:50:10 +0000 (14:50 +0100)]
tests: qemumigparamsdata: Drop deprecated fields

Migration compression parameters 'compress-level', 'compress-threads',
'decompress-threads' were deprecated by qemu. Drop them from the tests.

Note that the migration code automatically checks whether given
capability is supported by qemu and thus we don't need to add any
further code to prepare for the legacy compression to be dropped.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
17 months agoqemumigrationcookiexmltest: Don't crash when parsing of status XML fails
Peter Krempa [Thu, 9 Nov 2023 13:31:43 +0000 (14:31 +0100)]
qemumigrationcookiexmltest: Don't crash when parsing of status XML fails

Some sub-tests dereference 'data->vm' even when it is NULL.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
18 months agosystemd: More tweaks to Description and Documentation lines
Andrea Bolognani [Mon, 6 Nov 2023 18:39:51 +0000 (19:39 +0100)]
systemd: More tweaks to Description and Documentation lines

We recently unified all services and sockets, except a couple
were missed. Finish the job.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpcgen: use proper operators when comparing types
Laine Stump [Fri, 3 Nov 2023 23:40:32 +0000 (19:40 -0400)]
rpcgen: use proper operators when comparing types

flake8 (run on all python scripts as a part of the syntax checks)
version 6.1.0 (on macOS 14) issued many complaints like this on the
new rpcgen python scripts:

[...]libvirt/scripts/rpcgen/rpcgen/lexer.py:57:17: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`

This patch changes all [type] == [type] to use "is" instead of "==",
and similarly to use "is not" instead of "!=".

(flake8 5.03, e.g. on Fedora 38, is just fine with using "==" and "!=",
but python on both likes "is" and "is not")

Fixes: commit v9.9.0-24-g8ec79e5e14
Fixes: commit v9.9.0-22-gca3f025011
Fixes: commit v9.9.0-21-g031efb691f
Fixes: commit v9.9.0-20-g8c8b97685b
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpm: Add libxml2 BuildRequires for xmllint
Andrea Bolognani [Thu, 2 Nov 2023 15:48:03 +0000 (16:48 +0100)]
rpm: Add libxml2 BuildRequires for xmllint

It's already been dragged in by the -devel package, but since
we use the command line tool directly as part of our build
process it's more correct to explicitly depend on the runtime
package.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpm: Explain a couple of BuildRequires
Andrea Bolognani [Thu, 2 Nov 2023 15:33:15 +0000 (16:33 +0100)]
rpm: Explain a couple of BuildRequires

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpm: Rename module-init-tools -> kmod
Andrea Bolognani [Thu, 2 Nov 2023 15:35:59 +0000 (16:35 +0100)]
rpm: Rename module-init-tools -> kmod

The old package name is only kept around for compatibility
reasons.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpm: Explicitly enable NLS support
Andrea Bolognani [Thu, 2 Nov 2023 16:30:06 +0000 (17:30 +0100)]
rpm: Explicitly enable NLS support

We want it both for native builds and MinGW ones.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpm: Disable expensive tests for MinGW builds
Andrea Bolognani [Thu, 2 Nov 2023 15:15:50 +0000 (16:15 +0100)]
rpm: Disable expensive tests for MinGW builds

Tests are disabled so this combination never made any sense,
but with recent changes it has turned into a build failure.

Fixes: 8ce0decc372051d616018f57ae268e2f03082eec
Reported-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agoci: Drop macOS 12
Andrea Bolognani [Mon, 6 Nov 2023 10:36:40 +0000 (11:36 +0100)]
ci: Drop macOS 12

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agoci: Add macOS 14
Andrea Bolognani [Mon, 6 Nov 2023 10:36:15 +0000 (11:36 +0100)]
ci: Add macOS 14

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agoci: Add macOS 13
Andrea Bolognani [Mon, 6 Nov 2023 10:35:40 +0000 (11:35 +0100)]
ci: Add macOS 13

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agoci: Drop rpcgen override from macOS $PATH
Andrea Bolognani [Mon, 6 Nov 2023 10:34:24 +0000 (11:34 +0100)]
ci: Drop rpcgen override from macOS $PATH

We no longer use rpcgen.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agoci: Update generated files
Andrea Bolognani [Mon, 6 Nov 2023 10:32:44 +0000 (11:32 +0100)]
ci: Update generated files

Gain native gettext on MinGW, lose glusterfs on 32-bit
architectures and rpcgen everywhere.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agoTranslated using Weblate (Korean)
김인수 [Wed, 1 Nov 2023 09:40:36 +0000 (10:40 +0100)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10414 of 10414 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>
18 months agoUpdate translation files
Weblate [Wed, 1 Nov 2023 09:40:34 +0000 (10:40 +0100)]
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>
18 months agoTranslated using Weblate (Georgian)
Temuri Doghonadze [Wed, 1 Nov 2023 09:40:26 +0000 (10:40 +0100)]
Translated using Weblate (Georgian)

Currently translated at 4.4% (460 of 10413 strings)

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

Co-authored-by: Temuri Doghonadze <temuri.doghonadze@gmail.com>
Signed-off-by: Temuri Doghonadze <temuri.doghonadze@gmail.com>
18 months agoTranslated using Weblate (Russian)
Sergey A [Wed, 1 Nov 2023 09:40:26 +0000 (10:40 +0100)]
Translated using Weblate (Russian)

Currently translated at 88.4% (9214 of 10414 strings)

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

Translated using Weblate (Russian)

Currently translated at 88.4% (9206 of 10413 strings)

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

Co-authored-by: Sergey A <sw@atrus.ru>
Signed-off-by: "Sergey A." <sw@atrus.ru>
18 months agovirhostmem: Get total memory on macOS properly
Michal Privoznik [Fri, 20 Oct 2023 08:14:39 +0000 (10:14 +0200)]
virhostmem: Get total memory on macOS properly

Problem with HW_PHYSMEM sysctl on 64-bit macOS is that it
returns a 32-bit signed value. Thus it overflows. Switching to
HW_MEMSIZE is recommended as it's of an uint_64 type [1].

1: https://github.com/apple-oss-distributions/xnu/blob/xnu-10002.1.13/bsd/sys/sysctl.h

Reported-by: Jaroslav Suchanek <jsuchane@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agoci: workaround broken opensuse leap 15.5 tirpc
Daniel P. Berrangé [Fri, 3 Nov 2023 13:22:42 +0000 (09:22 -0400)]
ci: workaround broken opensuse leap 15.5 tirpc

Temporarily disable '-Wmissing-include-dirs' becuase the
libtirpc pkg-config file has a bogus include dir. The
headers can fortunately still be found since they are
in the system include dir.

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agoci: drop mipsel on Debian Sid
Daniel P. Berrangé [Fri, 3 Nov 2023 17:55:21 +0000 (13:55 -0400)]
ci: drop mipsel on Debian Sid

This port was discontinued and purged from the archives:

https://lists.debian.org/debian-devel-announce/2023/09/msg00000.html

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agobuild: suppress "ignoring duplicate libraries" warning on macOS
Laine Stump [Fri, 3 Nov 2023 17:07:19 +0000 (13:07 -0400)]
build: suppress "ignoring duplicate libraries" warning on macOS

Xcode 15, which provides the compiler toolchain for building libvirt
on macOS has switched to a new linker that warns about duplicated
"-lblah" options on the ld commandline. In practice this is impossible
to prevent in a large project, and also harmless.

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

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
18 months agoremote: use g_auto for client RPC return parameters
Daniel P. Berrangé [Thu, 22 Dec 2022 16:09:27 +0000 (11:09 -0500)]
remote: use g_auto for client RPC return parameters

Currently some, but not all, methods have a call to the
xdr_free function, for the 'ret' variable. This is done
on methods where there are complex structs containing
allocated memory. In other cases the structs contain
allocated memory, but the pointer is stolen, so xdr_free
is not called. In other cases no allocated memory is
present, so xdr_free.

This is hard to reason about, because the definition of
the struct is not visible in the client stubs.

Switch to use g_auto() for the 'ret' variable, which
means 'xdr_free' is always going to be called. Some
places now need to use g_steal_pointer as a result.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agoadmin: use g_auto for client RPC return parameters
Daniel P. Berrangé [Thu, 22 Dec 2022 16:09:27 +0000 (11:09 -0500)]
admin: use g_auto for client RPC return parameters

Currently some, but not all, methods have a call to the
xdr_free function, for the 'ret' variable. This is done
on methods where there are complex structs containing
allocated memory. In other cases the structs contain
allocated memory, but the pointer is stolen, so xdr_free
is not called. In other cases no allocated memory is
present, so xdr_free.

This is hard to reason about, because the definition of
the struct is not visible in the client stubs.

Switch to use g_auto() for the 'ret' variable, which
means 'xdr_free' is always going to be called. Some
places now need to use g_steal_pointer as a result.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpc: use g_auto for client RPC return parameters
Daniel P. Berrangé [Thu, 22 Dec 2022 16:09:27 +0000 (11:09 -0500)]
rpc: use g_auto for client RPC return parameters

Currently some, but not all, methods have a call to the
xdr_free function, for the 'ret' variable. This is done
on methods where there are complex structs containing
allocated memory. In other cases the structs contain
allocated memory, but the pointer is stolen, so xdr_free
is not called. In other cases no allocated memory is
present, so xdr_free.

This is hard to reason about, because the definition of
the struct is not visible in the client stubs.

Switch to use g_auto() for the 'ret' variable, which
means 'xdr_free' is always going to be called. Some
places now need to use g_steal_pointer as a result.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpcgen: add g_auto function support
Daniel P. Berrangé [Wed, 21 Dec 2022 17:19:46 +0000 (12:19 -0500)]
rpcgen: add g_auto function support

This will eliminate the need to call xdr_free to clear
pointers from data structures.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agobuild: switch over to new rpc generator code
Daniel P. Berrangé [Wed, 14 Dec 2022 11:58:51 +0000 (06:58 -0500)]
build: switch over to new rpc generator code

This replaces use of 'rpcgen' with our new python impl of
the RPC code generator. Since the new impl generates code
that matches our style/coding rules, and does not contain
long standing bugs, we no longer need to post-process the
output.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpcgen: define entrypoint for running new rpcgen impl
Daniel P. Berrangé [Mon, 19 Dec 2022 19:11:33 +0000 (14:11 -0500)]
rpcgen: define entrypoint for running new rpcgen impl

The new program takes the form

  rpcgen [--mode source|header|repr] \
         [--header include] \
         xdr-file output-file

If '--mode' is not given it parses the XDR file but does not
generate anything, which is useful as a syntax check. The
'source' mode gives the '.c' file content, while 'header'
gives the '.h' file content. 'repr' gives a representation
of the abstract syntax tree, mostly useful for debugging
the parser.

If '--header' is given, it is added as a local #include ".."
statement in the output and is valid for either 'header'
or 'source' modes.

Either 'xdr-file' or 'output-file' can be omitted in which
case they default to stdin/stdout respectively.

This rpcgen program will directly include the 'config.h'
header in its output.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpcgen: add test case for XDR serialization
Daniel P. Berrangé [Tue, 31 Jan 2023 18:10:43 +0000 (13:10 -0500)]
rpcgen: add test case for XDR serialization

Test the serialization done by libtirpc, so that when we later
switch to our own code, we can prove wire compatibility.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
18 months agorpcgen: add a C code generator for XDR protocol specs
Daniel P. Berrangé [Mon, 19 Dec 2022 19:08:09 +0000 (14:08 -0500)]
rpcgen: add a C code generator for XDR protocol specs

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

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

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

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

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

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

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

The parsing grammar requirements are detailed in

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

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

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

The syntax requirements are detailed in

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

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

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

The lexical rquirements are detailed in

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

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

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

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

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

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

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

   self.lookahead[skip : skip + 1]

which is a format that 'black' produces.

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

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

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

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

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

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

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

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

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

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

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

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

QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_SKIP_UNMAP is no longer
referenced inside the code.

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

Both thus can be removed.

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

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

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

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

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

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

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

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

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

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

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