]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agocpu: Run arch specific code for virCPUUpdate for all custom CPUs
Jiri Denemark [Thu, 19 Nov 2020 20:35:41 +0000 (21:35 +0100)]
cpu: Run arch specific code for virCPUUpdate for all custom CPUs

Until now, the function returned immediately when the guest CPU
definition did not use optional features or minimum match. Clearly,
there's nothing to be updated according to the host CPU in this case,
but the arch specific code may still want to do some compatibility
updates based on the model and features used in the guest CPU
definition.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agoconf: Add virCPUDefAddFeatureIfMissing
Jiri Denemark [Thu, 19 Nov 2020 17:44:48 +0000 (18:44 +0100)]
conf: Add virCPUDefAddFeatureIfMissing

This new function adds a feature to a CPU definition only if it is not
present there yet.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agoconf: Use enum in virCPUDefAddFeatureInternal
Jiri Denemark [Thu, 19 Nov 2020 17:34:02 +0000 (18:34 +0100)]
conf: Use enum in virCPUDefAddFeatureInternal

Replace the 'update' bool parameter with an enum so that we can have
more than two possible values.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agoconf: Rename virCPUDefUpdateFeatureInternal
Jiri Denemark [Thu, 19 Nov 2020 17:24:01 +0000 (18:24 +0100)]
conf: Rename virCPUDefUpdateFeatureInternal

The function is supposed to add a feature to a CPU definition, let's
name it virCPUDefAddFeatureInternal. The behavior in case the feature is
already present in the CPU def is configurable and we will soon add a
new option to not do anything in that case, which wouldn't really work
well with the current *Update* name.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agoschema: add support for Windows file paths and device names
Matt Coleman [Mon, 23 Nov 2020 17:39:53 +0000 (12:39 -0500)]
schema: add support for Windows file paths and device names

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Matt Coleman <matt@datto.com>
4 years agohyperv: XML parsing of storage volumes
Matt Coleman [Mon, 23 Nov 2020 17:39:52 +0000 (12:39 -0500)]
hyperv: XML parsing of storage volumes

dumpxml can now serialize:
* floppy drives
* file-backed and device-backed disk drives
* images mounted to virtual CD/DVD drives
* IDE and SCSI controllers

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
4 years agodocs: migration: Add a mention of VIR_MIGRATE_TLS and its enforcement for qemu
Peter Krempa [Tue, 24 Nov 2020 13:49:14 +0000 (14:49 +0100)]
docs: migration: Add a mention of VIR_MIGRATE_TLS and its enforcement for qemu

Mention the flag to enable TLS and also the knob to enforce it in the
qemu hypervisor driver.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: conf: Introduce "migrate_tls_force" qemu.conf option
Peter Krempa [Tue, 24 Nov 2020 13:08:04 +0000 (14:08 +0100)]
qemu: conf: Introduce "migrate_tls_force" qemu.conf option

Forgetting to use the VIR_MIGRATE_TLS flag with migration can lead to
leak of sensitive information. Add an administrative knob to force use
of the flag.

Note that without VIR_MIGRATE_PEER2PEER, the migration is driven by an
instance of the client library which doesn't necessarily run on either
of the hosts so the flag can't be used to assume VIR_MIGRATE_TLS even
if it wasn't provided by the user instead of rejecting if it's not.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/67
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agodocs: migration: Mention that features may not work with tunnelled migration
Peter Krempa [Tue, 24 Nov 2020 13:51:23 +0000 (14:51 +0100)]
docs: migration: Mention that features may not work with tunnelled migration

Enumerate some features which are incompatible with tunnelled migration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: migration: Forbid tunnelled non-shared storage migration with -blockdev
Peter Krempa [Tue, 24 Nov 2020 07:32:32 +0000 (08:32 +0100)]
qemu: migration: Forbid tunnelled non-shared storage migration with -blockdev

qemu's internals were not prepared for switching to -blockdev for the
legacy storage migration. Add a proper error message since qemu is
unlikely to attempt fixing the old protocol.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/65
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: migration: Aggregate logic depending on tunnelled migration
Peter Krempa [Tue, 24 Nov 2020 07:11:18 +0000 (08:11 +0100)]
qemu: migration: Aggregate logic depending on tunnelled migration

Move and aggregate all the logic which is switched based on whether the
migration is tunnelled or not before other checks. Further checks will
be added later.

While the code is being moved the error message is put on a single line
per new coding style.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: migration: Remove TODO about implementing NBD for TUNNELLED migration
Peter Krempa [Tue, 24 Nov 2020 07:04:36 +0000 (08:04 +0100)]
qemu: migration: Remove TODO about implementing NBD for TUNNELLED migration

Our streams are not the best transport for migration data and we support
TLS for security now. It's unlikely that there will be enough motivation
to add a new migration protocol to tunnel NBD too.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agodocs: migration: Fix example for unix socket migration
Peter Krempa [Tue, 24 Nov 2020 13:44:05 +0000 (14:44 +0100)]
docs: migration: Fix example for unix socket migration

