Commit Graph

39706 Commits

Author SHA1 Message Date
Michal Privoznik
6f88eb77e4 viridentitytest: Run more frequently
The viridentitytest tests our viridentity module which is
compiled on all platforms and OSes. There is no need to have
SELinux secdriver as individual test cases are skipped if SELinux
is missing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-09 15:43:53 +01:00
Daniel P. Berrangé
a4636c76fc rpm: more fixes for disabling features
The %meson macro sets "--auto-features=enabled", so it is not enough to
disable the driver options, we must also disable any library options
which the drivers depend on.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-11-09 13:15:28 +00:00
Peter Krempa
1841cfa49e qemustatusxml2xmltest: Remove 'virdeterministichash' mocking
Commit 89a3115bac was not updated after recent changes to
hash table usage and was still referencing the now removed deterministic
hash mock, which caused CI failure.

Fixes: 89a3115bac
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2020-11-09 13:23:25 +01:00
Peter Krempa
5ab8cc78c4 qemu: backup: Add partial validation of incremental backup checkpoint
Verify that the checkpoint requested by an incremental backup exists.
Unfortunately validating whether the checkpoint configuration actually
matches the disk may not be reasonably feasible as the disk may have
been renamed/snapshotted/etc. We still rely on bitmap presence.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:50 +01:00
Peter Krempa
a4d4d2bd5d qemu: checkpoint: Implement VIR_DOMAIN_CHECKPOINT_REDEFINE_VALIDATE
Validate that the bitmaps are present when redefining a checkpoint.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:50 +01:00
Peter Krempa
93873c9bcc conf: checkpoint: Split virDomainCheckpointRedefinePrep into two functions
First one prepares and validates the definition, the second one actually
either updates an existing checkpoint or assigns definition for the new
one.

This will allow driver code to add extra validation between those
steps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:50 +01:00
Peter Krempa
f37d306f6e virsh: checkpoint-create: Add support for VIR_DOMAIN_CHECKPOINT_REDEFINE_VALIDATE
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:50 +01:00
Peter Krempa
9b54eb84c8 checkpoint: Introduce VIR_DOMAIN_CHECKPOINT_REDEFINE_VALIDATE flag
Introduce a flag which will allow users to perform hypervisor-specific
validation when redefining the checkpoint metadata. This will allow
checking metadata which is stored e.g. in disk images when populating
the libvirt metadata.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:49 +01:00
Peter Krempa
e33e89d839 qemu: backup: Use VIR_ERR_CHECKPOINT_INCONSISTENT when starting a backup
If we don't have a consistent chain of bitmaps for the backup to proceed
we'd report VIR_ERR_INVALID_ARG error code, which makes it hard to
decide whether an incremental backup makes even sense.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:49 +01:00
Peter Krempa
facfa8262e error: Introduce VIR_ERR_CHECKPOINT_INCONSISTENT error code
This code will be used to signal cases when the checkpoint is broken
either during backup or other operations where a user might want to make
decision based on the presence of the checkpoint, such as do a full
backup instead of an incremental one.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:49 +01:00
Peter Krempa
af7047717f man: virsh: Mention that '--size' for 'checkpoint-dumpxml' may require running vm
Separate the docs for the '--size' flag into its own paragraph and
mention that the domain may be required to be running.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:49 +01:00
Peter Krempa
1bb33357ea checkpoint: Mention that VIR_DOMAIN_CHECKPOINT_XML_SIZE may require running vm
The qemu implementation requires that the VM associated with the
checkpoint is running when checking the size. Mention this possibility
with the flag.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:49 +01:00
Peter Krempa
dddd442798 virCPUDefFormatBufFull: Use virXMLFormatElement
The function was basically open-coding it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:49 +01:00
Peter Krempa
20feb62ed8 qemumigrationcookiexmltest: Add synthetic test case
Add a test case attempting to exercise the most of the cookie XML
parsing/formatting infra. Note that the data is not based on any real
case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:49 +01:00
Peter Krempa
5511bf32fe tests: Add testing of qemu migration cookie
Migration cookie transports a lot of information but there are no tests
for it.

