]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
3 years agoutil: virhash: Remove 'virHashFree'
Peter Krempa [Tue, 30 Nov 2021 13:20:02 +0000 (14:20 +0100)]
util: virhash: Remove 'virHashFree'

The code was converted to stop using this function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoSwitch away from virHashFree
Peter Krempa [Tue, 30 Nov 2021 13:13:28 +0000 (14:13 +0100)]
Switch away from virHashFree

Use 'g_clear_pointer(&ptr, g_hash_table_unref)' instead.

In few instances it allows us to also remove explicit clearing of
pointers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoqemuxml2argvtest: Use 'g_hash_table_unref' for clearing the qapi schema cache
Peter Krempa [Tue, 30 Nov 2021 13:07:36 +0000 (14:07 +0100)]
qemuxml2argvtest: Use 'g_hash_table_unref' for clearing the qapi schema cache

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoqemumonitorjsontest: mymain: Automatically free GHashTable
Peter Krempa [Tue, 30 Nov 2021 10:49:24 +0000 (11:49 +0100)]
qemumonitorjsontest: mymain: Automatically free GHashTable

Use separate automatically cleared variables for the x86_64 and s390
versions of the QAPI schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoqemumonitorjsontest: testBlockNodeNameDetect: Automatically free GHashTable
Peter Krempa [Tue, 30 Nov 2021 10:49:24 +0000 (11:49 +0100)]
qemumonitorjsontest: testBlockNodeNameDetect: Automatically free GHashTable

Additionally we no longer need the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agonwfilterxml2firewalltest: testCompareXMLToArgvFiles: Automatically free GHashTable
Peter Krempa [Tue, 30 Nov 2021 10:49:24 +0000 (11:49 +0100)]
nwfilterxml2firewalltest: testCompareXMLToArgvFiles: 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>
3 years agonwfilterxml2firewalltest: virNWFilterIncludeDefToRuleInst: Automatically free GHashTable
Peter Krempa [Tue, 30 Nov 2021 10:49:24 +0000 (11:49 +0100)]
nwfilterxml2firewalltest: virNWFilterIncludeDefToRuleInst: 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>
3 years agoqemuCheckpointGetXMLDescUpdateSize: Don't combine automatic freeing with manual
Peter Krempa [Tue, 30 Nov 2021 12:16:15 +0000 (13:16 +0100)]
qemuCheckpointGetXMLDescUpdateSize: Don't combine automatic freeing with manual

'blockNamedNodeData' is declared for automatic freeing but we also free
it manually and reuse which is a code pattern we don't normally allow.

Rewrite the code to have actually two separate hash tables.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoqemuProcessRefreshLegacyBlockjobs: Automatically free GHashTable and refactor cleanup
Peter Krempa [Tue, 30 Nov 2021 10:49:24 +0000 (11:49 +0100)]
qemuProcessRefreshLegacyBlockjobs: Automatically free GHashTable and refactor cleanup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoqemuProcessRefreshDisks: Automatically free GHashTable and refactor cleanup
Peter Krempa [Tue, 30 Nov 2021 10:49:24 +0000 (11:49 +0100)]
qemuProcessRefreshDisks: Automatically free GHashTable and refactor cleanup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoqemuProcessWaitForMonitor: Automatically free GHashTable
Peter Krempa [Tue, 30 Nov 2021 10:49:24 +0000 (11:49 +0100)]
qemuProcessWaitForMonitor: 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>
3 years agoqemuRefreshPRManagerState: Automatically free GHashTable and refactor cleanup
Peter Krempa [Tue, 30 Nov 2021 10:49:24 +0000 (11:49 +0100)]
qemuRefreshPRManagerState: Automatically free GHashTable and refactor cleanup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoqemuRefreshVirtioChannelState: Automatically free GHashTable and refactor cleanup
Peter Krempa [Tue, 30 Nov 2021 10:49:24 +0000 (11:49 +0100)]
qemuRefreshVirtioChannelState: Automatically free GHashTable and refactor cleanup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoqemuMigrationSrcFetchMirrorStats: Automatically free GHashTable
Peter Krempa [Tue, 30 Nov 2021 10:42:17 +0000 (11:42 +0100)]
qemuMigrationSrcFetchMirrorStats: 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>
3 years agoqemuDomainGetDiskErrors: Automatically free GHashTable
Peter Krempa [Tue, 30 Nov 2021 10:42:17 +0000 (11:42 +0100)]
qemuDomainGetDiskErrors: 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>
3 years agoqemuDomainBlocksStatsGather: Automatically free GHashTable and refactor cleanup
Peter Krempa [Tue, 30 Nov 2021 10:41:26 +0000 (11:41 +0100)]
qemuDomainBlocksStatsGather: Automatically free GHashTable and refactor cleanup

