]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agoconf: introduce new taint flag for deprecated configuration
Daniel P. Berrangé [Fri, 22 Jan 2021 11:43:02 +0000 (11:43 +0000)]
conf: introduce new taint flag for deprecated configuration

Hypervisors are capable of reporting that some features are deprecated.
This should be used to mark a domain as tainted.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: report whether a machine type is deprecated in capabilities
Daniel P. Berrangé [Fri, 22 Jan 2021 12:16:23 +0000 (12:16 +0000)]
qemu: report whether a machine type is deprecated in capabilities

QEMU has the ability to mark machine types as deprecated. This should be
exposed to management applications in the capabilities.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: report whether a CPU model is deprecated in dom capabilities
Daniel P. Berrangé [Fri, 22 Jan 2021 11:15:08 +0000 (11:15 +0000)]
qemu: report whether a CPU model is deprecated in dom capabilities

QEMU has the ability to mark CPUs as deprecated. This should be exposed
to management applications in the domain capabilities.

This attribute is only set when the model is actually deprecated.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodocs: use a relative link to the kbase page
Daniel P. Berrangé [Fri, 22 Jan 2021 15:24:34 +0000 (15:24 +0000)]
docs: use a relative link to the kbase page

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoviralloc: Remove VIR_ALLOC_VAR
Peter Krempa [Wed, 3 Feb 2021 12:43:28 +0000 (13:43 +0100)]
viralloc: Remove VIR_ALLOC_VAR

The use case VIR_ALLOC_VAR deals with is very unlikely. We had just 2
legitimate uses, which were reimplemented locally using g_malloc0 and
sizeof instead as they used a static number of members of the trailing
array.

Remove VIR_ALLOC_VAR since in most cases the direct implementation is
shorter and clearer and there are no users of it currently.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirNetDevGetEthtoolGFeatures: Avoid use of VIR_ALLOC_VAR
Peter Krempa [Wed, 3 Feb 2021 12:33:24 +0000 (13:33 +0100)]
virNetDevGetEthtoolGFeatures: Avoid use of VIR_ALLOC_VAR

In this case we need a 'struct ethtool_gfeatures' followed by two
'struct ethtool_get_features_block' so there's no risk of overflow.

Use g_malloc0 and sizeof() to allocate the memory instead of
VIR_ALLOC_VAR.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolocking: sanlock: Avoid use of VIR_ALLOC_VAR for 'struct sanlk_resource'
Peter Krempa [Wed, 3 Feb 2021 12:31:15 +0000 (13:31 +0100)]
locking: sanlock: Avoid use of VIR_ALLOC_VAR for 'struct sanlk_resource'

In both cases we need memory for a 'struct sanlk_resource' followed by
one 'struct sanlk_disk', thus there's no risk of overflow.

Use g_malloc0 and sizeof() to allocate the memory instead of
VIR_ALLOC_VAR.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirLockManagerSanlockAddDisk: Refactor cleanup
Peter Krempa [Wed, 3 Feb 2021 12:25:46 +0000 (13:25 +0100)]
virLockManagerSanlockAddDisk: Refactor cleanup

Use g_autofree to allow removal of 'cleanup:' and the 'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirLockManagerSanlockAddLease: Refactor cleanup
Peter Krempa [Wed, 3 Feb 2021 12:25:40 +0000 (13:25 +0100)]
virLockManagerSanlockAddLease: Refactor cleanup

Use g_autofree and remove the 'cleanup' section and 'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirNWFilterVarCombIter: Allocate 'iter' member separately
Peter Krempa [Wed, 3 Feb 2021 12:42:00 +0000 (13:42 +0100)]
virNWFilterVarCombIter: Allocate 'iter' member separately

Switch to the more common approach of having arrays allocated separately
rather than trailing the struct.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: alloc: Remove VIR_DISPOSE_STRING
Peter Krempa [Tue, 2 Feb 2021 15:22:43 +0000 (16:22 +0100)]
util: alloc: Remove VIR_DISPOSE_STRING

Users were replaced with virSecureEraseString with explicit freeing of
the memory.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirnetlibsshsession: Replace VIR_DISPOSE_STRING with virSecureEraseString
Peter Krempa [Tue, 2 Feb 2021 16:22:02 +0000 (17:22 +0100)]
virnetlibsshsession: Replace VIR_DISPOSE_STRING with virSecureEraseString

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: alloc: Remove VIR_AUTODISPOSE_STR
Peter Krempa [Tue, 2 Feb 2021 15:21:50 +0000 (16:21 +0100)]
util: alloc: Remove VIR_AUTODISPOSE_STR

