]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agosrc: Fix memory leak in virNWFilterBindingDispose
John Ferlan [Fri, 20 Jul 2018 14:58:45 +0000 (10:58 -0400)]
src: Fix memory leak in virNWFilterBindingDispose

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

Commit b57a9aec neglected to VIR_FREE(binding->filtername) as seen
in the following valgrind report

==6423== 17,328 bytes in 1,083 blocks are definitely lost in loss record 2,275 of 2,297
==6423==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
==6423==    by 0x83B20C9: strdup (in /usr/lib64/libc-2.17.so)
==6423==    by 0x533C144: virStrdup (virstring.c:977)
==6423==    by 0x54BDD53: virGetNWFilterBinding (datatypes.c:865)
==6423==    by 0x318D633C: nwfilterBindingCreateXML (nwfilter_driver.c:767)
==6423==    by 0x54F3FC5: virNWFilterBindingCreateXML (libvirt-nwfilter.c:701)
==6423==    by 0x539CE29: virDomainConfNWFilterInstantiate (domain_nwfilter.c:116)
==6423==    by 0x31E516C2: qemuInterfaceBridgeConnect (qemu_interface.c:589)
==6423==    by 0x31D98B56: qemuBuildInterfaceCommandLine (qemu_command.c:8418)
==6423==    by 0x31D9F783: qemuBuildNetCommandLine (qemu_command.c:8673)
==6423==    by 0x31D9F783: qemuBuildCommandLine (qemu_command.c:10354)
==6423==    by 0x31DE355F: qemuProcessLaunch (qemu_process.c:6292)
==6423==    by 0x31DE7881: qemuProcessStart (qemu_process.c:6686)

and

==6423== 17,328 bytes in 1,083 blocks are definitely lost in loss record 2,276 of 2,297
==6423==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
==6423==    by 0x83B20C9: strdup (in /usr/lib64/libc-2.17.so)
==6423==    by 0x533C144: virStrdup (virstring.c:977)
==6423==    by 0x54BDD53: virGetNWFilterBinding (datatypes.c:865)
==6423==    by 0x318D641F: nwfilterBindingLookupByPortDev (nwfilter_driver.c:678)
==6423==    by 0x54F3B63: virNWFilterBindingLookupByPortDev (libvirt-nwfilter.c:593)
==6423==    by 0x539CBC5: virDomainConfNWFilterTeardownImpl.isra.0 (domain_nwfilter.c:136)
==6423==    by 0x539CFA5: virDomainConfVMNWFilterTeardown (domain_nwfilter.c:170)
==6423==    by 0x31DE5651: qemuProcessStop (qemu_process.c:6912)
==6423==    by 0x31E37974: qemuDomainDestroyFlags (qemu_driver.c:2229)
==6423==    by 0x54C24BB: virDomainDestroy (libvirt-domain.c:475)
==6423==    by 0x1589A2: remoteDispatchDomainDestroy (remote_daemon_dispatch_stubs.h:4827)
==6423==    by 0x1589A2: remoteDispatchDomainDestroyHelper (remote_daemon_dispatch_stubs.h:4803)

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agorpc: Fix name of include guard
Marc Hartmayer [Tue, 3 Jul 2018 11:37:38 +0000 (13:37 +0200)]
rpc: Fix name of include guard

The include guard should match the file name and comment.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirt-admin: Fix two error messages
Marc Hartmayer [Tue, 3 Jul 2018 11:37:37 +0000 (13:37 +0200)]
virt-admin: Fix two error messages

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agodaemon: Raise an error if 'max_workers' < 1 in libvirtd.conf
Marc Hartmayer [Tue, 3 Jul 2018 11:37:36 +0000 (13:37 +0200)]
daemon: Raise an error if 'max_workers' < 1 in libvirtd.conf

Hypervisor drivers (e.g. QEMU) assume that they run in a separate
thread from the main event loop thread otherwise deadlocks can
occur. Therefore let's report an error if max_workers < 1 is set in
the libvirtd configuration file.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirThreadPool: Prevent switching between zero and non-zero maxWorkers
Marc Hartmayer [Tue, 3 Jul 2018 11:37:35 +0000 (13:37 +0200)]
virThreadPool: Prevent switching between zero and non-zero maxWorkers

...since maxWorkers=0 is only intended for virtlockd or virlogd which
must not be multithreaded.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agorpc: Fix deadlock if there is no worker pool available
Marc Hartmayer [Tue, 3 Jul 2018 11:37:33 +0000 (13:37 +0200)]
rpc: Fix deadlock if there is no worker pool available

@srv must be unlocked for the call virNetServerProcessMsg otherwise a
deadlock can occur.

Since the pointer 'srv->workers' will never be changed after
initialization and the thread pool has it's own locking we can release
the lock of 'srv' earlier. This also fixes the deadlock.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Replace qemuDomainDiskSourceDiffers by virStorageSourceIsSameLocation
Peter Krempa [Wed, 18 Jul 2018 15:11:50 +0000 (17:11 +0200)]
qemu: Replace qemuDomainDiskSourceDiffers by virStorageSourceIsSameLocation

