]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
15 months agomeson: Adjust -fstack-protector use
Andrea Bolognani [Sat, 20 Jan 2024 16:06:38 +0000 (17:06 +0100)]
meson: Adjust -fstack-protector use

Back in 2014, -fstack-protector was reported not to work on
aarch64, so fe881ae086ec disabled it on that target. OS-wise,
its use is currently limited to just Linux, FreeBSD and Windows.

Looking at the situation today, it seems that whatever issue was
affecting aarch64 a decade ago has been resolved; moreover,
macOS can also use the feature these days.

I haven't checked any of the other BSDs, but since the feature
works on FreeBSD it's pretty safe to assume that they can use
it too. If we get reports that it's not the case, we can always
further restrict its usage accordingly.

Best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Wed, 31 Jan 2024 07:36:49 +0000 (08:36 +0100)]
Translated using Weblate (Swedish)

Currently translated at 65.8% (6882 of 10447 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>
15 months agoscripts: Make check-symfile.py work on alpha
Andrea Bolognani [Sat, 20 Jan 2024 17:20:21 +0000 (18:20 +0100)]
scripts: Make check-symfile.py work on alpha

The script expects each of the symbols that it looks for to
be in one of three sections, which in nm(1) are described as
follows:

  T - The symbol is in the text (code) section.
  B - The symbol is in the BSS data section. This section
      typically contains zero-initialized or uninitialized
      data, although the exact behavior is system dependent.
  D - The symbol is in the initialized data section.

When building on alpha, however, some of the symbols show up
in one of two additional sections, specifically:

  S - The symbol is in an uninitialized or zero-initialized
      data section for small objects.
  G - The symbol is in an initialized data section for small
      objects.

In other words, S is the same as B and G is the same as D,
except with some optimization for small objects that for some
reason is applied on alpha but not on other architectures.

I have confirmed that, for all the symbols that the script
complained about being missing on alpha, the section is the
expected one, that is, symbols that are reported as B on x86
are reported as S on alpha, and symbols that are reported as
D on x86 are reported as G on alpha.

Note that, while the B section doesn't seem to be used at all
on alpha, at least in our case, the D section still is.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
15 months agoqemu_snapshot: create: don't require disk-only flag for offline external snapshot
Pavel Hrdina [Tue, 30 Jan 2024 11:13:32 +0000 (12:13 +0100)]
qemu_snapshot: create: don't require disk-only flag for offline external snapshot

Historically creating offline external snapshot required disk-only flag
as well. Now when user requests new snapshot for offline VM and at least
one disk is specified to use external snapshot we will no longer require
disk-only flag as all other not specified disk will use external
snapshots as well.

Resolves: https://issues.redhat.com/browse/RHEL-22797
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_snapshot: create: refactor external snapshot detection
Pavel Hrdina [Tue, 30 Jan 2024 10:33:23 +0000 (11:33 +0100)]
qemu_snapshot: create: refactor external snapshot detection

Introduce new function qemuSnapshotCreateUseExternal() that will return
true if we will use external snapshots as default location.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_snapshot: fix detection if non-leaf snapshot isn't in active chain
Pavel Hrdina [Tue, 30 Jan 2024 12:05:22 +0000 (13:05 +0100)]
qemu_snapshot: fix detection if non-leaf snapshot isn't in active chain

The condition was completely wrong. As per the comment for function
virDomainMomentIsAncestor() it checks that the first argument is
descendant of the second argument.

Consider the following snapshot tree for VM:

  s1
    |
    +- s2
    |   |
    |   +- s3
    |
    +- s4
        |
        +- s5 (current)

When deleting s2 with the original code we checked if
virDomainMomentIsAncestor(s2, s5) which would return false basically for
any snapshot as s5 is leaf snapshot so no children.

When deleting s2 with fixed code we check if
virDomainMomentIsAncestor(s5, s2) which still returns false but when
deleting s4 it will correctly return true.

Before this fix it fails with the following error:

    error: Failed to delete snapshot s2
    error: invalid argument: could not find base disk source in disk source chain

After the fix it fails with correct error:

    error: Failed to delete snapshot s2
    error: unsupported configuration: deletion of non-leaf external snapshot that is not in active chain is not supported

Resolves: https://issues.redhat.com/browse/RHEL-23212
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoch_driver: fix condition in virCHDomainRemoveInactive()
Purna Pavan Chandra Aekkaladevi [Mon, 29 Jan 2024 12:38:21 +0000 (12:38 +0000)]
ch_driver: fix condition in virCHDomainRemoveInactive()

Rectify the condition to remove a domain only if it is not persistent.

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
15 months agoqemu: Move qemuDomainGetSCSIControllerModel()
Andrea Bolognani [Fri, 19 Jan 2024 14:54:06 +0000 (15:54 +0100)]
qemu: Move qemuDomainGetSCSIControllerModel()

It has nothing to do with assigning addresses, so it makes more
sense to have it in qemu_domain.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: Add missing error handling
Andrea Bolognani [Mon, 22 Jan 2024 17:50:17 +0000 (18:50 +0100)]
qemu: Add missing error handling

qemuDomainGetSCSIControllerModel() can return -1 on failure,
but qemuDomainFindOrCreateSCSIDiskController() didn't implement
any handling for this scenario.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: Drop qemuDomainSetSCSIControllerModel()
Andrea Bolognani [Fri, 19 Jan 2024 15:04:39 +0000 (16:04 +0100)]
qemu: Drop qemuDomainSetSCSIControllerModel()

It only has a single caller.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: Drop qemuDomainFindSCSIControllerModel()
Andrea Bolognani [Fri, 19 Jan 2024 14:46:06 +0000 (15:46 +0100)]
qemu: Drop qemuDomainFindSCSIControllerModel()

It only has a single caller.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: Clean up qemuDomainDefaultNetModel()
Andrea Bolognani [Fri, 19 Jan 2024 14:27:32 +0000 (15:27 +0100)]
qemu: Clean up qemuDomainDefaultNetModel()

Group things together where it makes sense, avoid unnecessary
uses of 'else if', plus other tweaks.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: Default to no USB and no memballoon for new architectures
Andrea Bolognani [Tue, 16 Jan 2024 18:14:56 +0000 (19:14 +0100)]
qemu: Default to no USB and no memballoon for new architectures

The current defaults, that can be altered on a per-architecture
basis, are derived from the historical x86 behavior.

Every time support for a new architecture is added to libvirt,
care must be taken to override these default: if that doesn't
happen, guests will end up with additional hardware, which is
something that's generally undesirable.

Turn things around, and require architectures to explicitly
ask for the devices to be created by default instead. The
behavior for existing architectures is preserved.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: Fix a few comments
Andrea Bolognani [Wed, 24 Jan 2024 17:17:09 +0000 (18:17 +0100)]
qemu: Fix a few comments

They reference functions that have since been renamed.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Add default-models cases for many architectures
Andrea Bolognani [Wed, 17 Jan 2024 18:01:35 +0000 (19:01 +0100)]
tests: Add default-models cases for many architectures

These are similar to the minimal cases that we just introduced,
but are intended to demonstrate what device or controller model
libvirt will choose when one is not provided by the user.

Note that we want both regular and ABI_UPDATE variants of the
various test cases because, in some cases, the behavior for new
guests is not the same as that for existing ones due to backward
compatibility concerns.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Drop minimal
Andrea Bolognani [Wed, 17 Jan 2024 17:55:42 +0000 (18:55 +0100)]
tests: Drop minimal

We have just added a number of test cases that supersede it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Add minimal cases for many architectures
Andrea Bolognani [Wed, 17 Jan 2024 17:44:58 +0000 (18:44 +0100)]
tests: Add minimal cases for many architectures

We currently have a single test case called "minimal", which
suffers from two big flaws:

  * it's limited to the x86_64/pc machine type;
  * it explicitly enables a number of devices.

Add several test cases, one for each of the architectures and
machine types that we have good support for.

Unlike the existing one, they're *really* minimal: no devices
or controllers at all are present in the input XML. So the new
test cases demonstrate exactly what devices and controller
libvirt will decide to add automatically.

Note that we want both regular and ABI_UPDATE variants of the
various test cases because, in some cases, the behavior for new
guests is not the same as that for existing ones due to backward
compatibility concerns.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Rename and minimize no-memory
Andrea Bolognani [Wed, 17 Jan 2024 17:40:36 +0000 (18:40 +0100)]
tests: Rename and minimize no-memory

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Add aarch64-panic-no-model
Andrea Bolognani [Wed, 24 Jan 2024 09:31:25 +0000 (10:31 +0100)]
tests: Add aarch64-panic-no-model

This demonstrates that on aarch64, where a native panic device
doesn't exist, it's necessary for the user to specify the model
explicitly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Add usb-controller-automatic-unavailable-q35
Andrea Bolognani [Wed, 24 Jan 2024 10:25:56 +0000 (11:25 +0100)]
tests: Add usb-controller-automatic-unavailable-q35

For q35 guests, we normally add a USB controller by default,
but there's a scenario in which we can decide to skip it. Add
test coverage for it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Drop existing <title> and <description> tags
Andrea Bolognani [Wed, 17 Jan 2024 17:34:57 +0000 (18:34 +0100)]
tests: Drop existing <title> and <description> tags

Now that we have an explicit test case for the feature in
genericxml2xmltest, we can drop a bunch of duplicated accidental
coverage from qemuxmlconftest.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Add title-and-description
Andrea Bolognani [Fri, 26 Jan 2024 10:31:26 +0000 (11:31 +0100)]
tests: Add title-and-description

We have a few cases in qemuxmlconftest that cover the ability
to set <title> and <description> for a guest as a side effect.

Introduce an explicit case for the functionality in
genericxml2xmltest, as it's not specific to the QEMU driver.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_command: Generate cmd line for virtio-mem dynamicMemslots
Michal Privoznik [Thu, 4 Jan 2024 09:49:06 +0000 (10:49 +0100)]
qemu_command: Generate cmd line for virtio-mem dynamicMemslots

This is pretty straightforward.

Resolves: https://issues.redhat.com/browse/RHEL-15316
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_validate: Check capability for virtio-mem dynamicMemslots
Michal Privoznik [Thu, 4 Jan 2024 10:04:51 +0000 (11:04 +0100)]
qemu_validate: Check capability for virtio-mem dynamicMemslots

The QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI_DYNAMIC_MEMSLOTS reflects
whether QEMU is capable of .dynamic-memslots for virtio-mem.
Use it when validating domain configuration.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_capabilities: Add QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI_DYNAMIC_MEMSLOTS capability
Michal Privoznik [Thu, 4 Jan 2024 09:57:12 +0000 (10:57 +0100)]
qemu_capabilities: Add QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI_DYNAMIC_MEMSLOTS capability

Starting from v8.2.0-rc0~74^2~2 QEMU has .dynamic-memslots
attribute for virtio-mem-pci device. Introduce a capability which
reflects that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoconf: Introduce dynamicMemslots attribute for virtio-mem
Michal Privoznik [Thu, 4 Jan 2024 09:03:36 +0000 (10:03 +0100)]
conf: Introduce dynamicMemslots attribute for virtio-mem

Introduced in v8.2.0-rc0~74^2~2, QEMU now allows setting
.dynamic-memslots attribute for virtio-mem-pci devices. When
turned on, it allows memory exposed to guest to be split into
multiple memslots and thus smaller memory footprint (see the
original commit for detailed explanation).

Therefore, introduce new <target/> attribute which will control
that QEMU knob.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Mon, 29 Jan 2024 15:36:25 +0000 (16:36 +0100)]
Translated using Weblate (Swedish)

