Commit Graph

43177 Commits

Author SHA1 Message Date
Daniel P. Berrangé
1a29ec8bc9 gitlab: remove obsolete job rules for TEMPORARILY_DISABLED variable
We previously had a 'rules:' entry that caused a job to be skipped if
the variable "TEMPORARILY_DISABLED" was set. This is no longer needed
since we can set a similar flag in ci/manifest.yml and re-generate
to temporarily skip a job.

Unfortunately the 'rules:' entry had an unexpected side-effect on
the pipelines that was never previously noticed. Instead of only
running pipelines on push, the mere existance of the 'rules:' entry
caused triggering of pipelines on merge requests too.

The newly auto-generated ci/gitlab.yml file does not have a 'rules:'
for the container job template, and thus only runs on git push.

The result is that build jobs try to run on merge requests and the
container jobs they depend on don't exist. This breaks the entire
pipeline with a message that the config is invalid due to broken
job dependencies.

This fixes a regression introduced in

  commit ccc7a44adb
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Thu Sep 9 14:49:01 2021 +0100

    ci: re-generate containers/gitlab config from manifest

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-09-20 14:15:38 +01:00
Kristina Hanicova
19b77df5cc tools: virsh-snapshot: refactor small functions
This patch includes:
* removal of dead code
* simplifying nested if conditions
* removal of unnecessary variables
* usage of "direct" boolean return

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-20 09:35:22 +02:00
Tim Wiederhake
785a11cec8 Fix typos
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-09-17 14:28:00 +02:00
Peter Krempa
9d26af5e5b vsh: Move 'vshReadlineOptionsGenerator' out of '#if WITH_READLINE'
It's now also used in vshCompleteHelpCommand which is outside of the
conditionally compiled code.

Fixes: 80f70c74a7
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2021-09-17 11:00:13 +02:00
Peter Krempa
c580c8db70 virsh-completer: Provide completer for '--top' and '--base' for blockjobs
Complete with the indexed targets (e.g. vda[3]) based on existing
indexes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Peter Krempa
071bab399a virsh: Introduce virshCompleteEmpty and use it for places where we can't suggest anything
For now this serves just as an annotation because readline and also the
bash completion script insist on completing local paths when an empty
list is returned.

This will serve for future reference once we'll be able to properly
refuse to suggest anything.

The completer is used for fields such as names for new objects,
description strings, password strings etc, URIs and hostnames which we
can't feasibly autocomplete.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Peter Krempa
2732d81984 virsh: Use 'virshCompletePathLocalExisting' for options reading local files
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Peter Krempa
16252b16b7 virsh: completer: Introduce dummy completer for local files
For now the completion does the correct thing of completing a local path
if NULL is returned.

Introduce 'virshCompletePathLocalExisting' and use it in the
'VIRSH_COMMON_OPT_FILE' macro.

This for now serves as an annotation for the function which want to read
a file on the host running virsh. In the future this can be used with a
more sophisticated implementation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Peter Krempa
bc4739ed77 virsh: Expand VIRSH_COMMON_OPT_FILE for cases when it's not a local file used by virsh
In cases such as the APIs for managed save management, the file path
provided via the '--file' option is passed to the API.

We'll need to make them distinct from cases for when virsh is using the
file so that different completers can be used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Peter Krempa
119b139c76 virsh: Provide completers for options taking comma separated list of disk targets
'--storage' of the 'undefine' command and '--migrate-disks' of the
'migrate' command take a list of disk targets as an argument.

We can simply combine 'virshDomainDiskTargetCompleter' with
'virshCommaStringListComplete' to provide the completions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Peter Krempa
80f70c74a7 vsh: Add completer for '--command' of 'help' command
Wrap 'vshReadlineCommandGenerator' into a function with proper prototype
to provide a completer for the help command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Peter Krempa
f20512c414 virsh: Use 'virshStoragePoolNameCompleter' for two options
'--pool' of the 'pool-event' command and '--inputpool' of
'vol-create-from' use the above mentioned completer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Peter Krempa
573385dc9c virsh-snapshot: Use 'virshSnapshotNameCompleter' for '--from' of 'snapshot-list'
When listing a snapshot tree, the '--from' option takes a name of a
snapshot to limit the subset. Use virshSnapshotNameCompleter as
completer for the option.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Peter Krempa
8f5b8fac33 vsh: Introduce '--completers-missing' for 'self-test' command
Make it simple to spot which options of which commands are missing
autocompletion functions by introducing this hidden option.

In the future when we'll have completers for everything this can be also
used as a hard fail so that completers are always added.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Peter Krempa
7f72ed0707 vshCmddefCheckInternals: Sanitize command alias validation
We don't need to validate the real command twice, but it's better to
check that the real command name exists and it's not an alias to prevent
loops.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Peter Krempa
1726c572a2 virsh: Remove hack using 'VSH_CMD_FLAG_ALIAS' to hide virsh commands
Introduce a proper flag 'VSH_CMD_FLAG_HIDDEN' for hiding commands from
output so that we can validate that there aren't any loops or
misconfigured commands.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Peter Krempa
4402bff1ec virsh-completer*.h: Use modern header style
Prevent the need to edit the function declarations to put them into the
header. There was even inconsistent use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Peter Krempa
6246bc6601 virshCheckpointNameCompleter: Sanitize forward declaration use
Include the proper header instead of duplicating the declaration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-17 09:40:46 +02:00
Jonathon Jongsma
eba98a1db9 docs: update nodedev driver docs for new mdev features
Add up-to-date information about creating and defining mediated devices
in libvirt.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-16 09:54:29 -05:00
Jonathon Jongsma
70801504ca docs: Expand manpage documentation for nodedev commands
Bring the documentation for nodedev-list up to date with the latest
code, especially documenting the --active and -all options.

