Commit Graph

43983 Commits

Author SHA1 Message Date
Daniel P. Berrangé
f17b9c57c5 run: detect daemons when run via wrapper commands
The run script tries to detect when a daemon is being run in order to
shutdown other systemd unit files that clash. As implemented this
only works if the daemon name is the first argument. This won't be the
case if running via GDB or strace eg

  ./run strace -e trace=openat ./build/src/virtqemud

We need to check all argv to find which might be a daemon path/name.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 12:14:03 +00:00
Daniel P. Berrangé
6e1baedd2f qemu: mock swtpm initialization in tests
The domain capabilities won't report TPM support unless SWTPM can be
initialized. To avoid relying on the swtpm install in the host, mock
the entire initialization method, since all it needs todo is return
a non-error value.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 12:14:03 +00:00
Daniel P. Berrangé
6f7fc0b54a qemu: fill in domain capabilities for TPMs
This reports what TPM features QEMU supports, provided that swtpm is
installed in the host.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 12:14:03 +00:00
Daniel P. Berrangé
fd0aa7879f conf: add TPM devices to domain capabilities
This adds reporting of available TPM models and backends to the domain
capabilities schema

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 12:14:03 +00:00
Daniel P. Berrangé
193436c6a1 util: add a method for checking if swtpm is available
The QEMU domain capabilities code wants to quietly know whether swtpm is
available on the host.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 12:14:03 +00:00
Daniel P. Berrangé
45f83e3a0b util: pull TPM capabilities probing out of main init method
Many methods merely want to know that the swtpm binaries have been
found, and don't care about probing for capabilities. Even when
starting a guest, the QEMU driver may not need the capabilities.

Skipping probing ensures the VM startup path is as fast as possible
when capabilities are not required. It also removes various error
scenarios from the main init method.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 12:14:03 +00:00
Daniel P. Berrangé
63c42ba1d1 util: ensure all TPM global vars access is protected by lock
The virTPMEmulatorInit method updates various global variables
and holds a lock while doing so. Other methods which access
these variables, however, don't reliably hold locks over all
of their accesses.

Since virTPMEmulatorInit is no longer exported, we can push
the locking up into all the callers and achieve proper safety
for concurrent usage.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 12:14:03 +00:00
Daniel P. Berrangé
c032786e08 util: don't export virTPMEmulatorInit method
Every other exported API from virtpm.h will internally call
virTPMEmulatorInit, so there is no reason for this initializer
to be exported on its own.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 12:14:03 +00:00
Daniel P. Berrangé
ac674429c3 util: replace TPM global variables with a struct array
The virTPMEmulatorInit function defines a struct that gets filled with
pointers to global variables. It will be simpler to just use the struct
for the global variables directly.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 12:14:03 +00:00
Daniel P. Berrangé
e715648e8b util: refactor TPM helper methods to reduce duplicationm
The TPM helper methods for querying the binary path and capabilities
have the same patterns across all swtpm binaries. This code duplication
can be reduced by introducing helper methods.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 12:14:03 +00:00
Daniel P. Berrangé
7475907d1a util: rename typedef for parsing swtpm capabilities
Best practice is to have all types use a naming convention based on the
filename.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 12:14:03 +00:00
Daniel P. Berrangé
3d8ee06b6e util: use consistent naming for swtpm global variables
Use a '_path' suffix on all vars which are paths.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 12:14:03 +00:00
Kristina Hanicova
01f9873724 qemu_domainjob: move jobs_queued to struct qemuDomainJobObj
I think it makes more sense for the variable about jobs to be in
the job object. I also renamed it to be consistent with the rest
of the struct.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 12:45:40 +01:00
Daniel P. Berrangé
9b43ec60af qemu: don't strip audio elements with user config present
To support backwards live migration we must strip the default added
audio element, however, we are too aggressive in doing so. We are only
comparing a couple of attributes for equality, so risk stripping config
that was user customized. To improve this we need to a deep comparison
of the audio config.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 11:40:17 +00:00
Daniel P. Berrangé
557f96d224 conf: add helper for comparing virDomainAudioDef objects
It is useful to be able to deeply check them for equality.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-12-01 11:40:17 +00:00
Pavel Hrdina
3d34e5c2ff qemu_snapshot: create: drop redefine boolean
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 12:33:48 +01:00
Pavel Hrdina
9bad0fb809 qemu_snapshot: create: move snapshot create to separate function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 12:33:46 +01:00
Pavel Hrdina
f4aae9726d qemu_snapshot: create: move snapshot redefine to separate function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 12:33:44 +01:00
Pavel Hrdina
773bf7c846 qemu_snapshot: create: move saving metadata to separate function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 12:33:41 +01:00
Pavel Hrdina
29a0840475 qemu_snapshot: create: refactor endjob in qemuSnapshotCreateXML
The logic of saving metadata doesn't have to be in endjob section as
it will only happen if we have successfully created snapshot.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 12:33:38 +01:00
Pavel Hrdina
d9c7985b4f qemu_snapshot: create: drop update_current variable
There is no need for the extra variable as it is used only at one place.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 12:33:36 +01:00
Pavel Hrdina
5bd0c09570 qemu_snapshot: create: virDomainSnapshotGetCurrent is not used with redefine
Move it to code path for creating new snapshot.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 12:33:33 +01:00
Pavel Hrdina
fe52bc2638 qemu_snapshot: create: move virDomainSnapshotAssignDef to both code paths
This makes it obvious that the function is called for creating new
snapshot and redefining old snapshot as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 12:33:31 +01:00
Pavel Hrdina
0960353d6c qemu_snapshot: create: move disk align to separate function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 12:33:28 +01:00
Pavel Hrdina
061a395394 qemu_snapshot: create: move XML def validation to separate function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 12:33:25 +01:00
Pavel Hrdina
87d4fa71d3 qemu_snapshot: create: move XML parsing to separate function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 12:33:07 +01:00
Kristina Hanicova
4634d7b7da qemu_domainjob: remove dead code
Function qemuDomainJobAllowed() is never used -> remove it.

