]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
20 months agoqemu_snapshot: introduce qemuSnapshotDomainDefUpdateDisk
Pavel Hrdina [Mon, 20 Feb 2023 09:48:40 +0000 (10:48 +0100)]
qemu_snapshot: introduce qemuSnapshotDomainDefUpdateDisk

Extract the code that updates disks in domain definition while creating
external snapshots. We will use it later in the external snapshot revert
code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
20 months agovirDomainSnapshotAlignDisks: Allow overriding user-configured snapshot default
Pavel Hrdina [Wed, 12 Apr 2023 12:54:20 +0000 (14:54 +0200)]
virDomainSnapshotAlignDisks: Allow overriding user-configured snapshot default

This new option will be used by external snapshot revert code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
20 months agosnapshot_conf: introduce <revertDisks> metadata element
Pavel Hrdina [Mon, 20 Feb 2023 10:24:13 +0000 (11:24 +0100)]
snapshot_conf: introduce <revertDisks> metadata element

This new element will hold the new disk overlay created when reverting
to non-leaf snapshot in order to remember the files libvirt created.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
20 months agosnapshot_conf: use alternate domain definition in virDomainSnapshotDefAssignExternalNames
Pavel Hrdina [Wed, 1 Feb 2023 13:23:58 +0000 (14:23 +0100)]
snapshot_conf: use alternate domain definition in virDomainSnapshotDefAssignExternalNames

Commit <ef3f3884a2432958bdd4ea0ce45509d47a91a453> introduced new
argument for virDomainSnapshotAlignDisks() that allows passing alternate
domain definition in case the snapshot parent.dom is NULL.

In case of redefining snapshot it will not hit the part of code that
unconditionally uses parent.dom as there will not be need to generate
default external file names.

It should be still fixed to make it safe. Future external snapshot
revert code will use this to generate default file names and in this
case it would crash.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
20 months agosnapshot_conf: export virDomainSnapshotDiskDefClear
Pavel Hrdina [Mon, 20 Feb 2023 09:46:53 +0000 (10:46 +0100)]
snapshot_conf: export virDomainSnapshotDiskDefClear

We will need to call this function from qemu_snapshot when introducing
external snapshot revert support.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
20 months agolibvirt_private: list virDomainMomentDefPostParse
Pavel Hrdina [Mon, 20 Feb 2023 10:40:19 +0000 (11:40 +0100)]
libvirt_private: list virDomainMomentDefPostParse

We will need to call this function from qemu_snapshot when introducing
external snapshot revert support.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
20 months agoqemuxml2xmltest: Modernize all remaining fake capability tests
Peter Krempa [Tue, 15 Aug 2023 13:45:51 +0000 (15:45 +0200)]
qemuxml2xmltest: Modernize all remaining fake capability tests

Convert all cases using DO_TEST() to use DO_TEST_CAPS_LATEST() and
remove DO_TEST() to prevent further use.

Most of the changes are related to CPU being present in the output XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2xmltest: Modernize all 'net-' tests
Peter Krempa [Thu, 17 Aug 2023 11:16:34 +0000 (13:16 +0200)]
qemuxml2xmltest: Modernize all 'net-' tests

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2argvtest: Modernize 'net-*'
Peter Krempa [Wed, 16 Aug 2023 13:20:37 +0000 (15:20 +0200)]
qemuxml2argvtest: Modernize 'net-*'

Convert all tests using fake capabilities to use DO_TEST_CAPS_LATEST.

Note that rename detection in git didn't work too well here and the
files may not correspond.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2xmltest: Modernize all 'video-*' cases
Peter Krempa [Wed, 16 Aug 2023 12:52:34 +0000 (14:52 +0200)]
qemuxml2xmltest: Modernize all 'video-*' cases

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2argvtest: Moderinze 'video-*' cases
Peter Krempa [Wed, 16 Aug 2023 12:44:35 +0000 (14:44 +0200)]
qemuxml2argvtest: Moderinze 'video-*' cases

Use latest capabilities for all tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemu: capabilities: Retire unused QEMU_CAPS_DEVICE_IVSHMEM
Peter Krempa [Wed, 16 Aug 2023 11:49:24 +0000 (13:49 +0200)]
qemu: capabilities: Retire unused QEMU_CAPS_DEVICE_IVSHMEM

qemu removed the support for the old 'ivshmem' device in 4.0 release.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemu: Retire 'ivshmem' device
Peter Krempa [Wed, 16 Aug 2023 11:07:34 +0000 (13:07 +0200)]
qemu: Retire 'ivshmem' device

The device was removed in qemu-4.0 and is superseded by 'ivshmem-plain'
and 'ivshmem-doorbell'.

Always report error when the old version is used and drop the irrelevant
tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2(argv|xml)test: Modernize 'shmem' test cases
Peter Krempa [Wed, 16 Aug 2023 11:22:59 +0000 (13:22 +0200)]
qemuxml2(argv|xml)test: Modernize 'shmem' test cases

Upgrade the relevant test cases to use latest capabilities. Note that
the 'shmem' (ivshmem) device is no longer supported and will be dropped
later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2(argv|xml)test: Modernize 'fd-memory*' test cases
Peter Krempa [Tue, 15 Aug 2023 14:55:10 +0000 (16:55 +0200)]
qemuxml2(argv|xml)test: Modernize 'fd-memory*' test cases

Use latest real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuValidateDomainVCpuTopology: Always validate vcpu count against topology
Peter Krempa [Tue, 15 Aug 2023 15:17:14 +0000 (17:17 +0200)]
qemuValidateDomainVCpuTopology: Always validate vcpu count against topology

Historically we've used QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS as witness
that the topology must cover the maximum number ov vcpus. qemu started
to enforce this in qemu-2.5, thus we can now always do the check.

This change also requires aligning the topology in certain test files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2(argv|xml)test: Sanitize testing of default video type on x86_64
Peter Krempa [Tue, 15 Aug 2023 14:46:05 +0000 (16:46 +0200)]
qemuxml2(argv|xml)test: Sanitize testing of default video type on x86_64

