]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 months agoRelease of libvirt-10.2.0 v10.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>
18 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>
18 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>
18 months agoNEWS: Mention fix for PCI VPD error reporting v10.2.0-rc2
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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 months agoUpdate translation files
Weblate [Mon, 25 Mar 2024 11:29:40 +0000 (12:29 +0100)] 
Update translation files

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

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

Co-authored-by: Weblate <noreply@weblate.org>
Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
18 months agopo: Refresh potfile for v10.2.0 v10.2.0-rc1
Jiri Denemark [Mon, 25 Mar 2024 11:33:31 +0000 (12:33 +0100)] 
po: Refresh potfile for v10.2.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
18 months agoqemuDomainChangeNet: Error when boot index changes in live XML
Adam Julis [Fri, 22 Mar 2024 08:12:26 +0000 (09:12 +0100)] 
qemuDomainChangeNet: Error when boot index changes in live XML

If the original code detected a missing or null boot index in the
new XML, it automatically added the current value. This
autocompletion was incorrect because it was impossible to
distinguish between user intent and user error - changing the
boot order itself is forbidden and should always be an error.

Resolves: https://issues.redhat.com/browse/RHEL-23416
Fixes: aa3e07caec6179dfa6479deab14a21a493637d53
Signed-off-by: Adam Julis <ajulis@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agoNEWS: Mention loongarch64 guest support
Andrea Bolognani [Thu, 21 Mar 2024 14:37:50 +0000 (15:37 +0100)] 
NEWS: Mention loongarch64 guest support

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agoNEWS: Fix spacing
Andrea Bolognani [Thu, 21 Mar 2024 13:47:23 +0000 (14:47 +0100)] 
NEWS: Fix spacing

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agoqemu: warn on pausing of guest due to watchdog or io error
Lennart Fricke [Thu, 21 Mar 2024 12:46:28 +0000 (13:46 +0100)] 
qemu: warn on pausing of guest due to watchdog or io error

Change the log level for pauses of guests due to watchdog timeouts
or io errors from debug to warn to enhance the visibility of such
events.

Signed-off-by: Lennart Fricke <lennart.fricke@drehpunkt.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
18 months agoAdd test script for loongarch
Xianglai Li [Thu, 21 Mar 2024 03:30:29 +0000 (11:30 +0800)] 
Add test script for loongarch

Add domaincapstest qemuxml2argvtest qemuxml2xmltest
related test cases for loongarch.

Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
18 months agoImplement the method of getting host info for loongarch
Xianglai Li [Thu, 21 Mar 2024 03:30:28 +0000 (11:30 +0800)] 
Implement the method of getting host info for loongarch

Implement method for loongarch to get host info, such as
cpu frequency, system info, etc.

Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
18 months agoSupport for loongarch64 in the QEMU driver
Xianglai Li [Thu, 21 Mar 2024 03:30:27 +0000 (11:30 +0800)] 
Support for loongarch64 in the QEMU driver

Implement support for loongarch64 in the QEMU driver.

Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
18 months agoAdd loongarch cpu support
Xianglai Li [Thu, 21 Mar 2024 03:30:26 +0000 (11:30 +0800)] 
Add loongarch cpu support

Add loongarch cpu support, Define new cpu type 'loongarch64'
and implement it's driver functions.

Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
18 months agoremote: check for negative array lengths before allocation
Daniel P. Berrangé [Fri, 15 Mar 2024 10:47:50 +0000 (10:47 +0000)] 
remote: check for negative array lengths before allocation

While the C API entry points will validate non-negative lengths
for various parameters, the RPC server de-serialization code
will need to allocate memory for arrays before entering the C
API. These allocations will thus happen before the non-negative
length check is performed.

Passing a negative length to the g_new0 function will usually
result in a crash due to the negative length being treated as
a huge positive number.

This was found and diagnosed by ALT Linux Team with AFLplusplus.

CVE-2024-2494
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Found-by: Alexandr Shashkin <dutyrok@altlinux.org>
Co-developed-by: Alexander Kuznetsov <kuznetsovam@altlinux.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
19 months agoqemu: Tweak augeas schema
Andrea Bolognani [Tue, 28 Nov 2023 15:09:43 +0000 (16:09 +0100)] 
qemu: Tweak augeas schema