Fix the following issues:

1) the very long line is overflowing the code box
2) '--migrateuri' was missing for the qemu data stream
3) '--desturi' was not used making it non-obvious what the argument
   corresponds to

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: checkpoint: Write metadata of previously-'current' checkpoint on update
Peter Krempa [Mon, 23 Nov 2020 11:51:23 +0000 (12:51 +0100)]
qemu: checkpoint: Write metadata of previously-'current' checkpoint on update

Similarly to previous commit dealing with snapshots we must rewrite the
metadata of the previously-'current' checkpoint when changing which
checkpoint is considered 'current'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: snapshot: Write metadata of previously-'current' snapshot on update
Peter Krempa [Mon, 23 Nov 2020 10:56:12 +0000 (11:56 +0100)]
qemu: snapshot: Write metadata of previously-'current' snapshot on update

Whether a snapshot definition is considered 'current' or active is
stored in the metadata XML libvirt writes when we create metadata.

This means that if we are changing the 'current' snapshot we must
re-write the metadata of the previously 'current' snapshot to update the
field to prevent having multiple active snapshots.

Unfortunately the snapshot creation code didn't do this properly, which
resulted in the following error:

error : qemuDomainSnapshotLoad:430 : internal error: Too many snapshots claiming to be current for domain snapshot-test

being printed if libvirtd was terminated and restarted.

Introduce qemuSnapshotSetCurrent which writes out the old snapshot's
metadata when updating the current snapshot.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainSnapshotForEachQcow2: Pass in 'def' rather than selecting it internally
Peter Krempa [Mon, 23 Nov 2020 10:13:19 +0000 (11:13 +0100)]
qemuDomainSnapshotForEachQcow2: Pass in 'def' rather than selecting it internally

In some cases such as when creating an internal inactive snapshot we
know that the domain definition in the snapshot is equivalent to the
current definition. Additionally we set up the current definition for
the snapshotting but not the one contained in the snapshot. Thus in some
cases the caller knows better which def to use.

Make qemuDomainSnapshotForEachQcow2 take the definition by the caller
and copy the logic for selecting the definition to callers where we
don't know for sure that the above claim applies.

This fixes internal inactive snapshots when <disk type='volume'> is used
as we translate the pool/vol combo only in the current def.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/97
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainSnapshotForEachQcow2Raw: Lock out operation on unsupported storage
Peter Krempa [Mon, 23 Nov 2020 09:30:31 +0000 (10:30 +0100)]
qemuDomainSnapshotForEachQcow2Raw: Lock out operation on unsupported storage

Don't try to manipulate snapshots on network or unresolved volume backed
storage.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainSnapshotForEachQcow2Raw: Avoid a level of indentation
Peter Krempa [Mon, 23 Nov 2020 09:22:30 +0000 (10:22 +0100)]
qemuDomainSnapshotForEachQcow2Raw: Avoid a level of indentation

'continue' the loop if the device is not a disk. Saving the level makes
one of the error messages fit on a single line.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainDiskTranslateSourcePool: Don't break error message in half
Peter Krempa [Mon, 23 Nov 2020 09:03:30 +0000 (10:03 +0100)]
virDomainDiskTranslateSourcePool: Don't break error message in half

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirCommandAddArg: Don't abort on invalid input
Peter Krempa [Mon, 23 Nov 2020 08:59:54 +0000 (09:59 +0100)]
virCommandAddArg: Don't abort on invalid input

Commit 912c6b22fc622cd7c7d29c7f8eaeb816b266daac added abort() when the
'val' parameter is NULL along with setting the error variable for the
command. We don't want to abort in this case, just set the error.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirnetdaemon: Wait for "daemon-stop" thread to finish before quitting
Michal Privoznik [Fri, 13 Nov 2020 09:56:59 +0000 (10:56 +0100)]
virnetdaemon: Wait for "daemon-stop" thread to finish before quitting

When the host is shutting down then we get PrepareForShutdown
signal on DBus to which we react by creating a thread which
runs virStateStop() and thus qemuStateStop(). But if scheduling
the thread is delayed just a but it may happen that we receive
SIGTERM (sent by systemd) to which we respond by quitting our
event loop and cleaning up everything (including drivers). And
only after that the thread gets to run only to find qemu_driver
being NULL.