Also add documentation for the nodedev-define, nodedev-undefine, and
nodedev-start commands.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-16 09:51:03 -05:00
Jiri Denemark
88810c5267 virsh: Make code flow in cmdManagedSaveRemove more straightforward
By doing so we can get rid of the code which violates our coding style
guidelines.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-09-16 16:47:54 +02:00
Kristina Hanicova
4d31c02f05 virsh: add support for '--validate' option in create network
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-16 16:26:18 +02:00
Kristina Hanicova
f6b83df5b3 network: allow VIR_NETWORK_CREATE_VALIDATE flag
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-16 16:26:18 +02:00
Kristina Hanicova
d0c80da88a api: add virNetworkCreateFlags
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-16 16:26:18 +02:00
Kristina Hanicova
00182251d0 src: add driver support for networkCreateXMLFlags()
I added new driver functions to handle creating network with
given flags. I also replaced definitions of the functions without
flags with function calls to the new ones.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-16 16:26:18 +02:00
Kristina Hanicova
6a0a2840cf api: add public virNetworkCreateXMLFlags() and remote protocol
This new API creates network with given flags.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-16 16:26:18 +02:00
Laine Stump
ddba9f1dc9 conf: log error on attempts to modify ACPI index of active device
The ACPI index of a device in a running guest can't be modified, and
libvirt doesn't actually attempt to modify it, but it was possible for
a user to request such a modification, and libvirt wouldn't complain,
thus misleading the user into thinking that it had actually been changed.

Resolves: https://bugzilla.redhat.com/1998920

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-16 09:29:24 -04:00
Laine Stump
cf916af4a1 conf: reformat virDomainDefCompatibleDevice for upcoming additional check
The next patch will add another check similar to the existing check
for a change in alias name. This patch reformats the code in
preparation so that the next patch's purpose will be clear.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-16 09:29:24 -04:00
Kristina Hanicova
ceb0d2b71a tools/virsh-pool: refactor smaller functions
I think these functions look much more readable with just simple
if conditions.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-16 15:25:42 +02:00
Michal Privoznik
306a1ee685 qemu: Fix typo in qemuBuilNumaCellCache
The function should be named qemuBuildNumaCellCache (note the
missing 'd' in Build).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-16 08:45:48 +02:00
Jonathon Jongsma
815056cef8 news: mention new nodedev API
Add news item about the new API for node devices.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat>
2021-09-15 10:08:16 -05:00
Robin Lee
e6e1150523 docs: fix migration_features element name in formatcaps.html.in
Signed-off-by: Robin Lee <cheeselee@fedoraproject.org>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2021-09-15 17:00:19 +02:00
Peter Krempa
eb2e317c65 virshDomainGetVcpuBitmap: Refactor cleanup
Rename the temp variable that is being returned and use automatic
pointer clearing for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-09-15 15:31:17 +02:00
Peter Krempa
59e74c3193 virshDomainGetVcpuBitmap: Return bitmap when taking the fallback path
In case the specific VCPU states are not present in the XML we were
taking a fallback code path just noting that all cpus of the VM are
enabled.

This was broken by a mistake in a recent refactor where a 'goto cleanup'
was mistakenly replaced by a 'return NULL'. This broke reporting of cpus
and also caused a memory leak.

Return the fallback cpu map.

Fixes: bd1f40fe7d
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2004429
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-09-15 15:31:17 +02:00
Peter Krempa
3a90cb03ee qemu: validate: Allow 'preserve' action for on_crash lifecycle action
In fact keeping the VM around for debugging is a desirable configuration
and actually the implementation has no code as we keep the VM around.

Remove the validation and add a note that it's actually used.

Fixes: b1b85a475f
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2021-09-15 14:40:51 +02:00
Peter Krempa
cd09fd71d9 qemuxml2argvdata: Remove unused '.err' files
These are no longer referenced by any existing test as of:

os-firmware-invalid-type -> a9b1375d7d
tseg-explicit-size -> 604990a175

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-09-15 11:07:08 +02:00
Nick Chevsky
dbc605d8d9 qemu_tpm: Start swtpm(8) daemon with --terminate switch
Launch swtpm(8) with the --terminate switch, which guarantees that
the daemon will shut itself down when QEMU dies (current behavior).
We had so far been getting this "for free" (i.e. without --terminate)
due to a defect in upstream's connection handling logic [1], on which
libvirt should not rely since it will eventually be fixed. Adding
--terminate preserves and guarantees the current behavior.

[1] https://github.com/stefanberger/swtpm/pull/509