Current entries should always be listed before obsolete ones.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
19 months agosecurity: Drop virSecurity(DAC|SELinux)SetImageLabelRelative()
Andrea Bolognani [Tue, 21 Nov 2023 17:20:32 +0000 (18:20 +0100)] 
security: Drop virSecurity(DAC|SELinux)SetImageLabelRelative()

The single caller for each function passes the same value
for @src and @parent, which means that we don't really need
the additional API.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
19 months agosecurity: Drop virSecurity(DAC|SELinux)RestoreImageLabelSingle()
Andrea Bolognani [Mon, 20 Nov 2023 18:17:02 +0000 (19:17 +0100)] 
security: Drop virSecurity(DAC|SELinux)RestoreImageLabelSingle()

Each one only has a single, trivial caller.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
19 months agosecurity: Fix name for _virSecurityDACChardevCallbackData
Andrea Bolognani [Tue, 21 Nov 2023 16:36:56 +0000 (17:36 +0100)] 
security: Fix name for _virSecurityDACChardevCallbackData

It was clearly copied over from the SELinux driver without
updating its name in the process.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
19 months agosecurity: Fix alignment
Andrea Bolognani [Tue, 21 Nov 2023 16:17:10 +0000 (17:17 +0100)] 
security: Fix alignment

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
19 months agoNEWS: Mention save & restore support for ch driver
Purna Pavan Chandra Aekkaladevi [Mon, 11 Mar 2024 09:44:07 +0000 (09:44 +0000)] 
NEWS: Mention save & restore support for ch driver

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agodocs: Update doc for virDomainSave and virDomainRestore
Purna Pavan Chandra Aekkaladevi [Mon, 11 Mar 2024 09:44:06 +0000 (09:44 +0000)] 
docs: Update doc for virDomainSave and virDomainRestore

ch_driver expects path to be of a dir for save/restore. So, update
the documentation at global API as well.

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoch_driver: Add additional validation for save/restore
Purna Pavan Chandra Aekkaladevi [Mon, 11 Mar 2024 09:44:05 +0000 (09:44 +0000)] 
ch_driver: Add additional validation for save/restore

Save & Restore are supported without any network and hostdev config
defined. So, add a validation for it before performing save.

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoch_driver: cleanup any stale managed save dir before VM creation
Purna Pavan Chandra Aekkaladevi [Mon, 11 Mar 2024 09:44:04 +0000 (09:44 +0000)] 
ch_driver: cleanup any stale managed save dir before VM creation

There are chances that libvirt process is killed and it resulting in
stale managed save dirs. So check for it, and cleanup it there's any.

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoch_driver: Implement domain restore callbacks
Purna Pavan Chandra Aekkaladevi [Mon, 11 Mar 2024 09:44:03 +0000 (09:44 +0000)] 
ch_driver: Implement domain restore callbacks

Following callbacks have been implemented
* domainRestore
* domainRestoreFlags
The path parameter to these callbacks has to be of the directory where
libvirt has performed save. Additionally, call restore in `domainCreate`
if the domain has managedsave.

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoch_driver: Refactor virCHProcessStart
Purna Pavan Chandra Aekkaladevi [Mon, 11 Mar 2024 09:44:02 +0000 (09:44 +0000)] 
ch_driver: Refactor virCHProcessStart

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoch_driver: Implement more save callbacks
Purna Pavan Chandra Aekkaladevi [Mon, 11 Mar 2024 09:44:01 +0000 (09:44 +0000)] 
ch_driver: Implement more save callbacks

Following callbacks have been implemented
* domainSaveImageGetXMLDesc
* domainManagedSaveRemove
* domainManagedSaveGetXMLDesc
* domainHasManagedSaveImage

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoch_driver: Add domainManagedSave callback
Purna Pavan Chandra Aekkaladevi [Mon, 11 Mar 2024 09:44:00 +0000 (09:44 +0000)] 
ch_driver: Add domainManagedSave callback

Create libvirt managed saveDir and pass it to CH to save the VM

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoch_driver: Add domainSave, domainSaveFlags callbacks
Purna Pavan Chandra Aekkaladevi [Mon, 11 Mar 2024 09:43:59 +0000 (09:43 +0000)] 
ch_driver: Add domainSave, domainSaveFlags callbacks