Use real capabilities and remove the redundant test case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2(argv|xml)test: Modernize 'graphics-dbus*' tests
Peter Krempa [Tue, 15 Aug 2023 14:30:21 +0000 (16:30 +0200)]
qemuxml2(argv|xml)test: Modernize 'graphics-dbus*' tests

Use latest caps for this rather recent graphics protocol.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2xmltest: Convert rest of 'DO_TEST_NOCAPS' cases to 'DO_TEST_CAPS_LATEST'
Peter Krempa [Tue, 15 Aug 2023 11:27:41 +0000 (13:27 +0200)]
qemuxml2xmltest: Convert rest of 'DO_TEST_NOCAPS' cases to 'DO_TEST_CAPS_LATEST'

Finish the conversion of cases which didn't need any special
capabilities to use real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2xmltest: Use real caps for 'vxhs' disk tests
Peter Krempa [Tue, 15 Aug 2023 11:18:33 +0000 (13:18 +0200)]
qemuxml2xmltest: Use real caps for 'vxhs' disk tests

Version-lock the test to qemu-5.0.0 as it's the latest qemu that
supports 'vxhs' and thus the test can't use 'latest'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agovirschematest: Improve detection of 'invalid' XMLs
Peter Krempa [Tue, 15 Aug 2023 12:20:58 +0000 (14:20 +0200)]
virschematest: Improve detection of 'invalid' XMLs

The output files from 'qemuxml2argvtest' may have the real capability
suffix e.g. 'pci-rom-disabled-invalid.x86_64-latest.xml' which would not
be detected as being invalid and thus causing a test failure.

Change the logic to find '-invalid.' so that we can properly use
'virschematest' with test cases using real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2xmloutdata: Workaround wrong detection of 'disk-cdrom-empty-network-invalid...
Peter Krempa [Tue, 15 Aug 2023 12:43:20 +0000 (14:43 +0200)]
qemuxml2xmloutdata: Workaround wrong detection of 'disk-cdrom-empty-network-invalid' in virschematest

The 'disk-cdrom-empty-network-invalid' is a special case were the input
XML is invalid according to the schema, but after processing a valid XML
is produced.

This corner case doesn't play well with 'virschematest' which uses the
file suffix to determine whether the file is invalid.

Upcoming patch will change the 'virschematest' condition, which would
start detecting this XML as invalid.

Use the '-active'/'-inactive' suffix for the file, which is possible
with qemuxml2xmltest so that an upcoming patch will not cause test
failure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2xmltest: Modernize all 'DO_TEST_NOCAPS' tests
Peter Krempa [Fri, 11 Aug 2023 14:40:22 +0000 (16:40 +0200)]
qemuxml2xmltest: Modernize all 'DO_TEST_NOCAPS' tests

Convert all tests using the 'DO_TEST_NOCAPS' "fake" capability
invocation to use DO_TEST_CAPS_LATEST and remove the DO_TEST_NOCAPS
macro to prevent further use.

Most of the output file changes are related to default USB controller
type and the CPU becoming defined in the XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agotestutilsqemu: Drop fake data for VIR_ARCH_I686
Peter Krempa [Mon, 3 Apr 2023 11:24:41 +0000 (13:24 +0200)]
testutilsqemu: Drop fake data for VIR_ARCH_I686

There are no more tests depending on '/usr/bin/qemu-system-i386' thus we
don't have to carry the data any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2argvdata: Convert 'cpu' test cases to use 'x86_64'
Peter Krempa [Tue, 15 Aug 2023 08:49:39 +0000 (10:49 +0200)]
qemuxml2argvdata: Convert 'cpu' test cases to use 'x86_64'

Convert the rest of the files using 'qemu-system-i386' to
'qemu-system-x86_64'. The 'cpu*' tests are done separately to emphasise
that there's no change in the output.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2(argv|xml)test: Convert certain tests to DO_TEST_CAPS_LATEST
Peter Krempa [Mon, 14 Aug 2023 12:28:48 +0000 (14:28 +0200)]
qemuxml2(argv|xml)test: Convert certain tests to DO_TEST_CAPS_LATEST

Convert tests which use DO_TEST_NOCAPS in both tests and the
qemuxml2xml variant has a symlink back to the qemuxml2argv input file.

This is done to separate the conversion before a patch converts all
DO_TEST_NOCAPS variants in qemuxml2xmltest to use real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2argvdata: Replace 'qemu-system-i386' by 'qemu-system-x86_64' in most test...
Peter Krempa [Thu, 10 Aug 2023 14:00:50 +0000 (16:00 +0200)]
qemuxml2argvdata: Replace 'qemu-system-i386' by 'qemu-system-x86_64' in most test files

Replace the emulator and architecture to x86_64, for all non-cpu related
test cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2(argv|xml)test: Modernize 'net-many-models' case
Peter Krempa [Tue, 15 Aug 2023 10:21:07 +0000 (12:21 +0200)]
qemuxml2(argv|xml)test: Modernize 'net-many-models' case

Use real latest capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoqemuxml2argvtest: Drop 'master-key' test case
Peter Krempa [Thu, 10 Aug 2023 13:55:30 +0000 (15:55 +0200)]
qemuxml2argvtest: Drop 'master-key' test case

At this point we setup the master key with all VMs, so this specific
test case no longer makes sense.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoci: lcitool: Maintain project package deps lists here
Erik Skultety [Mon, 21 Aug 2023 09:42:36 +0000 (11:42 +0200)]
ci: lcitool: Maintain project package deps lists here

Each respective project that lcitool knows about and currently
maintains its list of package dependencies knows best what packages
they actually depend on. If a new dependency is currently needed, first
a change in lcitool is necessary before GitLab jobs and containers can
be updated. Provided a mapping already exists in lcitool (which can
quickly be added as an override via mappings.yml temporarily) we speed
up the whole CI update process by one step.
This patch adds all libvirt deps lists lcitool currently maintains for
libvirt.