Currently translated at 65.4% (6842 of 10447 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>
15 months agoTranslated using Weblate (Korean)
김인수 [Mon, 29 Jan 2024 15:36:25 +0000 (16:36 +0100)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10433 of 10433 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>
15 months agoremote_driver: Restore special behavior of remoteDomainGetBlockIoTune()
Michal Privoznik [Mon, 29 Jan 2024 09:07:05 +0000 (10:07 +0100)]
remote_driver: Restore special behavior of remoteDomainGetBlockIoTune()

In v9.10.0-rc1~103 the remote driver was switched to g_auto() for
client RPC return parameters. But whilst doing so a small bug
slipped in: previously, when virDomainGetBlockIoTune() was called
with *nparams == 0, the function set *nparams to the number of
supported params and zero was returned (so that client can
allocate memory and call the API second time). IOW - the usual,
old style of APIs where we didn't want to allocate memory on
caller's behalf. But because of this bug, a negative one is
returned instead.

Fixes: 501825011c1fe80f458820c7efe5a198e0af9be5
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Improve ABI_UPDATE macros
Andrea Bolognani [Fri, 26 Jan 2024 10:57:21 +0000 (11:57 +0100)]
tests: Improve ABI_UPDATE macros

There are a number of cases in which we want to test both the
normal behavior and the ABI_UPDATE behavior for the same input
XML.

The way this is currently implemented is ad-hoc, and involves
symlinking the input XML as well as coming up with an
alternative name for the ABI_UPDATE variant: in most cases the
-abi-update suffix is added, but since this is not enforced
there are a couple of cases where we do something else instead.

To make things simpler and more consistent, implement the
naming convention at the macro level. This way, we no longer
need to create any symlinks for the input file, and the output
files are automatically named correctly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Use ABI_UPDATE macros more
Andrea Bolognani [Fri, 26 Jan 2024 10:56:54 +0000 (11:56 +0100)]
tests: Use ABI_UPDATE macros more

In one case, the macro was open-coded.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agotests: Drop ppc64-usb-controller-legacy
Andrea Bolognani [Fri, 26 Jan 2024 11:16:39 +0000 (12:16 +0100)]
tests: Drop ppc64-usb-controller-legacy

The input file is a symlink for the ppc64-usb-controller input
file, so the output files are identical as well. It's just an
unnecessary duplicate.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu: block: fix error when blockcopy target is librbd encrypted
Or Ozeri [Thu, 12 Jan 2023 09:04:01 +0000 (03:04 -0600)]
qemu: block: fix error when blockcopy target is librbd encrypted

Encryption secrets are considered a format dependency, even
when being used by the storage node itself, as in the case of
using encryption engine=librbd.
Currently, the storage node is created (blockdev-add) before
creating the format dependencies (including encryption secrets).
As a result, when trying to perform a blockcopy when the target
disk uses librbd encryption, an error of this form is returned:

  "error: internal error: unable to execute QEMU command 'blockdev-add': No secret with id 'libvirt-5-format-encryption-secret0'"

To overcome this error, we change the order of commands so that
format dependencies are created BEFORE creating the storage node.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_hotplug: Don't lose 'created' flag in qemuDomainChangeNet()
Michal Privoznik [Wed, 24 Jan 2024 17:43:21 +0000 (18:43 +0100)]
qemu_hotplug: Don't lose 'created' flag in qemuDomainChangeNet()

After v9.1.0-rc1~116 we track whether it's us who created a
macvtap or not. But when updating a vNIC its definition might be
replaced with a new one (though, ifname is not allowed to
change), e.g. to reflect new QoS, link state, etc.

Now, the fact whether we created macvtap for given vNIC is stored
in net->privateData->created. And replacing definition is done by
simply freeing the old definition and making the pointer point to
the new one. But this does not preserve the 'created' flag, which
in turn means when a domain is shutting off, the macvtap is not
removed (see loop inside of qemuProcessStop()).

Copy this flag into new definition and leave a note in
_qemuDomainNetworkPrivate struct.

Fixes: 61d1b9e6592660121aeda66bf7adbcd39de06aa8
Resolves: https://issues.redhat.com/browse/RHEL-22714
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovmx: Separate disk target name generation into a function
Michal Privoznik [Fri, 15 Dec 2023 13:48:25 +0000 (14:48 +0100)]
vmx: Separate disk target name generation into a function

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovmx2xmltest: Add another test case
Michal Privoznik [Fri, 15 Dec 2023 12:55:53 +0000 (13:55 +0100)]
vmx2xmltest: Add another test case

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovmx: Accept empty fileName for cdrom-image
Michal Privoznik [Fri, 15 Dec 2023 13:12:42 +0000 (14:12 +0100)]
vmx: Accept empty fileName for cdrom-image

Turns out, there are two ways to specify an empty CD-ROM drive in
a .vmx file:

  1) .fileName = "emptyBackingString"
  2) .fileName = ""