Now that we have a saner replacement for checking if the disk source is
the same use it instead of formatting qemu command-line chunks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutils: storage: Add helper for checking if storage source is the same
Peter Krempa [Fri, 13 Jul 2018 15:25:33 +0000 (17:25 +0200)]
utils: storage: Add helper for checking if storage source is the same

To allow checking whether a storage source points to the same location
add a helper which checks the relevant fields. This will allow replacing
a similar check done by formatting the command line arguments for
qemu-like syntax.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Split out code to gather data from 'query-block'
Peter Krempa [Wed, 20 Jun 2018 08:43:07 +0000 (10:43 +0200)]
qemu: monitor: Split out code to gather data from 'query-block'

Extract the code for future reuse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: json: Extract gathering of block statistics
Peter Krempa [Mon, 31 Jul 2017 12:35:45 +0000 (14:35 +0200)]
qemu: json: Extract gathering of block statistics

The code is useful also when gathering statistics per node name, so
extract it to a separate functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Add the 'query-nodes' argument for query-blockstats
Peter Krempa [Fri, 15 Jun 2018 12:55:19 +0000 (14:55 +0200)]
qemu: monitor: Add the 'query-nodes' argument for query-blockstats

The 'query-blockstats' command does not return statistics for the
explicitly named nodes unless the new argument is specified. Add
infrastrucuture that will allow us to use the new approach if desired.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: command: use qemuDomainDiskGetBackendAlias in commandline building
Peter Krempa [Tue, 26 Jun 2018 05:32:28 +0000 (07:32 +0200)]
qemu: command: use qemuDomainDiskGetBackendAlias in commandline building

Use the proper backend for the block device both when using -drive and
when -blockdev will be used for disk drives and floppy disks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: domain: Add helper for getting the disk backend alias
Peter Krempa [Tue, 26 Jun 2018 04:58:47 +0000 (06:58 +0200)]
qemu: domain: Add helper for getting the disk backend alias

The disk backend alias was historically the alias of the -drive backing
the storage. For setups with -blockdev this will become more complex as
it will depend on other configs and generally will differ.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: domain: Move out clearing of backing chain in qemuDomainDetermineDiskChain
Peter Krempa [Tue, 24 Apr 2018 12:07:22 +0000 (14:07 +0200)]
qemu: domain: Move out clearing of backing chain in qemuDomainDetermineDiskChain

In some cases backing chain needs to be cleared prior to re-detection.
Move this step out of qemuDomainDetermineDiskChain as only certain
places need it and the function itself is able to skip to the end of the
chain to perform detection.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: driver: Reuse qemuDomainBlocksStatsGather in qemuDomainGetBlockInfo
Peter Krempa [Mon, 18 Jun 2018 11:06:53 +0000 (13:06 +0200)]
qemu: driver: Reuse qemuDomainBlocksStatsGather in qemuDomainGetBlockInfo

Allow updating capacity for the block devices returned by
qemuDomainBlocksStatsGather and replace the open-coded call to
qemuMonitorGetAllBlockStatsInfo by the helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutils: storage: Add copying of PR definition to virStorageSource
Peter Krempa [Fri, 13 Jul 2018 14:19:38 +0000 (16:19 +0200)]
utils: storage: Add copying of PR definition to virStorageSource

Despite the warning that virStorageSourceCopy needs to be populated on
additions to the structure commit 687730540e4 neglected to implement the
copy function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Add/remove managed PR objects on media change
Peter Krempa [Fri, 13 Jul 2018 16:37:43 +0000 (18:37 +0200)]
qemu: hotplug: Add/remove managed PR objects on media change

When changing cdrom media we did not handle the managed PR objects thus
we'd either have a stale PR object left behind or the media change would
fail.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Make qemuHotplugWaitForTrayEject reusable
Peter Krempa [Fri, 13 Jul 2018 15:55:59 +0000 (17:55 +0200)]
qemu: hotplug: Make qemuHotplugWaitForTrayEject reusable

Remove the issue of the monitor command to the caller so that the
function can be used with the modern approach.

Additionally improve the error message.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Extract legacy disk media changing bits
Peter Krempa [Fri, 13 Jul 2018 15:44:32 +0000 (17:44 +0200)]
qemu: hotplug: Extract legacy disk media changing bits

Prepare for the -blockdev implementation of ejectable media changing by
splitting up the old bits.

Additionally since both callers make sure that the device is a cdrom or
floppy the check is no longer necessary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Refactor/simplify PR managed addition to VM
Peter Krempa [Fri, 13 Jul 2018 12:14:17 +0000 (14:14 +0200)]
qemu: hotplug: Refactor/simplify PR managed addition to VM