What we can do is to delay exiting event loop and join the thread
that's executing virStateStop(). If the join doesn't happen in
given timeout (currently 30 seconds) then libvirtd shuts down
forcefully anyways (see virNetDaemonRun()).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1895359
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1739564

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: secret: remove cleanup labels
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:46 +0000 (16:09 -0600)]
util: secret: remove cleanup labels

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: storageencryption: remove cleanup labels
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:45 +0000 (16:09 -0600)]
util: storageencryption: remove cleanup labels

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: uri: remove cleanup label
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:43 +0000 (16:09 -0600)]
util: uri: remove cleanup label

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: cgroupv1: convert pointers to use g_autofree
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:40 +0000 (16:09 -0600)]
util: cgroupv1: convert pointers to use g_autofree

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: dnsmasq: convert pointers to use g_autofree
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:39 +0000 (16:09 -0600)]
util: dnsmasq: convert pointers to use g_autofree

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: hostcpu: convert pointers to use g_autofree
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:37 +0000 (16:09 -0600)]
util: hostcpu: convert pointers to use g_autofree

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: lockspace: convert pointers to use g_autofree
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:36 +0000 (16:09 -0600)]
util: lockspace: convert pointers to use g_autofree

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: log: convert pointers to use g_autofree
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:35 +0000 (16:09 -0600)]
util: log: convert pointers to use g_autofree

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: macmap: convert pointers to use g_autofree
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:34 +0000 (16:09 -0600)]
util: macmap: convert pointers to use g_autofree

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: secret: convert pointers to use g_autofree
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:29 +0000 (16:09 -0600)]
util: secret: convert pointers to use g_autofree

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: storageencryption: convert pointers to use g_autofree
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:28 +0000 (16:09 -0600)]
util: storageencryption: convert pointers to use g_autofree

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: storagefilebackend: convert pointers to use g_autofree
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:27 +0000 (16:09 -0600)]
util: storagefilebackend: convert pointers to use g_autofree

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: uri: convert pointers to use g_autofree
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:25 +0000 (16:09 -0600)]
util: uri: convert pointers to use g_autofree

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: xml: convert pointers to use g_autofree
Barrett Schonefeld [Mon, 23 Nov 2020 22:09:22 +0000 (16:09 -0600)]
util: xml: convert pointers to use g_autofree

Signed-off-by: Barrett Schonefeld <bschoney@utexas.edu>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: virsh-checkpoint/snapshot: Mark as expensive
Peter Krempa [Thu, 19 Nov 2020 15:40:25 +0000 (16:40 +0100)]
tests: virsh-checkpoint/snapshot: Mark as expensive

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agotests: virsh-output: Mark as expensive
Peter Krempa [Thu, 19 Nov 2020 15:34:20 +0000 (16:34 +0100)]
tests: virsh-output: Mark as expensive

The test takes more than a second on a beefy machine. While it's more
useful than some expensive tests it's not worth running all the time.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirsh: Added attach-disk support for network disk
Ryan Gahagan [Wed, 18 Nov 2020 23:48:13 +0000 (17:48 -0600)]
virsh: Added attach-disk support for network disk

Related issue: https://gitlab.com/libvirt/libvirt/-/issues/16
Added in support for the following parameters in attach-disk:
--source-protocol
--source-host-name
--source-host-socket
--source-host-transport

Added documentation to virsh.rst specifying usage.

Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirsh: cmdAttachDisk: Use virXMLFormatElement
Peter Krempa [Thu, 19 Nov 2020 12:05:05 +0000 (13:05 +0100)]
virsh: cmdAttachDisk: Use virXMLFormatElement

Convert the code to the new XML formatting approach for simpler code and
future additions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirsh: cmdAttachDisk: Use enum for disk source type
Peter Krempa [Thu, 19 Nov 2020 11:55:00 +0000 (12:55 +0100)]
virsh: cmdAttachDisk: Use enum for disk source type

For extendability and clarity add enum virshAttachDiskSourceType and
use it to drive the XML formatting.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirsh: virshAddress*: Move out of cmdAttachDisk block
Peter Krempa [Thu, 19 Nov 2020 13:17:21 +0000 (14:17 +0100)]
virsh: virshAddress*: Move out of cmdAttachDisk block

The helper started as helper for cmdAttachDisk but is now used outside
of it too.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirsh: Rename 'struct DiskAddress' and friends
Peter Krempa [Thu, 19 Nov 2020 13:09:33 +0000 (14:09 +0100)]
virsh: Rename 'struct DiskAddress' and friends

Use 'virshAddress' prefix for all the related structs and enums.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirsh: Refactor str2DiskAddress
Peter Krempa [Thu, 19 Nov 2020 11:33:48 +0000 (12:33 +0100)]
virsh: Refactor str2DiskAddress

Rewrite and rename the address parser.

As a fallout the use of the removed 'str2PCIAddress' is replaced by
virshAddressParse and virshAddressFormat.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirsh: Unify code for <address type='drive'
Peter Krempa [Thu, 19 Nov 2020 11:13:59 +0000 (12:13 +0100)]
virsh: Unify code for <address type='drive'

DISK_ADDR_TYPE_SATA, DISK_ADDR_TYPE_IDE and DISK_ADDR_TYPE_SCSI are
driven by basically identical data types. Unify them. Note that
changes to 'str2DiskAddress' are deliberately lazy as it will be
refactored later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirsh: Extract address formatting from cmdAttachDiskFormatAddress
Peter Krempa [Thu, 19 Nov 2020 11:07:32 +0000 (12:07 +0100)]
virsh: Extract address formatting from cmdAttachDiskFormatAddress

Introduce virshAddressFormat with code from cmdAttachDiskFormatAddress
to format the address.

