Commit Graph

39642 Commits

Author SHA1 Message Date
Michal Privoznik
c383dc948e hyperv: Reformat
This is mostly opening hyperv driver sources in vim, selecting
everything, hitting reformat and then fixing a very few places.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-22 16:11:56 +02:00
Michal Privoznik
e8fd9c91c2 hyperv: Use two empty lines between functions
In some places we separate functions with only one line, in
others with three lines and the rest uses two lines.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-22 16:11:56 +02:00
Michal Privoznik
864d79e452 hyperv: Use hypervRequestStateChange() in hypervDomainSuspend()
A few commits ago, hypervRequestStateChange() helper was
introduced which has exactly the same code as a part of
hypervDomainSuspend(). Deduplicate by calling the helper.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-22 16:11:56 +02:00
Michal Privoznik
458e2d6fc5 hyperv: Don't overwrite errors from hypervCreateInvokeParamsList()
The hypervCreateInvokeParamsList() function sets an error on a
failure, therefore there is no need to report another error in
callers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-22 16:11:56 +02:00
Peter Krempa
4505f11d65 virHashRemoveAll: Don't return number of removed items
Nobody uses the return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
7c1a4bc775 util: virhash: Remove key handling callbacks
Since we use virHashTable for string-keyed values only, we can remove
all the callbacks which allowed universal keys.

Code which wishes to use non-string keys should use glib's GHashTable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
d6d4c08daf util: hash: Change type of hash table name/key to 'char'
All users of virHashTable pass strings as the name/key of the entry.
Make this an official requirement by turning the variables to 'const
char *'.

For any other case it's better to use glib's GHashTable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
a2c699856a util: hash: Remove virHashCreateFull
The only place we call it is in virHashNew. Move the code to virHashNew
and remove virHashCreateFull.

Code wishing to use non-strings as hash table keys will be better off
using glib's GHashTable directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
8824fc8474 util: hash: Remove virHashValueFree
Use 'g_free' directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
b82dfe3ba7 Replace all instances of 'virHashCreate' with 'virHashNew'
It doesn't make much sense to configure the bucket count in the hash
table for each case specifically. Replace all calls of virHashCreate
with virHashNew which has a pre-set size and remove virHashCreate
completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
aa99658b06 qemuDomainObjPrivateAlloc: Use virHashNew instead of virHashCreate
virHashCreate will be removed in upcoming patches. This change has an
impact on ordering of the blockjob entries in one of the status XML->XML
tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
afc4139136 tests: hash: Prepare for replacement of virHashCreate
Most callers pass a random number. We have virHashNew which doesn't give
the callers the option to configure the table. Since we are going to
switch to virHashNew replace it in tests and remove multiple instances
of the 'testHashGrow' case as it doesn't make sense with the new
semantics.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
e12324d2af conf: nwfilter: Replace 'virNWFilterHashTableCreate' with 'virHashNew'
Export the freeing function rather than having a wrapper for the hash
creation function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
c28b680579 virHashAtomicNew: Remove 'size' argument
Use 'virHashNew' internally which uses a default size.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
07780553f6 conf: domain_addr: Refactor hash usage in zpci reservation code
Rewrite using GHashTable which already has interfaces for using a number
as hash key.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
32ab328461 virCgroupKillRecursive: Refactor cleanup
Remove 'cleanup' label and simplify remembering of the returned value
from the callback.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
b16629f00c util: cgroup: Use GHashTable instead of virHashTable
Rewrite using GHashTable which already has interfaces for using a number
as hash key. Glib's implementation doesn't copy the key by default, so
we need to allocate it, but overal the interface is more suited for this
case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
2751b9757b util: virhash: Remove virHashTableSize
It's used only in one place in tests which isn't even automatically
evaluated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
0778cff2ae virCgroupKillRecursive: Return -1 on failure condition
virCgroupKillRecursive sneakily initializes 'ret' to 0 rather than the
usual -1. 401030499b moved an error condition but didn't actually
modify 'ret' return the proper error code.

Fixes: 401030499b
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Michal Privoznik
db8e747af9 parthelper: Don't leak @canonical_path
The @canonical_path variable holds canonicalized path passed as
argv[1]. The canonicalized path is obtained either via
virFileResolveLink() or plain g_strdup(). Nevertheless, in both
cases it must be freed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-22 13:47:23 +02:00
Michal Privoznik
3b8deb9603 parthelper: Initialize error object
Some functions called from parthelper can report an error. But
that means that the error object must be initialized otherwise
virResetError() (which happens as a part of virReportError())
will free random pointers.

