]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agoqemuxml2xmltest: Remove 'WITH_QEMU' conditional
Peter Krempa [Mon, 5 Oct 2020 15:52:29 +0000 (17:52 +0200)]
qemuxml2xmltest: Remove 'WITH_QEMU' conditional

The test is compiled only when the qemu driver is enabled so we don't
need the conditional code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsh: Allow listing just domain IDs
Michal Privoznik [Mon, 13 May 2019 08:04:27 +0000 (10:04 +0200)]
virsh: Allow listing just domain IDs

Some completers for libvirt related tools might want to list
domain IDs only. Just like the one I've implemented for
virt-viewer [1]. I've worked around it using some awk magic,
but if it was possible to just 'virsh list --id' then I could
drop awk.

1: https://www.redhat.com/archives/virt-tools-list/2019-May/msg00014.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sun, 8 Nov 2020 18:35:48 +0000 (19:35 +0100)]
Translated using Weblate (Swedish)

Currently translated at 6.1% (637 of 10399 strings)

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

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
4 years agovirGDBusBusInit: Properly check for error when looking up D-Bus address
Michal Privoznik [Fri, 6 Nov 2020 12:47:19 +0000 (13:47 +0100)]
virGDBusBusInit: Properly check for error when looking up D-Bus address

The virGDBusBusInit is supposed to return a reference to
requested bus type (system/session) or, if non-shared bus is
requested then create a new bus of the type. As an argument, it
gets a double pointer to GError which is passed to all g_dbus_*()
calls which allocate it on failure. Pretty standard approach.
However, since it is a double pointer we must dereference the
first level to see if the value is NULL. IOW:

  if (*error)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemu: fix qemuMigrationSrcCleanup to use qemuMigrationJobFinish
Nikolay Shirokovskiy [Tue, 18 Aug 2020 08:01:40 +0000 (11:01 +0300)]
qemu: fix qemuMigrationSrcCleanup to use qemuMigrationJobFinish

qemuMigrationSrcCleanup uses qemuDomainObjDiscardAsyncJob currently. But
discard does not reduce jobs_queued counter so it leaks. Also discard does not
notify other threads that job condition is available. Discard does reset nested
job but nested job is not possible in this conditions.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoRevert "Revert "spec: Simplify setting features off by default""
Andrea Bolognani [Thu, 29 Oct 2020 10:00:37 +0000 (11:00 +0100)]
Revert "Revert "spec: Simplify setting features off by default""

As explained in the original commit (31d687a3218c), these values
are actually unaffected by the corresponding _without_* macros
and so we can leave out the additional processing / obfuscation.

This reverts commit ae23a87d85cfc2a964123d9bd44157a411428c0a.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
4 years agoutil: quieten virSCSIHostGetUniqueId
Ján Tomko [Wed, 4 Nov 2020 11:29:07 +0000 (12:29 +0100)]
util: quieten virSCSIHostGetUniqueId

The only caller of this function ignores failure
and just sets the unique_id to -1.

Failing to read the file is likely to the device no longer
being present, not a real error.

Stop reporting errors in this function.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoutil: use g_autofree in virSCSIHostGetUniqueId
Ján Tomko [Wed, 4 Nov 2020 11:08:19 +0000 (12:08 +0100)]
util: use g_autofree in virSCSIHostGetUniqueId

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoutil: xml: remove unused function virXMLChildElementCount
Yi Li [Thu, 5 Nov 2020 23:20:00 +0000 (07:20 +0800)]
util: xml: remove unused function virXMLChildElementCount

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: Remove 'virhashtest'
Peter Krempa [Fri, 23 Oct 2020 08:26:10 +0000 (10:26 +0200)]
tests: Remove 'virhashtest'

There's no much sense to test the remnants of the functions which just
NULL-check prior to handing off to g_hash_table* functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agoutil: hash: Add deprecation notices for functions which have g_hash_table replacements
Peter Krempa [Mon, 26 Oct 2020 15:24:28 +0000 (16:24 +0100)]
util: hash: Add deprecation notices for functions which have g_hash_table replacements

For functions which have reasonable replacement, let's encourage usage
of g_hash_table_ alternatives.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agoutil: hash: Retire 'virHashTable' in favor of 'GHashTable'
Peter Krempa [Thu, 22 Oct 2020 17:04:18 +0000 (19:04 +0200)]
util: hash: Retire 'virHashTable' in favor of 'GHashTable'

Don't hide our use of GHashTable behind our typedef. This will also
promote the use of glibs hash function directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agoutil: hash: Reimplement virHashTable using GHashTable
Peter Krempa [Thu, 22 Oct 2020 09:14:00 +0000 (11:14 +0200)]
util: hash: Reimplement virHashTable using GHashTable

Glib's hash table provides basically the same functionality as our hash
table.

In most cases the only thing that remains in the virHash* wrappers is
NULL-checks of '@table' argument as glib's hash functions don't tolerate
NULL.

In case of iterators, we adapt the existing API of iterators to glibs to
prevent having rewrite all callers at this point.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agoutil: hash: Don't use 'const' with virHashTablePtr
Peter Krempa [Thu, 22 Oct 2020 09:11:57 +0000 (11:11 +0200)]
util: hash: Don't use 'const' with virHashTablePtr

We didn't use it rigorously and some helpers even cast it away. Remove
const from all hash utility functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agoutil: hash: Use virHashForEachSafe in places which might delete the element
Peter Krempa [Fri, 23 Oct 2020 07:49:36 +0000 (09:49 +0200)]
util: hash: Use virHashForEachSafe in places which might delete the element

Convert all calls to virHashForEach where it's not obvious that the
callback is _not_ deleting the current element from the hash to
virHashForEachSafe which will be deemed safe to do such operation.

Now that no iterator used with virHashForEach deletes current element we
can document that virHashForEach must not touch the hash table in any
way.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agoutil: hash: Add delete-safe hash iterator
Peter Krempa [Mon, 26 Oct 2020 14:30:10 +0000 (15:30 +0100)]
util: hash: Add delete-safe hash iterator