Note that this patch fixes some whitespace inconsistencies in the
formatted addresses.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirsh: cmdAttachDisk: Split out formatting of disk address
Peter Krempa [Thu, 19 Nov 2020 10:45:11 +0000 (11:45 +0100)]
virsh: cmdAttachDisk: Split out formatting of disk address

First step is to remove all of the address handling code to a new
function called 'cmdAttachDiskFormatAddress'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirsh: cmdAttachDisk: Don't assume type='block' if file can't be examined
Peter Krempa [Thu, 19 Nov 2020 10:01:22 +0000 (11:01 +0100)]
virsh: cmdAttachDisk: Don't assume type='block' if file can't be examined

'virsh attach-disk' uses stat() to determine if the 'source' is a
regular file. If stat fails though it assumes that the file is block.

Since it's way more common to have regular files and the detection does
not work at all when accessing a remote host, modify the default to
assume type='file' by default.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirsh: cmdAttachDisk: Refactor control flow
Peter Krempa [Thu, 19 Nov 2020 09:44:12 +0000 (10:44 +0100)]
virsh: cmdAttachDisk: Refactor control flow

Remove the unnecessary 'cleanup:' label since we can directly return as
the memory clearing is now automated.

We can also remove the 'functionReturn' variable and use the usual
pattern of returning success.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirsh: cmdAttachDisk: Use automatic memory clearing for 'xml' and 'dom'
Peter Krempa [Thu, 19 Nov 2020 09:39:45 +0000 (10:39 +0100)]
virsh: cmdAttachDisk: Use automatic memory clearing for 'xml' and 'dom'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirsh: cmdAttachDisk: Declare one variable per line
Peter Krempa [Thu, 19 Nov 2020 09:38:10 +0000 (10:38 +0100)]
virsh: cmdAttachDisk: Declare one variable per line

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agotests: virsh: Add simple testsuite for using --print-xml of various commands
Peter Krempa [Thu, 19 Nov 2020 14:09:10 +0000 (15:09 +0100)]
tests: virsh: Add simple testsuite for using --print-xml of various commands

The test uses a script and compares the output against a template file.
VIR_TEST_REGENREATE_OUTPUT can be used on test failures. This test will
be marked as expensive once the refactors it guards are done.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: fix setting of scsi-id for ESP SCSI controllers
Daniel P. Berrangé [Fri, 20 Nov 2020 16:04:05 +0000 (16:04 +0000)]
qemu: fix setting of scsi-id for ESP SCSI controllers

The ESP SCSI controllers (NCR53C90, DC390, AM53C974) have the same
requirement as the LSI Logic controller for each disk to be set via
the scsi-id=NNN property, not the lun=NNN property.

Switching the code to use an enum will force authors to pay attention
to this difference when adding future SCSI controllers.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirDomainAuthorizedSSHKeysSet: Use uint for @nkeys
Michal Privoznik [Mon, 23 Nov 2020 12:09:35 +0000 (13:09 +0100)]
virDomainAuthorizedSSHKeysSet: Use uint for @nkeys

When introducing the API I've mistakenly used 'int' type for
@nkeys argument which does nothing more than tells the API how
many items there are in @keys array. Obviously, negative values
are not expected and therefore 'unsigned int' should have been
used.

Reported-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Fri, 20 Nov 2020 20:35:47 +0000 (21:35 +0100)]
Translated using Weblate (Swedish)