Note that as with any overrides (since commit f199dd50) lcitool must be
invoked as '$ lcitool -d/--data-dir ci/lcitool ...'

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
20 months agoNEWS: Mention fixes to firmware selection
Andrea Bolognani [Thu, 10 Aug 2023 15:55:26 +0000 (17:55 +0200)]
NEWS: Mention fixes to firmware selection

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotests: Reintroduce firmware-auto-efi-format-mismatch
Andrea Bolognani [Thu, 3 Aug 2023 13:22:10 +0000 (15:22 +0200)]
tests: Reintroduce firmware-auto-efi-format-mismatch

Since the previous version of this negative test now passes,
create a new version that still triggers the intended failure.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotests: Rename firmware-auto-efi-format-loader-qcow2-nvram-path
Andrea Bolognani [Thu, 3 Aug 2023 13:19:59 +0000 (15:19 +0200)]
tests: Rename firmware-auto-efi-format-loader-qcow2-nvram-path

Now that, after the recent changes, the test passes, its old
name is no longer accurate.

While at it, enable the xml2xml part for it as well.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agoconf: Don't default to raw format for loader/NVRAM
Andrea Bolognani [Tue, 16 May 2023 17:50:50 +0000 (19:50 +0200)]
conf: Don't default to raw format for loader/NVRAM

Due to the way the information is stored by the XML parser, we've
had this quirk where specifying any information about the loader
or NVRAM would implicitly set its format to raw. That is,

  <nvram>/path/to/guest_VARS.fd</nvram>

would effectively be interpreted as

  <nvram format='raw'>/path/to/guest_VARS.fd</nvram>

forcing the use of raw format firmware even when qcow2 format
would normally be preferred based on the ordering of firmware
descriptors. This behavior can be worked around in a number of
ways, but it's fairly unintuitive.

In order to remove this quirk, move the selection of the default
firmware format from the parser down to the individual drivers.

Most drivers only support raw firmware images, so they can
unconditionally set the format early and be done with it; the
QEMU driver, however, supports multiple formats and so in that
case we want this default to be applied as late as possible,
when we have already ruled out the possibility of using qcow2
formatted firmware images.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agoqemu: Match NVRAM template extension for new domains
Andrea Bolognani [Tue, 30 May 2023 16:24:40 +0000 (18:24 +0200)]
qemu: Match NVRAM template extension for new domains

Keep things consistent by using the same file extension for the
generated NVRAM path as the NVRAM template.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agoqemu: Filter firmware based on loader.readonly
Andrea Bolognani [Tue, 30 May 2023 16:01:58 +0000 (18:01 +0200)]
qemu: Filter firmware based on loader.readonly

If the user included loader.readonly=no in the domain XML, we
should not pick a firmware build that expects to work with
loader.readonly=yes.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agoqemu: Generate NVRAM path in more cases
Andrea Bolognani [Fri, 26 May 2023 12:40:02 +0000 (14:40 +0200)]
qemu: Generate NVRAM path in more cases

Right now, we only generate it after finding a matching entry
either among firmware descriptors or in the legacy firmware
list.

Even if the domain is configured to use a custom firmware build
that we know nothing about, however, we should still automatically
generate the NVRAM path instead of requiring the user to provide
it manually.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agoqemu: Don't overwrite NVRAM template for legacy firmware
Andrea Bolognani [Fri, 26 May 2023 17:59:06 +0000 (19:59 +0200)]
qemu: Don't overwrite NVRAM template for legacy firmware

Just because we have found a matching entry, it doesn't mean
that we should discard the information explicitly provided in
the domain XML.

https://bugzilla.redhat.com/show_bug.cgi?id=2196178
https://gitlab.com/libvirt/libvirt/-/issues/500

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotests: Include microvm in firmwaretest
Andrea Bolognani [Thu, 18 May 2023 12:57:07 +0000 (14:57 +0200)]
tests: Include microvm in firmwaretest

libvirt doesn't really support the microvm machine type, but
it can parse the firmware descriptor just fine.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotests: Drop tags from BIOS firmware descriptor
Andrea Bolognani [Mon, 31 Jul 2023 15:05:58 +0000 (17:05 +0200)]
tests: Drop tags from BIOS firmware descriptor

They aren't used for anything.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotests: Update firmware descriptor files
Andrea Bolognani [Thu, 11 May 2023 16:29:17 +0000 (18:29 +0200)]
tests: Update firmware descriptor files

These are imported from Fedora 38's edk2 package.

The files that are being replaced date back to RHEL 7 and no
longer represent what libvirt is likely to encounter on an
actual production system.

Notably, the paths have all changed, with both x86_64 and
aarch64 builds now living under /usr/share/edk2 and the AAVMF
name being having been phased out.

Additionally, the 4MB qcow2 format builds have been introduced
on x86_64 and given high priority, effectively making qcow2
the default format across architectures.

The impact of these changes on the test suite is, predictably,
quite severe.

For the cases where paths to firmware files were explicitly
provided as part of the input, they have been adjusted so that
the modern paths are used instead of the legacy ones. Other
than that, input files have been left untouched.

The following expected changes can be seen in output files:

  * where qcow2 firmware was used on x86_64, Secure Boot
    support is now enabled;

  * all ABI_UPDATE test cases for x86_64 now use qcow2
    formatted firmware;

  * test cases where legacy paths were manually provided
    no longer get additional information about the firmware
    added to the output XML.

Some of the changes described above highlight why, in order
to guarantee a stable guest ABI over time and regardless of
changes to the host's configuration, it was necessary to move
firmware selection from VM startup time to VM creation time.

