]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
12 months agodomain_interface: Fix build on FreeBSD
Michal Privoznik [Mon, 15 Apr 2024 06:51:23 +0000 (08:51 +0200)]
domain_interface: Fix build on FreeBSD

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

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

Currently translated at 69.1% (7223 of 10438 strings)

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

Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
12 months agoTranslated using Weblate (Swedish)
Weblate [Sat, 13 Apr 2024 12:17:45 +0000 (14:17 +0200)]
Translated using Weblate (Swedish)

Currently translated at 69.1% (7219 of 10438 strings)

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

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

Currently translated at 69.1% (7219 of 10438 strings)

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

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
12 months agovbox: Drop needless g_new0(..., 0) in vbox_snapshot_conf.c
Michal Privoznik [Fri, 12 Apr 2024 15:45:16 +0000 (17:45 +0200)]
vbox: Drop needless g_new0(..., 0) in vbox_snapshot_conf.c

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This effectively reverts commit 4b5cc57ed35dc24d11673dd3f04bfb8073c0340d.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
12 months agoqemusecuritytest: Don't call real virFileExists in mock
Jim Fehlig [Mon, 8 Apr 2024 18:40:42 +0000 (12:40 -0600)]
qemusecuritytest: Don't call real virFileExists in mock

Calling the real virFileExists in qemusecuritymock.c can cause a
segfault in qemusecuritytest. No segfaults are noticed when calling
access(2) instead of virFileExists.

Fixes: 4ed5ade753d8f1136cdbf17ddfe1d9093bcd933d
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
12 months agosecurity: Ensure file exists before attempting to restore label
Jim Fehlig [Mon, 25 Mar 2024 22:38:19 +0000 (16:38 -0600)]
security: Ensure file exists before attempting to restore label

When performing an install, it's common for tooling such as virt-install
to remove the install kernel/initrd once they are successfully booted and
the domain has been redefined to boot without them. After the installation
is complete and the domain is rebooted/shutdown, the DAC and selinux
security drivers attempt to restore labels on the now deleted files. It's
harmles wrt functionality, but results in error messages such as

Mar 08 12:40:37 virtqemud[5639]: internal error: child reported (status=125): unable to stat: /var/lib/libvirt/boot/vir>
Mar 08 12:40:37 virtqemud[5639]: unable to stat: /var/lib/libvirt/boot/virtinst-yvp19moo-linux: No such file or directo>
Mar 08 12:40:37 virtqemud[5639]: Unable to run security manager transaction

Add a check for file existence to the virSecurity*RestoreFileLabel functions,
and avoid relabeling if the file is no longer available. Skipping the restore
caused failures in qemusecuritytest, which mocks stat, chown, etc as part of
ensuring the security drivers properly restore labels. virFileExists is now
mocked in qemusecuritymock.c to return true when passed a file previously
seen by the mocked stat, chown, etc functions.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
12 months agorpcgen: tests: Include stdint.h in test_demo.c
Michal Privoznik [Mon, 8 Apr 2024 13:31:30 +0000 (15:31 +0200)]
rpcgen: tests: Include stdint.h in test_demo.c

Since header file structure is a bit different on MacOS, it
doesn't get uint64_t type declaration and thus test_demo.c must
include it explicitly. This is proper solution anyway, because on
Linux we're apparently relying on the header file sneaking
through some other include.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/619
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sat, 6 Apr 2024 20:36:02 +0000 (22:36 +0200)]
Translated using Weblate (Swedish)

Currently translated at 69.0% (7208 of 10438 strings)

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

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
13 months agoExtend libvirt-guests to shutdown only persistent VMs
Benjamin Taubmann [Tue, 26 Mar 2024 11:37:21 +0000 (11:37 +0000)]
Extend libvirt-guests to shutdown only persistent VMs

At the moment, there is no configuration option for the libvirt-guests
service that allows users to define that only persistent virtual machines
should be shutdown on host shutdown.

Currently, the service config allows to choose between two ON_SHUTDOWN
actions that are executed on running virtual machines when the host goes
down: shutdown, suspend.
The ON_SHUTDOWN action should be orthogonal to the type of the virtual
machine. However, the existing implementation, does not suspend
transient virtual machines.
This is the matrix of actions that is executed on virtual machines based
on the configured ON_SHUTDOWN action and the type of a virtual machine.

         | persistent | transient
shutdown | shutdown   | shutdown (what we want to change)
suspend  | suspend    | nothing

Add config option PERSISTENT_ONLY to libvirt-guests config that allows
users to define if the ON_SHUTDOWN action should be applied only on
persistent virtual machines. PERSISTENT_ONLY can be set to true, false,
default. The default option will implement the already existing logic.

Case 1: PERSISTENT_ONLY=default
         | persistent | transient
shutdown | shutdown   | shutdown
suspend  | suspend    | nothing

Case 2: PERSISTENT_ONLY=true
         | persistent | transient
shutdown | shutdown   | nothing
suspend  | suspend    | nothing

Case 3: PERSISTENT_ONLY=false
         | persistent | transient
shutdown | shutdown   | shutdown
suspend  | suspend    | suspend

Signed-off-by: Benjamin Taubmann <benjamin.taubmann@nutanix.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
13 months agonode_device_conf: virNodeDeviceGetSCSITargetCaps: fix memory leak
Marc Hartmayer [Wed, 27 Mar 2024 16:46:39 +0000 (17:46 +0100)]
node_device_conf: virNodeDeviceGetSCSITargetCaps: fix memory leak

Make sure the old value in `scsi_target->wwpn` is free'd before replacing it.
While at it, simplify the code.