Currently translated at 8.5% (891 of 10399 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>
4 years agotests: add minimal XML example for sparc VM
Daniel P. Berrangé [Wed, 18 Nov 2020 16:20:36 +0000 (16:20 +0000)]
tests: add minimal XML example for sparc VM

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotests: define QEMU driver capabilities for sparc architecture
Daniel P. Berrangé [Wed, 18 Nov 2020 17:06:45 +0000 (17:06 +0000)]
tests: define QEMU driver capabilities for sparc architecture

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotests: add capabilities data files for sparc emulator target
Daniel P. Berrangé [Wed, 18 Nov 2020 16:18:43 +0000 (16:18 +0000)]
tests: add capabilities data files for sparc emulator target

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotests: add fake host CPU for sparc architecture
Daniel P. Berrangé [Wed, 18 Nov 2020 16:53:50 +0000 (16:53 +0000)]
tests: add fake host CPU for sparc architecture

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: enable support for ESP SCSI controller family
Daniel P. Berrangé [Wed, 18 Nov 2020 16:33:16 +0000 (16:33 +0000)]
qemu: enable support for ESP SCSI controller family

The NCR53C90 is the built-in SCSI controller on all sparc machine types,
but not sparc64. Note that it has the fixed alias "scsi", which differs
from our normal naming convention of "scsi0".

The DC390 and AM53C974 are PCI SCSI controllers that can be added to any
PCI machine.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: add capabilities for the three ESP family SCSI controllers
Daniel P. Berrangé [Wed, 18 Nov 2020 16:37:54 +0000 (16:37 +0000)]
qemu: add capabilities for the three ESP family SCSI controllers

Probing for the NCR53C90 controller is a little unusual. The
qom-list-types QMP command returns a list of all types known to
the QEMU binary. It does not distinguish devices which are user
creatable from those which are built-in.

Any QEMU target that supports PCI will have the DC390 / AM53C974
devices because they are PCI based. Due to code dependencies
in QEMU though, existence of these two devices will also pull in
the NCR53C90 device (called just 'esp' in QEMU). The NCR53C90 is
not user-creatable and can only be used when built-in to the
machine type.

This is only the case on sparc machines, and certain mips64 and
m68k machines.  IOW, we don't rely on qom-list-types as a guide
for existence of NCR53C90, as it shouldn't really exist in most
QEMU binaries.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: add support for ESP SCSI controller family
Daniel P. Berrangé [Tue, 17 Nov 2020 18:15:44 +0000 (18:15 +0000)]
conf: add support for ESP SCSI controller family

The NCR53C90 is the built-in SCSI controller on all sparc machine types,
and some mips and m68k machine types.

The DC390 and AM53C974 are PCI SCSI controllers that can be added to any
PCI machine.

These are only interesting for emulating obsolete hardware platforms.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: add helper method for checking if ESP SCSI is builtin
Daniel P. Berrangé [Wed, 18 Nov 2020 16:11:05 +0000 (16:11 +0000)]
qemu: add helper method for checking if ESP SCSI is builtin

The NCR53C90 ESP SCSI controller is only usable when built-in to the
machine type. This method will facilitate checking that restriction
across many places.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: fix default devices on sparc machines
Daniel P. Berrangé [Wed, 18 Nov 2020 14:59:47 +0000 (14:59 +0000)]
qemu: fix default devices on sparc machines

The sparc machines have little in common with sparc64 machines.

No sparc machine type includes a PCI bus, so we should not be adding one
to the XML. This further means that we should not be adding a memory
balloon device, nor USB controller as these are both PCI based.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: add ARCH_IS_MIPS64 helper macro
Daniel P. Berrangé [Wed, 18 Nov 2020 16:10:07 +0000 (16:10 +0000)]
util: add ARCH_IS_MIPS64 helper macro

In most cases logic for MIPS64 and MIPS64EL will be identical.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agospec: Drop UUID handling for default network
Andrea Bolognani [Sun, 15 Nov 2020 15:42:23 +0000 (16:42 +0100)]
spec: Drop UUID handling for default network

We're no longer generating a UUID during installation, so we
clearly don't need to strip it afterwards; and since the network
driver is perfectly capable of generating a UUID if necessary, we
don't need to do that at %post time either.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agonetwork: Drop UUID handling for default network
Andrea Bolognani [Sun, 15 Nov 2020 15:30:34 +0000 (16:30 +0100)]
network: Drop UUID handling for default network

We are generating a fresh UUID and storing it in the XML for the
default network, but this is unnecessary because the network
driver will automatically generate one if it's missing from the
XML; the fact that we only do this if the uuidgen command happens
to be available on the build machine is further proof that we can
safely skip this step.

This patch is best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agoconf: Write network config to disk after generating UUID
Andrea Bolognani [Thu, 19 Nov 2020 15:08:13 +0000 (16:08 +0100)]
conf: Write network config to disk after generating UUID

While we generally expect libvirt objects to be defined using the
appropriate APIs, there are cases where it's reasonable for an
external entity, usually a package manager, to drop a valid
configuration file under /etc/libvirt and have libvirt take over
from there: notably, this is exactly how the default network is
handled.

For the most part, whether the configuration is saved back to disk
after being parsed by libvirt doesn't matter, because we'll end up
with the same values anyway, but an obvious exception to this is
data that gets randomly generated when not present, namely MAC
address and UUID.

Historically, both were handled by our build system, but commit
a47ae7c004e9 moved handling of the former inside libvirt proper;
this commit extends such behavior to the latter as well.

Proper error handling for the virNetworkSaveConfig() call, which
was missing until now, is introduced in the process.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Thu, 19 Nov 2020 00:19:35 +0000 (01:19 +0100)]
Translated using Weblate (Swedish)

Currently translated at 8.2% (853 of 10399 strings)

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

Translated using Weblate (Swedish)

Currently translated at 8.0% (833 of 10399 strings)

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

Translated using Weblate (Swedish)

Currently translated at 7.8% (813 of 10399 strings)

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

Translated using Weblate (Swedish)

Currently translated at 7.6% (796 of 10399 strings)

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

Translated using Weblate (Swedish)