While we do parse 1) successfully, the code does not accept 2)
and an error is reported. Modify the code to treat both cases the
same.

Resolves: https://issues.redhat.com/browse/RHEL-19380
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoAdd explanation about the attribute "delay"
Yalan Zhang [Wed, 10 Jan 2024 04:58:58 +0000 (12:58 +0800)]
Add explanation about the attribute "delay"

The libvirt created linux bridge has a configurable value "delay",
the default value is "0", but it will not take effect. That's because
kernel has a minimum value for linux bridge. Add some explanation
about it in the document.

Signed-off-by: Yalan Zhang <yalzhang@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoNEWS: Document recent rx-filter bugfix
Michal Privoznik [Thu, 25 Jan 2024 13:19:06 +0000 (14:19 +0100)]
NEWS: Document recent rx-filter bugfix

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agoqemu_process: Skip over non-virtio non-TAP NIC models when refreshing rx-filter
Michal Privoznik [Tue, 23 Jan 2024 16:20:42 +0000 (17:20 +0100)]
qemu_process: Skip over non-virtio non-TAP NIC models when refreshing rx-filter

After guest is started, or we are reconnecting to already running
one (after daemon restart), qemuProcessRefreshRxFilters() is
called to refresh rx-filters (basically MAC addresses of guest
NICs) as they might have changed while we were not running (for
the case when reconnecting to an already running guest), or we
need to enable them by running a command (for freshly started
guest - see processNicRxFilterChangedEvent()).

Now, our XML parser allowed trustGuestRxFilters attribute for all
types and models of <interface/> while in reality, only virtio
model AND TUN/TAP based types can see MAC address changes. For
other combinations, QEMU reports an error.