There are no users any more. The replacement is to use g_auto and
virSecureEraseString explicitly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirNetLibsshAuthenticatePassword: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR
Peter Krempa [Tue, 2 Feb 2021 16:05:23 +0000 (17:05 +0100)]
virNetLibsshAuthenticatePassword: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agocmdSecretGetValue: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR
Peter Krempa [Tue, 2 Feb 2021 16:05:23 +0000 (17:05 +0100)]
cmdSecretGetValue: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirStorageBackendRBDOpenRADOSConn: Use virSecureEraseString instead of VIR_AUTODISPOS...
Peter Krempa [Tue, 2 Feb 2021 16:05:23 +0000 (17:05 +0100)]
virStorageBackendRBDOpenRADOSConn: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemuBuildRBDSecinfoURI: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR
Peter Krempa [Tue, 2 Feb 2021 16:04:30 +0000 (17:04 +0100)]
qemuBuildRBDSecinfoURI: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR

In this instance attempting to be correct is really pointless since the
secret is formatted into another string which is not erased securely and
then put on the commandline.

Keep the secure handling for correctness.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolibxlMakeNetworkDiskSrc: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR
Peter Krempa [Tue, 2 Feb 2021 15:49:30 +0000 (16:49 +0100)]
libxlMakeNetworkDiskSrc: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: virsecureerase: Introduce virSecureEraseString
Peter Krempa [Tue, 2 Feb 2021 14:49:10 +0000 (15:49 +0100)]
util: virsecureerase: Introduce virSecureEraseString

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: viralloc: Remove VIR_DISPOSE(_N)
Peter Krempa [Mon, 1 Feb 2021 13:18:25 +0000 (14:18 +0100)]
util: viralloc: Remove VIR_DISPOSE(_N)

The macros are unused now and callers who care about clearing the memory
they use should use memset() appropriately.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotests: viralloc: Remove testDispose case
Peter Krempa [Mon, 1 Feb 2021 13:16:54 +0000 (14:16 +0100)]
tests: viralloc: Remove testDispose case

The VIR_DISPOSE* APIs will be phased out. Additionally the test isn't
really doing useful work in ensuring that the values are indeed cleared
thus there's no point in keeping it around.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agostorageBackendCreateQemuImgSecretPath: Use virSecureErase instead of VIR_DISPOSE_N
Peter Krempa [Mon, 1 Feb 2021 13:13:53 +0000 (14:13 +0100)]
storageBackendCreateQemuImgSecretPath: Use virSecureErase instead of VIR_DISPOSE_N

Clear out the value using virSecureErase and free it with g_free so
that VIR_DISPOSE_N can be phased out.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirCryptoEncryptDataAESgnutls: Use virSecureErase instead of memset
Peter Krempa [Tue, 2 Feb 2021 14:44:55 +0000 (15:44 +0100)]
virCryptoEncryptDataAESgnutls: Use virSecureErase instead of memset

Clear the key and IV structs using virSecureErase.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirCryptoEncryptDataAESgnutls: Use virSecureErase instead of VIR_DISPOSE_N
Peter Krempa [Mon, 1 Feb 2021 13:13:53 +0000 (14:13 +0100)]
virCryptoEncryptDataAESgnutls: Use virSecureErase instead of VIR_DISPOSE_N

Clear out the value using virSecureErase and free it with g_free so
that VIR_DISPOSE_N can be phased out.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirStorageBackendRBDOpenRADOSConn: Use virSecureErase instead of VIR_DISPOSE_N
Peter Krempa [Mon, 1 Feb 2021 13:11:52 +0000 (14:11 +0100)]
virStorageBackendRBDOpenRADOSConn: Use virSecureErase instead of VIR_DISPOSE_N

Switch the secret value to 'g_autofree' for handling of the memory and
clear it out using virSecureErase.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirsh: cmdSecretGetValue: Use virSecureErase instead of VIR_DISPOSE_N
Peter Krempa [Mon, 1 Feb 2021 13:09:01 +0000 (14:09 +0100)]
virsh: cmdSecretGetValue: Use virSecureErase instead of VIR_DISPOSE_N

Switch the secret value to 'g_autofree' for handling of the memory and
clear it out using virSecureErase.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: domain: Use virSecureErase for clearing secrets instead of VIR_DISPOSE_N
Peter Krempa [Mon, 1 Feb 2021 11:55:27 +0000 (12:55 +0100)]
qemu: domain: Use virSecureErase for clearing secrets instead of VIR_DISPOSE_N