'virHashForEach' historically allowed deletion of the current element as
'virHashRemoveSet' didn't exist. To prevent us from having to deeply
analyse all iterators add virHashForEachSafe which first gets a list of
elements and iterates them outside of the hash table.

This will allow replace the internals of the hash table with other
implementation which don't allow such operation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agotests: remove virdeterministichashmock.so
Peter Krempa [Wed, 21 Oct 2020 14:53:26 +0000 (16:53 +0200)]
tests: remove virdeterministichashmock.so

Code which is sensitive to ordering now uses deterministic iterator
functions, so we can remove the mock override.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agoUse virHashForEachSorted in tested code
Peter Krempa [Fri, 23 Oct 2020 07:07:02 +0000 (09:07 +0200)]
Use virHashForEachSorted in tested code

The simplest way to write tests is to check the output against expected
output, but we must ensure that the output is stable. We can use
virHashForEachSorted as a hash iterator to ensure stable ordering.

This patch fixes 3 instances of hash iteration which is tested in
various parts, including test output changes in appropriate places.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agoutil: hash: Introduce virHashForEachSorted
Peter Krempa [Mon, 26 Oct 2020 14:28:08 +0000 (15:28 +0100)]
util: hash: Introduce virHashForEachSorted

Iterate the hash elements sorted by key. This is useful to provide a
stable ordering such as in cases when the output is checked in tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agoutil: hash: Rewrite sorting of elements in virHashGetItems
Peter Krempa [Thu, 22 Oct 2020 15:38:53 +0000 (17:38 +0200)]
util: hash: Rewrite sorting of elements in virHashGetItems

All but one of the callers either use the list in arbitrary order or
sorted by key. Rewrite the function so that it supports sorting by key
natively and make it return the element count. This in turn allows to
rewrite the only caller to sort by value internally.

This allows to remove multiple sorting functions which were sorting by
key and the function will be also later reused for some hash operations
internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agovirhashtest: testHashGetItems: Remove test case for sorting by value
Peter Krempa [Thu, 22 Oct 2020 15:41:26 +0000 (17:41 +0200)]
virhashtest: testHashGetItems: Remove test case for sorting by value

Upcoming patch will rewrite virHashGetItems to remove the sorting
function since the prevalent mode is to order by keys.

Remove the test for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agoqemu_conf: Don't even attempt to enable rememberOwner if unsupported
Michal Privoznik [Tue, 3 Nov 2020 12:26:22 +0000 (13:26 +0100)]
qemu_conf: Don't even attempt to enable rememberOwner if unsupported

The remember owner feature uses XATTRs to store original
seclabels. But that means we don't want a regular user to be able
to change what we stored and thus trick us into setting different
seclabel. Therefore, we use namespaces that are reserved to
CAP_SYS_ADMIN only. Such namespaces exist on Linux and FreeBSD.
That also means, that the whole feature is enabled only for
qemu:///system. Now, while the secdriver code is capable of
dealing with XATTRs being unsupported (it has to, not all
filesystems support them) if the feature is enabled users will
get an harmless error message in the logs and the feature
disables itself.

Since we have virSecurityXATTRNamespaceDefined() we can use it to
make a wiser decision on the default state of the feature.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoqemusecuritytest: Skip on non supported platforms
Michal Privoznik [Tue, 3 Nov 2020 12:26:00 +0000 (13:26 +0100)]
qemusecuritytest: Skip on non supported platforms

For seclabel remembering we need to have XATTRs and a special
namespace that is accessibly to CAP_SYS_ADMIN only (we don't want
regular users to trick us into restoring to a different label).
And what qemusecuritytest does is it checks whether we have not
left any path behind with XATTRs or not restored to original
seclabel after setAll + restoreAll round trip. But it can hardly
do so if ran on a platform where there's no XATTR namespace we
can use.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoqemusecuritytest: Test SELinux too
Michal Privoznik [Mon, 2 Nov 2020 21:31:03 +0000 (22:31 +0100)]
qemusecuritytest: Test SELinux too

The qemusecuritytest checks for random domain XMLs from
qemuxml2argvdata/ whether set+restore seclabels leaves something
behind. It can be an XATTR that we forgot to remove or a file
that the owner was not restored on. But so far only DAC driver is
checked. Implement missing pieces and enable SELinux testing too.

This is done by mocking some libselinux APIs and following the
same logic used for DAC - everything is implemented in memory,
there is new hash table introduced that holds SELinux labels for
paths that were setfilecon_raw()-ed and in the end the hash table
is checked for entries that don't have the default SELinux label
(i.e. were not restored).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agosecurity_util: Don't error on macOS when getting/setting/moving XATTRs
Michal Privoznik [Mon, 2 Nov 2020 20:40:18 +0000 (21:40 +0100)]
security_util: Don't error on macOS when getting/setting/moving XATTRs

There are three internal APIs implemented in this security_util
file: virSecurityGetRememberedLabel(),
virSecuritySetRememberedLabel() and
virSecurityMoveRememberedLabel() for getting, setting and moving
remembered seclabel. All three have a special return value of -2
when XATTRs are not supported (for whatever reason) and callers
are expected to handle it gracefully. However, after my commit of
v5.7.0-rc1~115 it may happen that one of the three functions
returned -1 even though XATTRs are not supported (and thus -2
should have been returned).

Fixes: 7cfb7aab573a031880a1f4fd20747843fea109ba
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agovircgrouppriv: fix ATTRIBUTE_NONNULL for virCgroupNewDomainPartition
Pavel Hrdina [Thu, 5 Nov 2020 22:15:16 +0000 (23:15 +0100)]
vircgrouppriv: fix ATTRIBUTE_NONNULL for virCgroupNewDomainPartition

Commit <99d2c6519ad18651b5959fa0a3366bcb2c1e44f3> removed parameter
from the function but did not modified ATTRIBUTE_NONNULL.

Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
4 years agocpu_map: Add script to sync from QEMU i386 cpu models
Tim Wiederhake [Wed, 4 Nov 2020 10:53:50 +0000 (11:53 +0100)]
cpu_map: Add script to sync from QEMU i386 cpu models