In a few cases, updating the firmware descriptors changes the
behavior in a way that's undesired and uncovers latent bugs
in libvirt:

  * firmware-manual-efi-secboot-legacy-paths ends up with
    Secure Boot disabled, despite the input XML specifically
    requesting it to be enabled;

  * firmware-manual-efi-rw-modern-paths loses the
    loader.readonly=no part of the configuration and starts
    using an NVRAM file;

  * firmware-manual-efi-nvram-template-nonstandard starts
    failing altogether with a fairly obscure error message.

We're going to address all these issues with upcoming changes.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotests: Add more tests for firmware selection
Andrea Bolognani [Fri, 26 May 2023 16:19:24 +0000 (18:19 +0200)]
tests: Add more tests for firmware selection

Most of these are just additional coverage, but a few demonstrate
bugs in libvirt:

  * firmware-manual-efi-nvram-template-nonstandard sees the NVRAM
    template path, which was explicitly provided in the XML,
    being overridden by the firmware selection machinery;

  * firmware-auto-efi-rw* and firmware-manual-efi-rw-legacy-paths
    lose the loader.readonly=no setting and thus behave
    differently than requested;

  * firmware-manual-efi-loader-path-nonstandard fails because an
    NVRAM path doesn't get generated.

We're going to address all these issues with upcoming changes.

Note that the firmware-auto-efi-nvram-template-nonstandard
failure is expected: firmware autoselection has been enabled, but
the NVRAM template points to a custom path that's not mentioned
in any of the firmware descriptors and so it can't succeed.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotests: Add some more DO_TEST*ABI_UPDATE* macros
Andrea Bolognani [Tue, 16 May 2023 14:50:37 +0000 (16:50 +0200)]
tests: Add some more DO_TEST*ABI_UPDATE* macros

These are going to be useful later.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agoqemu: Fix lookup against stateless/combined pflash
Andrea Bolognani [Fri, 26 May 2023 15:47:42 +0000 (17:47 +0200)]
qemu: Fix lookup against stateless/combined pflash

Just like the more common split builds, these are of type
QEMU_FIRMWARE_DEVICE_FLASH; however, they have no associated
NVRAM template, so we can't access the corresponding structure
member unconditionally or we'll trigger a crash.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agoqemu: Fix return value for qemuFirmwareFillDomainLegacy()
Andrea Bolognani [Wed, 2 Aug 2023 15:18:32 +0000 (17:18 +0200)]
qemu: Fix return value for qemuFirmwareFillDomainLegacy()

The documentation states that, just like the Modern() variant,
this function should return 1 if a match wasn't found. It
currently doesn't do that, and returns 0 instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotests: Rename firmware-auto-efi-nvram-path
Andrea Bolognani [Fri, 26 May 2023 16:16:24 +0000 (18:16 +0200)]
tests: Rename firmware-auto-efi-nvram-path

The new name better describes the test scenario and will fit
better with the additional tests that we're about to introduce.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotests: Turn abi-update.xml into a symlink
Andrea Bolognani [Tue, 16 May 2023 14:55:41 +0000 (16:55 +0200)]
tests: Turn abi-update.xml into a symlink

Since the idea behind introducing the abi-update variant of
a test is showing that libvirt behaves differently based on
whether the configuration is for a newly-defined domain or an
existing one, we don't want the input files to ever go out of
sync.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotests: Consistently use /path/to/guest_VARS.fd
Andrea Bolognani [Mon, 15 May 2023 17:04:12 +0000 (19:04 +0200)]
tests: Consistently use /path/to/guest_VARS.fd

That's what we already use in almost all cases.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotests: Use virt-4.0 machine type for aarch64
Andrea Bolognani [Mon, 15 May 2023 16:39:18 +0000 (18:39 +0200)]
tests: Use virt-4.0 machine type for aarch64

Using the unversioned machine type means that firmware
descriptors can't be used to discover additional information
about the chosen firmware build.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotests: Switch to firmware autoselection for hvf
Andrea Bolognani [Mon, 15 May 2023 16:42:27 +0000 (18:42 +0200)]
tests: Switch to firmware autoselection for hvf

Firmware selection is not relevant to these tests, so adopt
the most convenient approach.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotests: Use DO_TEST_CAPS_*_ABI_UPDATE() for ppc64
Andrea Bolognani [Tue, 30 May 2023 15:48:58 +0000 (17:48 +0200)]
tests: Use DO_TEST_CAPS_*_ABI_UPDATE() for ppc64

We have a number of tests that can benefit from this macro
instead of open-coding it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agotest: qemu: Update qemu-8.1 test data on x86_64
Peter Krempa [Thu, 10 Aug 2023 11:33:53 +0000 (13:33 +0200)]
test: qemu: Update qemu-8.1 test data on x86_64

Update to v8.1.0-rc4

Notable changes:
 - 'dirty-limit' migration feature added
    - 'vcpu-dirty-limit', 'x-vcpu-dirty-limit-period' parameters added
    - 'dirty-limit-ring-full-time', 'dirty-limit-throttle-time-per-round' statistics added
 - migration statistic of number of skipped zero pages is now deprecated

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
20 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Thu, 17 Aug 2023 21:21:13 +0000 (23:21 +0200)]
Translated using Weblate (Swedish)