Implemented save callbacks. CH's vmm.snapshot API is called to save the
domain state. The path passed to these callbacks has to be of directory
as CH takes dir as input to snapshot and saves multiple files under it.

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoch_driver: Pass virCHDriverConfig to virCHMonitorNew
Purna Pavan Chandra Aekkaladevi [Mon, 11 Mar 2024 09:43:58 +0000 (09:43 +0000)] 
ch_driver: Pass virCHDriverConfig to virCHMonitorNew

Pass virCHDriverConfig to VirCHMonitorNew instead of just stateDir so
that the cfg can be used for any additional purposes.

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoch_driver: Support Save, Restore VM actions from monitor
Purna Pavan Chandra Aekkaladevi [Mon, 11 Mar 2024 09:43:57 +0000 (09:43 +0000)] 
ch_driver: Support Save, Restore VM actions from monitor

Implement folowing API calls from CH monitor
* vmm.snapshot -> to save a domain
* vmm.restore -> to restore saved domain

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoNEWS: Announce support for MTP filesystem driver type
Rayhan Faizel [Tue, 19 Mar 2024 19:43:22 +0000 (01:13 +0530)] 
NEWS: Announce support for MTP filesystem driver type

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agomeson: Check for sched_get_priority_min()
Andrea Bolognani [Tue, 27 Feb 2024 14:58:27 +0000 (15:58 +0100)] 
meson: Check for sched_get_priority_min()

virProcessSetScheduler() uses not just sched_setscheduler() but
also sched_get_priority_{min,max}(). Currently we assume that
the former being available implies that the latter are as well,
but that's not the case for at least GNU/Hurd.

Make sure all functions are actually available before
attempting to use them.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agomeson: Restore check for sched_getaffinity()
Andrea Bolognani [Tue, 27 Feb 2024 14:52:15 +0000 (15:52 +0100)] 
meson: Restore check for sched_getaffinity()

Commit c07cf0a68693 replaced this check with one for the
presence of cpu_set_t.

The idea at the time was that only sched_{get,set}affinity()
were visible by default, while making cpu_set_t visible required
defining _WITH_CPU_SET_T. So libvirt would detect the function
and attempt to use it, but the code would not compile because
the necessary data type had not been made accessible.

The commit in question brought three FreeBSD commits as evidence
of this. While [1] and [2] do indeed seem to support this
explanation, [3] from just a few days later made it so that not
just cpu_set_t, but also the functions, required user action to
be visible. This arguably would have made the change unnecessary.

However, [4] from roughly a month later changed things once
again: it completely removed _WITH_CPU_SET_T, making both the
functions and the data type visible by default.

This is the status quo that seems to have persisted until
today. If one were to check any recent FreeBSD build job
performed as part of our CI pipeline, for example [5] and [6]
for FreeBSD 13 and 14 respectively, they would be able to
confirm that in both cases cpu_set_t is detected as available.

Since there is no longer a difference between the availability
of the functions and that of the data type, go back to what we
had before.

This has the interesting side-effect of fixing a bug
introduced by the commit in question.

When detection was changed from the function to the data type,
most uses of WITH_SCHED_GETAFFINITY were replaced with uses of
WITH_DECL_CPU_SET_T, but not all of them: specifically, those
that decided whether qemuProcessInitCpuAffinity() would be
actually implemented or replaced with a no-op stub were not
updated, which means that we've been running the stub version
everywhere except on FreeBSD ever since.

The code has been copied to the Cloud Hypervisor driver in
the meantime, which is similarly affected. Now that we're
building the actual implementation, we need to add virnuma.h
to the includes.

As a nice bonus this also makes things work correctly on
GNU/Hurd, where cpu_set_t is available but
sched_{get,set}affinity() are non-working stubs.

[1] https://cgit.freebsd.org/src/commit/?id=160b4b922b6021848b6b48afc894d16b879b7af2
[2] https://cgit.freebsd.org/src/commit/?id=43736b71dd051212d5c55be9fa21c45993017fbb
[3] https://cgit.freebsd.org/src/commit/?id=90fa9705d5cd29cf11c5dc7319299788dec2546a
[4] https://cgit.freebsd.org/src/commit/?id=5e04571cf3cf4024be926976a6abf19626df30be
[5] https://gitlab.com/libvirt/libvirt/-/jobs/6266401204
[6] https://gitlab.com/libvirt/libvirt/-/jobs/6266401205

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoutil: Add debug print missing from BSD
Andrea Bolognani [Fri, 23 Feb 2024 00:41:15 +0000 (01:41 +0100)] 
util: Add debug print missing from BSD

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
19 months agoutil: Prefer cpuset_{get,set}affinity() on BSD
Andrea Bolognani [Fri, 23 Feb 2024 00:37:22 +0000 (01:37 +0100)] 
util: Prefer cpuset_{get,set}affinity() on BSD