==9104== 38 bytes in 2 blocks are definitely lost in loss record 1,943 of 3,250
==9104==    at 0x483B8C0: malloc (vg_replace_malloc.c:442)
==9104==    by 0x4DFB69B: g_malloc (gmem.c:130)
==9104==    by 0x4E1921D: g_strdup (gstrfuncs.c:363)
==9104==    by 0x495D60B: g_strdup_inline (gstrfuncs.h:321)
==9104==    by 0x495D60B: virFCReadRportValue (virfcp.c:62)
==9104==    by 0x4A5F5CB: virNodeDeviceGetSCSITargetCaps (node_device_conf.c:2914)
==9104==    by 0xBF62529: udevProcessSCSITarget (node_device_udev.c:657)
==9104==    by 0xBF62529: udevGetDeviceDetails (node_device_udev.c:1406)
==9104==    by 0xBF62529: udevAddOneDevice (node_device_udev.c:1563)
==9104==    by 0xBF639B5: udevProcessDeviceListEntry (node_device_udev.c:1637)
==9104==    by 0xBF639B5: udevEnumerateDevices (node_device_udev.c:1691)
==9104==    by 0xBF639B5: nodeStateInitializeEnumerate (node_device_udev.c:2009)
==9104==    by 0x49BDBFD: virThreadHelper (virthread.c:256)
==9104==    by 0x5242069: start_thread (in /usr/lib64/libc.so.6)

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
13 months agoqemucapabilitiestest: Update qemu-9.0 capabilities for RC1
Peter Krempa [Mon, 25 Mar 2024 13:04:59 +0000 (14:04 +0100)]
qemucapabilitiestest: Update qemu-9.0 capabilities for RC1

Update the capabilities to v9.0.0-rc1-55-g7fcf7575f3

Notable changes:
 - Q35 machine now supports 4096 cpus

 - 'kvm-asyncpf-vmexit' cpu feature added
 - 'x2apic' cpu feature is now migratable

 - LUKS detached header support added
 - LUKS sm4 cipher alg support added

 - 'console' chardev backend type removed
 - 'memory' chardev backend type deprecated

 - 'mapped-ram' migration capability added
 - 'zero-page-detection' migration parameter added

 - 'acpi-generic-initiator' 'object' added

 - 'request-ebpf' QMP command added

 - 'legacy-reset', 'resettable-container', 'vhost-user-snd*' QOM types
   added

 - 'vdpa' property added for following device models:
    - virtio-balloon-pci
    - virtio-blk-pci
    - virtio-gpu-pci
    - virtio-iommu-pci
    - virtio-mem-pci
    - virtio-net-pci
    - virtio-scsi-pci

 - 'win2k-install-hack' property of 'ide-hd' added
 - 'aw-bits', 'granule', properties of 'virtio-iommu-pci' added
 - 'ebpf-rss-fds' property of 'virtio-net-pci' added

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
13 months agotests: Add testcase for usb-net
Rayhan Faizel [Tue, 2 Apr 2024 09:18:36 +0000 (14:48 +0530)]
tests: Add testcase for usb-net

Add small test case to demonstrate use of usb-net with user networking
backend.

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
13 months agoconf: Automatically assign address to usb-net device
Rayhan Faizel [Tue, 2 Apr 2024 09:18:35 +0000 (14:48 +0530)]
conf: Automatically assign address to usb-net device

This patch will allow usb-net devices to be automatically assigned a USB
address (and skip any attempt to assign a PCI one).

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
13 months agoremote: properly initialize objects in ACL helpers
Denis V. Lunev [Tue, 19 Mar 2024 14:07:04 +0000 (15:07 +0100)]
remote: properly initialize objects in ACL helpers

Commit 2ecdf259299813c2c674377e22a0acbce5ccbbb2 was intended to
implement two things: reduce stack usage inside ACL helpers and
minimally initialize virDomainDef object to avoid passing garbage
inside validation framework. Though original commit has not
touched other ACL helpers.

This patch adds proper clauses to
    remoteRelayNetworkEventCheckACL
    remoteRelayStoragePoolEventCheckACL
    remoteRelayNodeDeviceEventCheckACL
    remoteRelaySecretEventCheckACL

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
13 months agovirsysinfo: Try reading DMI table
Brett Holman [Tue, 26 Mar 2024 19:38:50 +0000 (14:38 -0500)]
virsysinfo: Try reading DMI table

Add DMI support for risc-v and mips. Attempt to read dmidecode and
fall back to old behavior if that fails.

The SMBIOS specification[1] officially supports both RISC-V and LoongArch.
Some mips-based Loongson-3 processors also have SMBIOS.

[1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.7.0.pdf

Signed-off-by: Brett Holman <brett.holman@canonical.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
13 months agoqemu: enable display/ramfb for vfio pci hostdevs
Jonathon Jongsma [Thu, 14 Mar 2024 21:59:13 +0000 (16:59 -0500)]
qemu: enable display/ramfb for vfio pci hostdevs

Implement display="on" and ramfb="on" for vfio PCI host devices in qemu.
This enables passthrough PCI devices for display just like we did for
mdevs.

Resolves: https://issues.redhat.com/browse/RHEL-28808

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
13 months agoconf: allow display and ramfb for vfio pci hostdevs
Jonathon Jongsma [Wed, 13 Mar 2024 15:53:06 +0000 (10:53 -0500)]
conf: allow display and ramfb for vfio pci hostdevs

We already allow the user to specify display="on" and ramfb="on" for
mdev host devices. But newer GPU models will no longer use the mdev
framework, so we should enable this same functionality for other
non-mdev passthrough PCI devices.

Resolves: https://issues.redhat.com/browse/RHEL-28808

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
13 months agovirsh: Show 'connected to console' message later
Andrea Bolognani [Thu, 28 Mar 2024 22:36:40 +0000 (23:36 +0100)]
virsh: Show 'connected to console' message later

Right now, we display the message before actually attempting
to connect to the VM console. That operation, however, can
fail for a number of reasons: for example, is the VM doesn't
have a serial device, the output ends up looking like

  $ virsh console cirros
  Connected to domain 'cirros'
  Escape character is ^] (Ctrl + ])
  error: internal error: cannot find character device <null>