Phase out use of VIR_DISPOSE_N from the qemu driver. Use memset in the
appropriate cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolibxlMakeNetworkDiskSrc: Avoid use of VIR_DISPOSE_N
Peter Krempa [Mon, 1 Feb 2021 11:50:00 +0000 (12:50 +0100)]
libxlMakeNetworkDiskSrc: Avoid use of VIR_DISPOSE_N

Clear the secret right after use with virSecureErase.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agostorage_backend_iscsi(_direct): Properly clear secrets
Peter Krempa [Mon, 1 Feb 2021 11:15:57 +0000 (12:15 +0100)]
storage_backend_iscsi(_direct): Properly clear secrets

The code pretends that it cares about clearing the secret values, but
passes the secret value to a realloc, which may copy the value somewhere
else and doesn't sanitize the original location when it does so.

Since we want to construct a string from the value, let's copy it to a
new piece of memory which has the space for the 'NUL' byte ourselves, to
prevent a random realloc keeping the data around.

While at it, use virSecureErase instead of VIR_DISPOSE_N since it's
being phased out.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirsh: cmdSecretSetValue: Rework handling of the secret value
Peter Krempa [Mon, 1 Feb 2021 13:01:57 +0000 (14:01 +0100)]
virsh: cmdSecretSetValue: Rework handling of the secret value

Use a single buffer for the secret to make it easier to follow it's
lifecycle. For base64 decoding use a local temporary buffer which will
be cleared right away.

This also uses virSecureErase for clearing the bufer instead of
VIR_DISPOSE_N which is being phased out.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: Introduce virsecureerase module
Peter Krempa [Tue, 2 Feb 2021 14:27:22 +0000 (15:27 +0100)]
util: Introduce virsecureerase module

The module will provide functions for disposing secrets stored in
memory.

Note that for now it's implemented using memset, which is not really
secure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirNetLibsshSessionAuthAddPrivKeyAuth: Refactor cleanup
Peter Krempa [Tue, 2 Feb 2021 15:00:28 +0000 (16:00 +0100)]
virNetLibsshSessionAuthAddPrivKeyAuth: Refactor cleanup

Shuffle the code around to remove the need for temporary variables and
labels for cleaning them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirNetLibsshSessionAuthAddPrivKeyAuth: Don't unlock unlocked 'sess' on error
Peter Krempa [Tue, 2 Feb 2021 14:57:06 +0000 (15:57 +0100)]
virNetLibsshSessionAuthAddPrivKeyAuth: Don't unlock unlocked 'sess' on error

The check whether @keyfile is non-NULL is before locking @sess, but uses
the 'error' label which unlocks '@sess'.

While touching the error path, update the error message to be on one
line.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agocmdSecretSetValue: Make it obvious that --file, --base64 and --interactive are exlcusive
Peter Krempa [Mon, 1 Feb 2021 12:10:59 +0000 (13:10 +0100)]
cmdSecretSetValue: Make it obvious that --file, --base64 and --interactive are exlcusive

Convert the conditions to else if so that it's obvious that only one of
the cases will ever be used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemuDomainMasterKeyCreate: Don't use VIR_DISPOSE_N on failure
Peter Krempa [Mon, 1 Feb 2021 11:52:07 +0000 (12:52 +0100)]
qemuDomainMasterKeyCreate: Don't use VIR_DISPOSE_N on failure

When virRandomBytes fails we don't get any random bytes and even if we
did they don't have to be treated as secret as they weren't used in any
way.

Add a temporary variable with automatic freeing for the secret buffer
and assign it only on success.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolibxlMakeDomBuildInfo: Don't use VIR_DISPOSE_N for USB device list
Peter Krempa [Mon, 1 Feb 2021 11:12:42 +0000 (12:12 +0100)]
libxlMakeDomBuildInfo: Don't use VIR_DISPOSE_N for USB device list

The list isn't secret which would need being disposed of. Just expand
the array and return failure when adding the NULL terminator similarly
to how we expand the list for adding devices in a loop.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agohypervFreeInvokeParams: Don't use VIR_DISPOSE_N for freeing 'params'
Peter Krempa [Mon, 1 Feb 2021 11:08:13 +0000 (12:08 +0100)]
hypervFreeInvokeParams: Don't use VIR_DISPOSE_N for freeing 'params'

The struct doesn't contain any secrets to clear before freeing and even
if it did VIR_DISPOSE_N wouldn't help as the struct contains only
pointers thus the actual memory pointing to isn't sanitized.