FreeBSD 14 implements sched_{get,set}affinity() for
compatibility with Linux, but we should still use the native
syscalls instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
19 months agoutil: Accept TIDs for virProcess{Get,Set}Affinity() on BSD
Andrea Bolognani [Fri, 23 Feb 2024 00:29:28 +0000 (01:29 +0100)] 
util: Accept TIDs for virProcess{Get,Set}Affinity() on BSD

Depending on the situation, the IDs that we pass to these
functions can be either referring to processes or threads.

Linux doesn't have separate interfaces for one or the other,
but FreeBSD does and we're explicitly telling it that the ID
refers to a process. When it refers to a thread instead, the
call will fail, and the VM will not be able to start.

Luckily, another possible choice is CPU_WHICH_TIDPID, which
makes things behave the same as Linux.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
19 months agoqemu_command: Generate command line for MTP filesystem
Rayhan Faizel [Tue, 19 Mar 2024 15:16:30 +0000 (16:16 +0100)] 
qemu_command: Generate command line for MTP filesystem

The source tag sets the rootdir property of the device, which is
the directory exposed to the guest via the MTP device. The target
tag sets the desc property.  This device supports read-only mode
as well. Like virtiofs, it does not support additional access
modes.

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoconf: Introduce support for usb-mtp devices
Rayhan Faizel [Tue, 19 Mar 2024 15:15:50 +0000 (16:15 +0100)] 
conf: Introduce support for usb-mtp devices

Expose usb-mtp device as another type of <filesystem/>.

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoqemu_capabilities: Add QEMU_CAPS_DEVICE_USB_MTP capability
Rayhan Faizel [Fri, 8 Mar 2024 20:16:45 +0000 (01:46 +0530)] 
qemu_capabilities: Add QEMU_CAPS_DEVICE_USB_MTP capability

This capability reflects presence of -device usb-mtp.

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agovirt-admin: Fix segfault when libvirtd dies
Adam Julis [Tue, 19 Mar 2024 11:02:51 +0000 (12:02 +0100)] 
virt-admin: Fix segfault when libvirtd dies

vshAdmCatchDisconnect requires non-NULL structure vshControl for
getting connection name (stored at opaque), but
virAdmConnectRegisterCloseCallback at vshAdmConnect called it
with NULL.

Signed-off-by: Adam Julis <ajulis@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
19 months agonode_device_driver: use g_autofree instead of VIR_FREE()
Karim Taha [Sun, 17 Mar 2024 15:19:21 +0000 (17:19 +0200)] 
node_device_driver: use g_autofree instead of VIR_FREE()

Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoopenvz_driver: use g_autofree instead of VIR_FREE()
Karim Taha [Sun, 17 Mar 2024 15:19:20 +0000 (17:19 +0200)] 
openvz_driver: use g_autofree instead of VIR_FREE()

Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoqemu: virtiofs: error out if getting the group or user name fails
Ján Tomko [Thu, 7 Mar 2024 12:36:45 +0000 (13:36 +0100)] 
qemu: virtiofs: error out if getting the group or user name fails

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoqemu: virtiofs: set correct label when creating the socket
Ján Tomko [Wed, 6 Mar 2024 16:26:40 +0000 (17:26 +0100)] 
qemu: virtiofs: set correct label when creating the socket

Use svirt_t instead of virtd_t, since virtd_t is not available in the
session mode and qemu with svirt_t won't be able to talk to unconfined_t
socket.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoqemu: virtiofs: do not crash if cgroups are missing
Ján Tomko [Tue, 5 Mar 2024 13:55:26 +0000 (14:55 +0100)] 
qemu: virtiofs: do not crash if cgroups are missing

On domain startup, qemuSetupCgroupForExtDevices checks
if a cgroup controller is present and skips the setup if not.

