]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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>
4 years agovirpci, domain_audit: use virPCIDeviceAddressAsString()
Daniel Henrique Barboza [Mon, 4 Jan 2021 12:54:25 +0000 (09:54 -0300)]
virpci, domain_audit: use virPCIDeviceAddressAsString()

There is no need to open code the PCI address string format
when we have a function that does exactly that.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoRevert "remote: Add libvirtd dependency to virt-guest-shutdown.target"
Jim Fehlig [Thu, 28 Jan 2021 19:09:18 +0000 (12:09 -0700)]
Revert "remote: Add libvirtd dependency to virt-guest-shutdown.target"

Further testing revealed commit f035f53baa regresses Debian bug 955216

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=955216

Restarting libvirt-guests on libvirtd restart is worse than the original
dependency issue, so revert the commit until a better solution is found.

This reverts commit f035f53baa2e5dc00b8e866e594672a90b4cea78.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodocs: compiling: mention build dir
Ján Tomko [Fri, 29 Jan 2021 13:21:46 +0000 (14:21 +0100)]
docs: compiling: mention build dir

Our docs have not been fully updated to reflect the separate
build directory.

Suggested-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonews: document virtiofs boot order
Ján Tomko [Fri, 29 Jan 2021 13:39:36 +0000 (14:39 +0100)]
news: document virtiofs boot order

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: format bootindex for vhost-user-fs
Ján Tomko [Tue, 5 Jan 2021 18:03:03 +0000 (19:03 +0100)]
qemu: format bootindex for vhost-user-fs

Wire up the QEMU command line for this option.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoAdd validation for virtiofs boot order setting
Ján Tomko [Tue, 5 Jan 2021 18:15:07 +0000 (19:15 +0100)]
Add validation for virtiofs boot order setting

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: add QEMU_CAPS_VHOST_USER_FS_BOOTINDEX
Ján Tomko [Mon, 4 Jan 2021 15:03:57 +0000 (16:03 +0100)]
qemu: add QEMU_CAPS_VHOST_USER_FS_BOOTINDEX

Introduced by QEMU commit:

commit 6da32fe5efdd71c9d254a436ce972194ff631285
Author:     Laszlo Ersek <lersek@redhat.com>
AuthorDate: 2021-01-12 14:16:03 +0100
Commit:     Michael S. Tsirkin <mst@redhat.com>
CommitDate: 2021-01-13 09:06:37 -0500

    vhost-user-fs: add the "bootindex" property

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: add boot order to filesystem
Ján Tomko [Tue, 5 Jan 2021 18:39:46 +0000 (19:39 +0100)]
conf: add boot order to filesystem

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: switch vhost-user-fs-hugepages to use boot order
Ján Tomko [Tue, 5 Jan 2021 18:43:07 +0000 (19:43 +0100)]
tests: switch vhost-user-fs-hugepages to use boot order

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: rename virDomainCheckVirtioOptions
Boris Fiuczynski [Fri, 29 Jan 2021 11:39:22 +0000 (12:39 +0100)]
conf: rename virDomainCheckVirtioOptions

Rename virDomainCheckVirtioOptions into
virDomainCheckVirtioOptionsAreAbsent since it checks if all
virtio options are absent. The old name was very misleading.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Add virtio related options to vsock
Boris Fiuczynski [Wed, 27 Jan 2021 18:46:59 +0000 (19:46 +0100)]
qemu: Add virtio related options to vsock

Add virtio related options iommu, ats and packed as driver element attributes
to vsock devices. Ex:

 <vsock model='virtio'>
   <cid auto='no' address='3'/>
   <driver iommu='on'/>
 </vsock>

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: Improve virDomainVirtioOptionsCheckABIStability()
Michal Privoznik [Thu, 28 Jan 2021 13:13:32 +0000 (14:13 +0100)]
conf: Improve virDomainVirtioOptionsCheckABIStability()

The virDomainVirtioOptionsCheckABIStability() function is called
from various ABI stability check functions. Every caller checks
if both old and new definitions have virtio options set and only
after that they call the function. This is suboptimal because:

  a) this check can be done in the function itself (making all
  callers shorter),
  b) is inherently wrong, because it doesn't catch case where one
  definition has virtio options set and the other doesn't.