The last use was removed in commit 3f2fa8f303

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 10:56:58 +01:00
Ján Tomko
9a9a93e2eb qemu: absorb qemuDomainObjExitMonitorInternal
qemuDomainObjExitMonitor is just an alias for it at this point.

This also removes the incomplete ATTRIBUTE_NONNULL(1) annotation.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-01 10:56:58 +01:00
Ján Tomko
f1ea5bd506 qemu: turn qemuDomainObjExitMonitor into void
This reverts my
    commit dc2fd51fd7
    Check for domain liveness in qemuDomainObjExitMonitor
which fixed the symptoms of the bug later fixed by
    commit 81f50cb92d
    qemu: Avoid calling qemuProcessStop without a job

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-01 10:56:58 +01:00
Ján Tomko
c3e79a9008 qemu: remove ignore_value for qemuDomainObjExitMonitor
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-01 10:56:58 +01:00
Ján Tomko
57d665b390 qemu: do not check return value of qemuDomainObjExitMonitor
Remove the check from conditions where it's coupled with some other
checks.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-01 10:56:58 +01:00
Ján Tomko
d7b23755ef qemu: do not check return value of qemuDomainObjExitMonitor
Remove the unreachable code.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-01 10:56:58 +01:00
Ján Tomko
0200cd4910 qemu: do not propagate return value of qemuDomainObjExitMonitor
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-01 10:56:58 +01:00
Ján Tomko
8a51f4c6e4 qemu: qemuDomainObjExitMonitor: do not warn on unused result
This wrapper for qemuDomainObjExitMonitorInternal was
extended by my commit dc2fd51fd7
to check whether the domain is still alive, because
we were observing crashes if the QEMU process died
while some of our APIs were in the monitor and the thread
processing the EOF event freed the domain definition.

This bug was fixed by:
    commit 81f50cb92d
    qemu: Avoid calling qemuProcessStop without a job
but we kept checking for the return value since.

Remove the G_GNUC_WARN_UNUSED_RESULT attribute since
all of the calls that could set def->id to -1 are protected
by qemuProcessBeginStopJob and cannot happen while we have a job
in the monitor.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-12-01 10:56:58 +01:00
Jiri Denemark
83131a4ecc Post-release version bump to 8.0.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2021-12-01 10:53:20 +01:00
Jiri Denemark
795c3a8053 Release of libvirt-7.10.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2021-12-01 10:50:47 +01:00
Peter Krempa
4c8650ea98 NEWS: Mention two minor regression fixes and addition to bulk stats
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2021-11-30 23:06:05 +01:00
Daniel Henrique Barboza
2873c069d4 NEWS: document DEVICE_UNPLUG_GUEST_ERROR support
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2021-11-30 23:06:00 +01:00
Ján Tomko
ac3e9f5efc vz: fix vzCapsAddGuestDomain
There is a stray 'return -1' executed on all code paths.