Add a similar check to qemuVirtioFSSetupCgroup to prevent
crashing when hotplugging a virtiofs filesystem.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agovirthreadpool: create threads from the newly expanded workers
Wei Gong [Mon, 18 Mar 2024 13:31:14 +0000 (21:31 +0800)] 
virthreadpool: create threads from the newly expanded workers

when the thread pool is dynamically expanded, threads should
not be created from the existing workers; they should be created
from the newly expanded workers

Signed-off-by: Wei Gong <gongwei833x@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoopenvz_conf: Use g_autofree
Rayhan Faizel [Thu, 14 Mar 2024 20:22:49 +0000 (01:52 +0530)] 
openvz_conf: Use g_autofree

Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
19 months agoNEWS: Document the fix for migration or vmx enabled domains
Jiri Denemark [Tue, 12 Mar 2024 16:54:41 +0000 (17:54 +0100)] 
NEWS: Document the fix for migration or vmx enabled domains

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to Westmere*
Jiri Denemark [Thu, 7 Mar 2024 13:03:38 +0000 (14:03 +0100)] 
Add vmx-* features to Westmere*

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to Snowridge
Jiri Denemark [Thu, 7 Mar 2024 13:05:53 +0000 (14:05 +0100)] 
Add vmx-* features to Snowridge

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to Skylake*
Jiri Denemark [Thu, 7 Mar 2024 13:00:53 +0000 (14:00 +0100)] 
Add vmx-* features to Skylake*

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to SapphireRapids
Jiri Denemark [Thu, 7 Mar 2024 13:05:34 +0000 (14:05 +0100)] 
Add vmx-* features to SapphireRapids

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to SandyBridge*
Jiri Denemark [Thu, 7 Mar 2024 13:03:18 +0000 (14:03 +0100)] 
Add vmx-* features to SandyBridge*

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to Penryn
Jiri Denemark [Thu, 7 Mar 2024 13:05:20 +0000 (14:05 +0100)] 
Add vmx-* features to Penryn

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to Nehalem*
Jiri Denemark [Thu, 7 Mar 2024 13:04:21 +0000 (14:04 +0100)] 
Add vmx-* features to Nehalem*

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to kvm*
Jiri Denemark [Thu, 7 Mar 2024 13:06:37 +0000 (14:06 +0100)] 
Add vmx-* features to kvm*

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to IvyBridge*
Jiri Denemark [Thu, 7 Mar 2024 13:04:01 +0000 (14:04 +0100)] 
Add vmx-* features to IvyBridge*

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to Icelake*
Jiri Denemark [Thu, 7 Mar 2024 13:02:47 +0000 (14:02 +0100)] 
Add vmx-* features to Icelake*

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to Haswell*
Jiri Denemark [Thu, 7 Mar 2024 13:01:50 +0000 (14:01 +0100)] 
Add vmx-* features to Haswell*

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to core{,2}duo
Jiri Denemark [Thu, 7 Mar 2024 13:06:13 +0000 (14:06 +0100)] 
Add vmx-* features to core{,2}duo

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to Cooperlake
Jiri Denemark [Thu, 7 Mar 2024 13:05:01 +0000 (14:05 +0100)] 
Add vmx-* features to Cooperlake

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to Conroe
Jiri Denemark [Thu, 7 Mar 2024 13:04:45 +0000 (14:04 +0100)] 
Add vmx-* features to Conroe

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to Cascadelake*
Jiri Denemark [Thu, 7 Mar 2024 13:01:25 +0000 (14:01 +0100)] 
Add vmx-* features to Cascadelake*

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoAdd vmx-* features to Broadwell*
Jiri Denemark [Thu, 7 Mar 2024 13:00:15 +0000 (14:00 +0100)] 
Add vmx-* features to Broadwell*

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agocpu_map: Do not ignore VMX features in sync_qemu_models script
Jiri Denemark [Thu, 7 Mar 2024 12:21:31 +0000 (13:21 +0100)] 
cpu_map: Do not ignore VMX features in sync_qemu_models script

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
19 months agoqemu: domain: Drop added features from migratable CPU
Jiri Denemark [Mon, 11 Mar 2024 16:04:48 +0000 (17:04 +0100)] 
qemu: domain: Drop added features from migratable CPU