Reported-by: Katerina Koukiou <kkoukiou@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-22 13:47:23 +02:00
Daniel P. Berrangé
7b1ed1cd73 qemu: stop passing -enable-fips to QEMU >= 5.2.0
Use of the -enable-fips option is being deprecated in QEMU >= 5.2.0. If
FIPS compliance is required, QEMU must be built with libcrypt which will
unconditionally enforce it.

Thus there is no need for libvirt to pass -enable-fips to modern QEMU.
Unfortunately there was never any way to probe for -enable-fips in the
first instance, it was enabled by libvirt based on version number
originally, and then later unconditionally enabled when libvirt dropped
support for older QEMU. Similarly we now use a version number check to
decide when to stop passing -enable-fips.

Note that the qemu-5.2 capabilities are currently from the pre-release
version and will be updated once qemu-5.2 is released.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-22 09:03:33 +02:00
Peter Krempa
ca8f7b8a02 qemuxml2argvtest: Sanitize testing of '-enable-fips'
Rename 'FLAG_FIPS' to 'FLAG_FIPS_HOST' to signify that we are simulating
a host supporting fips mode and use the flag to assert 'enabeFips'
argument of 'qemuProcessCreatePretendCmdBuild' rather than passing it
via QEMU_CAPS_ENABLE_FIPS.

This prepares the testsuite for testing of -enable-fips deprecation in
qemu-5.2.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-22 09:03:28 +02:00
Laine Stump
25cb07498e util: remove unused function virPCIGetSysfsFile()
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-21 15:19:34 -04:00
Laine Stump
4dc39a204a util: don't use virPCIGetSysfsFile()
virPCIDeviceAddressGetSysfsFile() is simpler to call.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-21 15:18:08 -04:00
Laine Stump
668dd10ba9 util: remove unneeded cleanup:/ret in virpci.c
These were nops once enough cleanup was g_auto'd.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-21 15:17:19 -04:00
Laine Stump
ca35e8dad1 util: use more g_autofree in virpci.c
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-21 15:16:43 -04:00
Laine Stump
fefd478644 util: avoid manual VIR_FREE of a g_autofree pointer in virPCIGetName()
thisPhysPortID is only used inside a conditional, so reduce its scope
to just the body of that conditional, which will eliminate the need
for the undesirable manual VIR_FREE().

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-21 15:16:08 -04:00
Laine Stump
bc7c4f5415 util: simplify virPCIProbeStubDriver()
This function had a loop that was only executed twice; it was
artificially constructed with a label, a goto, and a boolean to tell
that it had already been executed once. Aside from that, the body of
the loop contained only two lines that needed to be repeated (the
second time through, everything beyond those two lines would be
skipped).

One side effect of this strange loop was that a g_autofree string was
manually freed and re-initialized; I've been told that manually
freeing a g_auto_free object is highly discouraged.

This patch refactors the function to simply repeat the 2 lines that
might possibly be executed twice, thus eliminating the ugly use of
goto to construct a loop, and also takes advantage of the fact that
virPCIDriverDir() was previously returning *exactly* the same string
both times it was called to eliminate the manual VIR_FREE of drvpath.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-21 15:15:32 -04:00
Laine Stump
b3066b55bf util: simplify virPCIDriverDir() and its callers
There is no need for a temporary variable in this function, and since
it can't return NULL, no need for callers to check for it.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-21 15:15:00 -04:00
Laine Stump
862f7e5c73 util: simplify virPCIFile() and its callers
There is no need for a temporary variable in this function, and ever
since we switched to glib for memory allocation, there is no possibility
it can return NULL, so callers don't need to check for it.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-21 15:14:12 -04:00
Laine Stump
06e318c328 util: simplify virHostdevPCISysfsPath()
Apparently at some point in the past, when there were multiple types
to represent PCI addresses, the function
virPCIDeviceAddressGetSysfsFile() used one of those types, while
virDomainHostDevDef used another. It's been quite awhile since we
reduced the number of different representations of PCI address, but
this function was still creating a temporary virPCIDeviceAddress, then
copying the individual elements into this temporary object from the
same type of object in the virDomainHostDevDef.