The initial message is misleading. Change things so that it's
only printed if we actually successfully connected to the VM
console.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
13 months agotests: Drop 'test-lib.sh'
Peter Krempa [Thu, 21 Mar 2024 13:52:05 +0000 (14:52 +0100)]
tests: Drop 'test-lib.sh'

We no longer have any shell-based tests that use it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt virsh-uriprecedence test case
Peter Krempa [Fri, 22 Mar 2024 15:23:57 +0000 (16:23 +0100)]
virshtest: Adapt virsh-uriprecedence test case

Reimplement the virsh-uriprecedence test case in virshtest. To do this
we need to add infrastructure to pass extra environment variables to the
tested virsh.

The user config files are shipped in repo rather than created in the
script.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agotests: Reimplement 'libvirtd-fail' case directly in meson
Peter Krempa [Fri, 22 Mar 2024 09:32:52 +0000 (10:32 +0100)]
tests: Reimplement 'libvirtd-fail' case directly in meson

The test simply invokes libvirtd and expects it to fail. We can do that
directly in meson without the need for a wrapper script.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agotests: Re-implement '(virsh|virt-admin)-self-test' directly in meson
Peter Krempa [Fri, 22 Mar 2024 09:02:02 +0000 (10:02 +0100)]
tests: Re-implement '(virsh|virt-admin)-self-test' directly in meson

The self-test command for both virsh and virt-admin is self contained
and directly reports success, thus we don't actually need to run a shell
wrapper around it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt 'libvirtd-pool'
Peter Krempa [Thu, 21 Mar 2024 21:21:34 +0000 (22:21 +0100)]
virshtest: Adapt 'libvirtd-pool'

The test case is a fairly simple invocation of pool-create-as which can
be done easily from 'virshtest'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt 'virsh-read-bufsiz' and 'virsh-read-non-seekable'
Peter Krempa [Thu, 21 Mar 2024 16:50:09 +0000 (17:50 +0100)]
virshtest: Adapt 'virsh-read-bufsiz' and 'virsh-read-non-seekable'

Test both situations (reading from non-regular file and reading a file
larger than (arbitrary) buffer size) via 'virshtest'.

To feed the pipe we need to create a thread that does it, but otherwise
it's fairly straightforward.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt 'virsh-checkpoint' test
Peter Krempa [Thu, 21 Mar 2024 12:49:07 +0000 (13:49 +0100)]
virshtest: Adapt 'virsh-checkpoint' test

Invoke the majority of the command via DO_TEST_SCRIPT in 'virshtest'.
Some adaptation was needed to avoid printing of tables with volatile
data such as checkpoint creation time, which were converted to list
names-only.

To proprely test redefinition we store XMLs rather than taking them from
the defined checkpoints and use them separately to test redefinition of
checkpoint XMLs. This makes use of the 'cd' command in non-interactive
mode.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt 'virsh-snapshot' test
Peter Krempa [Thu, 21 Mar 2024 12:49:07 +0000 (13:49 +0100)]
virshtest: Adapt 'virsh-snapshot' test

Invoke the majority of the command via DO_TEST_SCRIPT in 'virshtest'.
Some adaptation was needed to avoid printing of tables with volatile
data such as snapshot creation time, which were converted to list
names-only.

To proprely test redefinition we store XMLs rather than taking them from
the defined snapshots and use them separately to test redefinition of
snapshot XMLs. This makes use of the 'cd' command in non-interactive
mode.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovsh: Allow non-interactive use of 'cd' command
Peter Krempa [Thu, 21 Mar 2024 13:46:29 +0000 (14:46 +0100)]
vsh: Allow non-interactive use of 'cd' command

For testing purposes it will come handy to change the directory from a
batch-mode script. Remove the check forbidding use of the 'cd' command
in batch mode.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: Fix '--name' and '--parent' used together in '(snapshot|checkpoint)-list'...
Peter Krempa [Thu, 21 Mar 2024 12:15:40 +0000 (13:15 +0100)]
virsh: Fix '--name' and '--parent' used together in '(snapshot|checkpoint)-list' command

Until now when '--name' was used the parent was not printed and the
option was ignored. One option would be to declare the options mutually
exclusive, but for testing it may come handy to print both the snapshot
name and parent. Adjust the code to print them tab-separated and adjust
the docs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt 'virsh-start' and 'virsh-undefine' tests as 'lifecycle' case
Peter Krempa [Thu, 21 Mar 2024 11:14:06 +0000 (12:14 +0100)]
virshtest: Adapt 'virsh-start' and 'virsh-undefine' tests as 'lifecycle' case

The 'virsh-start' case simply tried to start an already running VM. This
can be easily tested together with the tests for undefining a VM.

For this test the test driver config with multiple VMs comes handy as we
need to test 3 situations when we undefine and stop the VM.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt 'virsh-schedinfo'
Peter Krempa [Thu, 21 Mar 2024 09:51:02 +0000 (10:51 +0100)]
virshtest: Adapt 'virsh-schedinfo'