Features marked with added='yes' in CPU model definitions have to be
removed before migration, otherwise older libvirt would complain about
unknown CPU features. We only do this for features that were enabled for
a given CPU model even with older libvirt, which just ignored the
features. And only for features we added ourselves when updating CPU
definition during domain startup, that is we do not remove features
which were explicitly mentioned by a user.

That said, this is not the safest thing we could do, but it's
effectively the same thing we did before the affected features were
added: we ignored them completely on both sides of migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoconf: cpu: Introduce virCPUDefListFeatures
Jiri Denemark [Mon, 11 Mar 2024 14:37:32 +0000 (15:37 +0100)] 
conf: cpu: Introduce virCPUDefListFeatures

The function returns a list of explicitly mentioned features in the CPU
definition.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agoqemu: domain: Check arch in qemuDomainMakeCPUMigratable
Jiri Denemark [Mon, 11 Mar 2024 14:34:37 +0000 (15:34 +0100)] 
qemu: domain: Check arch in qemuDomainMakeCPUMigratable

The content is arch specific and checking for Icelake-Server CPU model
on non-x86 architectures does not make sense.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agocpu: x86: Add support for adding features to existing CPU models
Jiri Denemark [Thu, 7 Mar 2024 13:50:48 +0000 (14:50 +0100)] 
cpu: x86: Add support for adding features to existing CPU models

This is not a good idea in general, but we can (and have to) do it in
specific cases when a feature has always been part of a CPU model in
hypervisor's definition, but we ignored it and did not include the
feature in our definition.

Blindly adding the features to the CPU map and not adding them to
existing CPU models breaks migration between old and new libvirt in both
directions. New libvirt would complain the features got unexpectedly
enabled (as they were not mentioned in the incoming domain XML) even
though they were also enabled on the source and the old libvirt just
didn't know about them. On the other hand, old libvirt would refuse to
accept incoming migration of a domain started by new libvirt because the
domain XML would contain CPU features unknown to the old libvirt.

This is exactly what happened when several vmx-* features were added a
few releases back. Migration between libvirt releases before and after
the addition is now broken.

This patch adds support for added these features to existing CPU models
by marking them with added='yes'. The features will not be considered
part of the CPU model and will be described explicitly via additional
<feature/> elements, but the compatibility check will not complain if
they are enabled by the hypervisor even though they were not explicitly
mentioned in the CPU definition and incoming migration from old libvirt
will succeed.

To fix outgoing migration to old libvirt, we also need to drop all those
features from domain XML unless they were explicitly requested by the
user. This will be handled by a later patch.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
19 months agotests: mock __open_2()
Michal Privoznik [Wed, 13 Mar 2024 16:25:35 +0000 (17:25 +0100)] 
tests: mock __open_2()

As of commit [1] glibc may overwrite a call to open() with call
to __open_2() (if only two arguments are provided and the code is
compiled with clang). But since we are not mocking the latter our
test suite is broken as tests try to access paths outside of our
repo.

1: https://sourceware.org/git/?p=glibc.git;a=commit;h=86889e22db329abac618c6a41f86c84657a15324
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
19 months agovirusbmock: Switch to VIR_MOCK_REAL_INIT()
Michal Privoznik [Wed, 13 Mar 2024 16:35:15 +0000 (17:35 +0100)] 
virusbmock: Switch to VIR_MOCK_REAL_INIT()

Since virusbmock was written 10 years ago, back when we didn't
have virmock.h and its helpers, it open codes symbol resolution
(VIR_MOCK_REAL_INIT). With a bit of cleanup (e.g. renaming
realopen to real_open and so on) it can use virmock.h provided
macros.

And while at it, drop include of virusb.h - there is no
compelling reason for it include the file. The mock just
redirects paths passed to open()/opendir().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
19 months agovsh: remove VSH_OFLAG_REQ
Peter Krempa [Tue, 5 Mar 2024 16:21:05 +0000 (17:21 +0100)] 
vsh: remove VSH_OFLAG_REQ

The flag was replaced by the 'required' field in the option definition.
Remove last few uses and all assignments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovsh: Replace VSH_OT_DATA by VSH_OT_STRING
Peter Krempa [Tue, 5 Mar 2024 15:07:36 +0000 (16:07 +0100)] 
vsh: Replace VSH_OT_DATA by VSH_OT_STRING