This script is intended to help in synchronizing i386 QEMU cpu model
definitions with libvirt.

As the QEMU cpu model definitions are post processed by QEMU and not
meant to be consumed by third parties directly, parsing this
information is imperfect. Additionally, the libvirt models contain
information that cannot be generated from the QEMU data, preventing
fully automated usage. The output should nevertheless be helpful for
a human in determining potentially interesting changes.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agodomain_conf: make virDomainDiskSetSource() void
Matt Coleman [Thu, 5 Nov 2020 06:23:41 +0000 (01:23 -0500)]
domain_conf: make virDomainDiskSetSource() void

The function only returns zero or aborts, so it might as well be void.
This has the added benefit of simplifying the code that calls it.

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsh-domain: Remove unused virshNodeIsSuperset
Yi Li [Thu, 5 Nov 2020 08:37:46 +0000 (16:37 +0800)]
virsh-domain: Remove unused virshNodeIsSuperset

The function is marked as unused. Remove it from the tree
until a new use case can be found.
Unused since: 38cc07b7bc76d3ffdf55deb65f4acf11c0fa9014

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoremote: Add libvirtd dependency to virt-guest-shutdown.target
Jim Fehlig [Wed, 4 Nov 2020 02:14:39 +0000 (19:14 -0700)]
remote: Add libvirtd dependency to virt-guest-shutdown.target

When restarting libvirt services and sockets *and* libvirt-guests.service
is running, the latter will sometimes hang when trying to connect to
libvirtd. Even though libvirt-guests has 'Wants=libvirtd.service' and
'After=libvirtd.service', we can see via journalctl that it is not
shutdown before libvirtd when executing something like

systemctl try-restart libvirtd.service libvirtd.socket \
libvirtd-ro.socket virtlockd.service virtlockd.socket \
virtlogd.service virtlogd.socket virt-guest-shutdown.target

Oct 28 15:53:31 systemd[1]: Stopping Virtualization daemon...
Oct 28 15:53:31 systemd[1]: libvirtd.service: Succeeded.
Oct 28 15:53:31 systemd[1]: Stopped Virtualization daemon.
Oct 28 15:53:31 systemd[1]: libvirtd-admin.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Libvirt admin socket.
Oct 28 15:53:31 systemd[1]: Stopping Libvirt admin socket.
Oct 28 15:53:31 systemd[1]: libvirtd-ro.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Libvirt local read-only socket.
Oct 28 15:53:31 systemd[1]: Stopping Libvirt local read-only socket.
Oct 28 15:53:31 systemd[1]: libvirtd.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Libvirt local socket.
Oct 28 15:53:31 systemd[1]: Stopping Libvirt local socket.
Oct 28 15:53:31 systemd[1]: Listening on Libvirt local socket.
Oct 28 15:53:31 systemd[1]: Listening on Libvirt admin socket.
Oct 28 15:53:31 systemd[1]: Listening on Libvirt local read-only socket.
Oct 28 15:53:31 systemd[1]: virtlockd.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Virtual machine lock manager socket.
Oct 28 15:53:31 systemd[1]: Stopping Virtual machine lock manager socket.
Oct 28 15:53:31 systemd[1]: Listening on Virtual machine lock manager socket.
Oct 28 15:53:31 systemd[1]: virtlogd.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Virtual machine log manager socket.
Oct 28 15:53:31 systemd[1]: Stopping Virtual machine log manager socket.
Oct 28 15:53:31 systemd[1]: Listening on Virtual machine log manager socket.
Oct 28 15:53:31 systemd[1]: Stopping Suspend/Resume Running libvirt Guests...

In this case, the try-restart command hung and libvirt-guests was stuck
trying to connect to libvirtd. In the following case, the try-restart
worked since libvirtd was started again before libvirt-guests was stopped!

Oct 28 15:19:02  systemd[1]: Stopping Virtualization daemon...
Oct 28 15:19:02  systemd[1]: Stopped Virtualization daemon.
Oct 28 15:19:02  systemd[1]: Closed Libvirt admin socket.
Oct 28 15:19:02  systemd[1]: Stopping Libvirt admin socket.
Oct 28 15:19:02  systemd[1]: Closed Virtual machine lock manager socket.
Oct 28 15:19:02  systemd[1]: Stopping Virtual machine lock manager socket.
Oct 28 15:19:02  systemd[1]: Listening on Virtual machine lock manager socket.
Oct 28 15:19:02  systemd[1]: Closed Libvirt local read-only socket.
Oct 28 15:19:02  systemd[1]: Stopping Libvirt local read-only socket.
Oct 28 15:19:02  systemd[1]: Closed Libvirt local socket.
Oct 28 15:19:02  systemd[1]: Stopping Libvirt local socket.
Oct 28 15:19:02  systemd[1]: Listening on Libvirt local socket.
Oct 28 15:19:02  systemd[1]: Listening on Libvirt admin socket.
Oct 28 15:19:02  systemd[1]: Listening on Libvirt local read-only socket.
Oct 28 15:19:02  systemd[1]: Closed Virtual machine log manager socket.
Oct 28 15:19:02  systemd[1]: Stopping Virtual machine log manager socket.
Oct 28 15:19:02  systemd[1]: Listening on Virtual machine log manager socket.
Oct 28 15:19:02  systemd[1]: Starting Virtualization daemon...
Oct 28 15:19:02  systemd[1]: Stopping Suspend/Resume Running libvirt Guests...
Oct 28 15:19:02  systemd[1]: Started Virtualization daemon.
Oct 28 15:19:02  libvirt-guests.sh[4912]: Running guests on default URI: no running guests.
Oct 28 15:19:02  systemd[1]: Stopped Suspend/Resume Running libvirt Guests.
Oct 28 15:19:02  systemd[1]: Stopped target Libvirt guests shutdown.
Oct 28 15:19:02  systemd[1]: Stopping Libvirt guests shutdown.
Oct 28 15:19:02  systemd[1]: Reached target Libvirt guests shutdown.
Oct 28 15:19:02  systemd[1]: Starting Suspend/Resume Running libvirt Guests...
Oct 28 15:19:02  systemd[1]: Started Suspend/Resume Running libvirt Guests.