It's a simple virsh invocation which can be done in 'virshtest'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt 'virsh-int-overflow'
Peter Krempa [Thu, 21 Mar 2024 09:42:13 +0000 (10:42 +0100)]
virshtest: Adapt 'virsh-int-overflow'

It's a simple test case invoking one virsh command thus it can be moved
to 'virshtest'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt 'virsh-vcpupin' test
Peter Krempa [Thu, 21 Mar 2024 09:20:25 +0000 (10:20 +0100)]
virshtest: Adapt 'virsh-vcpupin' test

As all cases are negative we can test them all in one virsh run.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agoqemuxmlconftest: Adapt XMLs from 'virsh-cpuset' and 'virsh-define-dev-segfault' cases
Peter Krempa [Thu, 21 Mar 2024 09:09:33 +0000 (10:09 +0100)]
qemuxmlconftest: Adapt XMLs from 'virsh-cpuset' and 'virsh-define-dev-segfault' cases

Rather than using 'virsh define' for the tests use the XML (or idea what
the XML is testing) and use them as 'qemuxmlconftest' cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Reimplement 'virsh-output' test
Peter Krempa [Tue, 19 Mar 2024 14:19:26 +0000 (15:19 +0100)]
virshtest: Reimplement 'virsh-output' test

Adapt the 'tests/virsh-output-commands' file from 'virsh-output' test as
a source. Apart from expanding the bash function to each command, I've
also had to drop the negative tests for argument population, as a
command parsing error aborts the execution of the script right away
rather than just reporting the error.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt 'event' option arg handling tests from 'virsh-optparse'
Peter Krempa [Mon, 18 Mar 2024 14:38:39 +0000 (15:38 +0100)]
virshtest: Adapt 'event' option arg handling tests from 'virsh-optparse'

Move the argument parsing tests excercising 'virsh event' options
from 'virsh-optparse' to 'virshtest'.

As the test invokes 'virsh event' with a timeout and thus waits for one
second pointlessly the patch also adds infrastructure to mark individual
cases as expensive and is skipped normally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt numeric option arg handling tests from 'virsh-optparse'
Peter Krempa [Mon, 18 Mar 2024 14:38:39 +0000 (15:38 +0100)]
virshtest: Adapt numeric option arg handling tests from 'virsh-optparse'

Move the argument parsing tests excercising various numeric options
(except 'virsh event') from 'virsh-optparse' to 'virshtest'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt 'snapshot-create-as' arg handling tests from 'virsh-optparse'
Peter Krempa [Mon, 18 Mar 2024 14:38:39 +0000 (15:38 +0100)]
virshtest: Adapt 'snapshot-create-as' arg handling tests from 'virsh-optparse'

Move the argument parsing tests excercising 'virsh snapshot-create-as'
from 'virsh-optparse' to 'virshtest'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt argument parsing tests from 'virsh-optparse'
Peter Krempa [Mon, 18 Mar 2024 14:19:34 +0000 (15:19 +0100)]
virshtest: Adapt argument parsing tests from 'virsh-optparse'

Move the argument parsing tests excercising 'virsh setvcpus' from
'virsh-optparse' to 'virshtest'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Drop support for testing against hardcoded strings
Peter Krempa [Fri, 22 Mar 2024 14:10:15 +0000 (15:10 +0100)]
virshtest: Drop support for testing against hardcoded strings

Now that all tests were converted, this is no longer needed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt 'iothread' tests to DO_TEST_SCRIPT
Peter Krempa [Wed, 20 Mar 2024 16:58:39 +0000 (17:58 +0100)]
virshtest: Adapt 'iothread' tests to DO_TEST_SCRIPT

Adapt the tests to be invoked in one run. Note that multiple fake VMs
were used for the distinct tests so that they don't influence each
other.

This is the final coversion of tests to run in batch mode which halved
the runtime of 'virshtest' on my machine (1.11s vs 2.33s).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt 'blkiotune' tests to DO_TEST_SCRIPT
Peter Krempa [Wed, 20 Mar 2024 16:52:19 +0000 (17:52 +0100)]
virshtest: Adapt 'blkiotune' tests to DO_TEST_SCRIPT

The query and update can be tested in one run and validated against
files rather than hardcoded strings.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt tests for domain id lookup and state query to DO_TEST_SCRIPT
Peter Krempa [Wed, 20 Mar 2024 16:48:12 +0000 (17:48 +0100)]
virshtest: Adapt tests for domain id lookup and state query to DO_TEST_SCRIPT

All of the commands can be tested in one 'virsh' run in batch mode and
tested against a file rather than hardcoded strings.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Replace list and nodeinfo tests by equivalent VIR_TEST_SCRIPT variant
Peter Krempa [Wed, 20 Mar 2024 16:34:45 +0000 (17:34 +0100)]
virshtest: Replace list and nodeinfo tests by equivalent VIR_TEST_SCRIPT variant

Add the basic list and info commands into a script and run it via
VIR_TEST_RUN_SCRIPT to simplify the code and save up on 'virsh'
instances exec'd for the test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Drop string form of expected output data of "echo" tests
Peter Krempa [Tue, 12 Mar 2024 13:34:03 +0000 (14:34 +0100)]
virshtest: Drop string form of expected output data of "echo" tests

Now that the output is tested against files these are not needed any
more. The brief existence of both proved that the output is identical.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Test against output files ("echo" tests)
Peter Krempa [Tue, 12 Mar 2024 13:13:19 +0000 (14:13 +0100)]
virshtest: Test against output files ("echo" tests)