Use the new 'positional' field to do decisions rather than have a
special type for positional strings.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovshCmddefHelp: Refactor and fix printing of help for _STRING/_INT arguments
Peter Krempa [Tue, 5 Mar 2024 15:53:55 +0000 (16:53 +0100)] 
vshCmddefHelp: Refactor and fix printing of help for _STRING/_INT arguments

Use the new flags to do the decisions which will also fix the case when
an _INT option is required but non-positional.

This fixes the help for the 'timeout' argument of 'daemon-timeout'
virt-admin command:

     SYNOPSIS
  -    daemon-timeout <timeout>
  +    daemon-timeout --timeout <number>

[...]
     OPTIONS
  -    [--timeout] <number>  number of seconds the daemon will run without any active connection
  +    --timeout <number>  number of seconds the daemon will run without any active connection

Resolves: https://issues.redhat.com/browse/RHEL-25993
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovshCmdGrpHelp: Refactor formatting of help for VSH_OT_ARGV
Peter Krempa [Tue, 5 Mar 2024 15:32:40 +0000 (16:32 +0100)] 
vshCmdGrpHelp: Refactor formatting of help for VSH_OT_ARGV

Use the new properties rather than infer the states.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovshCmddefCheckInternals: Remove refactoring safety checks
Peter Krempa [Tue, 5 Mar 2024 15:23:19 +0000 (16:23 +0100)] 
vshCmddefCheckInternals: Remove refactoring safety checks

Now that the code was refactored and proved identical, remove the checks
so that they don't impede further refactors.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovsh: Require that positional non-argv arguments are required
Peter Krempa [Tue, 5 Mar 2024 15:17:21 +0000 (16:17 +0100)] 
vsh: Require that positional non-argv arguments are required

This is logically enforced by existing checks, thus we can formalize it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovsh: Fix broken assumption that required VSH_OT_INT must be positional
Peter Krempa [Tue, 5 Mar 2024 15:00:41 +0000 (16:00 +0100)] 
vsh: Fix broken assumption that required VSH_OT_INT must be positional

In at least one case we've wanted a mandatory argument which requires
the explicit flag. Fix the assumption before converting everything over
to the new flags.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovsh: Annotate 'required' and 'positional' arguments explicitly
Peter Krempa [Tue, 5 Mar 2024 14:07:47 +0000 (15:07 +0100)] 
vsh: Annotate 'required' and 'positional' arguments explicitly

Add 'positional' and 'required' fields to vshCmdOptDef, which will
explicitly track the two properties of arguments.

To ensure that we have proper coverage, add checks to
vshCmddefCheckInternals validating the state of the above flags by
infering it from existing data.

This conversion will allow us:
 - remove VSH_OT_DATA in favor of VSH_OT_STRING
 - use VSH_OT_INT when required both as positional and non-positional
 - properly annotate which VSH_OT_ARGV are positional and which are not
   (currently inferred by whether an previous positional option exists)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovirsh: Inline only use of VIRSH_COMMON_OPT_DOMAIN_OT_ARGV macro
Peter Krempa [Tue, 5 Mar 2024 14:22:35 +0000 (15:22 +0100)] 
virsh: Inline only use of VIRSH_COMMON_OPT_DOMAIN_OT_ARGV macro

There's just one command taking a list of domains as argument, thus
declare it inline.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovshCmddefGetOption: Improve readability
Peter Krempa [Tue, 5 Mar 2024 11:35:51 +0000 (12:35 +0100)] 
vshCmddefGetOption: Improve readability

Declare one argument per line, separate disticnt conditions by newline,
move some checks earlier.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovshCmddefHelp: Refactor printing of help (argument description)
Peter Krempa [Fri, 1 Mar 2024 13:51:46 +0000 (14:51 +0100)] 
vshCmddefHelp: Refactor printing of help (argument description)

Extract flag check to a separate variable and replace ternary operators
by normal conditions and use allocated buffer instead of a static one
to improve readability.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
19 months agovshCmddefHelp: Refactor printing of help (list of arguments)
Peter Krempa [Fri, 1 Mar 2024 13:51:46 +0000 (14:51 +0100)] 
vshCmddefHelp: Refactor printing of help (list of arguments)

Extract flag check to a separate variable and replace ternary operators
by normal conditions and directly output the text rather than using
extra variable to improve readability.

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