Currently translated at 7.0% (736 of 10399 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>
4 years agosockettest: testMaskNetwork: use g_auto
Ján Tomko [Thu, 19 Nov 2020 15:57:52 +0000 (16:57 +0100)]
sockettest: testMaskNetwork: use g_auto

This has the added benefit of 'gotnet' only being freed after
it was possibly used in the output string.

../src/internal.h:519:27: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  519 | # define fprintf(fh, ...) g_fprintf(fh, __VA_ARGS__)
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~
../tests/sockettest.c:194:9: note: in expansion of macro ‘fprintf’
  194 |         fprintf(stderr, "Expected %s, got %s\n", networkstr, gotnet);
      |         ^~~~~~~

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Jaroslav Suchanek <jsuchane@redhat.com>
Fixes: ba08c5932e556aa4f5101357127a6224c40e5ebe
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_conf: use g_free() in virDomainPostParseCheckISCSIPath()
Matt Coleman [Fri, 6 Nov 2020 03:32:39 +0000 (22:32 -0500)]
domain_conf: use g_free() in virDomainPostParseCheckISCSIPath()

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoopenvzDomainMigratePrepare3Params: use g_auto
Ján Tomko [Thu, 19 Nov 2020 10:09:43 +0000 (11:09 +0100)]
openvzDomainMigratePrepare3Params: use g_auto

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoopenvzDomainMigratePrepare3Params: remove else after goto
Ján Tomko [Thu, 19 Nov 2020 10:06:56 +0000 (11:06 +0100)]
openvzDomainMigratePrepare3Params: remove else after goto

We jump to the error label if the 'if' condition is true.
Remove the explicit else to make it more obvious that 'hostname'
is filled on both branches of 'if (!uri_in)'.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoopenvzDomainMigratePrepare3Params: correctly use hostname
Ján Tomko [Thu, 19 Nov 2020 09:58:09 +0000 (10:58 +0100)]
openvzDomainMigratePrepare3Params: correctly use hostname

In case no uri_in was supplied, we forgot to set the hostname
to the current hostname and formatted a useless uri_out.

src/util/glibcompat.h:57:26: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  57 | # define g_strdup_printf vir_g_strdup_printf
src/openvz/openvz_driver.c:2136:16: note: in expansion of macro ‘g_strdup_printf’
2136 |     *uri_out = g_strdup_printf("ssh://%s", hostname);

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Jaroslav Suchanek <jsuchane@redhat.com>
Fixes: e3c626a61d6c3d808555653684c0fb1e7c4d74ec
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agogitlab-ci: add coverity job
Pavel Hrdina [Thu, 12 Nov 2020 13:56:25 +0000 (14:56 +0100)]
gitlab-ci: add coverity job

Introduce new job to make a coverity build and upload coverity data to
scan.coverity.com where the analysis is then executed.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosrc: rework static analysis detection
Pavel Hrdina [Mon, 16 Nov 2020 09:57:56 +0000 (10:57 +0100)]
src: rework static analysis detection

Inspired by QEMU code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodomain_capabilities: Assert enums fit into unsigned int bitmask
Michal Privoznik [Wed, 18 Nov 2020 10:58:01 +0000 (11:58 +0100)]
domain_capabilities: Assert enums fit into unsigned int bitmask

The way our domain capabilities work currently, is that we have
virDomainCapsEnum struct which contains 'unsigned int values'
member which serves as a bitmask. More complicated structs are
composed from this struct, giving us whole virDomainCaps
eventually.

Whenever we want to report that a certain value is supported, the
'1 << value' bit is set in the corresponding unsigned int member.
This works as long as the resulting value after bitshift does not
overflow unsigned int. There is a check inside
virDomainCapsEnumSet() which ensures exactly this, but no caller
really checks whether virDomainCapsEnumSet() succeeded. Also,
checking at runtime is a bit too late.

Fortunately, we know the largest value we want to store in each
member, because each enum of ours ends with _LAST member.
Therefore, we can check at build time whether an overflow can
occur.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agocpu_map: Add Phytium FT-2000+ and Tengyun-S2500
Shaojun Yang [Thu, 19 Nov 2020 00:26:15 +0000 (08:26 +0800)]
cpu_map: Add Phytium FT-2000+ and Tengyun-S2500

Signed-off-by: Shaojun Yang <yangshaojun@phytium.com.cn>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agocgroup: add stub for virCgroupNew
Ján Tomko [Thu, 19 Nov 2020 10:16:27 +0000 (11:16 +0100)]
cgroup: add stub for virCgroupNew

The previous commit exported the function but forgot to add
a non-Linux stub.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 126cb34a206a44f04e364700b46426dff9f387d5
4 years agovirt-host-validate: fix detection with cgroups v2
Pavel Hrdina [Wed, 18 Nov 2020 12:08:22 +0000 (13:08 +0100)]
virt-host-validate: fix detection with cgroups v2

Using virtCgroupNewSelf() is not correct with cgroups v2 because the
the virt-host-validate process is executed from from the same cgroup
context as the terminal and usually not all controllers are enabled
by default.

To do a proper check we need to use the root cgroup to see what
controllers are actually available. Libvirt or systemd ensures that
all controllers are available for VMs as well.

This still doesn't solve the devices controller with cgroups v2 where
there is no controller as it was replaced by eBPF. Currently libvirt
tries to query eBPF programs which usually works only for root as
regular users will get permission denied for that operation.

Fixes: https://gitlab.com/libvirt/libvirt/-/issues/94
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoNEWS: restore backtick balance
Ján Tomko [Wed, 18 Nov 2020 15:47:17 +0000 (16:47 +0100)]
NEWS: restore backtick balance

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Michal Prívozník <mprivozn@redhat.com>
Fixes: db98d17709eeb13603730352a70f3817becd7372
4 years agonews: Document recent OpenSSH authorized key file mgmt APIs
Michal Privoznik [Tue, 10 Nov 2020 14:00:45 +0000 (15:00 +0100)]
news: Document recent OpenSSH authorized key file mgmt APIs

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: Implement OpenSSH authorized key file mgmt APIs
Michal Privoznik [Tue, 10 Nov 2020 11:35:12 +0000 (12:35 +0100)]
qemu: Implement OpenSSH authorized key file mgmt APIs

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1888537
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu_agent: add qemuAgentSSH{Add,Remove,Get}AuthorizedKeys
Marc-André Lureau [Sat, 7 Nov 2020 09:12:53 +0000 (13:12 +0400)]
qemu_agent: add qemuAgentSSH{Add,Remove,Get}AuthorizedKeys

In QEMU 5.2, the guest agent learned to manipulate a user
~/.ssh/authorized_keys. Bind the JSON API to libvirt.

https://wiki.qemu.org/ChangeLog/5.2#Guest_agent

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirsh: Expose OpenSSH authorized key file mgmt APIs
Michal Privoznik [Tue, 10 Nov 2020 08:25:27 +0000 (09:25 +0100)]
virsh: Expose OpenSSH authorized key file mgmt APIs

The new virsh commands are:

  get-user-sshkeys
  set-user-sshkeys

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoremote: Implement OpenSSH authorized key file mgmt APIs
Michal Privoznik [Mon, 9 Nov 2020 21:23:44 +0000 (22:23 +0100)]
remote: Implement OpenSSH authorized key file mgmt APIs

Since both APIs accept/return an array of strings we can't have
client/server dispatch code generated. But implementation is
fairly trivial, although verbose.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoIntroduce OpenSSH authorized key file mgmt APIs
Michal Privoznik [Mon, 9 Nov 2020 19:45:36 +0000 (20:45 +0100)]
Introduce OpenSSH authorized key file mgmt APIs

When setting up a new guest or when a management software wants
to allow access to an existing guest the
virDomainSetUserPassword() API can be used, but that might be not
good enough if user want to ssh into the guest. Not only sshd has
to be configured to accept password authentication (which is
usually not the case for root), user have to type in their
password. Using SSH keys is more convenient. Therefore, two new
APIs are introduced:

virDomainAuthorizedSSHKeysGet() which lists authorized keys for
given user, and

virDomainAuthorizedSSHKeysSet() which modifies the authorized
keys file for given user (append, set or remove keys from the
file).

It's worth nothing that while authorized_keys file entries have
some structure (as defined by sshd(8)), expressing that structure
goes beyond libvirt's focus and thus "keys" are nothing but an
opaque string to libvirt.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu_conf: fix a typo in comment
Ján Tomko [Wed, 18 Nov 2020 13:59:37 +0000 (14:59 +0100)]
qemu_conf: fix a typo in comment

Ceci n'est pas un objet.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 7db61843b05a6e4295b1d2e27a3d86f162ef04a0
4 years agonews: Mention Cooperlake cpu model in v6.4.0
Han Han [Wed, 28 Oct 2020 07:51:48 +0000 (15:51 +0800)]
news: Mention Cooperlake cpu model in v6.4.0

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoDo not disable incompatible-pointer-types-discards-qualifiers
Martin Kletzander [Thu, 12 Nov 2020 12:58:53 +0000 (13:58 +0100)]
Do not disable incompatible-pointer-types-discards-qualifiers

This reverts commit b3710e9a2af402a2b620de570b062294e11190eb.

That check is very valuable for our code, but it causes issue with glib >=
2.67.0 when building with clang.

The reason is a combination of two commits in glib, firstly fdda405b6b1b which
adds a g_atomic_pointer_{set,get} variants that enforce stricter type
checking (by removing an extra cast) for compilers that support __typeof__, and
commit dce24dc4492d which effectively enabled the new variant of glib's atomic
code for clang.  This will not be necessary when glib's issue #600 [0] (8 years
old) is fixed.  Thankfully, MR #1719 [1], which is supposed to deal with this
issue was opened 3 weeks ago, so there is a slight sliver of hope.