Adding 'Requires=libvirtd.service' to virt-guest-shutdown.target results
in expected behavior

Oct 28 15:40:00  systemd[1]: Stopping Suspend/Resume Running libvirt Guests...
Oct 28 15:40:00  libvirt-guests.sh[5245]: Running guests on default URI: no running guests.
Oct 28 15:40:00  systemd[1]: Stopped Suspend/Resume Running libvirt Guests.
Oct 28 15:40:00  systemd[1]: Stopped target Libvirt guests shutdown.
Oct 28 15:40:00  systemd[1]: Stopping Libvirt guests shutdown.
Oct 28 15:40:00  systemd[1]: Stopping Virtualization daemon...
Oct 28 15:40:00  systemd[1]: Stopped Virtualization daemon.
Oct 28 15:40:00  systemd[1]: Closed Virtual machine log manager socket.
Oct 28 15:40:00  systemd[1]: Stopping Virtual machine log manager socket.
Oct 28 15:40:00  systemd[1]: Listening on Virtual machine log manager socket.
Oct 28 15:40:00  systemd[1]: Closed Libvirt admin socket.
Oct 28 15:40:00  systemd[1]: Stopping Libvirt admin socket.
Oct 28 15:40:00  systemd[1]: Closed Libvirt local read-only socket.
Oct 28 15:40:00  systemd[1]: Stopping Libvirt local read-only socket.
Oct 28 15:40:00  systemd[1]: Closed Libvirt local socket.
Oct 28 15:40:00  systemd[1]: Stopping Libvirt local socket.
Oct 28 15:40:00  systemd[1]: Listening on Libvirt local socket.
Oct 28 15:40:00  systemd[1]: Listening on Libvirt admin socket.
Oct 28 15:40:00  systemd[1]: Listening on Libvirt local read-only socket.
Oct 28 15:40:00  systemd[1]: Closed Virtual machine lock manager socket.
Oct 28 15:40:00  systemd[1]: Stopping Virtual machine lock manager socket.
Oct 28 15:40:00  systemd[1]: Listening on Virtual machine lock manager socket.
Oct 28 15:40:00  systemd[1]: Starting Virtualization daemon...
Oct 28 15:40:00  systemd[1]: Started Virtualization daemon.
Oct 28 15:40:00  systemd[1]: Reached target Libvirt guests shutdown.
Oct 28 15:40:00  systemd[1]: Starting Suspend/Resume Running libvirt Guests...
Oct 28 15:40:00  systemd[1]: Started Suspend/Resume Running libvirt Guests.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
4 years agoconf: node_device: cleanup virNodeDevCapCCWParseXML
Boris Fiuczynski [Fri, 23 Oct 2020 17:31:51 +0000 (19:31 +0200)]
conf: node_device: cleanup virNodeDevCapCCWParseXML

Make use of g_autofree

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoschema: refactor mdev_types out of PCI nodedev schema
Boris Fiuczynski [Fri, 23 Oct 2020 17:31:50 +0000 (19:31 +0200)]
schema: refactor mdev_types out of PCI nodedev schema

Refactor mdev_types into standalone define for later reuse.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoconf: node_device: refactor CSS formatting
Boris Fiuczynski [Fri, 23 Oct 2020 17:31:49 +0000 (19:31 +0200)]
conf: node_device: refactor CSS formatting

Move XML formatting code into a new method.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoconf: node_device: refactor mdev_types XML parsing
Boris Fiuczynski [Fri, 23 Oct 2020 17:31:48 +0000 (19:31 +0200)]
conf: node_device: refactor mdev_types XML parsing

Extract PCI code from virNodeDevPCICapMdevTypesParseXML to make
method virNodeDevCapMdevTypesParseXML generic for later reuse.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoconf: node_device: refactor capability mdev_types formatting
Boris Fiuczynski [Fri, 23 Oct 2020 17:31:47 +0000 (19:31 +0200)]
conf: node_device: refactor capability mdev_types formatting

Extract the XML formatting for mdev_types from PCI capability into
a generic standalone method for later reuse.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoconf: node_device: refactor GetPCIMdevTypesCaps into GetMdevTypeCapes
Boris Fiuczynski [Fri, 23 Oct 2020 17:31:46 +0000 (19:31 +0200)]
conf: node_device: refactor GetPCIMdevTypesCaps into GetMdevTypeCapes

Extracting PCI from virNodeDeviceGetPCIMdevTypesCaps creating
virNodeDeviceGetMdevTypesCaps to make later reuse possible.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: refactor mdev_types methods return code usage
Boris Fiuczynski [Fri, 23 Oct 2020 17:31:45 +0000 (19:31 +0200)]
util: refactor mdev_types methods return code usage

Remove mix of array length and error code in the return code.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: refactor mdev_types method from PCI to mdev
Boris Fiuczynski [Fri, 23 Oct 2020 17:31:44 +0000 (19:31 +0200)]
util: refactor mdev_types method from PCI to mdev

Extract virPCIGetMdevTypes from PCI as virMediatedDeviceGetMdevTypes
into mdev for later reuse.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoconf: node_device: fix mdev_types format and XML parsing code to match schema
Boris Fiuczynski [Fri, 23 Oct 2020 17:31:43 +0000 (19:31 +0200)]
conf: node_device: fix mdev_types format and XML parsing code to match schema

The nodedev schema defines that a mdev_types capability must have
one or more type elements. The XML parsing and the format allows to
accept and to write mdev_types capability without any type element.
This patches fixes this.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: add docs for 'fmode' and 'dmode' options
Brian Turek [Thu, 8 Oct 2020 14:32:26 +0000 (15:32 +0100)]
qemu: add docs for 'fmode' and 'dmode' options

Adds documentation for QEMU 9pfs 'fmode' and 'dmode' options.

Signed-off-by: Brian Turek <brian.turek@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: add support for 'fmode' and 'dmode'
Brian Turek [Thu, 8 Oct 2020 14:32:25 +0000 (15:32 +0100)]
qemu: add support for 'fmode' and 'dmode'