Similarly to qemuDomainDiskRemoveManagedPR make it enter monitor on
its own so that it can be reused. Future users will be in the snapshot
code and in removable media change code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Simplify removal of managed PR infrastructure on unplug
Peter Krempa [Wed, 11 Jul 2018 12:24:49 +0000 (14:24 +0200)]
qemu: hotplug: Simplify removal of managed PR infrastructure on unplug

Extract the (possible) removal of the PR backend and daemon into a
separate helper which enters monitor on its own. This simplifies the
code and allows reuse of this function in the future e.g. for blockjobs
where removing a image with PR may result into PR not being necessary.

Since the PR is not used often the overhead of entering monitor again
should be negligible.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Reuse qemuHotplugDiskSourceRemove for disk backend removal
Peter Krempa [Wed, 11 Jul 2018 09:16:41 +0000 (11:16 +0200)]
qemu: hotplug: Reuse qemuHotplugDiskSourceRemove for disk backend removal

Add code which will convert a disk definition into
qemuHotplugDiskSourceData and then reuse qemuHotplugDiskSourceRemove to
remove all the backend related objects.

This unifies the detach code as much as possible with the already
existing helpers and will allow reuse this infrastructure when changing
removable disk media.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Don't leak 'disk' if VM crashes during unplug finishing
Peter Krempa [Fri, 13 Jul 2018 10:54:26 +0000 (12:54 +0200)]
qemu: hotplug: Don't leak 'disk' if VM crashes during unplug finishing

qemuDomainRemoveDiskDevice would leak the disk to be removed if the VM
crashed since it was removed from the definition but not freed.

Broken in commit 105bcdde76b which moved the removal from the definition
earlier.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Prepare for multiple backing chain member hotplug
Peter Krempa [Wed, 11 Jul 2018 16:26:12 +0000 (18:26 +0200)]
qemu: hotplug: Prepare for multiple backing chain member hotplug

Similarly to how we've intergrated data belonging to a single
virStorageSource for purposes of attaching it to a qemu instance we will
need to agregate data relevant for the whole disk. With blockdev there
will be some disk-wide backing chain members such as the copy-on-read
handler.

Introduce qemuHotplugDiskSourceData which agregates the backing chain
and other data relevant for the disk and functions which generate it
and apply and rollback it.

In addition to disk hotplug this will also be reused for media changing
where we need to exchange the full disk backend.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Don't format NULL in %s in qemuHotplugPrepareDiskAccess
Peter Krempa [Wed, 11 Jul 2018 15:30:19 +0000 (17:30 +0200)]
qemu: hotplug: Don't format NULL in %s in qemuHotplugPrepareDiskAccess

The warning messages which include the disk source could potentially
format NULL using %s as virDomainDiskGetSource may return NULL for e.g.
NBD disks. As most of the APIs are NOOP for remote disks the usage of
the source string only should be fine for now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Remove pointless variable
Peter Krempa [Wed, 11 Jul 2018 15:25:19 +0000 (17:25 +0200)]
qemu: hotplug: Remove pointless variable

Now that there's only one use of it, replace it directly by the code
filling it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Reuse qemuHotplugPrepareDiskAccess in qemuDomainRemoveDiskDevice
Peter Krempa [Wed, 11 Jul 2018 15:21:36 +0000 (17:21 +0200)]
qemu: hotplug: Reuse qemuHotplugPrepareDiskAccess in qemuDomainRemoveDiskDevice

qemuHotplugPrepareDiskAccess can be used to tear down disk access so we
can replace the open-coded version collecting the same function calls.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotools: Fix typo generating adapter_wwpn field
John Ferlan [Thu, 19 Jul 2018 18:00:07 +0000 (14:00 -0400)]
tools: Fix typo generating adapter_wwpn field

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

Fix typo from commit id d45bee449 for the parent_wwpn field
resulting in parent_wwnn being printed twice.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: monitor: Remove old code for dual handling of 'transaction' data
Peter Krempa [Tue, 3 Jul 2018 12:21:56 +0000 (14:21 +0200)]
qemu: monitor: Remove old code for dual handling of 'transaction' data

Now that we use only the separate function for creating data for the
'transaction' command we can remove all the boilerplate which was
necessary before.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Remove old external snapshot code
Peter Krempa [Tue, 3 Jul 2018 12:16:27 +0000 (14:16 +0200)]
qemu: monitor: Remove old external snapshot code

Remove the dual mode code which allowed to create snapshots without
support for 'transaction'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: block: Create helper for creating data for legacy snapshots
Peter Krempa [Tue, 3 Jul 2018 12:13:29 +0000 (14:13 +0200)]
qemu: block: Create helper for creating data for legacy snapshots

With 'transaction' support we don't need to keep around the multipurpose
code which would create the snapshot if 'transaction' is not supported.

To simplify this add a new helper that just wraps the arguments for
'blockdev-snapshot-sync' operation in 'transaction' and use it instead
of qemuBlockSnapshotAddLegacy.