Just free the params array pointer and then the struct itself.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: add realtime parameter for rtc
gongwei [Tue, 2 Feb 2021 14:20:46 +0000 (09:20 -0500)]
conf: add realtime parameter for rtc

Pass the parameter clock rt to qemu to ensure that the
virtual machine is not synchronized with the host time

Signed-off-by: gongwei <gongwei@smartx.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: virstring: Remove unused prototypes for virStr(n)dup
Peter Krempa [Mon, 1 Feb 2021 13:46:46 +0000 (14:46 +0100)]
util: virstring: Remove unused prototypes for virStr(n)dup

The headers weren't removed after use of VIR_STRDUP was removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovircommand: Simplify virCommandAddArg
Tim Wiederhake [Mon, 1 Feb 2021 12:42:07 +0000 (13:42 +0100)]
vircommand: Simplify virCommandAddArg

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovircryptotest: Directly assign string to avoid memcpy
Tim Wiederhake [Mon, 1 Feb 2021 12:42:06 +0000 (13:42 +0100)]
vircryptotest: Directly assign string to avoid memcpy

Found by clang-tidy's "bugprone-not-null-terminated-result" check.

clang-tidy's finding is a false positive in this case, as the
memset call guarantees null termination. The assignment can be
simplified though, and this happens to silence the warning.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agotests: Prevent malloc with size 0
Tim Wiederhake [Mon, 1 Feb 2021 12:42:05 +0000 (13:42 +0100)]
tests: Prevent malloc with size 0

Found by clang-tidy's "clang-analyzer-optin.portability.UnixAPI" check.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirhostuptime: Fix rounding in uptime calculation
Tim Wiederhake [Mon, 1 Feb 2021 12:42:04 +0000 (13:42 +0100)]
virhostuptime: Fix rounding in uptime calculation

"f + 0.5" does not round correctly for values very close to
".5" for every integer multiple, e.g. "0.499999975".

Found by clang-tidy's "bugprone-incorrect-roundings" check.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoudevProcessCCW: Initialize variable
Tim Wiederhake [Mon, 1 Feb 2021 12:42:03 +0000 (13:42 +0100)]
udevProcessCCW: Initialize variable

`udevGetIntSysfsAttr` does not necessarily write to the third parameter,
even when it returns 0.

This was found by clang-tidy's
"clang-analyzer-core.UndefinedBinaryOperatorResult" check.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoReplace bzero() with memset()
Tim Wiederhake [Mon, 1 Feb 2021 12:42:02 +0000 (13:42 +0100)]
Replace bzero() with memset()

This was found by clang-tidy's
"clang-analyzer-security.insecureAPI.bzero" check.

bzero is marked as deprecated ("LEGACY") in POSIX.1-2001 and
removed in POSIX.1-2008.

Besides its deprecation, bzero can be unsafe to use under certain
circumstances, e.g. when used to zero-out memory containing secrects.
These calls can be optimized away by the compiler, if it concludes no
further access happens to the memory, thus leaving the secrets still
in memory. Hence its classification as "insecureAPI".

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirsh-domain: Fix error handling of pthread_sigmask
Tim Wiederhake [Mon, 1 Feb 2021 12:42:01 +0000 (13:42 +0100)]
virsh-domain: Fix error handling of pthread_sigmask

pthread_sigmask() returns 0 on success and "a non-zero value
on failure", but not neccessarily a negative one.

Found by clang-tidy's "bugprone-posix-return" check.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu_tpm: Fix indentation in qemuTPMEmulatorBuildCommand
Tim Wiederhake [Mon, 1 Feb 2021 12:42:00 +0000 (13:42 +0100)]
qemu_tpm: Fix indentation in qemuTPMEmulatorBuildCommand

This was found by clang-tidy's "readability-misleading-indentation"
check.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoxen: Fix indentation in xenParseXLSpice
Tim Wiederhake [Mon, 1 Feb 2021 12:41:59 +0000 (13:41 +0100)]
xen: Fix indentation in xenParseXLSpice

This was found by clang-tidy's "readability-misleading-indentation"
check.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirfile: Remove redundant #ifndef
Tim Wiederhake [Mon, 1 Feb 2021 12:41:58 +0000 (13:41 +0100)]
virfile: Remove redundant #ifndef

This section is guarded by "#ifndef WIN32" in line 2109--2808.