Add logic to validate and then pass through 'fmode' and 'dmode' to the
QEMU call.

Signed-off-by: Brian Turek <brian.turek@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: add 'fmode' and 'dmode' options
Brian Turek [Thu, 8 Oct 2020 14:32:24 +0000 (15:32 +0100)]
qemu: add 'fmode' and 'dmode' options

Expose QEMU's 9pfs 'fmode' and 'dmode' options via attributes on the
'filesystem' node in the domain XML. These options control the creation
mode of files and directories, respectively, when using
accessmode=mapped.

Signed-off-by: Brian Turek <brian.turek@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: capabilities: add QEMU_CAPS_FSDEV_CREATEMODE
Brian Turek [Thu, 8 Oct 2020 14:32:23 +0000 (15:32 +0100)]
qemu: capabilities: add QEMU_CAPS_FSDEV_CREATEMODE

The QEMU 9pfs 'fmode' and 'dmode' options have existed since QEMU 2.10.
Probe QEMU's command line set to check whether these options are
available, and if yes, enable this new QEMU_CAPS_FSDEV_CREATEMODE
capability on libvirt side.

Signed-off-by: Brian Turek <brian.turek@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agodoc: document new filters and not documented ones
Aleksandr Alekseev [Thu, 22 Oct 2020 18:15:52 +0000 (21:15 +0300)]
doc: document new filters and not documented ones

Signed-off-by: Aleksandr Alekseev <alexander.alekseev@virtuozzo.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoexample: add ipv6 filters examples
Aleksandr Alekseev [Thu, 22 Oct 2020 18:15:51 +0000 (21:15 +0300)]
example: add ipv6 filters examples

Signed-off-by: Aleksandr Alekseev <alexander.alekseev@virtuozzo.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoexample: fix typo and formatting
Aleksandr Alekseev [Thu, 22 Oct 2020 18:15:50 +0000 (21:15 +0300)]
example: fix typo and formatting

Signed-off-by: Aleksandr Alekseev <alexander.alekseev@virtuozzo.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agocpu_ppc64: compare CPU function is ignoring return value
Julio Faracco [Tue, 27 Oct 2020 16:04:24 +0000 (13:04 -0300)]
cpu_ppc64: compare CPU function is ignoring return value

Function to compare CPU on 64-bits PowerPC is ignoring the flag to avoid failure
in case of CPUs (host and guest) are incompatible. Basically, the function is
returning -1 even if it is set to continue.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agolibvirt-guests: Sync time for autostarted guests
Orion Poplawski [Wed, 28 Oct 2020 13:59:35 +0000 (14:59 +0100)]
libvirt-guests: Sync time for autostarted guests

Setting SYNC_TIME=1 does not work on autostarted guests.

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

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agostoragepoolxml2argvtest: Reorder gluster arguments
Roman Bolshakov [Tue, 3 Nov 2020 14:26:30 +0000 (17:26 +0300)]
storagepoolxml2argvtest: Reorder gluster arguments

Commit f00cde7f1133 changed order of mount arguments in
virStorageBackendFileSystemMountGlusterArgs() and introduced per-OS
mount options and new test data. Old test data was left unmodified with
prior order of arguments. That causes a test failure on all OSes but
Linux and FreeBSD, i.e. on macOS:

  15) Storage Pool XML-2-argv pool-netfs-gluster
      ...
  In
  '/Users/roolebo/dev/libvirt/tests/storagepoolxml2argvdata/pool-netfs-gluster.argv':
  Offset 39
  Expect [-o direct-io-mode=1 /mnt/gluster]
  Actual [/mnt/gluster -o direct-io-mode=1]

Fixes: f00cde7f1133 ("storage: Add default mount options for fs/netfs storage pools")
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agovirpcimock: Enable on macOS
Roman Bolshakov [Tue, 3 Nov 2020 14:26:29 +0000 (17:26 +0300)]
virpcimock: Enable on macOS

In general, it has little sense to use Linux pci mock on macOS but
virPCIDeviceAddressGetIOMMUGroupNum() is relying on the filesystem
layout mocked by virpcimock. And all tests that rely on correct
execution of virPCIDeviceAddressGetIOMMUGroupNum() fail.

The change fixes qemuhotplugtest, qemumemlocktest and qemuxml2xmltest.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agovirpcimock: Initialize real_close before using it
Roman Bolshakov [Tue, 3 Nov 2020 14:26:28 +0000 (17:26 +0300)]
virpcimock: Initialize real_close before using it

real_close() is not inialized by the first invocation of close(). That
causes an issue when the mock is used before others and a call of
real_close() results in a jump to NULL pointer.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agovircgroup: drop condition for absolute path from copyPlacement callbacks
Pavel Hrdina [Mon, 2 Nov 2020 22:06:19 +0000 (23:06 +0100)]
vircgroup: drop condition for absolute path from copyPlacement callbacks

Now that every caller to copyPlacement doesn't pass absolute path there
is no need to have a condition to handle that case.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: refactor virCgroupNewPartition
Pavel Hrdina [Mon, 2 Nov 2020 21:50:58 +0000 (22:50 +0100)]
vircgroup: refactor virCgroupNewPartition

The old code passed an absolute path to virCgroupNewFromParent() which
is not necessary. The code can take the current placement of parent
cgroup and append a relative path.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: move parentPath declaration
Pavel Hrdina [Mon, 2 Nov 2020 21:11:36 +0000 (22:11 +0100)]
vircgroup: move parentPath declaration

It's used only inside the if condition.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: refactor virCgroupEnableMissingControllers
Pavel Hrdina [Mon, 2 Nov 2020 15:05:07 +0000 (16:05 +0100)]
vircgroup: refactor virCgroupEnableMissingControllers

Use virStringSplit() to get the list of directories needed to be
created. This improves readability of the code and stops passing
absolute path to virCgroupNewFromParent().

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: drop @create from virCgroupNewDomainPartition
Pavel Hrdina [Wed, 21 Oct 2020 23:43:57 +0000 (01:43 +0200)]
vircgroup: drop @create from virCgroupNewDomainPartition