Additionally this allows to format the arguments prior to creating the
file for simpler cleanup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Add API to help creating 'transaction' arguments
Peter Krempa [Tue, 3 Jul 2018 07:24:40 +0000 (09:24 +0200)]
qemu: monitor: Add API to help creating 'transaction' arguments

Add a new helper that will be solely used to create arguments for the
transaction command. Later on this will make it possible to remove the
overloading which was caused by the fact that snapshots were created
without transaction and also will help in blockdevification of snapshots.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: snapshot: Audit actual disk snapshot creation
Peter Krempa [Tue, 3 Jul 2018 05:58:48 +0000 (07:58 +0200)]
qemu: snapshot: Audit actual disk snapshot creation

Currently we'd audit that we managed to format the data for the
'transaction' command rather than the (un)successful attempt to create
the snapshot.

Move the auditing code so that it can actually audit the result of the
'transaction' command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: snapshot: Unify conditions checking whether snapshot needs to be taken
Peter Krempa [Tue, 3 Jul 2018 05:52:11 +0000 (07:52 +0200)]
qemu: snapshot: Unify conditions checking whether snapshot needs to be taken

In the cleanup path we already checked whether a snapshot needed to be
taken by looking into the collected data. Use the same approach when
creating the snapshot command data and when committing the changes to the
domain definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: snapshot: Remove monitor code now that 'transaction' is always used
Peter Krempa [Tue, 5 Jun 2018 12:56:01 +0000 (14:56 +0200)]
qemu: snapshot: Remove monitor code now that 'transaction' is always used

Since we now always do the snapshot via the 'transaction' command we can
drop the code which would enter monitor for individual disk snapshots.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: snapshot: Require support of 'transaction' command for external snapshots
Peter Krempa [Tue, 3 Jul 2018 05:17:29 +0000 (07:17 +0200)]
qemu: snapshot: Require support of 'transaction' command for external snapshots

While qemu supports the 'transaction' command since v1.1.0
(52e7c241ac766406f05fa) and the 'blockdev-snapshot-sync' command since
v0.14.0-rc0 we need to keep the capability bits present since some qemu
downstreams (RHEL/CentOS 7 for example) chose to cripple qemu by
arbitrarily compiling out some stuff which was already present at that
time.

To simplify the crazy code just require both commands to be present at
the beginning of an external snapshot so that we can remove the case when
'transaction' would not be supported.

This also allows to drop any logic connected to the
VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC flag since snapshots are atomic with
the 'transaction' command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agovirt-xml-validate: Add schema for nwfilterbinding
Han Han [Fri, 13 Jul 2018 01:39:29 +0000 (09:39 +0800)]
virt-xml-validate: Add schema for nwfilterbinding

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

Add nwfilterbinding schema in virt-xml-validate for autoprobing.
Add document of nwfilterbinding schema in tools/virt-xml-validate.pod.

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agobuild: Fix accidental revert of .gnulib update
John Ferlan [Thu, 19 Jul 2018 19:48:34 +0000 (15:48 -0400)]
build: Fix accidental revert of .gnulib update

Commit id 1bff5bbe25eb7a7e7a4e0067c4ca7cbc1cb34999 accidentally
reverted .gnulib back to d6397dde2e127e246e3eeb5254a21f42cac783c8
which was two updates ago.

Update to the latest 68df637b5f1b5c10370f6981d2a43a5cf74368df
which includes three changes since the previous fetch of
cdbf3d385a32ff904c96f20c26f3470bd8345248.

> autoupdate
> hard-locale: simplify by removing hard-locale.m4
> gnulib-tool: limit line length for git send-email

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agotest: Implement virConnectListAllInterfaces
Cole Robinson [Tue, 10 Jul 2018 19:01:45 +0000 (15:01 -0400)]
test: Implement virConnectListAllInterfaces

This adds some generic virinterfaceobj code, roughly matching what
is used by other stateful drivers like network, storage, etc.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Fix broken autostart symlink after renaming domain
Julio Faracco [Thu, 19 Jul 2018 04:21:48 +0000 (01:21 -0300)]
qemu: Fix broken autostart symlink after renaming domain

If a domain is configured to start on boot, it has a symlink to the
domain definition inside the autostart directory. If you rename this
domain, the definition is renamed too. The symlink need to be pointed to
this renamed file. This commit recreates the symlink after renaming the
XML file.

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

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: set OOM in virCopyLastError if error is not set
Nikolay Shirokovskiy [Mon, 2 Jul 2018 11:16:52 +0000 (14:16 +0300)]
util: set OOM in virCopyLastError if error is not set

virCopyLastError is intended to be used after last error is set.
However due to virLastErrorObject failures (very unlikely though
as thread local error is allocated on first use) we can have zero
fields in a copy as a result. In particular code field can be set
to VIR_ERR_OK.

In some places (qemu monitor, qemu agent and qemu migaration code
for example) we use copy result as a flag and this leads to bugs.