This all means that when the daemon is restarted and it
reconnects to a guest with, well invalid configuration, or when
such guest is restored from a saved image, or migrated then we
issue the monitor command, to which QEMU replies with an error
which is then propagated to users:

  error: internal error: unable to execute QEMU command 'query-rx-filter': invalid net client name: hostdev0

While on one hand users should fix their configuration (and after
v10.0.0-rc1~123 they can do that even on live domains), libvirt
can also has some logic built in that prevent issuing the command
in the first place (for obviously wrong cases).

Fixes: 060d4c83ef436cf56abfad51a4d64c39448e199d
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
15 months agobuild: Make daemons depend on generated *_protocol.[ch]
Jiri Denemark [Wed, 24 Jan 2024 18:23:54 +0000 (19:23 +0100)]
build: Make daemons depend on generated *_protocol.[ch]

This should fix build failures when a daemon code is compiled before the
included *_protocol.h headers are ready, such as:

    FAILED: src/virtqemud.p/remote_remote_daemon_config.c.o
    ../src/remote/remote_daemon_config.c: In function ‘daemonConfigNew’:
    ../src/remote/remote_daemon_config.c:111:30: error:
        ‘REMOTE_AUTH_POLKIT’ undeclared (first use in this function)
      111 |         data->auth_unix_rw = REMOTE_AUTH_POLKIT;
          |                              ^~~~~~~~~~~~~~~~~~
    ../src/remote/remote_daemon_config.c:111:30: note: each undeclared
        identifier is reported only once for each function it appears in
    ../src/remote/remote_daemon_config.c:115:30: error:
        ‘REMOTE_AUTH_NONE’ undeclared (first use in this function)
      115 |         data->auth_unix_rw = REMOTE_AUTH_NONE;
          |                              ^~~~~~~~~~~~~~~~
    ../src/remote/remote_daemon_config.c: In function
        ‘daemonConfigLoadOptions’:
    ../src/remote/remote_daemon_config.c:252:31: error:
        ‘REMOTE_AUTH_POLKIT’ undeclared (first use in this function)
      252 |     if (data->auth_unix_rw == REMOTE_AUTH_POLKIT) {
          |                               ^~~~~~~~~~~~~~~~~~

or

    FAILED: src/virtqemud.p/remote_remote_daemon_dispatch.c.o
    In file included from ../src/remote/remote_daemon.h:28,
                     from ../src/remote/remote_daemon_dispatch.c:26:
    src/remote/lxc_protocol.h:13:5: error:
        unknown type name ‘remote_nonnull_domain’
       13 |     remote_nonnull_domain dom;
          |     ^~~~~~~~~~~~~~~~~~~~~
    In file included from ../src/remote/remote_daemon.h:29,
                     from ../src/remote/remote_daemon_dispatch.c:26:
    src/remote/qemu_protocol.h:13:5: error:
        unknown type name ‘remote_nonnull_domain’
       13 |     remote_nonnull_domain dom;
          |     ^~~~~~~~~~~~~~~~~~~~~
    src/remote/qemu_protocol.h:14:5: error:
        unknown type name ‘remote_nonnull_string’
       14 |     remote_nonnull_string cmd;
          |     ^~~~~~~~~~~~~~~~~~~~~
    ...

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
15 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Wed, 24 Jan 2024 09:36:12 +0000 (10:36 +0100)]
Translated using Weblate (Swedish)