All callers pass true.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: introduce virCgroupSetPlacement
Pavel Hrdina [Wed, 21 Oct 2020 12:35:48 +0000 (14:35 +0200)]
vircgroup: introduce virCgroupSetPlacement

Currently this task is done by virCgroupCopyPlacement when the @path
starts with "/".

virCgroupNew is always called with @path starting with "/" and there is
no parent to copy path from. To make it obvious what the code is doing
introduce new helper.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: drop @pid argument from virCgroupNew
Pavel Hrdina [Thu, 15 Oct 2020 15:05:17 +0000 (17:05 +0200)]
vircgroup: drop @pid argument from virCgroupNew

Now it is always -1.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: no need to use PID in virCgroupEnableMissingControllers
Pavel Hrdina [Thu, 15 Oct 2020 14:59:03 +0000 (16:59 +0200)]
vircgroup: no need to use PID in virCgroupEnableMissingControllers

This function is relevant only with cgroups v1 where it creates
hierarchy for controllers that are not managed by systemd. PID is used
to detect a placement of current process but in this situation we are
building the hierarchy for already known placement.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: expand virCgroupDetect into virCgroupNew
Pavel Hrdina [Thu, 15 Oct 2020 11:11:28 +0000 (13:11 +0200)]
vircgroup: expand virCgroupDetect into virCgroupNew

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: virCgroupNew is now always called with absolute path
Pavel Hrdina [Thu, 15 Oct 2020 10:36:40 +0000 (12:36 +0200)]
vircgroup: virCgroupNew is now always called with absolute path

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: drop @parent from virCgroupNew
Pavel Hrdina [Wed, 14 Oct 2020 15:01:02 +0000 (17:01 +0200)]
vircgroup: drop @parent from virCgroupNew

Now it is always NULL.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: introduce virCgroupNewParent
Pavel Hrdina [Tue, 3 Nov 2020 12:27:08 +0000 (13:27 +0100)]
vircgroup: introduce virCgroupNewParent

The current code uses virCgroupNew() as a single point of entry and
calls into virCgroupDetect() as well. Both have logic for several paths
which is difficult to figure out.

Extract the actually used code path from the two functions to make
it obvious what's happening in this case.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: extract virCgroupNewDetect from virCgroupNew
Pavel Hrdina [Wed, 14 Oct 2020 09:23:27 +0000 (11:23 +0200)]
vircgroup: extract virCgroupNewDetect from virCgroupNew

The current code uses virCgroupNew() as a single point of entry and
calls into virCgroupDetect() as well. Both have logic for several paths
which is difficult to figure out.

Extract the actually used code path from the two functions to make
it obvious what's happening in this case.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: introduce virCgroupDetectControllers helper
Pavel Hrdina [Wed, 14 Oct 2020 09:17:26 +0000 (11:17 +0200)]
vircgroup: introduce virCgroupDetectControllers helper

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: introduce virCgroupValidatePlacement helper
Pavel Hrdina [Wed, 14 Oct 2020 09:15:53 +0000 (11:15 +0200)]
vircgroup: introduce virCgroupValidatePlacement helper

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: introduce virCgroupCopyPlacement helper
Pavel Hrdina [Wed, 14 Oct 2020 09:14:34 +0000 (11:14 +0200)]
vircgroup: introduce virCgroupCopyPlacement helper

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: introduce virCgroupCopyMounts helper
Pavel Hrdina [Wed, 14 Oct 2020 09:12:46 +0000 (11:12 +0200)]
vircgroup: introduce virCgroupCopyMounts helper

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: introduce virCgroupSetBackends helper
Pavel Hrdina [Wed, 14 Oct 2020 09:08:21 +0000 (11:08 +0200)]
vircgroup: introduce virCgroupSetBackends helper

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: remove useless cgroup->path variable
Pavel Hrdina [Wed, 14 Oct 2020 08:29:45 +0000 (10:29 +0200)]
vircgroup: remove useless cgroup->path variable

It is only used for debug and error purposes which can be easily
replaced by @placement.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroupv2: detect controllers enabled in parent cgroup
Pavel Hrdina [Thu, 29 Oct 2020 15:05:20 +0000 (16:05 +0100)]
vircgroupv2: detect controllers enabled in parent cgroup

With cgroups v2 working with controllers is a bit more complicated then
with cgroups v1 where the controller had to be mounted.

There are two files, cgroups.controllers and cgroup.subtree_control.
The file cgroup.controllers lists all controllers enabled in the current
cgroup and cgroups.subtree_control, as the name suggest, controls which
controllers are enabled for a subtree of cgroups.

Now the issue here is that the current code doesn't make any difference
if the @parent variable is NULL or not because ../cgroup.subtree_control
will list the same controllers as ./cgroup.controllers.

The whole point of the @parent variable is when we are building the
cgroup topology ourselves without systemd help we need to detect which
controllers are enabled in the parent cgroup in order to enable them for
the current cgroup as well and for that we need to check
cgroup.controllers of the parent group.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroupv2: properly detect placement of running VM
Pavel Hrdina [Tue, 13 Oct 2020 11:29:43 +0000 (13:29 +0200)]
vircgroupv2: properly detect placement of running VM

When libvirtd starts a VM it internally stores a path to the main
cgroup. When we restart libvirtd we should get to the same state.

When we start a VM on host with systemd the cgroup is created for us and
the process is already placed into that cgroup and we detect the path
created by systemd using /proc/$PID/cgroup. After that we create
sub-cgroups and move all threads there.

Once libvirtd is restarted we again detect the cgroup path using
/proc/$PID/cgroup, but in this case we will get a different path because
the main thread was moved to a "emulator" cgroup.

Instead of ignoring the "emulator" directory when validating cgroups
remove it completely when detecting cgroup otherwise cgroups will not
work properly when libvirtd is restarted.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroupv2: properly detect empty tasks
Pavel Hrdina [Tue, 13 Oct 2020 11:25:22 +0000 (13:25 +0200)]
vircgroupv2: properly detect empty tasks