Managing output files is much simpler especially with
VIR_TEST_REGENERATE_OUTPUT compared to putting the expected string blobs
into the C source file.

For now the output is tested both against the hardcoded strings as well
as the output files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Prepare for simpler testing - echo tests
Peter Krempa [Tue, 12 Mar 2024 12:38:24 +0000 (13:38 +0100)]
virshtest: Prepare for simpler testing - echo tests

Embedding the expected output in a C source code makes it very hard to
extend tests. In order to be able to test the outputs against data in
files on disk we need better naming of the tests themselves.

Use virTestCounterNext/Reset with appropriate tags to give reasonable
names to the 'virsh echo' tests' and prepare the 'DO_TEST' macro for
wider use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt some 'escaping' tests via DO_TEST_SCRIPT
Peter Krempa [Wed, 20 Mar 2024 15:27:18 +0000 (16:27 +0100)]
virshtest: Adapt some 'escaping' tests via DO_TEST_SCRIPT

Express what's possible via a "virsh script" rather than invoking
separate virsh for each one.

We need to keep a few for parity as the argument parser behaves
differently when processing argv-like input compared to a string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Drop some redundant 'echo' cases
Peter Krempa [Wed, 20 Mar 2024 14:40:02 +0000 (15:40 +0100)]
virshtest: Drop some redundant 'echo' cases

Both argument passing and multiple command handling is already tested in
the 'multiple commands' cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Adapt 'echo --split' tests to DO_TEST_SCRIPT
Peter Krempa [Wed, 20 Mar 2024 13:42:46 +0000 (14:42 +0100)]
virshtest: Adapt 'echo --split' tests to DO_TEST_SCRIPT

Optimize invocation of the tests to share one 'virsh' binary as they
don't influence each other.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Add support for testing commands read from input file and adapt alias...
Peter Krempa [Wed, 20 Mar 2024 08:48:32 +0000 (09:48 +0100)]
virshtest: Add support for testing commands read from input file and adapt alias tests

Add support for reading a file and passing it to virsh in 'batch' mode
so that multiple commands can be easily tested with one invocation of
virsh.

To show how it's used adapt the alias handling tests to be invoked all
at once.

As in batch mode the arguments are read from a string and separated
inside virsh, one test is kept separate to be parsed in argv mode.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Filter multiple occurences of string to drop in testFilterLine
Peter Krempa [Wed, 20 Mar 2024 16:45:56 +0000 (17:45 +0100)]
virshtest: Filter multiple occurences of string to drop in testFilterLine

Upcoming patches will require that possibly multiple occurences of the
string to drop are present in the output string thus we need to adapt
testFilterLine to handle them.

Additionally we drop the unused return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Allow to test failure of commands
Peter Krempa [Tue, 12 Mar 2024 16:15:39 +0000 (17:15 +0100)]
virshtest: Allow to test failure of commands

Modify the test code so that if virsh fails both 'stdout' and 'stderr'
are captured and compared against the output and also the return value
is checked by appending it to the output.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirshtest: Prepare for testing against output files
Peter Krempa [Tue, 12 Mar 2024 12:52:48 +0000 (13:52 +0100)]
virshtest: Prepare for testing against output files

Modify testCompareOutputLit to take a filename argument and compare it
against and populate the arguments.

For tests which don't use the 'data' from virTestRun, we'll expect to
pass the output filename, thus we also propagate it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovshCmdOptDef: Remove unused 'flags' member
Peter Krempa [Mon, 11 Mar 2024 12:22:23 +0000 (13:22 +0100)]
vshCmdOptDef: Remove unused 'flags' member

Drop the last enum member VSH_OFLAG_NONE and remove the 'flags' variable
from vshCmdOptDef.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovsh: Replace 'VSH_OFLAG_EMPTY_OK' bitwise flag with a separate struct member
Peter Krempa [Mon, 11 Mar 2024 12:17:50 +0000 (13:17 +0100)]
vsh: Replace 'VSH_OFLAG_EMPTY_OK' bitwise flag with a separate struct member

Replace the last bitwise flag with a separate member.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovsh: Make positional parsing of arguments opt-in
Peter Krempa [Tue, 5 Mar 2024 21:37:43 +0000 (22:37 +0100)]
vsh: Make positional parsing of arguments opt-in

Switch the command parser from using the VSH_OFLAG_REQ_OPT flag
opting out from positional parsing of arguments to a combination of the
'positional' flags for truly positional arguments and
'unwanted_positional' preserving semantics for the existing arguments
where the parser did it due to bad design.

This patch retires VSH_OFLAG_REQ_OPT along with the infrastructure that
was needed to refactor all uses properly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirt-admin: Annodate 'unwanted_positional' arguments
Peter Krempa [Thu, 14 Mar 2024 16:17:19 +0000 (17:17 +0100)]
virt-admin: Annodate 'unwanted_positional' arguments

Historically the command parser in virsh parses/fills even optional
arguments with values as if they were positional unless opted out using
VSH_OFLAG_REQ_OPT. This creates unexpected situations when commands can
break in this unwanted semantics:

 $ virsh snapshot-create-as --print-xml 1 2 3
 <domainsnapshot>
   <name>2</name>
   <description>3</description>
 </domainsnapshot>

To prevent any further addition annotate the rest of the arguments with
the 'unwanted_positional' flag, so that the parser can keep parsing them
as such but any further optional argument will not have this behaviour.

Certain arguments where it makes sense are annotated as 'positional' too
in this patch.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: Annodate 'unwanted_positional' arguments
Peter Krempa [Thu, 14 Mar 2024 16:17:19 +0000 (17:17 +0100)]
virsh: Annodate 'unwanted_positional' arguments