Let's set OOM-like error in copy in case of virLastErrorObject failures.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agolocking: don't create qemu-sanlock.conf file when QEMU isn't enabled
Daniel P. Berrangé [Wed, 18 Jul 2018 16:59:51 +0000 (17:59 +0100)]
locking: don't create qemu-sanlock.conf file when QEMU isn't enabled

The test targets result in the qemu-sanlock.conf file being created
when sanlock is enabled, even if QEMU is not enabled. As a result it
never gets cleaned up when distclean is run, breaking distcheck.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agodocs: news: Provide an update about the video type 'none'
Erik Skultety [Thu, 12 Jul 2018 14:52:44 +0000 (16:52 +0200)]
docs: news: Provide an update about the video type 'none'

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Introduce new video type 'none'
Erik Skultety [Mon, 21 May 2018 12:29:26 +0000 (14:29 +0200)]
conf: Introduce new video type 'none'

Historically, we've always enabled an emulated video device every time we
see that graphics should be supported with a guest. With the appearance
of mediated devices which can support QEMU's vfio-display capability,
users might want to use such a device as the only video device.
Therefore introduce a new, effectively a 'disable', type for video
device.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agodocs: Rephrase the mediated devices hostdev section a bit
Erik Skultety [Thu, 12 Jul 2018 08:57:12 +0000 (10:57 +0200)]
docs: Rephrase the mediated devices hostdev section a bit

Currently it reads:
Refer MDEV to create a mediated device on the host

...even though it resembles English, it's not a proper English.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agodocs: Update news about the VNC console enablement for mdevs
Erik Skultety [Mon, 9 Jul 2018 13:12:50 +0000 (15:12 +0200)]
docs: Update news about the VNC console enablement for mdevs

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: command: Enable formatting vfio-pci.display option onto cmdline
Erik Skultety [Fri, 25 May 2018 13:55:42 +0000 (15:55 +0200)]
qemu: command: Enable formatting vfio-pci.display option onto cmdline

Since QEMU 2.12, QEMU understands a new vfio-pci device option 'display'
which can be used to turn on display capabilities on vgpu-enabled
mediated devices, IOW emulated GPU devices like QXL will no longer be
needed with vgpu-enable mdevs.
QEMU defaults to 'auto' for the 'display' attribute, which is not
foolproof, so we need to play it safe here and default to display='off'
if this attribute wasn't provided in the XML explicitly.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Introduce new <hostdev> attribute 'display'
Erik Skultety [Thu, 24 May 2018 14:04:26 +0000 (16:04 +0200)]
conf: Introduce new <hostdev> attribute 'display'

QEMU 2.12 introduced a new type of display for mediated devices using
vfio-pci backend which allows a mediated device to be used as a VGA
compatible device as an alternative to an emulated video device. QEMU
exposes this feature via a vfio device property 'display' with supported
values 'on/off/auto' (libvirt will default to 'off').

This patch adds the necessary bits to domain config handling in order to
expose this feature. Since there's no convenient way for libvirt to come
up with usable defaults for the display setting, simply because libvirt
is not able to figure out which of the display implementations - dma-buf
which requires OpenGL support vs vfio regions which doesn't need OpenGL
(works with OpenGL enabled too) - the underlying mdev uses.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Replace 'error' with 'cleanup' in virDomainHostdevDefParseXMLSubsys
Erik Skultety [Wed, 11 Jul 2018 11:09:51 +0000 (13:09 +0200)]
conf: Replace 'error' with 'cleanup' in virDomainHostdevDefParseXMLSubsys

The exit path is the same for both success and failure, so the label
should be called cleanup.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainGraphicsDefHasOpenGL helper
Erik Skultety [Sat, 30 Jun 2018 16:20:33 +0000 (18:20 +0200)]
conf: Introduce virDomainGraphicsDefHasOpenGL helper

A simple helper which will loop through all the graphics elements and
checks whether at least one of them enables OpenGL support, either by
containing <gl enable='yes'/> or being of type 'egl-headless'.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: caps: Add vfio-pci.display capability
Erik Skultety [Thu, 24 May 2018 15:27:33 +0000 (17:27 +0200)]
qemu: caps: Add vfio-pci.display capability

QEMU 2.12 introduced a new vfio-pci device option 'display=on/off/auto'.
This patch introduces the necessary capability.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Introduce a new graphics display type 'headless'
Erik Skultety [Sat, 30 Jun 2018 14:23:01 +0000 (16:23 +0200)]
qemu: Introduce a new graphics display type 'headless'

Since 2.10 QEMU supports a new display type egl-headless which uses the
drm nodes for OpenGL rendering copying back the rendered bits back to
QEMU into a dma-buf which can be accessed by standard "display" apps
like VNC or SPICE. Although this display type can be used on its own,
for any practical use case it makes sense to pair it with either VNC or
SPICE display. The clear benefit of this display is that VNC gains
OpenGL support, which it natively doesn't have, and SPICE gains remote
OpenGL support (native OpenGL support only works locally through a UNIX
socket, i.e. listen type=socket/none).

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: caps: Introduce a capability for egl-headless
Erik Skultety [Sat, 30 Jun 2018 14:16:24 +0000 (16:16 +0200)]
qemu: caps: Introduce a capability for egl-headless