Currently translated at 52.2% (5426 of 10393 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>
20 months agoqemu_domain: Drop unused variables from qemuDomainChrDefDropDefaultPath()
Michal Privoznik [Thu, 17 Aug 2023 15:43:54 +0000 (17:43 +0200)]
qemu_domain: Drop unused variables from qemuDomainChrDefDropDefaultPath()

In mu previous commits I've moved internals of
qemuDomainChrDefDropDefaultPath() into a separate function
(qemuDomainChrMatchDefaultPath()) but forgot to remove @buf and
@regexp variables which are now unused.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
20 months agoqemu: Move channelTargetDir into stateDir
Michal Privoznik [Thu, 20 Apr 2023 08:16:43 +0000 (10:16 +0200)]
qemu: Move channelTargetDir into stateDir

For historical reasons (i.e. unknown reason) we put channel
sockets into a path derived from cfg->libDir which is a path that
survives host reboots (e.g. /var/lib/libvirt/...). This is not
necessary and in fact for session daemon creates a longer prefix:

  XDG_CONFIG_HOME -> /home/user/.config
  XDG_RUNTIME_DIR -> /run/user/1000

Worse, if host is rebooted suddenly (e.g. due to power loss) then
we leave files behind and nobody will ever remove them.

Therefore, place the channel target dir into state dir.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2173980
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
20 months agoqemu: Generate shorter channel target paths
Michal Privoznik [Tue, 18 Apr 2023 15:34:12 +0000 (17:34 +0200)]
qemu: Generate shorter channel target paths

A <channel/> device is basically an UNIX socket into guest.
Whatever is sent from the host, appears in the guest and vice
versa. But because of that, the length of the path to the socket
is important (underscored by fact that we derive the path from
domain short name). But there are still cases where we might not
fit into UNIX_PATH_MAX limit (usually 108 characters), because
the path is derived also from other variables, e.g.
XDG_CONFIG_HOME for session domains.

There are two components though, that are needless: "/target/"
and "domain-" prefix. Drop them. This is safe to do, because
running domains have their path saved in status XML and even
though paths are dropped on migration, they are not part of guest
ABI and thus we are free to change them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
20 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Wed, 16 Aug 2023 15:21:14 +0000 (17:21 +0200)]
Translated using Weblate (Swedish)