Found by clang-tidy's "readability-redundant-preprocessor" check.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Use automatic memory management in main
Tim Wiederhake [Mon, 1 Feb 2021 11:28:04 +0000 (12:28 +0100)]
commandhelper: Use automatic memory management in main

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Use automatic memory management in printInput
Tim Wiederhake [Mon, 1 Feb 2021 11:28:03 +0000 (12:28 +0100)]
commandhelper: Use automatic memory management in printInput

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Use automatic memory management in printCwd
Tim Wiederhake [Mon, 1 Feb 2021 11:28:02 +0000 (12:28 +0100)]
commandhelper: Use automatic memory management in printCwd

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Use automatic memory management in printEnvironment
Tim Wiederhake [Mon, 1 Feb 2021 11:28:01 +0000 (12:28 +0100)]
commandhelper: Use automatic memory management in printEnvironment

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Use automatic memory management in parseArguments
Tim Wiederhake [Mon, 1 Feb 2021 11:28:00 +0000 (12:28 +0100)]
commandhelper: Use automatic memory management in parseArguments

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Make number of fds variable in parseArguments
Tim Wiederhake [Mon, 1 Feb 2021 11:27:59 +0000 (12:27 +0100)]
commandhelper: Make number of fds variable in parseArguments

Fixes a buffer overflow triggered when more than three "--readfd"
arguments were given on the command line.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Make number of fds variable in printInput
Tim Wiederhake [Mon, 1 Feb 2021 11:27:58 +0000 (12:27 +0100)]
commandhelper: Make number of fds variable in printInput

Fixes a buffer overflow triggered when more than three "--readfd"
arguments were given on the command line.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Factor out printInput
Tim Wiederhake [Mon, 1 Feb 2021 11:27:57 +0000 (12:27 +0100)]
commandhelper: Factor out printInput

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Factor out printCwd
Tim Wiederhake [Mon, 1 Feb 2021 11:27:56 +0000 (12:27 +0100)]
commandhelper: Factor out printCwd

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Factor out printDaemonization
Tim Wiederhake [Mon, 1 Feb 2021 11:27:55 +0000 (12:27 +0100)]
commandhelper: Factor out printDaemonization

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Factor out printFds
Tim Wiederhake [Mon, 1 Feb 2021 11:27:54 +0000 (12:27 +0100)]
commandhelper: Factor out printFds

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Factor out printEnvironment
Tim Wiederhake [Mon, 1 Feb 2021 11:27:53 +0000 (12:27 +0100)]
commandhelper: Factor out printEnvironment

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Factor out printArguments
Tim Wiederhake [Mon, 1 Feb 2021 11:27:52 +0000 (12:27 +0100)]
commandhelper: Factor out printArguments

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Factor out parseArguments
Tim Wiederhake [Mon, 1 Feb 2021 11:27:51 +0000 (12:27 +0100)]
commandhelper: Factor out parseArguments

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Split argument parsing and printing
Tim Wiederhake [Mon, 1 Feb 2021 11:27:50 +0000 (12:27 +0100)]
commandhelper: Split argument parsing and printing

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Consolidate argument parsing
Tim Wiederhake [Mon, 1 Feb 2021 11:27:49 +0000 (12:27 +0100)]
commandhelper: Consolidate argument parsing

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Consolidate error paths
Tim Wiederhake [Mon, 1 Feb 2021 11:27:48 +0000 (12:27 +0100)]
commandhelper: Consolidate error paths

Preparation for later conversion to g_auto* memory handling.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Simplify envsort
Tim Wiederhake [Mon, 1 Feb 2021 11:27:47 +0000 (12:27 +0100)]
commandhelper: Simplify envsort

This saves two invocations of each `strndup` and `free`.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Remove numpollfds variable
Tim Wiederhake [Mon, 1 Feb 2021 11:27:46 +0000 (12:27 +0100)]
commandhelper: Remove numpollfds variable

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocommandhelper: Remove origenv variable
Tim Wiederhake [Mon, 1 Feb 2021 11:27:45 +0000 (12:27 +0100)]
commandhelper: Remove origenv variable

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agonews: implement new Hyper-V APIs
Matt Coleman [Tue, 2 Feb 2021 00:48:48 +0000 (19:48 -0500)]
news: implement new Hyper-V APIs

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: provide a more detailed error message for WSMan faults
Matt Coleman [Tue, 2 Feb 2021 00:48:47 +0000 (19:48 -0500)]
hyperv: provide a more detailed error message for WSMan faults

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: implement domainScreenshot
Matt Coleman [Tue, 2 Feb 2021 00:48:46 +0000 (19:48 -0500)]
hyperv: implement domainScreenshot

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: implement networkGetXMLDesc
Matt Coleman [Tue, 2 Feb 2021 00:48:45 +0000 (19:48 -0500)]
hyperv: implement networkGetXMLDesc