No need for the cleanup section once we switch to g_autoptr.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoqemuDomainUpdateMemoryDeviceInfo: Automatically free temporary GHashTable
Peter Krempa [Tue, 30 Nov 2021 10:38:48 +0000 (11:38 +0100)]
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>
3 years agovirNWFilterBuildAll: Automatically free temporary GHashTable
Peter Krempa [Tue, 30 Nov 2021 10:35:42 +0000 (11:35 +0100)]
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>
3 years agovirNWFilterDoInstantiate: Automatically free temporary GHashTable
Peter Krempa [Tue, 30 Nov 2021 10:35:42 +0000 (11:35 +0100)]
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>
3 years agolibxlLoggerNew: Avoid virHashFree by rearranging code
Peter Krempa [Tue, 30 Nov 2021 10:34:43 +0000 (11:34 +0100)]
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>
3 years agovirDomainDeviceValidateAliasImpl: Automatically free GHashTable and remove cleanup
Peter Krempa [Tue, 30 Nov 2021 10:33:52 +0000 (11:33 +0100)]
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>
3 years agovirDomainNetDefParseXML: Automatically free GHashTable
Peter Krempa [Tue, 30 Nov 2021 10:33:10 +0000 (11:33 +0100)]
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>
3 years agovirStorageSourceIsSameLocation: Special-case storage sources of type 'volume'
Peter Krempa [Fri, 26 Nov 2021 12:21:47 +0000 (13:21 +0100)]
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>
3 years agoqemuBlockJobRewriteConfigDiskSource: Add debug statements when skipping disk update
Peter Krempa [Fri, 26 Nov 2021 12:30:49 +0000 (13:30 +0100)]
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>
3 years agoconf: domain: Convert all string length checks to STRLIM
Peter Krempa [Thu, 25 Nov 2021 12:38:19 +0000 (13:38 +0100)]
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>
3 years agovirDomainDeviceLoadparmIsValid: Use 'strspn' instead of a loop
Peter Krempa [Thu, 25 Nov 2021 12:44:13 +0000 (13:44 +0100)]
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>
3 years agovirDomainDeviceLoadparmIsValid: Simplify value lenght check
Peter Krempa [Thu, 25 Nov 2021 12:32:18 +0000 (13:32 +0100)]
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>
3 years agointernal: Add STRLIM macro for checking string length using strnlen()
Peter Krempa [Wed, 24 Nov 2021 16:03:07 +0000 (17:03 +0100)]
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>
3 years agoconf: seclabel: Parse booleans using virXMLPropTristateBool instead of virStringParse...
Peter Krempa [Wed, 24 Nov 2021 13:53:04 +0000 (14:53 +0100)]
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>
3 years agoutil: enum: Add helpers for converting virTristate* to a plain bool
Peter Krempa [Wed, 24 Nov 2021 13:48:12 +0000 (14:48 +0100)]
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>
3 years agorun: detect daemons when run via wrapper commands
Daniel P. Berrangé [Wed, 24 Nov 2021 12:02:20 +0000 (12:02 +0000)]
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>
3 years agoqemu: mock swtpm initialization in tests
Daniel P. Berrangé [Tue, 23 Nov 2021 17:39:16 +0000 (17:39 +0000)]
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>
3 years agoqemu: fill in domain capabilities for TPMs
Daniel P. Berrangé [Tue, 23 Nov 2021 17:18:36 +0000 (17:18 +0000)]
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>
3 years agoconf: add TPM devices to domain capabilities
Daniel P. Berrangé [Tue, 23 Nov 2021 17:17:20 +0000 (17:17 +0000)]
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>
3 years agoutil: add a method for checking if swtpm is available
Daniel P. Berrangé [Wed, 24 Nov 2021 13:36:21 +0000 (13:36 +0000)]
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>
3 years agoutil: pull TPM capabilities probing out of main init method
Daniel P. Berrangé [Wed, 24 Nov 2021 13:30:19 +0000 (13:30 +0000)]
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>
3 years agoutil: ensure all TPM global vars access is protected by lock
Daniel P. Berrangé [Wed, 24 Nov 2021 10:30:25 +0000 (10:30 +0000)]
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>
3 years agoutil: don't export virTPMEmulatorInit method
Daniel P. Berrangé [Wed, 24 Nov 2021 12:10:10 +0000 (12:10 +0000)]
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>
3 years agoutil: replace TPM global variables with a struct array
Daniel P. Berrangé [Wed, 24 Nov 2021 10:22:11 +0000 (10:22 +0000)]
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>
3 years agoutil: refactor TPM helper methods to reduce duplicationm
Daniel P. Berrangé [Wed, 24 Nov 2021 13:13:15 +0000 (13:13 +0000)]
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>
3 years agoutil: rename typedef for parsing swtpm capabilities
Daniel P. Berrangé [Wed, 24 Nov 2021 10:19:49 +0000 (10:19 +0000)]
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>
3 years agoutil: use consistent naming for swtpm global variables
Daniel P. Berrangé [Wed, 24 Nov 2021 10:15:22 +0000 (10:15 +0000)]
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>
3 years agoqemu_domainjob: move jobs_queued to struct qemuDomainJobObj
Kristina Hanicova [Wed, 1 Dec 2021 09:41:41 +0000 (10:41 +0100)]
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>
3 years agoqemu: don't strip audio elements with user config present
Daniel P. Berrangé [Wed, 10 Nov 2021 17:58:48 +0000 (17:58 +0000)]
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>
3 years agoconf: add helper for comparing virDomainAudioDef objects
Daniel P. Berrangé [Wed, 10 Nov 2021 17:58:18 +0000 (17:58 +0000)]
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>
3 years agoqemu_snapshot: create: drop redefine boolean
Pavel Hrdina [Tue, 12 Oct 2021 10:10:32 +0000 (12:10 +0200)]
qemu_snapshot: create: drop redefine boolean

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_snapshot: create: move snapshot create to separate function
Pavel Hrdina [Thu, 25 Nov 2021 15:11:52 +0000 (16:11 +0100)]
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>
3 years agoqemu_snapshot: create: move snapshot redefine to separate function
Pavel Hrdina [Tue, 5 Oct 2021 09:52:02 +0000 (11:52 +0200)]
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>
3 years agoqemu_snapshot: create: move saving metadata to separate function
Pavel Hrdina [Mon, 4 Oct 2021 18:18:49 +0000 (20:18 +0200)]
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>
3 years agoqemu_snapshot: create: refactor endjob in qemuSnapshotCreateXML
Pavel Hrdina [Wed, 29 Sep 2021 17:18:57 +0000 (19:18 +0200)]
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>
3 years agoqemu_snapshot: create: drop update_current variable
Pavel Hrdina [Wed, 29 Sep 2021 17:02:39 +0000 (19:02 +0200)]
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>
3 years agoqemu_snapshot: create: virDomainSnapshotGetCurrent is not used with redefine
Pavel Hrdina [Thu, 25 Nov 2021 14:59:42 +0000 (15:59 +0100)]
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>
3 years agoqemu_snapshot: create: move virDomainSnapshotAssignDef to both code paths
Pavel Hrdina [Wed, 29 Sep 2021 16:53:52 +0000 (18:53 +0200)]
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>
3 years agoqemu_snapshot: create: move disk align to separate function
Pavel Hrdina [Wed, 29 Sep 2021 16:51:09 +0000 (18:51 +0200)]
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>
3 years agoqemu_snapshot: create: move XML def validation to separate function
Pavel Hrdina [Wed, 3 Nov 2021 09:53:12 +0000 (10:53 +0100)]
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>
3 years agoqemu_snapshot: create: move XML parsing to separate function
Pavel Hrdina [Wed, 22 Sep 2021 11:28:34 +0000 (13:28 +0200)]
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>
3 years agoqemu_domainjob: remove dead code
Kristina Hanicova [Tue, 30 Nov 2021 12:33:47 +0000 (13:33 +0100)]
qemu_domainjob: remove dead code