Historically the command parser in virsh parses/fills even optional
arguments with values as if they were positional unless opted out using
VSH_OFLAG_REQ_OPT. This creates unexpected situations when commands can
break in this unwanted semantics:

 $ virsh snapshot-create-as --print-xml 1 2 3
 <domainsnapshot>
   <name>2</name>
   <description>3</description>
 </domainsnapshot>

To prevent any further addition annotate the rest of the arguments with
the 'unwanted_positional' flag, so that the parser can keep parsing them
as such but any further optional argument will not have this behaviour.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: Annotate "unwanted_positional" arguments for 'pool-(define|create)-as' commands
Peter Krempa [Wed, 13 Mar 2024 21:54:05 +0000 (22:54 +0100)]
virsh: Annotate "unwanted_positional" arguments for 'pool-(define|create)-as' commands

Annotate arguments which can be unintentionally parsed positionally.
(See previous commits for explanation.)

All of these options were added in order thus we must declare all of
them as 'unwanted_positional'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: volume: Mark optional 'pool' argument as 'positional'
Peter Krempa [Thu, 14 Mar 2024 14:34:03 +0000 (15:34 +0100)]
virsh: volume: Mark optional 'pool' argument as 'positional'

Annotate arguments which can be unintentionally parsed positionally.
(See previous commits for explanation.)

The pool name is optional but in all cases it can be promoted to an
optional positional argument so that it can be properly aligned with the
expectations of the parser.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: Annotate some optional arguments as positional
Peter Krempa [Thu, 14 Mar 2024 16:13:05 +0000 (17:13 +0100)]
virsh: Annotate some optional arguments as positional

Make certain optional arguments truly positional in cases when it makes
semantic sense.

Previously it wasn't possible to have optional positional arguments, but
the parser filled them regardless, thus this preserves functionality.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh-backup: Fix argument annotations of 'backup-begin' command
Peter Krempa [Thu, 14 Mar 2024 17:05:07 +0000 (18:05 +0100)]
virsh-backup: Fix argument annotations of 'backup-begin' command

Mark the 'backupxml' as positional optional and the 'checkpointxml' as
'unwanted_positional' to preserve the positional parsing quirk.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: Make '(snapshot|checkpoint)-create' 'xmlfile' argument positional
Peter Krempa [Thu, 14 Mar 2024 16:25:02 +0000 (17:25 +0100)]
virsh: Make '(snapshot|checkpoint)-create' 'xmlfile' argument positional

The argument is optional thus couldn't be marked as positional until now,
despite being parsed positionally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: snapshot: Make 'snapshotname' argument positional
Peter Krempa [Wed, 13 Mar 2024 22:01:18 +0000 (23:01 +0100)]
virsh: snapshot: Make 'snapshotname' argument positional

The 'snapshotname' argument is optional as by default "current" snapshot
is considered. Regardless of that we should treat it as positional as
it's the common usage. This is now possible as we can have one optional
positional argument.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovsh: Make the only argument of 'connect', 'cd', and 'help' commands positional
Peter Krempa [Thu, 14 Mar 2024 15:58:40 +0000 (16:58 +0100)]
vsh: Make the only argument of 'connect', 'cd', and 'help' commands positional

The intended use of those commands is to use the argument directly
without the flag. Since the argument is optional in all cases we
couldn't declare them as positional until now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovsh: Allow one optional positional argument
Peter Krempa [Thu, 14 Mar 2024 15:21:58 +0000 (16:21 +0100)]
vsh: Allow one optional positional argument

We already allow a optional positional _ARGV argument but there's no
reason why any other argument type could not be allowed this way.

Add checks that there's just one such argument and it's placed after
required positional arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh-checkpoint: Make 'checkpointname' positional and required
Peter Krempa [Thu, 14 Mar 2024 15:56:16 +0000 (16:56 +0100)]
virsh-checkpoint: Make 'checkpointname' positional and required

The argument was being parsed positionally due to the command parser
quirk as we didn't opt out of it.

Since the code in virshLookupCheckpoint requires that the checkpointname
is present we can mark all the options as positional and required and
remove the redundant check from virshLookupCheckpoint.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: Require option flags for all optional arguments of 'attach-disk'
Peter Krempa [Wed, 13 Mar 2024 21:57:04 +0000 (22:57 +0100)]
virsh: Require option flags for all optional arguments of 'attach-disk'

Annotate arguments which can be unintentionally parsed positionally.
(See previous commits for explanation.)

Currently virsh accepts the arguments such as:

 $ virsh attach-disk --print-xml 1 2 3 4 5 6 7 8 9 10
 <disk type='file' device='10'>
   <driver name='5' type='6' iothread='7' cache='8' io='9'/>
   <source file='2'/>
   <target dev='3' bus='4'/>
 </disk>

While making virsh require the flags is technically a breaking change,
there were multiple instances where arguments were added to the argument
list thus changing the order the positional arguments would be
interpreted as. Examples are commits: 7e157858b4bbc5a8090afa,
ca21d75d25. As of such there are multiple breaks of compatibility for
the positional arguments.

As of such, require the option flag for all optional arguments with
value for 'virsh attach-disk'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: Fix "positional" argument annotations for 'migrate' command
Peter Krempa [Wed, 13 Mar 2024 21:52:12 +0000 (22:52 +0100)]
virsh: Fix "positional" argument annotations for 'migrate' command

Annotate arguments which can be unintentionally parsed positionally.
(See previous commits for explanation.)