The test supports both xml2xml testing and also testing of the
population of the migration cookie data from a domain object, although
that option is not very useful as many things are collected from running
qemu and thus can't be tested efficiently here.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:49 +01:00
Peter Krempa
f8b0866878 qemu_migration_cookie: Make cookie parsing robust against missing domain job
In testing code we don't properly populate the job sometimes. If it
isn't populated we should not touch it though in the migration cookie
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>
2020-11-09 12:25:49 +01:00
Peter Krempa
ed2e78089b tests: Add mock library for virGetHostname and virGetHostUUID
The 'qemu_migration_cookie' module uses these. Provide a stable override
for tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:49 +01:00
Peter Krempa
b2d6fc67ab qemu_migration_cookie: Export qemuMigrationCookieXMLFormat for tests
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:49 +01:00
Peter Krempa
49c845bb4e qemu_migration_cookie: Make header standalone
Include qemu_domain.h and qemu_domainjob.h as the types from those
headers are used by this header.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:49 +01:00
Peter Krempa
89a3115bac qemuxml2xmltest: Split out status XML testing to qemustatusxml2xmltest.c
Separate the test files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:49 +01:00
Peter Krempa
60129c06ba 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>
2020-11-09 12:25:49 +01:00
Michal Privoznik
0995f20d0a 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>
2020-11-09 11:28:23 +01:00
Göran Uddeborg
ee1a90242a 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>
2020-11-08 19:35:48 +01:00
Michal Privoznik
3113f3d815 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>
2020-11-06 16:52:11 +01:00
Nikolay Shirokovskiy
7e34d9a9e0 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>
2020-11-06 17:28:37 +03:00
Andrea Bolognani
8dfb6ed826 Revert "Revert "spec: Simplify setting features off by default""
As explained in the original commit (31d687a321), these values
are actually unaffected by the corresponding _without_* macros
and so we can leave out the additional processing / obfuscation.

This reverts commit ae23a87d85.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-11-06 15:19:21 +01:00
Ján Tomko
4a56278e77 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>
2020-11-06 15:03:39 +01:00
Ján Tomko
843b709954 util: use g_autofree in virSCSIHostGetUniqueId
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-11-06 15:03:39 +01:00
Yi Li
2c211820cf 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>
2020-11-06 11:18:17 +01:00
Peter Krempa
818bd9fc05 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>
2020-11-06 10:41:08 +01:00
Peter Krempa
5ca84b6cae 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>
2020-11-06 10:40:56 +01:00
Peter Krempa
62a01d84a3 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>
2020-11-06 10:40:51 +01:00
Peter Krempa
de41e74bbc 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>
2020-11-06 10:31:57 +01:00
Peter Krempa
85d5b8bd9a 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>
2020-11-06 10:31:57 +01:00
Peter Krempa
247460ab41 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>
2020-11-06 10:31:57 +01:00
Peter Krempa
80f3af5fd8 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>
2020-11-06 10:31:57 +01:00
Peter Krempa
5f1b1da1b9 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>
2020-11-06 10:31:57 +01:00
Peter Krempa
947d2db31b 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>
2020-11-06 10:31:57 +01:00
Peter Krempa
280a6d8330 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>
2020-11-06 10:31:57 +01:00
Peter Krempa
4eb8e9ae8b 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>
2020-11-06 10:31:57 +01:00
Peter Krempa
6e29698037 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>
2020-11-06 10:31:57 +01:00
Michal Privoznik
ef164fb3f9 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>
2020-11-06 09:16:21 +01:00
Michal Privoznik
995394c5a3 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>
2020-11-06 09:14:53 +01:00
Michal Privoznik
df8ff46a16 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>
2020-11-06 09:14:01 +01:00
Michal Privoznik
d337543f06 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: 7cfb7aab57
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-11-06 09:04:35 +01:00
Pavel Hrdina
8f0f6ff082 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>
2020-11-05 23:15:16 +01:00
Tim Wiederhake
6886b47f8d 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>
2020-11-05 20:57:03 +01:00
Matt Coleman
b1423cf1ea 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>
2020-11-05 16:31:16 +01:00
Yi Li
ed3cc76b48 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: 38cc07b7bc

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2020-11-05 10:47:47 +01:00
Jim Fehlig
f035f53baa 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>
2020-11-04 16:26:27 -07:00