Currently translated at 64.5% (6741 of 10447 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>
15 months agotests: Remove readahead and timeout from ssh tests
Jonathon Jongsma [Fri, 19 Jan 2024 21:18:21 +0000 (15:18 -0600)]
tests: Remove readahead and timeout from ssh tests

These values are currently unsupported for ssh disks, and in fact aren't
even parsed for ssh disks. So while this didn't result in any test
errors, we can remove them from the test input files.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
15 months agoqemu: Fix bug in nbdkit-backed backing chains
Jonathon Jongsma [Thu, 18 Jan 2024 23:17:07 +0000 (17:17 -0600)]
qemu: Fix bug in nbdkit-backed backing chains

When trying to start nbdkit-backed disks in backing chains, we were
accidentally always checking the private data of the top of the chain
instead of using the loop variable.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
15 months agoExplicitly convert type to double to avoid losing precision
Egor Makrushin [Tue, 23 Jan 2024 09:28:34 +0000 (12:28 +0300)]
Explicitly convert type to double to avoid losing precision

Division between integers will also be integer.
Thus, to preserve fractional part explicitly
convert first operand to double.

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

Fixes: 28d54aab05 ("examples: Introduce domtop")
Signed-off-by: Egor Makrushin <emakrushin@astralinux.ru>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
15 months agoconf: make virNetDevVPortProfileFormat() void
Alexandra Diupina [Wed, 17 Jan 2024 16:04:58 +0000 (19:04 +0300)]
conf: make virNetDevVPortProfileFormat() void

Since commit 4af3cbafdd0e the function always returns 0, so it is
possible to make this function void and remove return value checks.

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

Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru>
15 months agoqemuxmlconftest: Move 'qemuxml2xmloutdata' into 'qemuxmlconfdata'
Peter Krempa [Mon, 22 Jan 2024 15:49:18 +0000 (16:49 +0100)]
qemuxmlconftest: Move 'qemuxml2xmloutdata' into 'qemuxmlconfdata'

Unify the output directory. Symlinks needed to be adapted to work
properly, but the 'qemuxml2argvdata' symlink can now be removed.

The virschematest exceptions needed to be moved to the proper directory
once the files are moved.

The unification of the output directory now also ensures that files
won't be forgotten once tests are removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agoqemuxmlconftest: Move data directory 'qemuxml2argvdata' to 'qemuxmlconfdata'
Peter Krempa [Mon, 22 Jan 2024 12:18:56 +0000 (13:18 +0100)]
qemuxmlconftest: Move data directory 'qemuxml2argvdata' to 'qemuxmlconfdata'

Unify the naming of the data directory with the test name.

'tests/qemuxml2argvdata' is for the time converted to a symlink to
'qemuxmlconfdata', to preserve the symlinks in
'tests/qemuxml2xmloutdata'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agoqemuxml2xmloutdata: Drop unused output files
Peter Krempa [Tue, 23 Jan 2024 13:29:01 +0000 (14:29 +0100)]
qemuxml2xmloutdata: Drop unused output files

Remove leftover output files. The list of files was identified by
temporarily hacking testConfXMLEnumerate to also enumerate
'tests/qemuxml2xmloutdata' directory.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agoqemuxmlconftest: Check also output files for usage
Peter Krempa [Tue, 23 Jan 2024 12:44:50 +0000 (13:44 +0100)]
qemuxmlconftest: Check also output files for usage

Include also the output files in the validation of used files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agoqemuxmlconftest: Populate output/error file only when needed
Peter Krempa [Tue, 23 Jan 2024 12:35:39 +0000 (13:35 +0100)]
qemuxmlconftest: Populate output/error file only when needed

Populate the output filename strings only when the files are expected to
exist, so that other logic can be based on the presence of the strings
rather than having to re-check the test flags for expected state.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agovirschematest: Don't bother checking symlinked XMLs
Peter Krempa [Tue, 23 Jan 2024 12:59:11 +0000 (13:59 +0100)]
virschematest: Don't bother checking symlinked XMLs

There's plenty symlinks in qemuxml2argvdata and qemuxml2xmlout
directories pointing to other files in the same directory. It makes no
sense to check those files twice, thus we can simply skip symlinks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agodomain_validate: Check for domain address conflicts fully
Michal Privoznik [Fri, 19 Jan 2024 07:22:13 +0000 (08:22 +0100)]
domain_validate: Check for domain address conflicts fully

Current implementation of virDomainMemoryDefCheckConflict() does
only a one way comparison, i.e. if there's a memory device within
def->mems[] which address falls in [mem->address, mem->address +
mem->size] range (mem is basically an iterator within
def->mems[]). And for static XML this works just fine. Problem is
with hot/cold plugging of a memory device. Then mem points to
freshly parsed memory device and these half checks are
insufficient. Not only we must check whether an existing memory
device doesn't clash with freshly parsed memory device, but also
whether freshly parsed memory device does not fall into range of
already existing memory device.

Resolves: https://issues.redhat.com/browse/RHEL-4452
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
15 months agomeson: drop explicit python interpreter
Biswapriyo Nath [Sun, 21 Jan 2024 06:25:57 +0000 (06:25 +0000)]
meson: drop explicit python interpreter

meson wraps python scripts already on win32, so we end up with these
failing commands:

[185/868] Generating src/rpc/virnetprotocol.h with a custom command
FAILED: src/rpc/virnetprotocol.h
"sh" "libvirt/scripts/meson-python.sh" "F:/msys64/ucrt64/bin/python3.EXE" "F:/msys64/ucrt64/bin/python.exe" "libvirt/scripts/rpcgen/main.py" "--mode=header" "../src/rpc/virnetprotocol.x" "src/rpc/virnetprotocol.h"
SyntaxError: Non-UTF-8 code starting with '\x90' in file F:/msys64/ucrt64/bin/python.exe on line 1, but no encoding declared; see https://peps.python.org/pep-0263/ for details

The issue was introduced in a62486b95feed2cf17ce4adbe794a1ecff9ef22a commit.
These changes are similar as e06beacec2f8e57bbc5cd8f6eb9d44a1f291966d commit.

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
15 months agoTranslated using Weblate (Georgian)
Mariam Low-Ghelaghutashvili [Fri, 19 Jan 2024 13:51:07 +0000 (14:51 +0100)]
Translated using Weblate (Georgian)

Currently translated at 4.4% (461 of 10433 strings)

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

Co-authored-by: Mariam Low-Ghelaghutashvili <mariamlow@zusmail.xyz>
Signed-off-by: Mariam Low-Ghelaghutashvili <mariamlow@zusmail.xyz>
15 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Fri, 19 Jan 2024 13:51:06 +0000 (14:51 +0100)]
Translated using Weblate (Swedish)

Currently translated at 63.5% (6641 of 10447 strings)

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

Translated using Weblate (Swedish)