Annotate '--migrateuri', '--graphicsuri', '--listen-address', '-dname',
'--timeout', '--xml', '--migrate-disks' and '--disks port' as
'unwanted_positional'. These were declared in chronological order per
git history.

All others are annotated with VSH_OFLAG_REQ_OPT which makes the parser
require the '--optionname'. This is due to the fact that '--disks-uri'
was introduced later and put in front of others declared earlier
breaking the order they would be accepted, thus changing the behaviour
between versions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: Require option flags for 'blkdeviotune' arguments
Peter Krempa [Wed, 13 Mar 2024 21:50:02 +0000 (22:50 +0100)]
virsh: Require option flags for 'blkdeviotune' arguments

Make all of the tunable parameter flags require the option name (don't
parse them positionally).

While techically this would be a breaking change if anyone were to
specify the tunable values positionally this is not the case as the
first two tunables are not compatible with each other:

  $ virsh blkdeviotune cd vda 4 5
  error: Unable to change block I/O throttle
  error: invalid argument: total and read/write of bytes_sec cannot be set at the same time

The above is produced by all implementations of the API (qemu and test
drivers). It is true that the first tunable can be specified
positionally (--total-bytes-sec) but it is misleading and shoud not be
allowed either.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovsh: Fix option formatting for 'VHS_OT_ARGV' options
Peter Krempa [Wed, 13 Mar 2024 15:58:52 +0000 (16:58 +0100)]
vsh: Fix option formatting for 'VHS_OT_ARGV' options

While previous fixes kept the help output unchanged as base for the
refactors it turns out that the formatting of help for argv options is
wrong.

Specifically in SYNOPSIS the non-positional _ARGV would have the option
name in square brackets (which in other cases means that given thing is
optional) despite being required.

Similarly in the DESCRIPTION section positional versions would not show
the optional argument name and also didn't use the three dots to signal
that it can be used multiple times.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: Annotate rest of _ARGV arguments as positional
Peter Krempa [Wed, 13 Mar 2024 21:45:04 +0000 (22:45 +0100)]
virsh: Annotate rest of _ARGV arguments as positional

In most cases it's the usual/recommended way to use those commands:

 $ virsh qemu-monitor-command VMNAME cmd args args args

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: Annotate '--diskspec' _ARGV options as unwanted positional
Peter Krempa [Wed, 13 Mar 2024 21:44:44 +0000 (22:44 +0100)]
virsh: Annotate '--diskspec' _ARGV options as unwanted positional

Our documentation in most places explicitly mentions --diskspec and it
was never meant to be positional, although we can't change the parser
any more. Annotate them as 'unwanted_positional'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovsh: Introduce annotation for vsh options which are unexpectedly parsed positionally
Peter Krempa [Wed, 13 Mar 2024 21:31:20 +0000 (22:31 +0100)]
vsh: Introduce annotation for vsh options which are unexpectedly parsed positionally

Based on the rationale in previous commit, all commands which were
parsed as positional but not documented as such will be annotated with
this flag.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovsh: Introduce tool to find unwanted positional arguments to 'self-test'
Peter Krempa [Wed, 13 Mar 2024 20:13:44 +0000 (21:13 +0100)]
vsh: Introduce tool to find unwanted positional arguments to 'self-test'

While the virsh option definitions specify (either explicitly after
recent refactors, or implicitly before) whether an argument is
positional or not, the actual parser is way more lax and actually and
allows also arguments which were considered/documented as non-positional
to be filled positionally unless VSH_OFLAG_REQ_OPT is used in the flags.

This creates situations such as 'snapshot-create-as' which has the
following docs:

SYNOPSIS
  snapshot-create-as <domain> [--name <string>] [--description <string>]
    [--print-xml] [--no-metadata] [--halt] [--disk-only]
    [--reuse-external] [--quiesce] [--atomic] [--live] [--validate]
    [--memspec <string>] [[--diskspec] <string>]...

Thus showing as if '--name' and '--description' required the option, but
in fact the following happens when only positionals are passed:

  $ virsh snapshot-create-as --print-xml 1 2 3 4 5
  <domainsnapshot>
    <name>2</name>
    <description>3</description>
    <disks>
      <disk name='4'/>
      <disk name='5'/>
    </disks>
  </domainsnapshot>

In the above example e.g. '--memspec' is not populated.

This disconnect makes it impossible to refactor the parser itself and
allows users to write buggy interactions with virsh.

In order to address this we'll be annotating every single of these
unwanted positional options as such so that this doesn't happen in the
future, while still preserving the quirk in the parser.

This patch introduces a tool which outputs list of options which are not
marked as positional but are lacking the VSH_OFLAG_REQ_OPT flag.

This tool will be removed once all the offenders found by it will be
addressed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: Inline VIRSH_COMMON_OPT_NETWORK_OT_STRING macro
Peter Krempa [Thu, 14 Mar 2024 21:22:08 +0000 (22:22 +0100)]
virsh: Inline VIRSH_COMMON_OPT_NETWORK_OT_STRING macro

The macro is used in just one place and the definition of the option is
going to be modified. Inline the macro.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: Inline VIRSH_COMMON_OPT_FILE_FULL macro
Peter Krempa [Thu, 14 Mar 2024 21:14:31 +0000 (22:14 +0100)]
virsh: Inline VIRSH_COMMON_OPT_FILE_FULL macro

The macro is used in one place only and the command definition will be
altered. Inline it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirsh: Inline VIRSH_COMMON_OPT_DOMAIN_OT_STRING macro
Peter Krempa [Thu, 14 Mar 2024 21:09:06 +0000 (22:09 +0100)]
virsh: Inline VIRSH_COMMON_OPT_DOMAIN_OT_STRING macro