Function qemuDomainJobAllowed() is never used -> remove it.

The last use was removed in commit 3f2fa8f3032779bf09590a4b24898636ee916876

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>
3 years agoqemu: absorb qemuDomainObjExitMonitorInternal
Ján Tomko [Wed, 24 Nov 2021 12:32:42 +0000 (13:32 +0100)]
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>
3 years agoqemu: turn qemuDomainObjExitMonitor into void
Ján Tomko [Wed, 24 Nov 2021 12:41:09 +0000 (13:41 +0100)]
qemu: turn qemuDomainObjExitMonitor into void

This reverts my
    commit dc2fd51fd727bbb6de172e0ca4b7dd307bb99180
    Check for domain liveness in qemuDomainObjExitMonitor
which fixed the symptoms of the bug later fixed by
    commit 81f50cb92d16643bcd749e3ab5b404b8b7cec643
    qemu: Avoid calling qemuProcessStop without a job

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: remove ignore_value for qemuDomainObjExitMonitor
Ján Tomko [Wed, 24 Nov 2021 12:12:40 +0000 (13:12 +0100)]
qemu: remove ignore_value for qemuDomainObjExitMonitor

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: do not check return value of qemuDomainObjExitMonitor
Ján Tomko [Wed, 24 Nov 2021 12:11:52 +0000 (13:11 +0100)]
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>
3 years agoqemu: do not check return value of qemuDomainObjExitMonitor
Ján Tomko [Wed, 24 Nov 2021 12:09:32 +0000 (13:09 +0100)]
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>
3 years agoqemu: do not propagate return value of qemuDomainObjExitMonitor
Ján Tomko [Wed, 24 Nov 2021 12:42:09 +0000 (13:42 +0100)]
qemu: do not propagate return value of qemuDomainObjExitMonitor

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: qemuDomainObjExitMonitor: do not warn on unused result
Ján Tomko [Wed, 24 Nov 2021 12:44:56 +0000 (13:44 +0100)]
qemu: qemuDomainObjExitMonitor: do not warn on unused result