Currently translated at 51.8% (5386 of 10393 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>
20 months agoci: Udate FreeBSD-13 image with lcitool manifest
Erik Skultety [Wed, 16 Aug 2023 08:39:48 +0000 (10:39 +0200)]
ci: Udate FreeBSD-13 image with lcitool manifest

Now that we have a local OS target override for lcitool in place, we
can bump the cirrus FreeBSD image version in GitLab CI.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agoci: Introduce a new 'lcitool' data directory
Erik Skultety [Wed, 16 Aug 2023 08:21:33 +0000 (10:21 +0200)]
ci: Introduce a new 'lcitool' data directory

We've reached a point in lcitool where we can't steer its development
based solely on libvirt's needs IOW there will be times where a local
override of value (e.g. package mapping) will be necessary - an example
of this would be QEMU.
In case of this particular patch we need to add an override for the
cirrus FreeBSD 13 image we request in our CI to fix:

    /usr/local/lib/libtasn1.so.6: Undefined symbol "strverscmp@FBSD_1.7"

The reason why we can't/should not make the fix in upstream lcitool
just yet is that we store a libosinfo ID in lcitool's OS target YAML
configs and at the time of writing this patch libosinfo does not have
a corresponding entry/ID for FreeBSD 13.2 so we have to stick with 13.1
in lcitool until they do so.

For the time being, the fix can easily be done on libvirt side as does
this patch.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agoci: Move Debian-11 workloads to Debian-12
Erik Skultety [Fri, 11 Aug 2023 09:46:20 +0000 (11:46 +0200)]
ci: Move Debian-11 workloads to Debian-12

Let's move our Debian CI workloads to Debian-12 since it's the latest
release and mark Debian-11 jobs as optional.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agoci: Add Debian-12 target
Erik Skultety [Fri, 11 Aug 2023 09:37:46 +0000 (11:37 +0200)]
ci: Add Debian-12 target

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
20 months agoTranslated using Weblate (Korean)
김인수 [Tue, 8 Aug 2023 05:41:35 +0000 (07:41 +0200)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10393 of 10393 strings)

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

Translated using Weblate (Korean)

Currently translated at 100.0% (10393 of 10393 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>
20 months agoci: build.sh: Join MESON_ARGS and MESON_OPTS
Erik Skultety [Wed, 1 Feb 2023 14:22:59 +0000 (15:22 +0100)]
ci: build.sh: Join MESON_ARGS and MESON_OPTS

It is quite confusing seeing these two in a call like this one:
    $ meson build $MESON_OPTS $MESON_ARGS

One has to ask 'how are they different' and 'shouldn't these be
merged'. In fact, these variables hold very different things and we
should make it more obvious. The problem is that renaming MESON_OPTS to
something more meaningful, like 'MESON_CROSS_OPTS' which is what
MESON_OPTS really does would require changes to lcitool and would
impact Dockerfile generation which in turn might have an impact on
other projects which rely on this lcitool functionality which is risky.

Instead, provide a docstring for the former to supplement the latter
and join the two variables in a single one MESON_ARGS which is then
passed to meson's command line so it's a little less confusing.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
20 months agoci: build.sh: Drop the CI prefix from the CI_{MESON,NINJA}_ARGS vars
Erik Skultety [Tue, 31 Jan 2023 17:06:53 +0000 (18:06 +0100)]
ci: build.sh: Drop the CI prefix from the CI_{MESON,NINJA}_ARGS vars

Although it is currently consistent with the other variables we define
when running ci in a local container environment, it isn't consistent
with the variable naming we use in GitLab recipes. Since the idea is
to unite the two, we're likely going to drop a few other variables from
the local env configuration anyway, hence this renaming.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
20 months agoci: build.sh: Always assume -Dsystem=true
Erik Skultety [Thu, 2 Feb 2023 15:40:37 +0000 (16:40 +0100)]
ci: build.sh: Always assume -Dsystem=true

There's no harm in always building in system mode, i.e. setting the
right paths.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
20 months agoci: build.sh: Use 'meson setup' explicitly
Erik Skultety [Wed, 25 Jan 2023 12:22:49 +0000 (13:22 +0100)]
ci: build.sh: Use 'meson setup' explicitly

Even though 'setup' is assumed when no other command is given, we're
being explicit in our GitLab recipes, so do the same for the local
build.sh script too.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
20 months agoci: build.sh: Drop the commentary about CI_BUILD_SCRIPT
Erik Skultety [Wed, 1 Feb 2023 14:33:47 +0000 (15:33 +0100)]
ci: build.sh: Drop the commentary about CI_BUILD_SCRIPT

build.sh is not the place where this should be mentioned as the
official entrypoint for this script locally is ci/helper which can
download the right image from our upstream CI registry. Since the idea
is to ultimately drop the usage of a Makefile for the local executions,
this patch doesn't provide an alternative place for the comment in
question as the functionality is going to be altered substantially in
the future.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
20 months agogitlab-ci.yml: Use $HOME for rpmbuild's topdir instead of PWD
Erik Skultety [Wed, 1 Feb 2023 17:02:01 +0000 (18:02 +0100)]
gitlab-ci.yml: Use $HOME for rpmbuild's topdir instead of PWD

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
20 months agogitlab-ci.yml: Replace all explicit calls to ninja with meson commands
Erik Skultety [Fri, 27 Jan 2023 10:12:06 +0000 (11:12 +0100)]
gitlab-ci.yml: Replace all explicit calls to ninja with meson commands

This is continuation of what commit b56e2be68e3 started. If we stick to
only calling meson commands directly, we can achieve much better
consistency in passing arguments to meson especially if we unify the
recipes run in gitlab CI and what we can currently run locally in
containers using docker/podman.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
20 months agodocs: index: Add a quick link to Submitting patches
Erik Skultety [Tue, 4 Jul 2023 08:06:18 +0000 (10:06 +0200)]
docs: index: Add a quick link to Submitting patches

We still get MRs in Gitlab from individual contributors on a regular
basis which in some ways just makes maintainer's or reviewer's life
just a bit more complicated. This ultimately means our guidelines are
probably not visible enough on the main page
(or some people wouldn't read them anyway). While this patch can't make
the problem go away, it can at least attempt to mitigate it by creating
a quick link to the 'hacking' page, skipping a lot of TL;DR contents
in contributing.rst which we link from the main page.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
20 months agoci: integration: Drop the Fedora 35 check
Erik Skultety [Tue, 18 Jul 2023 08:09:05 +0000 (10:09 +0200)]
ci: integration: Drop the Fedora 35 check

We're already past Fedora 35 and so all new fedora's default to
modular daemon setup.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
21 months agovirsh: doMigrate: Require --copy-storage-(all|inc) with --migrate-disks
Peter Krempa [Wed, 9 Aug 2023 13:14:35 +0000 (15:14 +0200)]
virsh: doMigrate: Require --copy-storage-(all|inc) with --migrate-disks

Users need to enable non-shared-storage migration, otherwise the disks
specified via '--migrate-disks' will be ignored.

Add an error message to inform the users of their wrong config.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agovirsh: doMigrate: Rework virsh option to migration flag conversion
Peter Krempa [Wed, 9 Aug 2023 13:02:04 +0000 (15:02 +0200)]
virsh: doMigrate: Rework virsh option to migration flag conversion

Convert the flags declaratively as in the vast majority of cases it's a
simple binary addition if the flag exists.

In one instance there was also an additional check, which was moved up
after the new code, and the error message was fixed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agoqemuMigrationSrcBeginPhase: Require storage migration when 'migrate_disks' parameter...
Peter Krempa [Wed, 9 Aug 2023 12:18:58 +0000 (14:18 +0200)]
qemuMigrationSrcBeginPhase: Require storage migration when 'migrate_disks' parameter is specified

If a user passes a list of disks to migrate but don't actually use
'VIR_MIGRATE_NON_SHARED_DISK' or 'VIR_MIGRATE_NON_SHARED_INC' flags the
parameter would be simply ignored without informing the user of the
error.

Add a proper error in such case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agoqemuMigrationSrcBeginPhase: Properly report error when non-shared storage migration...
Peter Krempa [Wed, 9 Aug 2023 12:10:14 +0000 (14:10 +0200)]
qemuMigrationSrcBeginPhase: Properly report error when non-shared storage migration is requested over tunnel

When VIR_MIGRATE_TUNNELLED is used without
VIR_MIGRATE_NON_SHARED_DISK/VIR_MIGRATE_NON_SHARED_INC
an error was reported without actually returning failure.

This was caused by a refactor which dropped many error paths.

Fixes: 6111b235224
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agovirStorageBackendLogicalCheckPool: Properly mark empty logical pools as active
Peter Krempa [Tue, 8 Aug 2023 13:53:53 +0000 (15:53 +0200)]
virStorageBackendLogicalCheckPool: Properly mark empty logical pools as active

The '/dev' filesystem convenience directory for a LVM volume group is
not created when the volume group is empty.

The logic in 'virStorageBackendLogicalCheckPool' which is used to see
whether a pool is active was first checking presence of the directory,
which failed for an empty VG.

Since the second step is virStorageBackendLogicalMatchPoolSource which
is checking mapping between configured PVs and the VG, we can simply
rely on the function to also check presence of the pool.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2228223
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
21 months agoconf: fix error message
Анастасия Белова [Mon, 7 Aug 2023 13:37:34 +0000 (16:37 +0300)]
conf: fix error message

In case of invalid placement its value should
be passed as a parameter of virReportError
instead of mode.

Fixes: 93e82727ec ("numatune: Encapsulate numatune configuration in order to unify results")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agolxc_container: Increase stack size for lxcContainerChild()
Michal Privoznik [Fri, 4 Aug 2023 12:56:37 +0000 (14:56 +0200)]
lxc_container: Increase stack size for lxcContainerChild()

When spawning a new container (via clone()) we allocate stack for
lxcContainerChild(). So far, we allocate 4 pages for the stack
and this used to be enough until we started rewriting everything
to glib. With glib we switched to g_strerror() which localizes
errno strings and thus increases stack usage, while the
previously used strerror_r() was more compact.

Fortunately, the solution is easy - just increase how much stack
the child can use (16 pages ought to be enough for anybody).

And while at it, lets use mmap() for allocation which offer some
nice features:

MAP_STACK - align allocation to be suitable for stack (even
            though, currently ignored on Linux),
MAP_GROWSDOWN - kernel guards out of bounds access from child

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/511
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agosrc: fix max file limits in systemd services
Daniel P. Berrangé [Wed, 2 Aug 2023 09:00:22 +0000 (10:00 +0100)]
src: fix max file limits in systemd services

This fixes

  commit 38abf9c34dc481b0dc923bdab446ee623bdc5ab6
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Wed Jun 21 13:22:40 2023 +0100

    src: set max open file limit to match systemd >= 240 defaults

The bug referenced in that commit had suggested to set

  LimitNOFile=512000:1024

on the basis that matches current systemd default behaviour and is
compatible with old systemd. That was good except

 * The setting is LimitNOFILE and these are case sensitive
 * The hard and soft limits were inverted - soft must come
   first and so it would have been ignored even if the
   setting name was correct.
 * The default hard limit is 524288 not 512000

Reported-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
21 months agodaemon: Treat logging of VIR_ERR_MULTIPLE_INTERFACES same as VIR_ERR_NO_INTERFACE
Peter Krempa [Wed, 2 Aug 2023 08:05:57 +0000 (10:05 +0200)]
daemon: Treat logging of VIR_ERR_MULTIPLE_INTERFACES same as VIR_ERR_NO_INTERFACE

When a query for an interface via virInterfaceLookupByMACString finds
multiple interfaces an error is returned. Treat such error with the same
'debug' priority as we treat when the interface was not found to avoid
spamming logs with such configurations.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/514
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agovirLXCProcessReportStartupLogError: Strip trailing newline from error
Peter Krempa [Wed, 2 Aug 2023 07:25:22 +0000 (09:25 +0200)]
virLXCProcessReportStartupLogError: Strip trailing newline from error

Since the error message originates from a log file it contains a
trailing newline. Strip it as all error handling adds it's own newline.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agovirLXCProcessReadLogOutputData: Refill buffer after filtering out noise
Peter Krempa [Wed, 2 Aug 2023 07:20:24 +0000 (09:20 +0200)]
virLXCProcessReadLogOutputData: Refill buffer after filtering out noise

The caller passes in a 1k buffer, which when debug logging is in use is
easily filled with debug messages only. Thus after the first pass which
is common if the controller process already terminated the buffer will
not contain the real error, but rather a truncated debug message,
which will result in an error such as:

  error: internal error: guest failed to start: 2023-08-01 12:58:31.948+0000: 798195: i

instead of the proper error:

 error: internal error: guest failed to start: Failure in libvirt_lxc startup: Failed to create /home/rootfs/.oldroot: Permission denied

To fix the above retry the reading loop if the filtering function made
space in the buffer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agovirLXCControllerSetupUsernsMap: Modify debug logging for clean startup errors
Peter Krempa [Tue, 1 Aug 2023 13:32:16 +0000 (15:32 +0200)]
virLXCControllerSetupUsernsMap: Modify debug logging for clean startup errors

Avoid logging multiline debug logs so that the function which attempts
to extract a non-debug log error message can work properly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agolib: Prefer sizeof(variable) instead of sizeof(type) in memset
Michal Privoznik [Thu, 3 Aug 2023 08:25:43 +0000 (10:25 +0200)]
lib: Prefer sizeof(variable) instead of sizeof(type) in memset

If one of previous commits taught us something, it's that:
sizeof(variable) and sizeof(type) are not the same. Especially
because for live enough code the type might change (e.g. as we
use autoptr more). And since we don't get any warnings when an
incorrect length is passed to memset() it is easy to mess up. But
with sizeof(variable) instead, it's not as easy. Therefore,
switch to using memset(variable, 0, sizeof(*variable)), or its
alternatives, depending on level of pointers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agolib: Finish using struct zero initializer manually
Michal Privoznik [Thu, 3 Aug 2023 09:48:30 +0000 (11:48 +0200)]
lib: Finish using struct zero initializer manually

There are some cases left after previous commit which were not
picked up by coccinelle. Mostly, becuase the spatch was not
generic enough. We are left with cases like: two variables
declared on one line, a variable declared in #ifdef-s (there are
notoriously difficult for coccinelle), arrays, macro definitions,
etc.

Finish what coccinelle started, by hand.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agolib: use struct zero initializer instead of memset
Michal Privoznik [Wed, 2 Aug 2023 08:09:52 +0000 (10:09 +0200)]
lib: use struct zero initializer instead of memset

This is a more concise approach and guarantees there is
no time window where the struct is uninitialized.

Generated using the following semantic patch:

  @@
  type T;
  identifier X;
  @@
  -  T X;
  +  T X = { 0 };
     ... when exists
  (
  -  memset(&X, 0, sizeof(X));
  |
  -  memset(&X, 0, sizeof(T));
  )

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agovirnetdaemon.c: Use struct zero initializer instead of memset
Michal Privoznik [Thu, 3 Aug 2023 07:45:14 +0000 (09:45 +0200)]
virnetdaemon.c: Use struct zero initializer instead of memset

Ideally, these would be fixed by coccinelle (see next commit),
but because of various reasons they aren't. Fix them manually.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agovirnetclient: Update comment about memset()
Michal Privoznik [Thu, 3 Aug 2023 09:48:57 +0000 (11:48 +0200)]
virnetclient: Update comment about memset()

Instead of suggesting to zero structs out using memset() we
should suggest initializing structs with zero initializer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agovirnetlink: Drop unused variable from virNetlinkCommand()
Michal Privoznik [Thu, 3 Aug 2023 08:43:13 +0000 (10:43 +0200)]
virnetlink: Drop unused variable from virNetlinkCommand()

The fds variable inside of virNetlinkCommand() is not used
really. It's passed to memset() (hence compilers do not
complain), but that's about it. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agovirfirewalld: Drop useless memset() in virFirewallDApplyRule()
Michal Privoznik [Thu, 3 Aug 2023 08:30:12 +0000 (10:30 +0200)]
virfirewalld: Drop useless memset() in virFirewallDApplyRule()

This is a residue of v6.8.0-rc1~100. The error variable inside of
virFirewallDApplyRule() is already initialized to NULL. There's
no need to memset() it to zero again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agoremote_driver: Drop explicit memset(&sargs) in remoteAuthSASL()
Michal Privoznik [Thu, 3 Aug 2023 07:39:03 +0000 (09:39 +0200)]
remote_driver: Drop explicit memset(&sargs) in remoteAuthSASL()

Inside of remoteAuthSASL() the sargs variable is already
initialized to zero during declaration. There's no need to
memset() it again as it's unused in between it's declaration and
said memset().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agoqemu: Don't reuse variable in processSerialChangedEvent()
Michal Privoznik [Thu, 3 Aug 2023 06:52:57 +0000 (08:52 +0200)]
qemu: Don't reuse variable in processSerialChangedEvent()

When a VSERPORT_CHANGE event is processed, we firstly do a little
detour and try to detect whether the event is coming from guest
agent. If so, we notify threads that are currently talking to the
agent about this fact. Then we proceed with usual event
processing (BeginJob(), update domain def, emit event, and so
on).

In both cases we use the same @dev variable to refer to domain
device. While this works, it will make writing semantic patch
unnecessary harder (see next commit(s)). Therefore, introduce a
separate variable for the detour code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agoDecrease scope of some variables
Michal Privoznik [Wed, 2 Aug 2023 13:30:04 +0000 (15:30 +0200)]
Decrease scope of some variables

There are couple of variables that are declared at function
beginning but then used solely within a block (either for() loop
or if() statement). And just before their use they are zeroed
explicitly using memset(). Decrease their scope, use struct zero
initializer and drop explicit memset().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agovirt-aa-helper: Use struct zero initializer instead of memset
Michal Privoznik [Wed, 2 Aug 2023 13:42:31 +0000 (15:42 +0200)]
virt-aa-helper: Use struct zero initializer instead of memset

This is similar to the previous commit, except this is for a
different type (vahControl) and also fixes the case where _ctl is
passed not initialized to vah_error() (via ctl pointer so that's
probably why compilers don't complain).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agotools: Fix vshControl declaration and initialization
Michal Privoznik [Wed, 2 Aug 2023 12:57:44 +0000 (14:57 +0200)]
tools: Fix vshControl declaration and initialization

Both virsh and virt-admin have vshControl typed variables and
also pointers to these variables. In both cases these are
declared on a single line. Do the following:

  1) break declaration into two lines,
  2) use struct zero initializer for vshControl and
     virshControl/vshAdmControl structs,
  3) drop explicit memset(.., 0, ...) ;

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
21 months agoqemu: don't add --mac-addr option to passt commandline
Laine Stump [Thu, 13 Jul 2023 15:51:28 +0000 (11:51 -0400)]
qemu: don't add --mac-addr option to passt commandline