Upcoming patches will need to tweak some of the properties of the
command. Since the macro is used in just two places expand it inline.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovshCmddefCheckInternals: Improve some checks
Peter Krempa [Thu, 14 Mar 2024 09:31:17 +0000 (10:31 +0100)]
vshCmddefCheckInternals: Improve some checks

 - move the check that completer_flags are 0 if no completer is set
   into a common place and remove duplication
 - add check that _BOOL arguments are not positional
 - add missing checks to _ALIAS

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovshCmddefHelp: Drop empty line at the end
Peter Krempa [Wed, 13 Mar 2024 14:54:47 +0000 (15:54 +0100)]
vshCmddefHelp: Drop empty line at the end

All virsh commands in non-quiet mode append another separator line thus
having two is unnecessary and in quiet mode it still has a trailing
blank line. Remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agoqemu_snapshot: correctly update metadata when deleting external snapshot with multipl...
Pavel Hrdina [Wed, 21 Feb 2024 16:45:50 +0000 (17:45 +0100)]
qemu_snapshot: correctly update metadata when deleting external snapshot with multiple branches

XML metadata for snapshot contains only single list of disk overlays
from the moment when the snapshot was taken. When user creates multiple
branches of snapshots the parent snapshot will still list only the
original disk overlays. This may cause an issue in a specific scenario:

     s1
      |
      +- s2
      +- s3 (active)

For this snapshot topology when we delete s2 metadata for s1 are not
updated. Now when we delete s1 the code operated with incorrect
overlays from s1 metadata in order to update s3 metadata resulting in no
changes to s3 metadata.

Now when user tries to delete s3 it fails with following error:

    error: Failed to delete snapshot s3
    error: operation failed: snapshot VM disk source and parent disk source are not the same

For the actual deletion there is a code to figure out the correct disk
source but it was not used to update metadata as well. Due to reasons
how block commit in libvirt works we need to create a copy of that disk
source in order to have it available when updating metadata as the
original source will be freed at that point.

Resolves: https://issues.redhat.com/browse/RHEL-26276
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
13 months agoqemu_snapshot: call qemuSnapshotDeleteUpdateDisks only for external snapshots
Pavel Hrdina [Wed, 21 Feb 2024 16:45:08 +0000 (17:45 +0100)]
qemu_snapshot: call qemuSnapshotDeleteUpdateDisks only for external snapshots

Calling this function when deleting internal snapshot isn't required
because with internal snapshots all changes are done within the file
itself so there is no file deletion and no need to update snapshot
metadata.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
13 months agoPost-release version bump to 10.3.0
Jiri Denemark [Tue, 2 Apr 2024 11:43:31 +0000 (13:43 +0200)]
Post-release version bump to 10.3.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
13 months agoRelease of libvirt-10.2.0
Jiri Denemark [Tue, 2 Apr 2024 11:38:48 +0000 (13:38 +0200)]
Release of libvirt-10.2.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
13 months agoTranslated using Weblate (Korean)
김인수 [Fri, 29 Mar 2024 14:36:18 +0000 (15:36 +0100)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10438 of 10438 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>
13 months agoNEWS: Update
Ján Tomko [Wed, 27 Mar 2024 15:05:51 +0000 (16:05 +0100)]
NEWS: Update

Update NEWS with new news.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
13 months agoNEWS: Mention fix for PCI VPD error reporting
Peter Krempa [Wed, 27 Mar 2024 15:39:55 +0000 (16:39 +0100)]
NEWS: Mention fix for PCI VPD error reporting

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agopci: Remove error reporting from PCI VPD parsing
Peter Krempa [Tue, 26 Mar 2024 14:06:58 +0000 (15:06 +0100)]
pci: Remove error reporting from PCI VPD parsing

The PCI VPD (Vital Product Data) may be missing or the kernel can report
presence but not actually have the data. Also the data is specified by
the device vendor and thus may be invalid in some cases.

To avoid log spamming, since the only usage in the node device driver is
ignoring errors, remove all error reporting.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/607
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agovirpcivpd: Revert error reporting from PCI VPD parser
Peter Krempa [Wed, 27 Mar 2024 12:52:54 +0000 (13:52 +0100)]
virpcivpd: Revert error reporting from PCI VPD parser

The VPD parsing is fragile and depends on hardware vendor's adherance to
standards. Since libvirt only ever uses this data to report it in the
nodedev XML which ignores any errors there's no much point in having
error reporting which I've added recently.

Turn the errors into VIR_DEBUG statements in preparation for upcoming
patch which completely removes the expectation to report errors.

This effectively reverts commits dfc85658bd0 and f85a382a0e7.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
13 months agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Wed, 27 Mar 2024 17:36:11 +0000 (18:36 +0100)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10438 of 10438 strings)

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

Co-authored-by: Yuri Chornoivan <yurchor@ukr.net>
Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
13 months agoTranslated using Weblate (Korean)
김인수 [Wed, 27 Mar 2024 17:36:10 +0000 (18:36 +0100)]
Translated using Weblate (Korean)

Currently translated at 99.5% (10394 of 10438 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>
13 months agovirsh: cmdDomdisplayReload: Require option name for --type
Peter Krempa [Wed, 13 Mar 2024 16:55:53 +0000 (17:55 +0100)]
virsh: cmdDomdisplayReload: Require option name for --type

As this command was introduced in this release add the flag requiring to
pass optionname.

This is needed to actually disallow positional parsing of the value
despite documenting that the flag name is required.

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