With cgroups v2 the file cgroup.procs will never be empty if threading
is enabled as it will always have ID of all processes even if all
threads of the processes are moved to sub-cgroups. If that happens the
file cgroup.threads will be empty.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu_dbus: use emulator cgroup for dbus-daemon
Pavel Hrdina [Wed, 28 Oct 2020 02:20:37 +0000 (03:20 +0100)]
qemu_dbus: use emulator cgroup for dbus-daemon

All other helper processes are moved to cgroup with QEMU emulator
thread as we keep the root VM cgroup without any processes. This
assumption is validated in qemuRestoreCgroupState() which is called
when libvirtd is restarted and reconnected to all running VMs.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: remove dead code that setup cgroups for helper processes
Pavel Hrdina [Wed, 28 Oct 2020 02:13:04 +0000 (03:13 +0100)]
qemu: remove dead code that setup cgroups for helper processes

In both cases priv->cgroup will always be NULL because it is called
before the QEMU process is started and cgroups are configured.

In qemuProcessLaunch() the call order is following:

    qemuExtDevicesStart()
    ...
    virCommandRun()
    ...
    qemuSetupCgroup()

where qemuDBusStart() is called from qemuExtDevicesStart() but we
cgroups are created in qemuSetupCgroup().

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu_cgroup: remove unused @empty variable
Pavel Hrdina [Tue, 13 Oct 2020 11:24:32 +0000 (13:24 +0200)]
qemu_cgroup: remove unused @empty variable

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu_map: Unify apostrophe and quotation mark usage
Tim Wiederhake [Mon, 19 Oct 2020 07:36:15 +0000 (09:36 +0200)]
cpu_map: Unify apostrophe and quotation mark usage

Usage was mixed.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agohyperv: call openwsman's ws_serializer_free_mem
Matt Coleman [Tue, 3 Nov 2020 00:22:08 +0000 (19:22 -0500)]
hyperv: call openwsman's ws_serializer_free_mem

This should have been included with the upgrade to openwsman 2.6.3.

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: minor formatting fix in hyperv_wmi.h
Matt Coleman [Tue, 3 Nov 2020 00:22:07 +0000 (19:22 -0500)]
hyperv: minor formatting fix in hyperv_wmi.h

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: consistent names for SettingData functions
Matt Coleman [Tue, 3 Nov 2020 00:22:06 +0000 (19:22 -0500)]
hyperv: consistent names for SettingData functions

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: move hypervGetProcSDByVSSDInstanceId to hyperv_wmi.c
Matt Coleman [Tue, 3 Nov 2020 00:22:05 +0000 (19:22 -0500)]
hyperv: move hypervGetProcSDByVSSDInstanceId to hyperv_wmi.c

This places it next to existing related functions.

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: move hypervGetWmiClass to hyperv_wmi.h
Matt Coleman [Tue, 3 Nov 2020 00:22:04 +0000 (19:22 -0500)]
hyperv: move hypervGetWmiClass to hyperv_wmi.h

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: WMI class list function general cleanup
Matt Coleman [Tue, 3 Nov 2020 00:22:03 +0000 (19:22 -0500)]
hyperv: WMI class list function general cleanup

* use the same section comment in the header and code
* place the items in the same relative location within the .h and .c
* one parameter per line for multiline function definitions

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: remove spaces after hypervObject* casts
Matt Coleman [Tue, 3 Nov 2020 00:22:02 +0000 (19:22 -0500)]
hyperv: remove spaces after hypervObject* casts

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: g_autofree username and password in hypervConnectOpen()
Matt Coleman [Tue, 3 Nov 2020 00:22:01 +0000 (19:22 -0500)]
hyperv: g_autofree username and password in hypervConnectOpen()

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoremove unnecessary cleanup labels and unused return variables
Laine Stump [Tue, 27 Oct 2020 21:49:11 +0000 (17:49 -0400)]
remove unnecessary cleanup labels and unused return variables

After converting all DIR* to g_autoptr(DIR), many cleanup: labels
ended up just having "return ret", and every place that set ret would
just immediately goto cleanup. Remove the cleanup label and its
return, and just return the set value immediately, thus eliminating
the need for the return variable itself.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: refactor function to simplify and remove label
Laine Stump [Tue, 27 Oct 2020 02:04:31 +0000 (22:04 -0400)]
util:  refactor function to simplify and remove label

Once the DIR* in virPCIGetName() was made g_autoptr, the cleanup:
label just had a "return ret;", but the rest of the function was more
compilcated than it needed to be, doing funky things with the value of
ret inside multi-level conditionals and a while loop that might exit
early via a break with ret == 0 or exit early via a goto cleanup with
ret == -1.

It really didn't need to be nearly as complicated. After doing the
trivial replacements of "goto cleanup" with appropriate direct
returns, it became obvious that:

1) the outermost level of the nested conditional at the end of the
   function ("if (ret < 0)") was now redundant, since ret is now
   *always* < 0 by that point (otherwise the function has returned).