Fixes: c18d9e23fa
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-30 12:27:31 +01:00
Daniel P. Berrangé
b719d82f4a util: canonicalize 'arm64' arch to 'aarch64'
macOS on Apple silicon reports 'arm64' as the architecture from uname,
which we need to canonicalize to VIR_ARCH_AARCH64 / 'aarch64'.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-11-30 10:51:33 +00:00
Daniel P. Berrangé
e674218dc2 tools: fix iterating over argv when recovering xattr
The libvirt_recover_xattrs.sh tool hangs when run. When no flags
are provided OPTIND is 1, so the loop expands to 'shift 0' which
has not effect. Rewrite to just loop over $@ instead which involves
less cleverness.

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-11-30 10:45:35 +00:00
Michal Privoznik
010613cfd8 wireshark: Drop needless comment in dissect_xdr_bytes()
In the dissect_xdr_bytes() there's a comment that the string
allocated by xdr_bytes() can't be freed using xdr_free(). Well,
that is expected because xdr_bytes() used plain calloc() AND the
string is not an XDR struct but plain 'char *' type. Passing it
to xdr_free() must result in weird things happening.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-11-29 15:05:43 +01:00
Michal Privoznik
7e299ba649 wireshark: Switch to tvb_bytes_to_str()
When the dissector sees a byte sequence that is either an opaque
data (xdr_opaque) or a byte sequence (xdr_bytes) it formats the
bytes as a hex numbers using our own implementation. But
wireshark already provides a function for it: tvb_bytes_to_str().
NB, the reason why it returns a const string is so that callers
don't try to free it - the string is allocated using an allocator
which will decide when to free it.

The wireshark formatter was introduced in wireshark commit of
v1.99.2~479 and thus is present in the version we require at
least (2.6.0).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-11-29 15:05:33 +01:00
Yuri Chornoivan
540c8cbef0 Translated using Weblate (Ukrainian)
Currently translated at 100.0% (10439 of 10439 strings)

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

Co-authored-by: Yuri Chornoivan <yurchor@ukr.net>
Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
2021-11-27 16:16:17 +01:00
simmon
37255ba0e2 Translated using Weblate (Korean)
Currently translated at 100.0% (10439 of 10439 strings)

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

Translated using Weblate (Korean)

Currently translated at 99.8% (10423 of 10439 strings)

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

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
2021-11-27 16:16:17 +01:00
Weblate
67ff445c23 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

Co-authored-by: Weblate <noreply@weblate.org>
Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
2021-11-27 16:16:14 +01:00
Peter Krempa
a453ebcd2b qemu: Fix validation of PCI option rom settings on hotplug
Commit 24be92b8e moved the option rom settings validation code to the
validation callbacks, but that doesn't work properly with device hotplug
as we assign addresses only after parsing the whole XML. The check is
too strict for that and caused failures when hotplugging devices such
as:

 <interface type='network'>
   <source network='default'/>
   <model type='virtio'/>
   <rom enabled='no'/>
 </interface>

This patch relaxes the check in the validation callback to accept also
_NONE and _UNASSIGNED address types and returns the check to
'qemuBuildRomProps' so that we preserve the full validation as we've
used to.

Fixes: 24be92b8e3
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2021437
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-26 10:02:32 +01:00
Peter Krempa
d120fc5253 qemu: monitor: Fix usage of 'query-blockstats'
Commit bc24810c2c modified code querying blockstats to use the
'query-nodes' parameter so that we can fetch stats also for images which
are not attached to a frontend such as block copy and backup scratch
images.

Unfortunately that broke the old blockstats because if 'query-nodes' is
enabled qemu doesn't output the 'qdev' parameter which our code used for
matching to the disk and also qemu neglects to populate the frontend
stats at all so we can't even switch to using nodename for matching.

To fix this we need to do two calls, one with 'query-nodes' disabled
using the old logic to populate everything and then an additional one
which populates all the remaining images.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/246
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Erik Skultety <eskultet@redhat.com>
2021-11-25 15:27:56 +01:00
Ján Tomko
4b453bbb2f NEWS: document tcp_min_ssf
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-25 11:41:10 +01:00
Jiri Denemark
b9af0cdfd6 po: Refresh potfile for v7.10.0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2021-11-25 10:19:23 +01:00