Since QEMU 2.10, it's possible to use a new type of display -
egl-headless which uses drm nodes to provide OpenGL support. This patch
adds a capability for that. However, since QEMU doesn't provide a QMP
command to probe it, we have to base the capability on specific QEMU
version.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoqemu: qemuBuildHostdevCommandLine: Use a helper variable mdevsrc
Erik Skultety [Wed, 18 Jul 2018 12:07:39 +0000 (14:07 +0200)]
qemu: qemuBuildHostdevCommandLine: Use a helper variable mdevsrc

Decrease the number of accessors we have to use.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agom4: Introduce STABLE_ORDERING_JANSSON
Ján Tomko [Tue, 3 Jul 2018 14:46:04 +0000 (16:46 +0200)]
m4: Introduce STABLE_ORDERING_JANSSON

Add a second check for Jansson >= 2.8, which includes
fixes to preserve ordering of object keys.

Use this constant to guard tests that depend on stable ordering.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agobuild: require Jansson if QEMU driver is enabled
Ján Tomko [Fri, 11 May 2018 12:27:02 +0000 (14:27 +0200)]
build: require Jansson if QEMU driver is enabled

If the QEMU driver was requested, require Jansson, since we need to use
the JSON monitor to probe capabilities for all QEMU version supported
by libvirt.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agobuild: switch --with-qemu default from yes to check
Ján Tomko [Fri, 11 May 2018 12:25:33 +0000 (14:25 +0200)]
build: switch --with-qemu default from yes to check

Unless explicitly requested, enable the QEMU driver
only if the Jansson library is present.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoRemove virJSONValueNewStringLen
Ján Tomko [Tue, 15 May 2018 12:16:27 +0000 (14:16 +0200)]
Remove virJSONValueNewStringLen

It is no longer used.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agobuild: remove references to WITH_YAJL for SETUID_RPC_CLIENT
Ján Tomko [Fri, 11 May 2018 12:45:43 +0000 (14:45 +0200)]
build: remove references to WITH_YAJL for SETUID_RPC_CLIENT

We no longer allow building WITH_YAJL, remove the remaining
uses of the macro.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoRemove functions using yajl
Ján Tomko [Fri, 11 May 2018 11:59:47 +0000 (13:59 +0200)]
Remove functions using yajl

We no longer support building WITH_YAJL, remove the dead code
as well as the virJSONParser structures that are no longer used.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoSwitch from yajl to Jansson
Ján Tomko [Wed, 2 May 2018 15:17:01 +0000 (17:17 +0200)]
Switch from yajl to Jansson

Yajl has not seen much activity upstream recently.
Switch to using Jansson >= 2.5.

All the platforms we target on https://libvirt.org/platforms.html
have a version >= 2.7 listed on the sites below:
https://repology.org/metapackage/jansson/versions
https://build.opensuse.org/package/show/devel:libraries:c_c++/libjansson

Additionally, Ubuntu 14.04 on Travis-CI has 2.5. Set the requirement
to 2.5 since we don't use anything from newer versions.

Implement virJSONValue{From,To}String using Jansson, delete the yajl
code (and the related virJSONParser structure) and report an error
if someone explicitly specifies --with-yajl.

Also adjust the test data to account for Jansson's different whitespace
usage for empty arrays and tune up the specfile to keep 'make rpm'
working when bisecting.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agobuild: undef WITH_JANSSON for SETUID_RPC_CLIENT
Ján Tomko [Wed, 9 May 2018 12:32:05 +0000 (14:32 +0200)]
build: undef WITH_JANSSON for SETUID_RPC_CLIENT

There is no code using WITH_JANSSON yet, but once we add it,
it should not be compiled for the setuid_rpc_client.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agobuild: add --with-jansson
Ján Tomko [Wed, 2 May 2018 15:16:46 +0000 (17:16 +0200)]
build: add --with-jansson

Introduce the configure argument and check for Jansson >= 2.5

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: vnc: switch to tls-creds-x509
Ján Tomko [Tue, 17 Jul 2018 13:10:23 +0000 (15:10 +0200)]
qemu: vnc: switch to tls-creds-x509

The tls, x509 and x509verify options were deprecated in QEMU v2.5.0:

commit 3e305e4a4752f70c0b5c3cf5b43ec957881714f7
Author:     Daniel P. Berrange <berrange@redhat.com>

    ui: convert VNC server to use QCryptoTLSSession

Use the tls-creds-x509 object when available.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemu: test more versions for graphics-vnc-tls
Ján Tomko [Mon, 16 Jul 2018 13:15:21 +0000 (15:15 +0200)]
tests: qemu: test more versions for graphics-vnc-tls

Add a test with QEMU 2.4.0 capabilites, as well as the latest caps.