Signed-off-by: Nick Chevsky <nchevsky@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-15 09:54:06 +02:00
Michal Privoznik
757ed5b09c node_device_conf: Don't prealloc @vfs in virNodeDeviceGetPCISRIOVCaps()
The array of virtual functions @vfs in
virNodeDeviceGetPCISRIOVCaps() is allocated twice: the first time
during its declaration and the second time inside
virPCIGetVirtualFunctions() which leads to a memleak:

==16691== 1,128 bytes in 47 blocks are definitely lost in loss record 1,771 of 1,803
==16691==    at 0x4844CC1: calloc (vg_replace_malloc.c:1117)
==16691==    by 0x4E50070: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6800.3)
==16691==    by 0x4A7B034: virNodeDeviceGetPCISRIOVCaps (node_device_conf.c:2649)
==16691==    by 0x4A7B5E2: virNodeDeviceGetPCIDynamicCaps (node_device_conf.c:2762)
==16691==    by 0xA7F6E18: udevProcessPCI (node_device_udev.c:418)

Fixes: c97518d9b8
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-09-15 08:41:06 +02:00
Michal Privoznik
bdd3dfba15 docs: Format @variable properly
When documenting our public API in some places we use '@' to
refer to the variable. For instance:

 * This API tries to set guest time to the given value. The time
 * to set (@seconds and @nseconds) should be in seconds relative
 * to the Epoch of 1970-01-01 00:00:00 in UTC.

However, when generating HTML documentation these tokens are
copied verbatim. What we can do is drop the '@' character and
wrap the variable in <code/> so that it is formatted properly.

Due to the way we 'parse' docs a token might actually be slightly
more than just '@variable'. For instance in the example above we
will have the following tokens: '(@seconds' and '@nseconds)'.
Thus we need to handle possible substring before and after
variable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-09-15 08:37:40 +02:00
Jonathon Jongsma
0cb4550305 virsh: add nodedev-info
This is currently the only way to view the 'autostart' property for a
node device in virsh.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-09-14 14:25:56 -05:00
Jonathon Jongsma
24ffeef09c nodedev: Implement virNodeDeviceIsPersistent()/IsActive()
Implement these new API functions in the nodedev driver.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-09-14 14:25:55 -05:00
Jonathon Jongsma
6d0b85d792 api: add virNodeDeviceIsPersistent()/IsActive()
These two public APIs are implemented for almost all other objects that
have a concept of persistent definition and activatability. Now that we
have node devices (mdevs) that can be defined and inactive, it will be
useful to query the persistent/active state of node devices as well.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-09-14 14:25:10 -05:00
Jonathon Jongsma
16d078eded virsh: add nodedev-autostart
Add ability to set node devices to autostart on boot or parent device
availability.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-09-14 14:24:07 -05:00
Jonathon Jongsma
592031a580 nodedev: Add tests for mdevctl autostart command
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-09-14 14:24:07 -05:00
Jonathon Jongsma
dc60f91530 nodedev: implement virNodeDevice(Get|Set)Autostart()
Implement autostart functionality for mediated devices.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-14 14:24:00 -05:00
Jonathon Jongsma
c6607a25b9 api: add virNodeDevice(Get|Set)Autostart()
This will allow persistent mediated devices to be configured to be
restarted automatically when the host reboots.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-09-14 14:22:51 -05:00
Jim Fehlig
51eb680b26 libxl: Don't autostart domains on driver reload
When libxlAutostartDomain was introduced with commit fb92307f0d, one hunk
mistakenly added a call site in libxlStateReload. Domains should not be
autostarted when reloading the driver, so remove the offending hunk.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-09-14 11:37:35 -06:00
Jim Fehlig
65fab900c5 libxl: Fix driver reload
On reload, the libxl driver calls virDomainObjListLoadAllConfigs to load
all configs from /etc/libvirt/libxl/ but incorrectly passes 'true' for
the liveStatus parameter, resulting in error messages such as

libvirtd[21053]: XML error: unexpected root element <domain>, expecting <domstatus>
libvirtd[21053]: Failed to load config for domain 'sles15sp3'

Fix by not requesting live status when re-reading the persistent VM config
files.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-14 11:04:46 -06:00
Jim Fehlig
b75a16ae5e libxl: Improve reporting of die_id in capabilities
On Xen, libvirt runs in a VM (typically dom0) and does not have an accurate
picture of numa and cpu topology of the underlying physical machine using
the "usual" mechanisms. numa info and cpu toplogy are retrieved from libxl
and used to populate the libvirt conterparts. Commit 7b79ee2f78 introduced
support for reporting die_id in capabilities, but did not account for
special handling of numa and cpu topology in libxl.

Currently, Xen does not report die_id in the libxl_cputopology structure.
In the meantime, set die_id to 0, which was suggested by the Xen developers
and is slightly better than random garbage such as

<cpu id='1' socket_id='0' die_id='-1073069552' core_id='0' siblings='0-1'/>

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-14 11:02:26 -06:00
Andrea Bolognani
235e7c9509 ci: Regenerate configuration from manifest
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2021-09-14 18:58:49 +02:00