This patch just eliminates that pointless copy.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-21 15:13:21 -04:00
Laine Stump
6bd4505dea util: fix very old bug/typo in virNetDevParseVfInfo()
When this function was recently changed to add in parsing of
IFLA_VF_STATS, I noticed that the checks for existence of IFLA_VF_MAC
and IFLA_VF_VLAN were looking in the *wrong array*. The array that
contains the results of parsing each IFLA_VFINFO in
tb[IFLA_VFINFO_LIST] is tb_vf, but we were checking for these in tb
(which is the array containing the results of the toplevel parsing of
the netlink message, *not* the results of parsing one of the nested
IFLA_VFINFO's.

This incorrect code has been here since the function was originally
written in 2012. It has only worked all these years due to coincidence
- the items at those indexes in tb are IFLA_ADDRESS and IFLA_BROADCAST
(of the *PF*, not of any of its VFs), and those happen to always be
present in the toplevel netlink message; since we are only looking in
the incorrect place to check for mere existence of the attribute (but
are doing the actual retrieval of the attribute from the correct
place), this bug has no real consequences other than confusing anyone
trying to understand the code.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:30:50 -04:00
Adolfo Jayme Barrientos
75b74095e2 Translated using Weblate (Spanish)
Currently translated at 51.9% (5377 of 10354 strings)

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

Translated using Weblate (Portuguese (Brazil))

Currently translated at 52.3% (5418 of 10354 strings)

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

Translated using Weblate (Spanish)

Currently translated at 51.6% (5353 of 10354 strings)

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

Co-authored-by: Adolfo Jayme Barrientos <fitoschido@gmail.com>
Signed-off-by: Adolfo Jayme Barrientos <fitoschido@gmail.com>
2020-10-21 15:25:13 +02:00
Daniel P. Berrangé
a16c0402ba rpm: disable LTO in Fedora 34
A binutils change has caused breakage when linking the tests

/usr/bin/ld: tests/libtest_qemu_driver.so: undefined reference to `__open_missing_mode'

This is probably a regression in binutils, so disable LTO until we get
more clarity on the root cause and whether binutils or libvirt will need
changing.

  https://bugzilla.redhat.com/show_bug.cgi?id=1889763

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-21 14:24:53 +01:00
Matt Coleman
ccbe3ec798 news: more Hyper-V APIs
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:54 +02:00
Matt Coleman
747e0888a0 hyperv: fix domainManagedSave on Hyper-V V2
Signed-off-by: Matt Coleman <matt@datto.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:52 +02:00
Matt Coleman
a9f1a798fd hyperv: fix domainSuspend and domainResume on Hyper-V V2
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:50 +02:00
Matt Coleman
d4f09baa6b hyperv: implement domainShutdown and domainShutdownFlags
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:47 +02:00
Matt Coleman
8943b14838 hyperv: implement domainReboot and domainReset
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>
2020-10-21 14:20:44 +02:00
Matt Coleman
7bf302fb63 hyperv: implement nodeGetFreeMemory
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:41 +02:00
Matt Coleman
cc9248cc6c hyperv: implement domainSetAutostart
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:39 +02:00
Matt Coleman
26f5609e70 hyperv: avoid overwriting errors from hypervGetWmiClass()
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:37 +02:00
Matt Coleman
5140f97bcc hyperv: enable usage of g_autoptr for hypervInvokeParamsList
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:33 +02:00
zhenwei pi
f76848a7c1 util: rename virNetDevParseVfConfig to virNetDevParseVfInfo
virNetDevParseVfConfig has became a multifunctional helper function,
rename it to virNetDevParseVfInfo.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-10-20 17:29:48 -04:00
zhenwei pi
b295f06da4 util: support device stats collection for <interface type='hostdev'>
libvirt can retrieve traffic stats for emulated interfaces that are
backed by tap or macvtap devices, but this information wasn't
available for hostdev interfaces (those that are implemented by
assigning an SR-IOV VF device to a guest using vfio):

  #virsh domifstat instance --interface=52:54:00:2d:b2:35
  error: Failed to get interface stats instance 52:54:00:2d:b2:35
  error: internal error: Interface name not provided

For some SR-IOV VF devices this information is available via the
netlink VFINFO_LIST request/response, and that is what this patch uses
to implement stats retrieval for VF. Not that this is dependent on
support in the PF driver - for example, the Mellanox ConnectX-4 Lx
(mlx5) driver reports usable stats, while Intel 82599 (ixgbe) and
82576 (igb) just report all stats as 0.  (this is the same result as
"ip -s link show").

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-10-20 17:29:29 -04:00
Jonathon Jongsma
b79abf9c3c qemu: support hotplug of vdpa devices
By using the new qemu monitor functions to handle passing and removing
file descriptors, we can support hotplug of vdpa devices.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2020-10-20 15:15:06 -04:00
Jonathon Jongsma
b8998cc670 qemu: add monitor functions for handling file descriptors
add-fd, remove-fd, and query-fdsets provide functionality that can be
used for passing fds to qemu and closing fdsets that are no longer
necessary.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-10-20 15:14:37 -04:00
Jonathon Jongsma
0b1a05ffb5 qemu: add vdpa support
Enable <interface type='vdpa'> for qemu domains. This provides basic
support and does not support hotplug or migration.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-10-20 14:48:02 -04:00
Jonathon Jongsma
9825f71b53 qemu: add vhost-vdpa capability
Recent versions of qemu added the -netdev vhost-vdpa device. This
capability allows libvirt to know whether this is supported.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-10-20 14:47:20 -04:00