This wrapper for qemuDomainObjExitMonitorInternal was
extended by my commit dc2fd51fd727bbb6de172e0ca4b7dd307bb99180
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 81f50cb92d16643bcd749e3ab5b404b8b7cec643
    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>
3 years agoPost-release version bump to 8.0.0
Jiri Denemark [Wed, 1 Dec 2021 09:53:20 +0000 (10:53 +0100)]
Post-release version bump to 8.0.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoRelease of libvirt-7.10.0
Jiri Denemark [Wed, 1 Dec 2021 09:50:47 +0000 (10:50 +0100)]
Release of libvirt-7.10.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoNEWS: Mention two minor regression fixes and addition to bulk stats
Peter Krempa [Thu, 25 Nov 2021 14:54:45 +0000 (15:54 +0100)]
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>
3 years agoNEWS: document DEVICE_UNPLUG_GUEST_ERROR support
Daniel Henrique Barboza [Fri, 12 Nov 2021 18:47:48 +0000 (15:47 -0300)]
NEWS: document DEVICE_UNPLUG_GUEST_ERROR support

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovz: fix vzCapsAddGuestDomain
Ján Tomko [Mon, 29 Nov 2021 16:15:10 +0000 (17:15 +0100)]
vz: fix vzCapsAddGuestDomain

There is a stray 'return -1' executed on all code paths.

Fixes: c18d9e23fafabcfbb80481e0705931036b8e7331
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: canonicalize 'arm64' arch to 'aarch64'
Daniel P. Berrangé [Tue, 30 Nov 2021 10:51:33 +0000 (10:51 +0000)]
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>
3 years agotools: fix iterating over argv when recovering xattr
Daniel P. Berrangé [Fri, 26 Nov 2021 13:36:16 +0000 (13:36 +0000)]
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>
3 years agowireshark: Drop needless comment in dissect_xdr_bytes()
Michal Privoznik [Mon, 29 Nov 2021 09:20:05 +0000 (10:20 +0100)]
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>
3 years agowireshark: Switch to tvb_bytes_to_str()
Michal Privoznik [Mon, 29 Nov 2021 08:57:49 +0000 (09:57 +0100)]
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>
3 years agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Sat, 27 Nov 2021 15:16:17 +0000 (16:16 +0100)]
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>
3 years agoTranslated using Weblate (Korean)
simmon [Sat, 27 Nov 2021 15:16:17 +0000 (16:16 +0100)]
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>
3 years agoUpdate translation files
Weblate [Sat, 27 Nov 2021 15:16:14 +0000 (16:16 +0100)]
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>
3 years agoqemu: Fix validation of PCI option rom settings on hotplug
Peter Krempa [Thu, 25 Nov 2021 15:17:16 +0000 (16:17 +0100)]
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: 24be92b8e38762e9ba13e
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>
3 years agoqemu: monitor: Fix usage of 'query-blockstats'
Peter Krempa [Wed, 24 Nov 2021 16:22:29 +0000 (17:22 +0100)]
qemu: monitor: Fix usage of 'query-blockstats'