Currently translated at 63.3% (6621 of 10447 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>
15 months agodocs: Add redirects configuration for gitlab pages
Peter Krempa [Mon, 3 Apr 2023 14:18:54 +0000 (16:18 +0200)]
docs: Add redirects configuration for gitlab pages

Adapt the configuration of redirects from the server hosting libvirt.org

The redirect to the 'libvirt-console-proxy' Golang module is not adapted
as it doesn't exist on the current server.

NOTES:
 - The redirects are currently configured for hosting via the
   'gitlab.io/libvirt' URI. For hosting via custom domain it will need
   to be rewritten to drop the '/libvirt' prefixes.

 - gitlab pages doesn't currently support redirects to outside content,
   thus most of the redirects don't actually work:

     https://gitlab.com/gitlab-org/gitlab-pages/-/issues/601

 - The redirects file is only installed in the webpage job but is not
   actually distributed.

 - The validity of the redirects can be checked by visiting:

     https://libvirt.gitlab.io/_redirects

   Having them installed allows us to validate them before we'll be
   switching to use gitlab pages completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
15 months agogitlab-ci: Configure website build to be published via gitlab pages
Peter Krempa [Mon, 3 Apr 2023 14:02:05 +0000 (16:02 +0200)]
gitlab-ci: Configure website build to be published via gitlab pages

On pushes to master publish the webpage (built in the 'website_job' job)
via gitlab pages. The 'pages' job uses the default image that gitlab
assumes as it's consuming artifacts from an existing job and naming
them properly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
15 months agoci: Regenerate with latest 'lcitool' and fix manual job definitions
Peter Krempa [Thu, 18 Jan 2024 15:20:14 +0000 (16:20 +0100)]
ci: Regenerate with latest 'lcitool' and fix manual job definitions

The latest lcitool merged the 'prebuilt-env' and 'local-env' jobs into
one which use variables to pick up the right environment and steps
rather than duplicating everything.

Regenerate the generated job definitions, fix the helper definitions
and also fix the manually defined jobs (website-job).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
15 months agonews: document my changes for 10.0.0
Ján Tomko [Wed, 17 Jan 2024 14:30:13 +0000 (15:30 +0100)]
news: document my changes for 10.0.0

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: Improve qemuDomainSupportsPCIMultibus()
Andrea Bolognani [Wed, 17 Jan 2024 08:53:19 +0000 (09:53 +0100)]
qemu: Improve qemuDomainSupportsPCIMultibus()

Rewrite the function so that it's more compact and easier to
extend as new architectures, which will likely come with
multibus support right out the gate, are introduced.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: Move qemuDomainSupportsPCIMultibus()
Andrea Bolognani [Wed, 17 Jan 2024 08:39:48 +0000 (09:39 +0100)]
qemu: Move qemuDomainSupportsPCIMultibus()

It belongs next to qemuDomainSupportsPCI().

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: Improve qemuDomainSupportsPCI()
Andrea Bolognani [Tue, 16 Jan 2024 15:42:18 +0000 (16:42 +0100)]
qemu: Improve qemuDomainSupportsPCI()

The way the function is currently written sort of obscures this
fact, but ultimately we already unconditionally assume PCI
support on most architectures.

Arm and RISC-V need some additional checks to maintain
compatibility with existing configurations but for all future
architectures, such as the upcoming LoongArch64, we expect PCI
support to come out of the box.

Last but not least, the functions is made const-correct.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: Retire QEMU_CAPS_OBJECT_GPEX
Andrea Bolognani [Tue, 16 Jan 2024 15:36:58 +0000 (16:36 +0100)]
qemu: Retire QEMU_CAPS_OBJECT_GPEX

It's no longer used anywhere.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: Stop checking QEMU_CAPS_OBJECT_GPEX
Andrea Bolognani [Tue, 16 Jan 2024 15:36:46 +0000 (16:36 +0100)]
qemu: Stop checking QEMU_CAPS_OBJECT_GPEX

For all versions of QEMU that we support, the virt machine type
has a hard dependency on this device, so we can stop checking
whether the capability is present and just use it unconditionally.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Request virtio-mmio for balloon-mmio-deflate
Andrea Bolognani [Tue, 16 Jan 2024 14:44:44 +0000 (15:44 +0100)]
tests: Request virtio-mmio for balloon-mmio-deflate

For all supported QEMU version, the virt machine type has a hard
dependency on PCI support, so if we want to test virtio-balloon
together with virtio-mmio we have to either request that
explicitly or trick libvirt by masking capabilities. Do the
former instead of the latter.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Simplify balloon-mmio-deflate
Andrea Bolognani [Tue, 16 Jan 2024 14:45:53 +0000 (15:45 +0100)]
tests: Simplify balloon-mmio-deflate

Drop everything that's not directly related to the scenario
being tested.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Drop various redundant tests
Andrea Bolognani [Tue, 16 Jan 2024 14:52:52 +0000 (15:52 +0100)]
tests: Drop various redundant tests

All of these are either a subset of other tests, or provide
coverage for scenarios that are not really possible: for all
versions of QEMU that we support, the virt machine type has a
hard dependency on the generic PCIe controller, which means
that we will never need to fall back to virtio-mmio.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Add {aarch64,riscv64}-virt-headless-mmio
Andrea Bolognani [Tue, 16 Jan 2024 14:51:31 +0000 (15:51 +0100)]
tests: Add {aarch64,riscv64}-virt-headless-mmio

Even though virtio-mmio is no longer the default on either
architecture, and likely nobody is using it at this point, we
still provide a way to opt into virtio-mmio usage and want to
keep existing guests working. Add explicit test suite coverage
for this scenario.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Drop aarch64-virtio-pci-default
Andrea Bolognani [Tue, 16 Jan 2024 15:21:52 +0000 (16:21 +0100)]
tests: Drop aarch64-virtio-pci-default

After commit 1d8454639f40 (libvirt 3.0.0), the default address
type for aarch64/virt guests is PCI. These tests are then
pointless, as they are just a subset of other tests, and the
comment attached to them inaccurate.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: Fix handling of user aliases for default PHB
Andrea Bolognani [Tue, 16 Jan 2024 16:19:15 +0000 (17:19 +0100)]
qemu: Fix handling of user aliases for default PHB

The bus name for the default PHB is always "pci.0".

Fixes: 937f319536723fec57ad472b002a159d0f67a77c
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Add pseries-phb-user-alias
Andrea Bolognani [Tue, 16 Jan 2024 16:05:07 +0000 (17:05 +0100)]
tests: Add pseries-phb-user-alias

This is the same as the existing pseries-phb-simple, except that
each of the controllers is given a user alias. If we tried to
start the resulting guest, we'd get an error:

  Bus 'ua-phb0' not found

This is because, at the QEMU command line level, the default PHB
is not represented and so it can't be given a custom alias. We're
going to address this issue in a follow-up commit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Add devices to pseries-phb-simple
Andrea Bolognani [Tue, 16 Jan 2024 16:08:49 +0000 (17:08 +0100)]
tests: Add devices to pseries-phb-simple

We want to make sure that not only the controllers themselves
are added correctly, but also that devices attached to them
get assigned the expected bus value. In order to do that add
some devices, one per controller.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxml2conftest: Test re-parsing of formatted XML
Peter Krempa [Mon, 18 Dec 2023 15:38:46 +0000 (16:38 +0100)]
qemuxml2conftest: Test re-parsing of formatted XML

Re-parse and re-format the output XML to validate that the auto-added
bits and the formatter always agree. There's no way to specify an
alternative output file as a libvirt-formatted XML must be reformatted
identically.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirDomainDefAddConsoleCompat: Fix numbering of console targets after modification
Peter Krempa [Mon, 18 Dec 2023 15:41:01 +0000 (16:41 +0100)]
virDomainDefAddConsoleCompat: Fix numbering of console targets after modification

The XML parser for consoles sets the 'port=' attribute of '<target' to
be always the index of the console.

Thus when the "really crazy backcompat stuff for consoles" function
modifies the order of consoles by inserting the default one for a serial
port it must re-number the ports to ensure that the value will not
change on subsequent parse.

This luckily didn't cause any visible changes to the VM as the port
number isn't used for anything.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuDomainAssignPCIAddresses: Assign extension addresses when auto-assigning PCI...
Peter Krempa [Mon, 18 Dec 2023 21:23:35 +0000 (22:23 +0100)]
qemuDomainAssignPCIAddresses: Assign extension addresses when auto-assigning PCI address

Assigning a PCI address needs to also assign any extension addresses
right away. Otherwise they'd be assigned only after subsequent
format->parse cycle and thus be potentially missing on first run after
defining the VM and thus could change.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu: Move 'shmem' device size validation to qemu_validate
Peter Krempa [Mon, 18 Dec 2023 23:16:29 +0000 (00:16 +0100)]
qemu: Move 'shmem' device size validation to qemu_validate

The 'size' of a 'shmem' device is parsed and formatted as a "scaled"
value, stored in bytes, but the formatting scale is mebibytes. This
precission loss combined with the fact that the value was validated only
when starting and the size is formatted only when non-zero meant that
on first parse a value < 1 MiB would be accepted, but would be formatted
to the XML as 0 MiB as it was non-zero but truncated and a subsequent
parse would parse of such XML would parse it as 0 bytes, which in turn
would be interpreted as 'default' size.

Fix the issue by moving the validator, which ensures that the number is
a power of two and more than 1 MiB to the validator code so that it'll
be rejected at XML parsing time.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirDomainAssignControllerIndexes: Ensure controller ordering after assigning indexes
Peter Krempa [Mon, 18 Dec 2023 21:10:35 +0000 (22:10 +0100)]
virDomainAssignControllerIndexes: Ensure controller ordering after assigning indexes

Similarly to auto-adding of controllers, the assignment of indexes can
cause them to be considered in different ordering according to the logic
in 'virDomainControllerInsert' than they currently are.

To prevent changes in commandline between first run after defining a VM
xml and any subsequent run or restart of the daemon, we need to reorder
them when assigning the index.

The simplest method is to assign indexes and then create a new list of
controllers and re-instert them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoconf: domain: Insert auto-added controllers in same order as in XML parser
Peter Krempa [Mon, 18 Dec 2023 17:32:57 +0000 (18:32 +0100)]
conf: domain: Insert auto-added controllers in same order as in XML parser

'virDomainDefAddController' which is used in code-paths which auto-add
controllers to the definition such as 'virDomainDefMaybeAddController',
'virDomainDefAddUSBController', 'qemuDomainDefAddDefaultDevices' was
adding the controller at the end of the list. However that is not how
the XML parser would order the controller in the list as it uses
virDomainControllerInsert grouping them by type and additional
properties.

This would cause that auto-added controllers would re-order:
 - between first and any subsequent run of the VM (even on commandline)
 - after a libvirtd/virtqemud restart
 - after any update of the definition based on the 'define' operation
   (e.g. virsh edit)

To ensure that the ordering of controllers is identical always use
virDomainControllerInsert.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agovirDomainDefMaybeAddVirtioSerialController: Reformat hard to read linebreaks
Peter Krempa [Tue, 19 Dec 2023 21:51:41 +0000 (22:51 +0100)]
virDomainDefMaybeAddVirtioSerialController: Reformat hard to read linebreaks

Format the code the usual way despite having more than 80 columns so
that it's easier to read.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Rename 'qemuxml2argvtest' to 'qemuxmlconftest'
Peter Krempa [Mon, 18 Dec 2023 15:21:40 +0000 (16:21 +0100)]
tests: Rename 'qemuxml2argvtest' to 'qemuxmlconftest'

Since this tests inactive/config XML files rename it accordingly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agomeson: tests: Allow 'timeout' override for all tests
Peter Krempa [Mon, 8 Jan 2024 15:48:15 +0000 (16:48 +0100)]
meson: tests: Allow 'timeout' override for all tests

Don't special-case qemuxml2argvtest's handling of timeout but rather
allow each test array entry to have it's own.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxml2argvtest: Populate all outstanding def->xml cases
Peter Krempa [Sat, 16 Dec 2023 16:26:37 +0000 (17:26 +0100)]
qemuxml2argvtest: Populate all outstanding def->xml cases

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Remove qemuxml2xmltest
Peter Krempa [Sat, 16 Dec 2023 19:12:05 +0000 (20:12 +0100)]
tests: Remove qemuxml2xmltest

The full functionality was merged into qemuxmlconftest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxml2argvtest: Test (inactive) def -> xml conversion
Peter Krempa [Sat, 16 Dec 2023 16:13:35 +0000 (17:13 +0100)]
qemuxml2argvtest: Test (inactive) def -> xml conversion

This is an intermediate step to merge qemuxml2xmltest into this common
helper. This eliminates double setup/parsing of the input data as well
as will ensure that all input XMLs are tested both for ARGV as well as
XML output. For now we skip tests that don't have an output XML to show
that the this does everything that qemuxml2xmltest does.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxml2argvtest: Add parsing of the input XML as separate test
Peter Krempa [Mon, 18 Dec 2023 15:02:33 +0000 (16:02 +0100)]
qemuxml2argvtest: Add parsing of the input XML as separate test

Get clean separation between the parsing and argv conversion so that
it's obvious in the test output:

2409) QEMU XML def parse s390-async-teardown.s390x-6.0.0                ... libvirt: QEMU Driver error : unsupported configuration: asynchronous teardown is not available with this QEMU binary
OK
2410) QEMU XML def -> ARGV s390-async-teardown.s390x-6.0.0              ... SKIP

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxml2argvtest: Extract setup/parse step
Peter Krempa [Sat, 16 Dec 2023 15:30:57 +0000 (16:30 +0100)]
qemuxml2argvtest: Extract setup/parse step