The code paths for formatting TLS options will be altered and
2.4.0 is the newest version where QEMU_CAPS_OBJECT_TLS_CREDS_X509
is not supported.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agodocs: formatdomain: unify naming for CPUs/vCPUs
Katerina Koukiou [Wed, 18 Jul 2018 09:52:42 +0000 (11:52 +0200)]
docs: formatdomain: unify naming for CPUs/vCPUs

CPU is an acronym and should be written in uppercase
when part of plain text and not refering to an element.

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoexamples: Add clean-traffic-gateway into nwfilters
Ales Musil [Wed, 18 Jul 2018 08:33:03 +0000 (10:33 +0200)]
examples: Add clean-traffic-gateway into nwfilters

The filter purpose is to simulate isolated private VLAN.

The behavior can be achieved by limiting network traffic
to traffic between VM and gateway. Because there is no
concept of the PVLAN in the linux bridge.

The filter also contains parts from clean-traffic
to prevent VM from spoofing its IP and MAC address.

To use this filter the user just needs to set
the GATEWAY_MAC variable to gateway MAC address.

Signed-off-by: Ales Musil <amusil@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 years agotests: qemu: Remove disk from graphics-vnc-tls
Ján Tomko [Mon, 16 Jul 2018 13:37:28 +0000 (15:37 +0200)]
tests: qemu: Remove disk from graphics-vnc-tls

The disk command line is tested elsewhere.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agospec: remove libcgroup and cgconfig
Pavel Hrdina [Wed, 18 Jul 2018 10:29:35 +0000 (12:29 +0200)]
spec: remove libcgroup and cgconfig

RHEL-6/CentOS-6 is no longer supported, let's remove dependency on
libcgroup and code that enables/starts cgconfig service.

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

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agodocs: formatdomain: clarify period cputune subelement
Katerina Koukiou [Wed, 18 Jul 2018 09:34:12 +0000 (11:34 +0200)]
docs: formatdomain: clarify period cputune subelement

Although the name of the element is not self-explanatory,
it's affecting only the vcpu threads.

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agodocs: formatdomain: add info about global_period and global_quota for cputune
Katerina Koukiou [Tue, 17 Jul 2018 15:20:05 +0000 (17:20 +0200)]
docs: formatdomain: add info about global_period and global_quota for cputune

Commit 4d92d5 and 55ecda introduced the parameters but didn't update the docs.

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agotest: Implement virConnectListAllNodeDevices
Cole Robinson [Fri, 23 Feb 2018 20:08:46 +0000 (15:08 -0500)]
test: Implement virConnectListAllNodeDevices

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: nodedev: Don't refresh host caps in testdriver
Cole Robinson [Fri, 23 Feb 2018 23:09:20 +0000 (18:09 -0500)]
conf: nodedev: Don't refresh host caps in testdriver

Add a 'skipUpdateCaps' bool that we set for test_driver.c nodedevs
which will skip accessing host resources via virNodeDeviceUpdateCaps

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoAUTHORS: Add Katerina Koukiou
Ján Tomko [Mon, 16 Jul 2018 14:31:53 +0000 (16:31 +0200)]
AUTHORS: Add Katerina Koukiou

$ git log --format=oneline --committer=kkoukiou | wc -l
3

Also set up the mailmap entry to avoid duplicates in the
generated authors file.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agotests: Update capabilities data for QEMU 3.0.0 x86_64
Erik Skultety [Mon, 16 Jul 2018 14:33:20 +0000 (16:33 +0200)]
tests: Update capabilities data for QEMU 3.0.0 x86_64

The original capabilities didn't include a patched kernel for spectre,
SPICE gl support and had xen support enabled which we already have
dropped.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agotests: Add capabilities data for QEMU 2.11 x86_64
Erik Skultety [Mon, 16 Jul 2018 14:48:39 +0000 (16:48 +0200)]
tests: Add capabilities data for QEMU 2.11 x86_64

We were missing these for x86_64 arch, so this is just for completeness.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoUpdate to latest gnulib to fix ffs() detection on mingw
Daniel P. Berrangé [Tue, 17 Jul 2018 09:27:14 +0000 (10:27 +0100)]
Update to latest gnulib to fix ffs() detection on mingw

ffs() was not correctly detected on mingw with previous gnulib rebase:

  https://lists.gnu.org/archive/html/bug-gnulib/2018-07/msg00061.html.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: Add entry for balloon stat stat-disk-caches
Tomáš Golembiovský [Mon, 2 Jul 2018 11:19:42 +0000 (13:19 +0200)]
qemu: Add entry for balloon stat stat-disk-caches

QEMU commit bf1e7140e adds reporting of new balloon statistic to QEMU
2.12. Value represents the amount of memory that can be quickly
reclaimed without additional I/O. Let's add that too.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Fix setting global_period cputune element
Katerina Koukiou [Mon, 16 Jul 2018 13:08:44 +0000 (15:08 +0200)]
qemu: Fix setting global_period cputune element