Commit bc24810c2cab 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>
3 years agoNEWS: document tcp_min_ssf
Ján Tomko [Fri, 5 Nov 2021 13:02:25 +0000 (14:02 +0100)]
NEWS: document tcp_min_ssf

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agopo: Refresh potfile for v7.10.0
Jiri Denemark [Thu, 25 Nov 2021 09:19:23 +0000 (10:19 +0100)]
po: Refresh potfile for v7.10.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Wed, 24 Nov 2021 06:44:02 +0000 (07:44 +0100)]
Translated using Weblate (Swedish)

Currently translated at 29.0% (3037 of 10441 strings)

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

Translated using Weblate (Swedish)

Currently translated at 29.0% (3036 of 10441 strings)

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

Translated using Weblate (Swedish)

Currently translated at 29.0% (3030 of 10441 strings)

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

Translated using Weblate (Swedish)

Currently translated at 28.9% (3020 of 10441 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>
3 years agoTranslated using Weblate (Korean)
simmon [Wed, 24 Nov 2021 06:44:01 +0000 (07:44 +0100)]
Translated using Weblate (Korean)

Currently translated at 100.0% (10441 of 10441 strings)

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

Translated using Weblate (Korean)

Currently translated at 100.0% (10441 of 10441 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>
3 years agoqemu_alias: change return type to void if possible
Kristina Hanicova [Wed, 24 Nov 2021 16:12:54 +0000 (17:12 +0100)]
qemu_alias: change return type to void if possible

These functions always return success so it seems logical to not
return anything and remove unnecessary checks.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_alias: Rewrite of code pattern
Kristina Hanicova [Wed, 24 Nov 2021 16:12:53 +0000 (17:12 +0100)]
qemu_alias: Rewrite of code pattern

This patch rewrites the pattern using early return where it is
not needed and changes the return type of the functions to 'void'
if possible.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Rewrite code to the pattern
Kristina Hanicova [Wed, 24 Nov 2021 11:25:35 +0000 (12:25 +0100)]
qemu: Rewrite code to the pattern

I have seen this pattern a lot in the project, so I decided to
rewrite code I stumbled upon to the same pattern as well.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agolibxl: Don't derive libxlDomainObjPrivate from virObjectLockable
Jim Fehlig [Mon, 22 Nov 2021 17:54:04 +0000 (10:54 -0700)]
libxl: Don't derive libxlDomainObjPrivate from virObjectLockable

The libxlDomainObjPrivate object is never locked and hence does not need to
be a virObjectLockable object.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agolibxl: Remove unused macros
Jim Fehlig [Mon, 22 Nov 2021 17:43:13 +0000 (10:43 -0700)]
libxl: Remove unused macros

Remove unused JOB_MASK and DEFAULT_JOB_MASK macros.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Remove 'else' branches after 'return' or 'goto'
Kristina Hanicova [Tue, 23 Nov 2021 17:20:10 +0000 (18:20 +0100)]
qemu: Remove 'else' branches after 'return' or 'goto'

I think it makes no sense to have else branches after return or
goto as it will never reach them in cases it should not. This
patch makes the code more readable (at least to me).

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
3 years agovirDomainObjListAdd: Transfer definition ownership
Michal Privoznik [Tue, 2 Nov 2021 11:19:50 +0000 (12:19 +0100)]
virDomainObjListAdd: Transfer definition ownership

Upon successful return from virDomainObjListAdd() the
virDomainObj is the owner of secret definition. To make this
ownership transfer even more visible, lets pass the definition as
a double pointer and use g_steal_pointer().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agovirStoragePoolObjListAdd: Transfer definition ownership
Michal Privoznik [Tue, 23 Nov 2021 16:09:59 +0000 (17:09 +0100)]
virStoragePoolObjListAdd: Transfer definition ownership

Upon successful return from virStoragePoolObjListAdd() the
virStoragePoolObj is the owner of secret definition. To make this
ownership transfer even more visible, lets pass the definition as
a double pointer and use g_steal_pointer().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agovirSecretObjListAdd: Transfer definition ownership
Michal Privoznik [Tue, 23 Nov 2021 16:03:44 +0000 (17:03 +0100)]
virSecretObjListAdd: Transfer definition ownership

Upon successful return from virSecretObjListAdd() the
virSecretObj is the owner of secret definition. To make this
ownership transfer even more visible, lets pass the definition as
a double pointer and use g_steal_pointer().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agovirInterfaceObjListAssignDef: Transfer definition ownership
Michal Privoznik [Tue, 2 Nov 2021 10:02:27 +0000 (11:02 +0100)]
virInterfaceObjListAssignDef: Transfer definition ownership

Upon successful return from virInterfaceObjListAssignDef() the
virInterfaceObj is the owner of secret definition. To make this
ownership transfer even more visible, lets pass the definition as
a double pointer and use g_steal_pointer().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoutil: fix cache invalidation of swtpm capabilities
Daniel P. Berrangé [Wed, 24 Nov 2021 10:56:02 +0000 (10:56 +0000)]
util: fix cache invalidation of swtpm capabilities

The check for whether the swtpm binary was modified is checking pointers
to the mtime field in two distinct structs, so will always compare
different. This resulted in re-probing swtpm capabilities every time,
as many as 20 times for a single VM launch.

Fixes:

  commit 01cf7a1bb9f1da27ad8bcbaa82c4f7a948c6a793
  Author: Stefan Berger <stefanb@us.ibm.com>
  Date:   Thu Jul 25 14:22:04 2019 -0400

    tpm: Check whether previously found executables were updated

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoci: display installed packages at start of build
Daniel P. Berrangé [Tue, 23 Nov 2021 16:00:17 +0000 (16:00 +0000)]
ci: display installed packages at start of build

When a build fails it is helpful to know what packages were installed,
because by the time we look at the build job output, the original
container image might have changed.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoutil: virExec may blocked by reading pipe if grandchild prematurely exit
Xu Chao [Wed, 24 Nov 2021 02:33:11 +0000 (10:33 +0800)]
util: virExec may blocked by reading pipe if grandchild prematurely exit

When VIR_EXEC_DAEMON is set, if virPidFileAcquirePath/virSetInherit failed,
then pipesync[0] can not be closed when granchild process exit, because
pipesync[1] still opened in child process. and then saferead in child
process may blocked forever, and left grandchild process in defunct state.

Signed-off-by: Xu Chao <xu.chao6@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: xml: Remove virXMLPropStringLimit and virXPathStringLimit
Peter Krempa [Mon, 22 Nov 2021 16:44:49 +0000 (17:44 +0100)]
util: xml: Remove virXMLPropStringLimit and virXPathStringLimit

The functions have very difficult semantics where callers are not able
to tell whether the property is missing or failed the length check. Only
the latter produces errors.

Since usage of the functions was phased out, remove them completely to
avoid further broken code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirSecurityLabelDefParseXML: Don't use virXMLPropStringLimit
Peter Krempa [Mon, 22 Nov 2021 16:43:13 +0000 (17:43 +0100)]
virSecurityLabelDefParseXML: Don't use virXMLPropStringLimit

The function produces an error which is ignored in this code path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirSecurityDeviceLabelDefParseXML: Don't use 'virXPathStringLimit'
Peter Krempa [Mon, 22 Nov 2021 16:26:40 +0000 (17:26 +0100)]
virSecurityDeviceLabelDefParseXML: Don't use 'virXPathStringLimit'

virXPathStringLimit doesn't give callers a way to differentiate between
the queried XPath being empty and the length limit being exceeded.

This means that the callers is completely ignoring the error.

Move the length check into the caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirSecurityDeviceLabelDefParseXML: Use automatic memory clearing for temp strings
Peter Krempa [Mon, 22 Nov 2021 16:34:36 +0000 (17:34 +0100)]
virSecurityDeviceLabelDefParseXML: Use automatic memory clearing for temp strings

Apart from code simplification the refactor of 'model' fixes an unlikely
memory leak of the string if a duplicate model is found.

While the coversion of 'label' variable may seem unnecessary it will
come in handy in the next patch.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirSecurityLabelDefParseXML: Don't use 'virXPathStringLimit'
Peter Krempa [Mon, 22 Nov 2021 16:26:40 +0000 (17:26 +0100)]
virSecurityLabelDefParseXML: Don't use 'virXPathStringLimit'

virXPathStringLimit doesn't give callers a way to differentiate between
the queried XPath being empty and the length limit being exceeded.

This means that callers are either overwriting the error message or
ignoring it altogether.

Move the length checks into the caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>