Commit Graph

44197 Commits

Author SHA1 Message Date
Peter Krempa
e34a532229 qemuDomainUpdateMemoryDeviceInfo: Automatically free temporary GHashTable
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-12-01 13:53:11 +01:00
Peter Krempa
f7d9dd8ff8 virNWFilterBuildAll: Automatically free temporary GHashTable
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-12-01 13:53:11 +01:00
Peter Krempa
bdcd102eef virNWFilterDoInstantiate: Automatically free temporary GHashTable
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-12-01 13:53:11 +01:00
Peter Krempa
04bbaa2b1f libxlLoggerNew: Avoid virHashFree by rearranging code
Allocate the hash table only after the log file is opened so that we
don't need to deallocate it on failure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-12-01 13:53:11 +01:00
Peter Krempa
35ebb28f3f virDomainDeviceValidateAliasImpl: Automatically free GHashTable and remove cleanup
After the conversion to g_autofree, the cleanup label is no longer
needed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-12-01 13:53:11 +01:00
Peter Krempa
a977173aa6 virDomainNetDefParseXML: Automatically free GHashTable
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-12-01 13:53:11 +01:00
Peter Krempa
f654464f7a virStorageSourceIsSameLocation: Special-case storage sources of type 'volume'
The function is used also to compare virStorageSource which may not be
resolved to the image at that point in which case the 'path' is not yet
populated and the actual type is not yet set. This means that the
function fails to consider two identical volume-based disks as pointing
to the same thing.

Add a special case for both images being type=volume in which case we
compare only the pool/volume names.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/240
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-12-01 13:39:48 +01:00
Peter Krempa
c0b40323f8 qemuBlockJobRewriteConfigDiskSource: Add debug statements when skipping disk update
It makes it easier to see what's going on when trying to figure out why
the disk definition was not updated on a finalized blockjob.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-12-01 13:39:47 +01:00
Peter Krempa
70b0c2c183 conf: domain: Convert all string length checks to STRLIM
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 13:39:47 +01:00
Peter Krempa
55d951ef58 virDomainDeviceLoadparmIsValid: Use 'strspn' instead of a loop
In other places we use strspn to validate a character subset. Convert
the in-place loop and simplify the error message.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 13:39:47 +01:00
Peter Krempa
d23389d2b7 virDomainDeviceLoadparmIsValid: Simplify value lenght check
Use the new STRLIM macro and unify it with the empty string check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 13:39:47 +01:00
Peter Krempa
8eb7471eb3 internal: Add STRLIM macro for checking string length using strnlen()
As a microoprimization when checking whether length of a string fits
into a limit we don't necessarily need to calculate the full length but
can use strnlen to check only LIMIT+1 chars. Add a macro which will
simplify the expressions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 13:39:47 +01:00
Peter Krempa
9220413480 conf: seclabel: Parse booleans using virXMLPropTristateBool instead of virStringParseYesNo
Reduce the extent of custom logic and custom error messages by using
virXMLPropTristateBool.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 13:39:47 +01:00
Peter Krempa
7489b5e37e util: enum: Add helpers for converting virTristate* to a plain bool
The helpers will update the passed boolean if the tristate's value is
not _ABSENT.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-12-01 13:39:47 +01:00
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