Extract the common setup and parsing of the input XML into a separate
helper testQemuConfXMLCommon(). The helper has semantics which will
allow us to call it from multiple places so that VIR_TEST_RANGE will
still work properly even when we'll add multiple steps reusing the
prepared data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxml2argvtest: Setup fake driver only once
Peter Krempa [Sat, 16 Dec 2023 07:48:21 +0000 (08:48 +0100)]
qemuxml2argvtest: Setup fake driver only once

Move the setup of the fake driver from testCompareXMLToArgv to 'mymain'.
With this we also won't need to reset the fake drivers which was done
only partially.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxml2argvtest: Use virDomainDefParseFile instead of virXMLParse+virDomainDefParseNode
Peter Krempa [Sat, 16 Dec 2023 08:05:09 +0000 (09:05 +0100)]
qemuxml2argvtest: Use virDomainDefParseFile instead of virXMLParse+virDomainDefParseNode

As we don't do any additional parsing of the input file in
qemuxml2argvtest we can simplify the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxml2argvtest: Remove unused separate parsing of arch
Peter Krempa [Sat, 16 Dec 2023 07:58:55 +0000 (08:58 +0100)]
qemuxml2argvtest: Remove unused separate parsing of arch

Prior to all tests being converted to "DO_TEST_CAPS*" invocation the
fake-caps tests required knowing the architecture, which was pre-parsed
in qemuxml2argvtest. This code was now removed, but the arch parser was
forgotten.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxml2xmltest: Remove pointless inactive->active testing
Peter Krempa [Fri, 15 Dec 2023 21:51:48 +0000 (22:51 +0100)]
qemuxml2xmltest: Remove pointless inactive->active testing