Do proper checks at the beginning of the function and simplify
its calls.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoconf: Drop empty virDomainNetDefPostParse()
Michal Privoznik [Thu, 28 Jan 2021 13:08:24 +0000 (14:08 +0100)]
conf: Drop empty virDomainNetDefPostParse()

The previous commit rendered this function empty and needless.
Remove it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoconf: Move virDomainCheckVirtioOptions() into domain_validate.c
Michal Privoznik [Thu, 28 Jan 2021 13:06:55 +0000 (14:06 +0100)]
conf: Move virDomainCheckVirtioOptions() into domain_validate.c

The aim of virDomainCheckVirtioOptions() function is to check
whether no virtio options are set, i.e. no @iommu no @ats and no
@packed attributes were present in given device's XML (yeah, the
function has very misleading name). Nevertheless, this kind of
check belongs to validation phase, but now is done in post parse
phase. Move the function and its calls to domain_validate.c so
that future code is not tempted to repeat this mistake.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoTranslated using Weblate (Finnish)
Jan Kuparinen [Thu, 28 Jan 2021 09:56:17 +0000 (10:56 +0100)]
Translated using Weblate (Finnish)

Currently translated at 11.1% (1163 of 10451 strings)

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

Translated using Weblate (Finnish)

Currently translated at 11.1% (1162 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 agoTranslated using Weblate (Swedish)
Göran Uddeborg [Thu, 28 Jan 2021 09:56:16 +0000 (10:56 +0100)]
Translated using Weblate (Swedish)

Currently translated at 23.9% (2504 of 10451 strings)

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

Translated using Weblate (Swedish)

Currently translated at 23.6% (2474 of 10451 strings)

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

Translated using Weblate (Swedish)

Currently translated at 23.3% (2444 of 10451 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 agoTranslated using Weblate (Turkish)
Muha Aliss [Thu, 28 Jan 2021 09:56:15 +0000 (10:56 +0100)]
Translated using Weblate (Turkish)

Currently translated at 0.1% (7 of 10451 strings)

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

Added translation using Weblate (Turkish)

Co-authored-by: Muha Aliss <muhaaliss@gmail.com>
Signed-off-by: Muha Aliss <muhaaliss@gmail.com>
4 years agodocs: link to PCI docs from the kbase page
Daniel P. Berrangé [Fri, 22 Jan 2021 15:23:33 +0000 (15:23 +0000)]
docs: link to PCI docs from the kbase page

While the PCI docs are linked from formatdomain.html, finding those
links is not straightforward. It is good for users to highlight them in
the kbase pages.  The PCI docs are intentionally not moved to the kbase/
sub-directory in order to avoid breaking hyperlinks.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotests: qemucapabilities: Add test data for qemu-6.0 release cycle
Peter Krempa [Tue, 12 Jan 2021 14:48:59 +0000 (15:48 +0100)]
tests: qemucapabilities: Add test data for qemu-6.0 release cycle

Add the capabilities test data for the next qemu development cycle so
that we stay up to date.

Based on v5.2.0-1374-g9cd69f1a27

Notable changes detected by libvirt are the new machine types and
'intel-pt-lip', 'avx512-fp16', 'kvm-msi-ext-dest-id' cpu features
reported by qemu.

Other qemu changes not detected by libvirt include removal of the
'change' command, addition of 'sev-inject-launch-secret', 'yank',
'query-yank' commands and other device properties.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agospec: Drop gettext-devel from the SPEC file
Erik Skultety [Tue, 26 Jan 2021 16:15:32 +0000 (17:15 +0100)]
spec: Drop gettext-devel from the SPEC file

With meson, we don't need the gettext headers anymore, meson takes care
of that and we only need to have xgettext installed.
Without this patch RPM build in Fedora containers fails.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: fix release of virDomainObjPtr in SSH key APIs
Daniel P. Berrangé [Fri, 22 Jan 2021 14:51:17 +0000 (14:51 +0000)]
qemu: fix release of virDomainObjPtr in SSH key APIs

The qemuDomainObjFromDomain() API must be paired with
the virDomainObjEndAPI API. The qemuDomainAuthorizedSSHKeysGet
method simply did 'return -1' leaking a reference and lock
in two paths.

The qemuDomainAuthorizedSSHKeysSet method marked the object
as an autoptr while also have some code paths that will call
virDomainObjEndAPI. As a result the object will be released
but not unlocked in error paths.

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: Avoid crash in qemuStateShutdownPrepare() and qemuStateShutdownWait()
Michal Privoznik [Fri, 22 Jan 2021 09:25:45 +0000 (10:25 +0100)]
qemu: Avoid crash in qemuStateShutdownPrepare() and qemuStateShutdownWait()

If QEMU driver fails to initialize for whatever reason (it can be
as trivial as a typo on qemu.conf), the control jumps to error
label in qemuStateInitialize() where qemuStateCleanup() is called
which frees the driver. But the daemon then asks drivers to
prepare for shutdown, which in case of QEMU driver is implemented
in qemuStateShutdownPrepare(). In here, the driver is
dereferenced but since it was freed earlier, the pointer is NULL
which leads to instant crash.

Solution is simple - just check if qemu_driver is not NULL. But
doing so only in qemuStateShutdownPrepare() would push the
problem down to virStateShutdownWait(), well
qemuStateShutdownWait(). Therefore, duplicate the trick there
too.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1895359#c14
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoutil: Remove unused 'virStorageFileParseChainIndex'
Peter Krempa [Mon, 25 Jan 2021 14:25:28 +0000 (15:25 +0100)]
util: Remove unused 'virStorageFileParseChainIndex'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agotests: storage: Replace index testing in testStorageLookup
Peter Krempa [Mon, 25 Jan 2021 14:15:02 +0000 (15:15 +0100)]
tests: storage: Replace index testing in testStorageLookup

Test the actual index in the returned virStorageSource rather than the
parsed one. Some tests need to be adapted as they were on failed lookup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirStorageSourceChainLookup: Handle names like 'vda[4]' internally
Peter Krempa [Mon, 25 Jan 2021 14:02:26 +0000 (15:02 +0100)]
virStorageSourceChainLookup: Handle names like 'vda[4]' internally

All callers of this function called virStorageFileParseChainIndex
before. Internalize the logic of that function to prevent multiple calls
and passing around unnecessary temporary variables.

This is achieved by calling virStorageFileParseBackingStoreStr and using
it to fill the values internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agotest: storage: Remove double testing in testStorageLookup
Peter Krempa [Mon, 25 Jan 2021 13:57:35 +0000 (14:57 +0100)]
test: storage: Remove double testing in testStorageLookup

The function attempts two calls to virStorageSourceChainLookup to see
whether the function handles NULL correctly. This isn't very useful and
additionally upcoming patch will remove the 'idx' parameter thus the
test becomes obsolete. Remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirStorageSourceChainLookup: Don't break error message strings
Peter Krempa [Mon, 25 Jan 2021 13:54:57 +0000 (14:54 +0100)]
virStorageSourceChainLookup: Don't break error message strings

Put them on one line for greppability.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirt-aa-helper: Don't probe image metadata for terminated chains
Peter Krempa [Fri, 22 Jan 2021 16:16:38 +0000 (17:16 +0100)]
virt-aa-helper: Don't probe image metadata for terminated chains

A terminated chain has a virStorageSource with type ==
VIR_STORAGE_TYPE_NONE at the end. Since virStorageSourceHasBacking
is explicitly returning false in that case we'd probe the chain
needlessly. Just check whether src->backingStore is non-NULL.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirt-aa-helper: Use proper check for empty disk in 'get_files'
Peter Krempa [Fri, 22 Jan 2021 16:10:44 +0000 (17:10 +0100)]
virt-aa-helper: Use proper check for empty disk in 'get_files'

'virDomainDiskGetSource' returns src->path effectively. Checking whether
a disk is empty is done via 'virStorageSourceIsEmpty'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirStorageSourceGetMetadata: Refactor cleanup
Peter Krempa [Fri, 22 Jan 2021 16:03:22 +0000 (17:03 +0100)]
virStorageSourceGetMetadata: Refactor cleanup

Use g_autoptr for the hash table and remove the 'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agostorage_source: Move backing store parsers into new file
Peter Krempa [Fri, 22 Jan 2021 15:03:53 +0000 (16:03 +0100)]
storage_source: Move backing store parsers into new file

The parsers for the backing store strings are relatively self-contained
and rather massive piece of code. Move them to a new module called
storage_source_backingstore.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoutil: virstoragefile: Move virStorageIs[File|Relative] to storage_source
Peter Krempa [Fri, 22 Jan 2021 14:34:33 +0000 (15:34 +0100)]
util: virstoragefile: Move virStorageIs[File|Relative] to storage_source

There are no other files using it. Move it and make the functions
static.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirStorageSourceGetBackingStoreStr: Return relative paths only
Peter Krempa [Fri, 22 Jan 2021 14:08:23 +0000 (15:08 +0100)]
virStorageSourceGetBackingStoreStr: Return relative paths only

Rename the function to virStorageSourceFetchRelativeBackingPath and
return relative paths only. The function is only used to restore the
relative relationship between images so there's no need for it to be
universal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirStorageSourceGetBackingStoreStr: Move the function earlier
Peter Krempa [Fri, 22 Jan 2021 14:15:01 +0000 (15:15 +0100)]
virStorageSourceGetBackingStoreStr: Move the function earlier

Move it together with virStorageSourceGetRelativeBackingPath which is
the main reason why it exists. Upcoming patch will modify the comment
and arguments refering to virStorageSourceGetRelativeBackingPath so it's
better if they are together.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agotools: Set IFS for bash completion script
Michal Privoznik [Mon, 25 Jan 2021 12:48:31 +0000 (13:48 +0100)]
tools: Set IFS for bash completion script

The way our bash completion string is that is gets user's input
and lets virsh completion code do all the work by calling 'virsh
complete -- $INPUT". The 'complete' command is a "secret",
unlisted command that exists solely for this purpose. After it
has done it's part, it prints candidates onto stdout, each
candidate on its own line, e.g. like this:

  # virsh complete -- "net-u"
  net-undefine
  net-update
  net-uuid

These strings are then stored into a bash array $A like this:

  A=($($1 ${CMDLINE} complete -- "${INPUT[@]}" 2>/dev/null))

This array is then thrown back at bash completion to produce
desired output. So far so good. Except, when there is an option
with space. For instance:

  # virsh complete -- start --domain ""
  uefi\ duplicate
  uefi

Bash interprets that as another array item because by default,
Internal Field Separator (IFS) = set of characters that bash uses
to split words at, is: space, TAB, newline. We don't want space
nor TAB. Therefore, we have to set $IFS when storing 'virsh
complete' output into the array.

Thanks to Peter who suggested it.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/116
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovsh: Allow double quotes imbalance for auto completion in vshCommandStringGetArg()
Michal Privoznik [Thu, 7 Jan 2021 17:09:11 +0000 (18:09 +0100)]
vsh: Allow double quotes imbalance for auto completion in vshCommandStringGetArg()

If user is trying to auto complete a value that contains a space,
they have two options: use backslash to escape space or use
quotes, like this:

  virsh # start --domain "domain with space<TAB>

However, in this case our tokenizer sees imbalance in (double)
quotes: there is a starting one that's missing its companion.
Well, that's obvious - user is still in process of writing the
command. What we need to do in this case is to ignore the
imbalance and return success (from the tokenizer) - readline will
handle closing the quote properly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovsh: Rework how option to complete is found
Michal Privoznik [Tue, 26 Jan 2021 08:51:27 +0000 (09:51 +0100)]
vsh: Rework how option to complete is found

The way that auto completion works currently is that user's input
is parsed, and then we try to find the first --option (in the
parsed structure) that has the same value as user's input around
where <TAB> was pressed. For instance, for the following input:

  virsh # command --arg1 hello --arg2 world<TAB>

we will see "world" as text that user is trying to autocomplete
(this is affected by rl_basic_word_break_characters which
readline uses internally to break user's input into individual
words) and find that it is --arg2 that user is trying to
autocomplete. So far so good, for this naive approach. But
consider the following example:

  virsh # command --arg1 world --arg2 world<TAB>

Here, both arguments have the same value and because we see
"world" as text that user is trying to autocomplete we would
think that it is --arg1 that user wants to autocomplete. This is
obviously wrong.

Fortunately, readline stores the current position of cursor (into
rl_point) and we can use that when parsing user's input: whenever
we reach a position that matches the cursor then we know that
that is the place where <TAB> was pressed and hence that is the
--option that user wants to autocomplete. Readline stores the
cursor position as offset (numbered from 1) from the beginning of
user's input. We store this input into @parser->pos initially,
but then advance it as we tokenize it. Therefore, what we need is
to store the original position too.

Thanks to Martin who helped me with this.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovshReadlineParse: Escape list of candidates earlier
Michal Privoznik [Tue, 26 Jan 2021 08:23:24 +0000 (09:23 +0100)]
vshReadlineParse: Escape list of candidates earlier

The way our completer callbacks work is that they return all
possible candidates and then vshCompleterFilter() is called to
prune the list of all candidates removing those which don't match
user's input. This allows us to have simpler completer callbacks
as their only job is to fetch all possible candidates.

Anyway, if the completion candidate we're returning contains a
space, it has to be escaped (shell like escaping), unless there
is already a quote character (single quote or double quote).

But ordering is critical. Completer callback returns string
without any escaping, but the filter function sees the user input
escaped. For instance, if user's input is "domain with
space<TAB>" then the filtering function gets "domain\ with\
space" as user's input but completer returns "domain with space".
Since these two strings don't match the filtering function
removes this candidate from the list. What we need to do is to
escape strings before calling the filtering function. This way,
the filtering function will see two same strings.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovshReadlineParse: Rename @buf to @line
Michal Privoznik [Tue, 26 Jan 2021 08:23:10 +0000 (09:23 +0100)]
vshReadlineParse: Rename @buf to @line

In next commit the block that does escaping of returned string
will be brought into this block. But both contain variable @buf
and use it in different contexts. Rename @buf from @state == 0
block to @line which reflects its purpose better.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovshReadlineParse: Use g_auto*()
Michal Privoznik [Tue, 26 Jan 2021 09:23:32 +0000 (10:23 +0100)]
vshReadlineParse: Use g_auto*()

Instead of freeing @partial and @buf explicitly, we can use
g_auto*() to do that automatically.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovshReadlineParse: Bring some variables into !state block
Michal Privoznik [Tue, 26 Jan 2021 08:18:21 +0000 (09:18 +0100)]
vshReadlineParse: Bring some variables into !state block

On readline completion vshReadlineCompletion() is called which
does nothing more than calling rl_completion_matches() with
vshReadlineParse() as a callback. This means, that
vshReadlineParse() is called repeatedly, each time returning next
completion candidate, until it returns NULL which is interpreted
as the end of the list of candidates.

The function takes two parameters: @text which is a portion of
input line around cursor when TAB was pressed, and @state. The
@state is an integer that is zero on the very first call and
non-zero on each subsequent call (in fact, readline does @state++
on each call).

Anyway, the idea is that the callback gets the whole list of
candidates on @state == 0 and returns one candidate at each call.
And this is what vshReadlineParse() is doing but some variables
(@partial, @cmd and @opt) are really used only in the @state == 0
case but declared for whole function. We can limit their scope by
declaring them inside the @state == 0 body which also means that
they don't have to be static anymore.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovsh: Don't break word on backslash
Michal Privoznik [Thu, 7 Jan 2021 16:58:41 +0000 (17:58 +0100)]
vsh: Don't break word on backslash

A backslash is the way we escape characters in virsh. For
instance:

  virsh # start domain\ with\ long\ name

For readline completion, we do not want to get four separate
words ("domain", "with", "long", "name").  This means, that we
can't use virBufferEscapeShell() because it doesn't escape spaces
the way we want.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovshCommandStringGetArg: Drop @sz
Michal Privoznik [Thu, 7 Jan 2021 16:59:55 +0000 (17:59 +0100)]
vshCommandStringGetArg: Drop @sz

This variable is unused since introduction of the function in
v0.8.5~150.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agocpu_map: Remove intel-pt from x86 CPU models
Jiri Denemark [Fri, 22 Jan 2021 14:04:42 +0000 (15:04 +0100)]
cpu_map: Remove intel-pt from x86 CPU models

As explained in QEMU commit 4c257911dcc7c4189768e9651755c849ce9db4e8
intel-pt features should never be included in the CPU models as it was
not supported by KVM back then and even once it started to be supported,
users have to enable it by passing pt_mode=1 parameter to kvm_intel
module. The Icelake-* CPU models with intel-pt included were added to
QEMU 3.1.0 and removed right in the following 4.0.0 release (and even in
3.1.1 maintenance release).

In libvirt 6.10.0 I introduced 'removed' attribute for features included
in our CPU model definitions which we can use to drop intel-pt from
Icelake-* CPU models. Back then I explained we can safely do so only for
features which could never be enabled, which is not the case of intel-pt.

Theoretically, it could be possible to create an environment in which
QEMU would enable intel-pt without asking for it explicitly: it would
need to use a new enough kernel (not available at the time of QEMU
3.1.0) and pt_mode KVM parameter in combination with QEMU 3.1.0 running
a domain with q35 machine type and all that on a CPU which didn't really
exist at that time.

Migrating such domain to a host with newer SW stack including libvirt
with this patch applied would result in incompatible guest ABI (the
virtual CPU would lose intel-pt). However, QEMU changed its CPU models
unconditionally and thus migration would not work even without this
patch. That said, it is safe to follow QEMU and remove the feature from
Icelake-* CPU models in our cpu_map.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agoFix format network dns doc
Cédric Bosdonnat [Mon, 25 Jan 2021 13:56:01 +0000 (14:56 +0100)]
Fix format network dns doc

The code block on the srv name in the formatnetwork page is confusing
since the actual parameter is service. Moving the code block to the
service work makes it better.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
4 years agogitlab: force dwarf4 format for debuginfo in Fedora rawhide
Daniel P. Berrangé [Mon, 25 Jan 2021 18:13:57 +0000 (18:13 +0000)]
gitlab: force dwarf4 format for debuginfo in Fedora rawhide

Fedora 34 rawhide has pulled in a new GCC 11 build which now
defaults to dwarf5 format. This format is not compatible with
the pdwtags program used in our test suite to validate the
RPC files.

We have no need for debuginfo in CI except for pdwtags,
so the simplest short term fix is to force the older dwarf
version in the hope that a fixed dwarves release will
arrive before Fedora 34 is released, or GCC 11 becomes more
widespread. Eventually we might need to figure out a way to
probe for compatibility but for now, we'll hope that any
distro with GCC 11 will be able to have a fixed dwarves too.

https://bugzilla.redhat.com/show_bug.cgi?id=1919965
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoci: Refresh dockerfiles
Andrea Bolognani [Wed, 20 Jan 2021 16:28:03 +0000 (17:28 +0100)]
ci: Refresh dockerfiles

dtrace is now also installed when cross-building.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomeson: Fix cross-building of dtrace probes
Helmut Grohne [Mon, 18 Jan 2021 23:08:23 +0000 (00:08 +0100)]
meson: Fix cross-building of dtrace probes

dtrace invokes the C compiler, so when cross-building we need
to make sure that $CC is set in the environment and that it
points to the cross-compiler rather than the native one.

Until https://github.com/mesonbuild/meson/issues/266
is addressed, the workaround is to call dtrace via env(1).

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980334

Signed-off-by: Helmut Grohne <helmut@subdivi.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: Add phys_port_name support on virPCIGetNetName
Dmytro Linkin [Thu, 21 Jan 2021 12:15:22 +0000 (14:15 +0200)]
util: Add phys_port_name support on virPCIGetNetName

virPCIGetNetName is used to get the name of the netdev associated with
a particular PCI device. This is used when we have a VF name, but need
the PF name in order to send a netlink command (e.g. in order to
get/set the MAC address of the VF).

In simple cases there is a single netdev associated with any PCI
device, so it is easy to figure out the PF netdev for a VF - just look
for the PCI device that has the VF listed in its "virtfns" directory;
the only name in the "net" subdirectory of that PCI device's sysfs
directory is the PF netdev that is upstream of the VF in question.

In some cases there can be more than one netdev in a PCI device's net
directory though. In the past, the only case of this was for SR-IOV
NICs that could have multiple PF's per PCI device. In this case, all
PF netdevs associated with a PCI address would be listed in the "net"
subdirectory of the PCI device's directory in sysfs. At the same time,
all VF netdevs and all PF netdevs have a phys_port_id in their sysfs,
so the way to learn the correct PF netdev for a particular VF netdev
is to search through the list of devices in the net subdirectory of
the PF's PCI device, looking for the one netdev with a "phys_port_id"
matching that of the VF netdev.

But starting in kernel 5.8, the NVIDIA Mellanox driver began linking
the VFs' representor netdevs to the PF PCI address [1], and so the VF
representor netdevs would also show up in the net
subdirectory. However, all of the devices that do so also only have a
single PF netdev for any given PCI address.

This means that the net directory of the PCI device can still hold
multiple net devices, but only one of them will be the PF netdev (the
others are VF representors):

$ ls '/sys/bus/pci/devices/0000:82:00.0/net'
ens1f0  eth0  eth1

In this case the way to find the PF device is to look at the
"phys_port_name" attribute of each netdev in sysfs. All PF devices
have a phys_port_name matching a particular regex

  (p[0-9]+$)|(p[0-9]+s[0-9]+$)

Since there can only be one PF in the entire list of devices, once we
match that regex, we've found the PF netdev.

[1] - https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
      commit/?id=123f0f53dd64b67e34142485fe866a8a581f12f1

Co-Authored-by: Moshe Levi <moshele@nvidia.com>
Signed-off-by: Dmytro Linkin <dlinkin@nvidia.com>
Reviewed-by: Adrian Chiris <adrianc@nvidia.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agoutil: add virNetDevGetPhysPortName
Moshe Levi [Thu, 21 Jan 2021 12:15:21 +0000 (14:15 +0200)]
util: add virNetDevGetPhysPortName

This commit add virNetDevGetPhysPortName to read netdevice
phys_port_name from sysfs. It also refactor the code so
virNetDevGetPhysPortName and virNetDevGetPhysPortID will use
same method to read the netdevice sysfs.

Signed-off-by: Moshe Levi <moshele@nvidia.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agodocs: formatdomain: Fix poll-control XML example
Cole Robinson [Sun, 24 Jan 2021 23:40:17 +0000 (18:40 -0500)]
docs: formatdomain: Fix poll-control XML example

Fixes: 3fc4412c6f5
Signed-off-by: Cole Robinson <crobinso@redhat.com>
4 years agospec: Increase meson test timeout 10x
Cole Robinson [Thu, 21 Jan 2021 21:54:45 +0000 (16:54 -0500)]
spec: Increase meson test timeout 10x

Tests time out when building in slow environments, like emulated
s390x in Fedora copr. Bump up the test timeout

Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
4 years agohyperv: use g_auto for WsXmlDocH in hypervDomainAttachCDROM
Matt Coleman [Thu, 21 Jan 2021 18:51:35 +0000 (13:51 -0500)]
hyperv: use g_auto for WsXmlDocH in hypervDomainAttachCDROM

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use g_auto for WsXmlDocH in hypervDomainAttachVirtualDisk
Matt Coleman [Thu, 21 Jan 2021 18:51:34 +0000 (13:51 -0500)]
hyperv: use g_auto for WsXmlDocH in hypervDomainAttachVirtualDisk

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use GLib auto-cleanup in hypervCreateInvokeXmlDoc
Matt Coleman [Thu, 21 Jan 2021 18:51:33 +0000 (13:51 -0500)]
hyperv: use GLib auto-cleanup in hypervCreateInvokeXmlDoc

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use GLib auto-cleanup in hypervSerializeEmbeddedParam
Matt Coleman [Thu, 21 Jan 2021 18:51:32 +0000 (13:51 -0500)]
hyperv: use GLib auto-cleanup in hypervSerializeEmbeddedParam

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use GLib auto-cleanup in hypervEnumAndPull
Matt Coleman [Thu, 21 Jan 2021 18:51:31 +0000 (13:51 -0500)]
hyperv: use GLib auto-cleanup in hypervEnumAndPull

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use GLib auto-cleanup in hypervSerializeEprParam
Matt Coleman [Thu, 21 Jan 2021 18:51:30 +0000 (13:51 -0500)]
hyperv: use GLib auto-cleanup in hypervSerializeEprParam

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use g_autoptr for WMI classes in hypervDomainAttachDeviceFlags
Matt Coleman [Thu, 21 Jan 2021 18:51:29 +0000 (13:51 -0500)]
hyperv: use g_autoptr for WMI classes in hypervDomainAttachDeviceFlags

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use GLib auto-cleanup in hypervDomainGetXMLDesc
Matt Coleman [Thu, 21 Jan 2021 18:51:28 +0000 (13:51 -0500)]
hyperv: use GLib auto-cleanup in hypervDomainGetXMLDesc

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use g_autoptr for Win32_OperatingSystem in hypervNodeGetFreeMemory
Matt Coleman [Thu, 21 Jan 2021 18:51:27 +0000 (13:51 -0500)]
hyperv: use g_autoptr for Win32_OperatingSystem in hypervNodeGetFreeMemory

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use g_autoptr for Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor...
Matt Coleman [Thu, 21 Jan 2021 18:51:26 +0000 (13:51 -0500)]
hyperv: use g_autoptr for Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor in hypervDomainGetVcpus

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use GLib auto-cleanup in hypervMsvmVSMSAddResourceSettings and hypervMsvmVSMS...
Matt Coleman [Thu, 21 Jan 2021 18:51:25 +0000 (13:51 -0500)]
hyperv: use GLib auto-cleanup in hypervMsvmVSMSAddResourceSettings and hypervMsvmVSMSModifyResourceSettings

Fixes a memory leak when hypervCreateInvokeParamsList() fails.

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use GLib auto-cleanup in hypervInvokeMsvmComputerSystemRequestStateChange
Matt Coleman [Thu, 21 Jan 2021 18:51:24 +0000 (13:51 -0500)]
hyperv: use GLib auto-cleanup in hypervInvokeMsvmComputerSystemRequestStateChange

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use GLib auto-cleanup in hypervInvokeMethod
Matt Coleman [Thu, 21 Jan 2021 18:51:23 +0000 (13:51 -0500)]
hyperv: use GLib auto-cleanup in hypervInvokeMethod

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use GLib auto-cleanup in hypervDomainSendKey
Matt Coleman [Thu, 21 Jan 2021 18:51:22 +0000 (13:51 -0500)]
hyperv: use GLib auto-cleanup in hypervDomainSendKey

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use g_autoptr for Msvm_ComputerSystem in hypervConnectListAllDomains
Matt Coleman [Thu, 21 Jan 2021 18:51:21 +0000 (13:51 -0500)]
hyperv: use g_autoptr for Msvm_ComputerSystem in hypervConnectListAllDomains

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainManagedSaveRemove
Matt Coleman [Thu, 21 Jan 2021 18:51:20 +0000 (13:51 -0500)]
hyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainManagedSaveRemove

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainHasManagedSaveImage
Matt Coleman [Thu, 21 Jan 2021 18:51:19 +0000 (13:51 -0500)]
hyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainHasManagedSaveImage

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainManagedSave
Matt Coleman [Thu, 21 Jan 2021 18:51:18 +0000 (13:51 -0500)]
hyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainManagedSave

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainIsActive
Matt Coleman [Thu, 21 Jan 2021 18:51:17 +0000 (13:51 -0500)]
hyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainIsActive

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use g_autoptr for WMI classes in hypervDomainGetSchedulerParametersFlags
Matt Coleman [Thu, 21 Jan 2021 18:51:16 +0000 (13:51 -0500)]
hyperv: use g_autoptr for WMI classes in hypervDomainGetSchedulerParametersFlags

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use g_autoptr for Msvm_VirtualSystemSettingData in hypervDomainSetAutostart
Matt Coleman [Thu, 21 Jan 2021 18:51:15 +0000 (13:51 -0500)]
hyperv: use g_autoptr for Msvm_VirtualSystemSettingData in hypervDomainSetAutostart

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use g_autoptr for Msvm_VirtualSystemSettingData in hypervDomainGetAutostart
Matt Coleman [Thu, 21 Jan 2021 18:51:14 +0000 (13:51 -0500)]
hyperv: use g_autoptr for Msvm_VirtualSystemSettingData in hypervDomainGetAutostart

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agohyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainCreateWithFlags
Matt Coleman [Thu, 21 Jan 2021 18:51:13 +0000 (13:51 -0500)]
hyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainCreateWithFlags

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>