2) by switching the sense of the next level of the conditional (making
   it "if (!physPortID)", the "else" (which is now just "return 0;"
   becomes the "if", and the new "else" no longer needs to be inside
   the conditional.

3) the value of firstEntryName can be moved into *netname with
   g_steal_pointer()

Once that is all done, ret is no longer used and can be removed.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: remove unused VIR_DIR_CLOSE() macro
Laine Stump [Mon, 26 Oct 2020 02:43:20 +0000 (22:43 -0400)]
util: remove unused VIR_DIR_CLOSE() macro

Since every single use of DIR* was converted to use g_autoptr, this
function is not currently needed. Even if someone comes up with a
usage for a non-g_autoptr DIR* in the future, they can just use
virDirClose(), since there is no longer a semantic difference between
the two (VIR_DIR_CLOSE() previously had an extra & on the pointer so
that it could be transparently passed as a DIR** to virDirClose(), but
that was removed several commits back.)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoconf: convert final DIR* to g_autoptr
Laine Stump [Mon, 26 Oct 2020 02:40:40 +0000 (22:40 -0400)]
conf: convert final DIR* to g_autoptr

This use of DIR* was re-using the same function-scope DIR* each time
through a for loop, and due to multiple error gotos in the loop, it
needed to have the scope of the DIR* reduced to just the loop at the
same time as switching to g_autoptr. That's what this patch does.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agochange DIR* int g_autoptr(DIR) where appropriate
Laine Stump [Sun, 25 Oct 2020 21:50:51 +0000 (17:50 -0400)]
change DIR* int g_autoptr(DIR) where appropriate

All of these conversions are trivial - VIR_DIR_CLOSE() (aka
virDirClose()) is called only once on the DIR*, and it happens just
before going out of scope.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: declare g_autoptr cleanup function to auto-close DIR*
Laine Stump [Mon, 19 Oct 2020 13:15:50 +0000 (09:15 -0400)]
util: declare g_autoptr cleanup function to auto-close DIR*

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: change virDirClose to take a DIR* instead of DIR**.
Laine Stump [Tue, 13 Oct 2020 13:58:57 +0000 (09:58 -0400)]
util: change virDirClose to take a DIR* instead of DIR**.

In order to make a usable g_autoptr(DIR), we need to have a close
function that is a NOP when the pointer is NULL, but takes a simple
DIR*. But virDirClose() (candidate to be the g_autoptr cleanup
function) currently takes a DIR**, not DIR*. It does this so that it
can clear the pointer, thus making it safe to call virDirClose on the
same DIR multiple times.

In the past the clearing of the DIR* was essential in a few places,
but those few places have now been changed, so we can modify
virDirClose() to take a DIR*, and remove the side effect of clearing
the DIR*. This will make it directly usable as the g_autoptr cleanup,
and will mean that this:

   {
   DIR *dirp = NULL;
   blah blah ...
   VIR_DIR_CLOSE(dirp)
   }

is functionally identical to

   {
   g_autoptr(DIR) dirp = NULL;
   blah blah ...
   }

which will make conversion to using g_autoptr mechanical and simple to review.

(Note that virDirClose() will still check for NULL before attempting
to close, so that it can always be safely called, as long as the DIR*
was initialized to NULL (another prerequisite of becoming a g_autoptr
cleanup function)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: manually set dirp to NULL after closing in virCapabilitiesInitCache()
Laine Stump [Mon, 26 Oct 2020 01:10:08 +0000 (21:10 -0400)]
util: manually set dirp to NULL after closing in virCapabilitiesInitCache()

In all uses of VIR_DIR_CLOSE() except one, the DIR* is never
referenced after closing all the way until it goes out of
scope. virCapabilitiesInitCaches(), however, reuses the same DIR* over
and over in a loop, but due to having many error conditions that
result in a goto out of the loop, it's not well suited to reducing the
scope of the variable until we introduce a g_autoptr cleanup function
for DIR*.

In preparation for doing just that, we need to get rid of the side
effect of VIR_DIR_CLOSE() setting the DIR* to NULL, so in this one
case, let's manually set the DIR* to NULL. Then in an upcoming patch
we can safely remove the side effect from VIR_DIR_CLOSE().

This extra/ugly bit of code is only temporary: once we introduce the
g_autoptr cleanup function for DIR*, we will remove this manual
close/clear completely anyway.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: reduce scope of a DIR * in virCgroupV1SetOwner()
Laine Stump [Sun, 25 Oct 2020 21:31:53 +0000 (17:31 -0400)]
util: reduce scope of a DIR * in virCgroupV1SetOwner()

DIR *dh is being re-used each time through the for loop of this
function, so it must be closed and then re-opened, which means we
can't convert it to g_autoptr. By moving the definition of dh inside
the for loop, we make it possible to trivially convert to g_autoptr
(which will happen in a subsequent patch)

NB: VIR_DIR_CLOSE() is already called at the bottom of the for loop,
so removing the VIR_DIR_CLOSE() at the end of the function is *not*
creating a leak of a DIR*!

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agostorage: remove extraneous call to VIR_DIR_CLOSE()
Laine Stump [Mon, 26 Oct 2020 02:28:09 +0000 (22:28 -0400)]
storage: remove extraneous call to VIR_DIR_CLOSE()

VIR_DIR_CLOSE(dir) is called in the middle of
virStorageBackendRefreshLocal(), which is okay, but redundant - there
is no reference to dir between that call and the end of the function,
where VIR_DIR_CLOSE() is called again. Remove the extra call in the
middle to simplify the function and make the conversion to g_autoptr
trivial/mechanical.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agotools: reduce scope of a DIR* in virHostValidateIOMMU()
Laine Stump [Sun, 25 Oct 2020 21:56:22 +0000 (17:56 -0400)]
tools: reduce scope of a DIR* in virHostValidateIOMMU()

This will make the trivial nature of a conversion to g_autoptr (in a
later patch) more obvious.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoconsistently use VIR_DIR_CLOSE() instead of virDirClose()
Laine Stump [Tue, 13 Oct 2020 13:40:54 +0000 (09:40 -0400)]
consistently use VIR_DIR_CLOSE() instead of virDirClose()

This will make it easier to review upcoming patches that use g_autoptr
to auto-close all DIRs.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirDomainNetDefParseXML: Fix error message for unknown value of //mac/@type
Michal Privoznik [Mon, 2 Nov 2020 19:49:38 +0000 (20:49 +0100)]
virDomainNetDefParseXML: Fix error message for unknown value of //mac/@type

In v6.6.0-rc1~124 we've introduced a new mechanism for MAC
addresses for ESX: ignore all checks (type='static') that libvirt
or ESX would do (and possibly fail) for specified MAC address.
Accepted values for the @type attribute are "generated" and
"static". But the error message mentions a different attribute.

Fixes 454e5961abf40c14f8b6d7ee216229e68fd170bf
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1892130
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: do not overwrite errors from hypervInvokeMethod()
Matt Coleman [Thu, 22 Oct 2020 16:38:24 +0000 (12:38 -0400)]
hyperv: do not overwrite errors from hypervInvokeMethod()

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: reduce duplicate code for Msvm_ComputerSystem lookups
Matt Coleman [Thu, 22 Oct 2020 16:38:23 +0000 (12:38 -0400)]
hyperv: reduce duplicate code for Msvm_ComputerSystem lookups

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>