'virDomainDefFormatInternalSetRootName' which is the top level XML
formatter function has the following condition as the very first thing:

     if (def->id == -1)
         flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;

This makes it pointless to separately do inactive->active and
inactive->inactive XML -> XML testing as both will be in the end treated
as inactive->inactive.

This patch adds a warning to virDomainDefFormatInternalSetRootName and
removes the second pointless invocation of the test from
qemuxml2xmtest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxml2*test: Remove FLAG_SKIP_CONFIG_ACTIVE flag
Peter Krempa [Tue, 5 Dec 2023 09:12:41 +0000 (10:12 +0100)]
qemuxml2*test: Remove FLAG_SKIP_CONFIG_ACTIVE flag

Neither qemuxml2argvtest nor qemuxml2xmltest now test configs parsed as
active, thus this flag is no longer needed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxml2xmltest: Parse all input files as inactive
Peter Krempa [Fri, 15 Dec 2023 15:30:32 +0000 (16:30 +0100)]
qemuxml2xmltest: Parse all input files as inactive

In previous patches we've added testing of XML's explicitly parsed as
active (ensuring that it e.g. has a domain id) formatted into both
active and inactive versions.

Now qemuxml2xmltest can be simplified by making it test only XMLs parsed
as inactive.

To do this we pass VIR_DOMAIN_DEF_PARSE_INACTIVE in parseFlags. This
will also cause that all output files will become identical so the setup
of the test cases can be simplified by using the non-split output file
name.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxmlactivetest: Add qemu active XML to active/inactive XML tests
Peter Krempa [Mon, 18 Dec 2023 12:36:45 +0000 (13:36 +0100)]
qemuxmlactivetest: Add qemu active XML to active/inactive XML tests

Add explicit test cases for XMLs from qemuxml2argvdata which
historically had different output in qemuxml2xmltest.

qemuxmlactivetest explicitly ensures that the input XMLs are parsed in
'live' state and formatted both in inactive as well as live state,
rather than the previously present inactive->inactive,  live->live tests
only.

The XMLs picked in this case are those which had separate output files
in qemuxml2argvtest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxmlactivetest: Prepare for proper active/inactive -> active/inactive testing
Peter Krempa [Fri, 15 Dec 2023 15:30:20 +0000 (16:30 +0100)]
qemuxmlactivetest: Prepare for proper active/inactive -> active/inactive testing

Currently the xml->xml testing we have in qemuxml2xmltest covers only 3
of the 4 possibilities:

By invocation:
  active -> active;
  inactive -> inactive;

by unintentionally:
  active -> inactive  (for configs which don't set an 'id' as the
                       formatter assumes it's inactive)

To do it better introduce proper active -> inactive/active testing into
qemuxmlactivetest. It's chosen such as we only really parse an XML as
live when restoring a status XML. To give users possibility to avoid
constructing a full status XML add a simpler variant. As of such it will
be used only for configs where we specifically cared about parsing live
data.

To ensure that the formatter doesn't decide that a config is inactive
because it doesn't have an ID we fill in a domain ID if it was not
present in the source.

In this patch the tests are not yet added.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemu*xml2*test: Invoke tests from a function
Peter Krempa [Mon, 4 Dec 2023 16:00:54 +0000 (17:00 +0100)]
qemu*xml2*test: Invoke tests from a function

Refactor the code so that the test macros invoke a helper function with
no additional steps. This change prevents regressions in compilation
time when adding extra steps for the tests, which happen when the test
macro gets too complicated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotestutilsqemu: Create a typedef for struct testQemuInfo
Peter Krempa [Mon, 4 Dec 2023 21:28:10 +0000 (22:28 +0100)]
testutilsqemu: Create a typedef for struct testQemuInfo

The typedef will come in handy to create an autoptr cleaning function
later on.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotests: Rename 'qemustatusxml2xmltest' to 'qemuxmlactivetest'
Peter Krempa [Fri, 15 Dec 2023 12:39:49 +0000 (13:39 +0100)]
tests: Rename 'qemustatusxml2xmltest' to 'qemuxmlactivetest'

The test will be testing both status XMLs and active XMLs. Rename it to
a shorter name.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agotestCompareDomXML2XMLFiles: Sanitize handling of 'parse_flags'
Peter Krempa [Fri, 15 Dec 2023 14:57:50 +0000 (15:57 +0100)]
testCompareDomXML2XMLFiles: Sanitize handling of 'parse_flags'

Get rid of the extra temporary variable and set the parse and format
flags based on liveness together.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
15 months agoqemuxml2xmltest: Use same parameters as in qemuxml2argvtest for 'riscv64-virt'
Peter Krempa [Sat, 16 Dec 2023 18:59:15 +0000 (19:59 +0100)]
qemuxml2xmltest: Use same parameters as in qemuxml2argvtest for 'riscv64-virt'

The main idea of the test is to validate config when PCIe is compiled
out.

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