When I implemented passt support in libvirt, I saw the --mac-addr
option on the passt commandline, immediately assumed that this was
used for setting the guest interface's mac address somewhere within
passt, and read no further. As a result, "--mac-addr" is always added
to the passt commandline, specifying the setting from <mac
addr='blah'/> in the guest's interface config.

But as pointed out in this bugzilla comment:

https://bugzilla.redhat.com/2184967#c8

That is *not at all* what passt's --mac-addr option does. Instead, it
is used to force the *remote* mac address for incoming traffic to a
specific value. So setting --mac-addr results in all traffic on the
interface having the same (the guest's) mac address for both source
and destination in all traffic. Surprisingly, this still works, so
nobody noticed it during testing.

The proper thing is to not specify any mac address to passt - the
remote MAC addresses can and should remain untouched, and the local
MAC address will end up being known to passt just by the guest sending
out packets with that MAC address.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
21 months agoRevert "qemu_passt: Precreate passt logfile"
Michal Privoznik [Tue, 1 Aug 2023 14:20:58 +0000 (16:20 +0200)]
Revert "qemu_passt: Precreate passt logfile"

This reverts commit 8511b96a319836700b4829816cdae27c3630060d.

Turns out, we need to do a bit more than just plain
qemuSecurityDomainSetPathLabel() which sets svirt_image_t. Passt
has its own SELinux policy and as a part of that they invent
passt_log_t for log files. Right now, I don't know how libvirt
could query that and even if I did, passt SELinux policy would
need to permit relabelling from svirt_t to passt_log_t, which it
doesn't [1].

Until these problems are addressed we shouldn't be pre-creating
the file as it puts users into way worse position - even
scenarios that used to work don't work. But then again - using
log file for passt is usually valuable for developers only and
not regular users.

1: https://bugzilla.redhat.com/show_bug.cgi?id=2209191#c10
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agoRevert "qemu_passt: Actually use @logfd"
Michal Privoznik [Tue, 1 Aug 2023 14:18:47 +0000 (16:18 +0200)]
Revert "qemu_passt: Actually use @logfd"

This reverts commit 83686f1eea1a001a37a92f2c054ffb2689c43a40.

This is needed only so that the next revert is clean.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
21 months agodomain_event: Drop virDomainEventMemoryDeviceSizeChangePtr
Michal Privoznik [Tue, 27 Jun 2023 08:10:26 +0000 (10:10 +0200)]
domain_event: Drop virDomainEventMemoryDeviceSizeChangePtr

We dropped our private virXXXPtr typedefs in v7.3.0-rc1~229 but
somehow v7.9.0-rc1~292 introduced one back:
virDomainEventMemoryDeviceSizeChangePtr. There's no need for it
and it's internal only. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
21 months agolibvirt-guests: Remove unused variable 'libvirtd'
Jim Fehlig [Mon, 31 Jul 2023 16:53:41 +0000 (10:53 -0600)]
libvirt-guests: Remove unused variable 'libvirtd'

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>