[0] https://gitlab.gnome.org/GNOME/glib/-/issues/600
[1] https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agoqemu_validate: Deduplicate code for graphics type check
Michal Privoznik [Tue, 17 Nov 2020 10:00:31 +0000 (11:00 +0100)]
qemu_validate: Deduplicate code for graphics type check

Similarly to previous commits, we can utilize domCaps to check if
graphics type is supported.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
4 years agodomcaps: Report egl-headless graphics type
Michal Privoznik [Tue, 17 Nov 2020 10:00:26 +0000 (11:00 +0100)]
domcaps: Report egl-headless graphics type

QEMU supports egl-headless if QEMU_CAPS_EGL_HEADLESS capability
is present. There are some additional requirements but those are
checked for in qemuValidateDomainDeviceDefGraphics() and depend
on domain configuration and thus are not representable in domain
capabilities. Let's stick with plain qemuCaps check then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
4 years agoqemu_validate: Deduplicate code for RNG model check
Michal Privoznik [Tue, 17 Nov 2020 09:37:10 +0000 (10:37 +0100)]
qemu_validate: Deduplicate code for RNG model check

In my recent commit of 5216304bfe I've moved RNG model check
from domain capabilities validator into qemu validator. During
that I had to basically duplicate RNG model to qemuCaps checks.
Problem with this approach is that after my commit qemu validator
and domCaps are disconnected and thus domCaps might report (in
general) different set of supported RNG models.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
4 years agoqemu_validate: Deduplicate code for video model check
Michal Privoznik [Tue, 17 Nov 2020 09:26:14 +0000 (10:26 +0100)]
qemu_validate: Deduplicate code for video model check