Co-authored-by: Dawid Zamirski <dzamirski@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: implement networkGetAutostart, networkIsActive, and networkIsPersistent
Matt Coleman [Tue, 2 Feb 2021 00:48:44 +0000 (19:48 -0500)]
hyperv: implement networkGetAutostart, networkIsActive, and networkIsPersistent

Co-authored-by: Dawid Zamirski <dzamirski@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: implement connectNumOfDefinedNetworks and connectListDefinedNetworks
Matt Coleman [Tue, 2 Feb 2021 00:48:43 +0000 (19:48 -0500)]
hyperv: implement connectNumOfDefinedNetworks and connectListDefinedNetworks

Co-authored-by: Dawid Zamirski <dzamirski@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: implement networkLookupByName and networkLookupByUUID
Matt Coleman [Tue, 2 Feb 2021 00:48:42 +0000 (19:48 -0500)]
hyperv: implement networkLookupByName and networkLookupByUUID

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: implement connectListAllNetworks and connectNumOfNetworks
Matt Coleman [Tue, 2 Feb 2021 00:48:41 +0000 (19:48 -0500)]
hyperv: implement connectListAllNetworks and connectNumOfNetworks

Co-authored-by: Dawid Zamirski <dzamirski@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: add support for creating network adapters
Matt Coleman [Tue, 2 Feb 2021 00:48:40 +0000 (19:48 -0500)]
hyperv: add support for creating network adapters

Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: XML parsing of Ethernet adapters
Matt Coleman [Tue, 2 Feb 2021 00:48:39 +0000 (19:48 -0500)]
hyperv: XML parsing of Ethernet adapters

Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodomain_conf: enable use of g_autofree for virDomainNetDef
Matt Coleman [Tue, 2 Feb 2021 00:48:38 +0000 (19:48 -0500)]
domain_conf: enable use of g_autofree for virDomainNetDef

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: add support for creating serial devices
Matt Coleman [Tue, 2 Feb 2021 00:48:37 +0000 (19:48 -0500)]
hyperv: add support for creating serial devices

Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: XML parsing of serial ports
Matt Coleman [Tue, 2 Feb 2021 00:48:36 +0000 (19:48 -0500)]
hyperv: XML parsing of serial ports

Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirsh: Simplify @flags handing in cmdSetmem() and cmdSetmaxmem()
Michal Privoznik [Wed, 25 Nov 2020 09:40:50 +0000 (10:40 +0100)]
virsh: Simplify @flags handing in cmdSetmem() and cmdSetmaxmem()

What code tries to achieve is that if no flags were provided to
either 'setmem' or 'setmaxmem' commands then the old (no flags)
API is called to be able to communicate with older daemons.
Well, the code can be simplified a bit.

Note that with this change the old no flag version of APIs is
used more often. Previously if --current argument was given it
resulted in *Flags() version to be called even though it is not
necessary - VIR_DOMAIN_AFFECT_CURRENT is implied.

Therefore, this change in fact allows virsh to talk with broader
set of daemons. No other user visible changes were made.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoconf: replace VIR_FREE() with g_free() in vir*Free() functions
Laine Stump [Sat, 30 Jan 2021 19:05:50 +0000 (14:05 -0500)]
conf: replace VIR_FREE() with g_free() in vir*Free() functions

This patch takes on one set of examples of unnecessary use of
VIR_FREE() when g_free() is adequate - it modifies only vir*Free()
functions within the conf directory that take a single pointer and
free the object pointed to by that argument before returning. The
modification is to replace VIR_FREE() with g_free() for the object
itself *and* for all subordinate chunks of memory pointed to by that
object.

(NB: there are other functions that VIR_FREE subordinate memory of
objects that end up being freed before return (also sometimes with
VIR_FREE); I am purposefully ignoring those to reduce scope and focus
on a sub class where the pointlessness is obvious.)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: rename virStorageEncryptionInfoDefFree()
Laine Stump [Fri, 29 Jan 2021 05:12:28 +0000 (00:12 -0500)]
util: rename virStorageEncryptionInfoDefFree()