When VIR_DOMAIN_SCHEDULER_GLOBAL_PERIOD is matched "cputune.global_period"
should be updated and not "cputune.period".

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1600427
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Drop virArgvToString()
Andrea Bolognani [Mon, 16 Jul 2018 10:51:12 +0000 (12:51 +0200)]
util: Drop virArgvToString()

The last use has been removed in 026ae4933c6a.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Remove ATTRIBUTE_NONNULL from virNetDevTapInterfaceStats
John Ferlan [Sun, 15 Jul 2018 12:39:25 +0000 (08:39 -0400)]
util: Remove ATTRIBUTE_NONNULL from virNetDevTapInterfaceStats

Commit id 318d54e520 altered the code to check for a NULL
first parameter, but neglected to alter the prototype.

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: hotplug: report error when changing rom enabled attr for net iface
Katerina Koukiou [Fri, 13 Jul 2018 13:07:58 +0000 (15:07 +0200)]
qemu: hotplug: report error when changing rom enabled attr for net iface

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

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: don't overwrite error message in qemuDomainAttachNetDevice
Katerina Koukiou [Fri, 13 Jul 2018 15:01:44 +0000 (17:01 +0200)]
qemu: hotplug: don't overwrite error message in qemuDomainAttachNetDevice

Since commit f14c37, virDomainConfVMNWFilterTeardown is reporting errors
thus any previously reported error gets overwritten.
We need to save the errors in qemuDomainAttachNetDevice before calling
this function when we are in cleanup code.

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

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agovirmodule: Fix virModuleLoad stub
Michal Privoznik [Sun, 15 Jul 2018 10:09:09 +0000 (12:09 +0200)]
virmodule: Fix virModuleLoad stub

When building without dlfcn.h we are providing a virModuleLoad()
stub which is supposed to report an error. However, the format
string in virReportSystemError() call there requires two strings
but we are passing just one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoutil: remove unused variable inside virFileReadValueString().
Julio Faracco [Sat, 14 Jul 2018 16:14:06 +0000 (13:14 -0300)]
util: remove unused variable inside virFileReadValueString().

The commit 69b937f0358 introduced VIR_AUTOFREE and this macro removed
VIR_FREE. This change showed that 'str' variable was not being used
inside this method. This commit removes this unused variable.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
6 years agoutil: identity: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:55:09 +0000 (23:25 +0530)]
util: identity: use VIR_AUTOFREE instead of VIR_FREE for scalar types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: filecache: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:55:08 +0000 (23:25 +0530)]
util: filecache: use VIR_AUTOFREE instead of VIR_FREE for scalar types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: eventpoll: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:55:07 +0000 (23:25 +0530)]
util: eventpoll: use VIR_AUTOFREE instead of VIR_FREE for scalar types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: fcp: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:55:06 +0000 (23:25 +0530)]
util: fcp: use VIR_AUTOFREE instead of VIR_FREE for scalar types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: audit: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:55:05 +0000 (23:25 +0530)]
util: audit: use VIR_AUTOFREE instead of VIR_FREE for scalar types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: arptable: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:55:04 +0000 (23:25 +0530)]
util: arptable: use VIR_AUTOFREE instead of VIR_FREE for scalar types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: iohelper: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:55:03 +0000 (23:25 +0530)]
util: iohelper: use VIR_AUTOFREE instead of VIR_FREE for scalar types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: bitmap: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:55:02 +0000 (23:25 +0530)]
util: bitmap: use VIR_AUTOPTR for aggregate types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: bitmap: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:55:00 +0000 (23:25 +0530)]
util: bitmap: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC

Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in
src/util/viralloc.h, define a new wrapper around an existing
cleanup function which will be called when a variable declared
with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant
viralloc.h include, since that has moved from the source module into the
header.

When a variable of type virBitmapPtr is declared using
VIR_AUTOPTR, the function virBitmapFree will be run
automatically on it when it goes out of scope.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: json: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:54:59 +0000 (23:24 +0530)]
util: json: use VIR_AUTOPTR for aggregate types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: json: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:54:58 +0000 (23:24 +0530)]
util: json: use VIR_AUTOFREE instead of VIR_FREE for scalar types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: json: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:54:56 +0000 (23:24 +0530)]
util: json: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC

Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in
src/util/viralloc.h, define a new wrapper around an existing
cleanup function which will be called when a variable declared
with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant
viralloc.h include, since that has moved from the source module into the
header.

When a variable of type virJSONValuePtr is declared using
VIR_AUTOPTR, the function virJSONValueFree will be run
automatically on it when it goes out of scope.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: auth: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:54:55 +0000 (23:24 +0530)]
util: auth: use VIR_AUTOPTR for aggregate types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: auth: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:54:54 +0000 (23:24 +0530)]
util: auth: use VIR_AUTOFREE instead of VIR_FREE for scalar types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: authconfig: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Fri, 13 Jul 2018 17:54:52 +0000 (23:24 +0530)]
util: authconfig: use VIR_AUTOFREE instead of VIR_FREE for scalar types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>