In my recent commit of a33279daa8 I've moved video model check
from domain capabilities validator into qemu validator. During
that I had to basically duplicate video model to qemuCaps checks.
Problem with this approach is that after my commit qemu validator
and domCaps are disconnected and thus domCaps might report (in
general) different set of supported video models.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
4 years agodomain_capabilities: Introduce VIR_DOMAIN_CAPS_ENUM_IS_SET
Michal Privoznik [Tue, 17 Nov 2020 09:23:33 +0000 (10:23 +0100)]
domain_capabilities: Introduce VIR_DOMAIN_CAPS_ENUM_IS_SET

This is a convenient macro for querying whether particular domain
caps enum value is set or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
4 years agonodedev: report errors about missing integer properties
Daniel P. Berrangé [Tue, 17 Nov 2020 10:17:48 +0000 (10:17 +0000)]
nodedev: report errors about missing integer properties

The helper methods for getting integer properties ignore a missing
property setting its value to zero. This lack of error reporting
resulted in missing the regression handling hotplug of USB devices
with the vendor and model IDs getting set to zero silently.

The few callers which relied on this silent defaulting have been fixed,
so now we can report fatal errors immediately.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agonodedev: drop DKD_MEDIA_AVAILABLE property check
Daniel P. Berrangé [Tue, 17 Nov 2020 12:22:34 +0000 (12:22 +0000)]
nodedev: drop DKD_MEDIA_AVAILABLE property check

The access of DKD_MEDIA_AVAILABLE for floppy disks, is mistakenly
protected by a check for ID_CDROM_MEDIA, introduced in:

  commit 10427db77983edfaafec74ec13cc5015bab6aa95
  Author: Ján Tomko <jtomko@redhat.com>
  Date:   Fri Jun 3 16:10:21 2016 +0200

    Only return two values in udevGetUintProperty

Thus the check of DKD_MEDIA_AVAILABLE never run. In practice this didn't
matter since this property is set by the DeviceKit-Disks daemon which
was only around for 3 Fedora releases before being killed off around
F13. Thus we can just remove this legacy property.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agonodedev: dont rely on ignoring errors on missing properties
Daniel P. Berrangé [Tue, 17 Nov 2020 11:56:46 +0000 (11:56 +0000)]
nodedev: dont rely on ignoring errors on missing properties

The udevProcessStorage method relies on udevGetIntProperty ignoring
errors about non-existant properties and instead setting the value to
zero. In theory when seeing ID_CDROM=1, you might expect that devices
which are not CDs will get ID_CDROM=0, but that's not what happens in
practice. Instead the property simply won't get set at all.

IOW, the code does not need to care about the value of the property,
merely whether it exists or not.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agonodedev: improve debugging logs from udev device/event processing
Daniel P. Berrangé [Tue, 17 Nov 2020 11:54:54 +0000 (11:54 +0000)]
nodedev: improve debugging logs from udev device/event processing

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoapparmor: allow kvm-spice compat wrapper
Christian Ehrhardt [Mon, 16 Nov 2020 12:21:10 +0000 (13:21 +0100)]
apparmor: allow kvm-spice compat wrapper

'kvm-spice' is a binary name used to call 'kvm' which actually is a wrapper
around qemu-system-x86_64 enabling kvm acceleration. This isn't in use
for quite a while anymore, but required to work for compatibility e.g.
when migrating in old guests.

For years this was a symlink kvm-spice->kvm and therefore covered
apparmor-wise by the existing entry:
   /usr/bin/kvm rmix,
But due to a recent change [1] in qemu packaging this now is no symlink,
but a wrapper on its own and therefore needs an own entry that allows it
to be executed.

[1]: https://salsa.debian.org/qemu-team/qemu/-/commit/9944836d3

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Michal Privoznik <mprivozn redhat com>
4 years agotests: Add tests for kvm-poll-control feature
Tim Wiederhake [Fri, 13 Nov 2020 08:49:44 +0000 (09:49 +0100)]
tests: Add tests for kvm-poll-control feature

Update the KVM feature tests for QEMU's kvm-poll-control performance
hint.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>