usually a function call vir*Free() will take a single pointer to an
object as its argument, and will then free all resources associated
with that object, including the object
itself. virStorageEnctyptionInfoDefFree() doesn't do that - it frees
all the subordinate resources of the ojbect, but doesn't free the
object itself; usually a function like that is called
vir*Clear(). Let's rename this function to not be misleading.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: eliminate pointless setting of interface model
Laine Stump [Fri, 29 Jan 2021 04:39:33 +0000 (23:39 -0500)]
conf: eliminate pointless setting of interface model

There is no point in setting the interface model to unknown during
virDomainNetDefFree(), since we are about to free the object anyway
(and the model isn't used anywhere in the rest of the function).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: don't bother setting pointers to NULL in vir*Free() functions
Laine Stump [Wed, 27 Jan 2021 02:23:06 +0000 (21:23 -0500)]
conf: don't bother setting pointers to NULL in vir*Free() functions

The memory containing the pointer is going to be freed momentarily anyway.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: fix arg to virDomainPCIAddressSetExtensionFree()
Laine Stump [Sat, 30 Jan 2021 19:02:28 +0000 (14:02 -0500)]
conf: fix arg to virDomainPCIAddressSetExtensionFree()

This function clears out and frees a virDomainZPCIAddressIds object,
so that's that's what it should take as its argument, *not* the
pointer to a parent object that contains the object we want to free.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohostdevmgr: remove unneeded oldStateDir
Laine Stump [Tue, 26 Jan 2021 05:31:16 +0000 (00:31 -0500)]
hostdevmgr: remove unneeded oldStateDir

Back in commit 2c71d3826, which appeared in libvirt-1.2.3 in April
2014, the location used to store saved MAC addresses and vlan tags of
SRIOV VFs was changed from /var/run/libvirt/qemu to
/var/run/libvirt/hostdevmgr. For backward compatibility the code was
made to continue looking in the old location for the files when it
didn't find them in the new location.

It's now been 6 years, and even if there was somebody still running
libvirt-1.2.3 on their system, that system would now be out of support
for libvirt, so there would be no way for them to upgrade to a new
libvirt that no longer looks in  "oldStateDir" for the files. So
let's no longer look in "oldStateDir" for the files!

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agolog error if virConnectCacheOnceInit() fails
Laine Stump [Tue, 26 Jan 2021 04:54:57 +0000 (23:54 -0500)]
log error if virConnectCacheOnceInit() fails

virGetConnectNetwork() calls
 virGetConnectGeneric(), which calls
  virConnecCacheInitialize(), which is actually a call (only once) to
   virConnectCacheOnceInit() which calls
    virThreadLocalInit() several times, which calls
     pthread_key_create()

If pthread_key_create() fails, it (of course) doesn't log an error
(because it's not a part of libvirt), nor does any other function on
the call chain all the way up to virGetConnectNetwork(). But none of
the callers of virGetConnectNetwork() log an error either, so it is
possible that an API could fail due to virGetConnectNetwork() failing,
but would only log "an error was encountered, but the cause is
unknown. Deal with it."  (paraphrasing).

(In all likelyhood, virConnectCacheOnceInit() is going to be called at
some earlier time, and almost certainly pthread_key_create() will
never fail (and if it does, the user will have *much* bigger problems
than an obtuse error message from libvirt)).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirfile: workaround for when posix_fallocate() is not supported by FS
Roman Bogorodskiy [Sun, 31 Jan 2021 09:23:27 +0000 (13:23 +0400)]
virfile: workaround for when posix_fallocate() is not supported by FS

posix_fallocate() might be not supported by a filesystem, for example,
it's not supported by ZFS. In that case it fails with
return code 22 (EINVAL), and thus safezero_posix_fallocate() returns -1.

As safezero_posix_fallocate() is the first function tried by safezero()
and it tries other functions only when it returns -2, it fails
immediately without falling back to other methods, such as
safezero_slow().

Fix that by returning -2 if posix_fallocate() returns EINVAL, to give
safezero() a chance to try other functions.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: Clarify the documentation of the <css> elements
Thomas Huth [Fri, 29 Jan 2021 14:37:26 +0000 (15:37 +0100)]
docs: Clarify the documentation of the <css> elements

The channel subsystem elements describe a channel in the I/O subsystem
of a s390x machine, and not a normal device (like a disk or network card).
Reword the documentation here to make it this a little bit clearer.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1898074
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
4 years agoTranslated using Weblate (Finnish)
Jan Kuparinen [Sun, 31 Jan 2021 19:40:09 +0000 (20:40 +0100)]
Translated using Weblate (Finnish)

Currently translated at 13.0% (1366 of 10451 strings)

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

Co-authored-by: Jan Kuparinen <copper_fin@hotmail.com>
Signed-off-by: Jan Kuparinen <copper_fin@hotmail.com>
4 years agorpm: disable netcf for the interface driver in rpm build on new targets
Laine Stump [Sun, 17 Jan 2021 19:27:20 +0000 (14:27 -0500)]
rpm: disable netcf for the interface driver in rpm build on new targets

libvirt.spec currently adds a hardcoded -Dnetcf=enabled to the meson
commandline, so just setting the default in the meson.build file won't
have any effect for rpm builds - it will be overridden.

This patch changes the meson commandline in the spec file from
hardcoded -Dnetcf=enabled to %{arg_netcf}, which is itself set
according to the value of %{with_netcf}; and *that* is normally set
according to the distro release of the build target (1 for Fedora >=
34 and RHEL >= 9, 0 otherwise), but can be manually overridden by
adding "-without netcf" to the rpmbuild commandline.

Along with being used to determine what arg to pass to meson,
%{with_netcf} is also checked when deciding on whether or not to add
netcf build time / install time dependencies ("Requires: netcf-libs"
and "BuildRequires: netcf-devel")

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agobuild: support explicitly disabling netcf
Laine Stump [Thu, 21 Jan 2021 21:01:06 +0000 (16:01 -0500)]
build: support explicitly disabling netcf

placing "-Dnetcf=disabled" on the meson commandline was ignored,
meaning that even with that option the build would get WITH_NETCF if
the netcf-devel package was found - the only way to disable it was to
uninstall netcf-devel.

This patch adds the small bit of logic to check the netcf meson
commandline option (in addition to whether netcf-devel is installed)
before defining WITH_NETCF.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agosecurity_dac.c: use g_auto* in hostdev label set/restore functions
Daniel Henrique Barboza [Mon, 4 Jan 2021 12:54:32 +0000 (09:54 -0300)]
security_dac.c: use g_auto* in hostdev label set/restore functions

Use g_auto* cleanup to avoid free() calls.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agosecurity_selinux.c: use g_auto* in set/restore hostdev subsys functions
Daniel Henrique Barboza [Mon, 4 Jan 2021 12:54:31 +0000 (09:54 -0300)]
security_selinux.c: use g_auto* in set/restore hostdev subsys functions

Use g_auto* cleanup to avoid free() calls.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirpci.c: simplify virPCIDeviceNew() signature
Daniel Henrique Barboza [Mon, 4 Jan 2021 12:54:28 +0000 (09:54 -0300)]
virpci.c: simplify virPCIDeviceNew() signature

The current virPCIDeviceNew() signature, receiving 4 uints in sequence
(domain, bus, slot, function), is not neat.

We already have a way to represent a PCI address in virPCIDeviceAddress
that is used in the code. Aside from the test files, most of
virPCIDeviceNew() callers have access to a virPCIDeviceAddress reference,
but then we need to retrieve the 4 required uints (addr.domain, addr.bus,
addr.slot, addr.function) to satisfy virPCIDeviceNew(). The result is
that we have extra verbosity/boilerplate to retrieve an information that
is already available in virPCIDeviceAddress.

A better way is presented by virNVMEDeviceNew(), where the caller just
supplies a virPCIDeviceAddress pointer and the function handles the
details internally.

This patch changes virPCIDeviceNew() to receive a virPCIDeviceAddress
pointer instead of 4 uints.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agodomain_driver.c: use PCI address with virDomainDriverNodeDeviceGetPCIInfo()
Daniel Henrique Barboza [Mon, 4 Jan 2021 12:54:27 +0000 (09:54 -0300)]
domain_driver.c: use PCI address with virDomainDriverNodeDeviceGetPCIInfo()

Instead of receiving 4 uints in order and write domain/bus/slot/function,
receive a virPCIDeviceAddressPtr instead and write into it.

This change will allow us to simplify the API for virPCIDeviceNew()
in the next patch.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu, lxc: move NodeDeviceGetPCIInfo() function to domain_driver.c
Daniel Henrique Barboza [Mon, 4 Jan 2021 12:54:26 +0000 (09:54 -0300)]
qemu, lxc: move NodeDeviceGetPCIInfo() function to domain_driver.c

libxlNodeDeviceGetPCIInfo() and qemuNodeDeviceGetPCIInfo() are equal.
Let's move the logic to a new virDomainDriverNodeDeviceGetPCIInfo()
info to be used by libxl_driver.c and qemu_driver.c.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>