]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agoutil: iscsi: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:16 +0000 (23:31 +0530)]
util: iscsi: 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 agonews: Update for vhost-vsock-ccw support
Boris Fiuczynski [Mon, 6 Aug 2018 15:41:08 +0000 (17:41 +0200)]
news: Update for vhost-vsock-ccw support

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
6 years agoqemu: Add ccw support for vhost-vsock
Boris Fiuczynski [Mon, 6 Aug 2018 15:41:07 +0000 (17:41 +0200)]
qemu: Add ccw support for vhost-vsock

Add support and tests for vhost-vsock-ccw.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
6 years agotests: qemuxml2argv: add CAPS_ARCH_LATEST macro
Bjoern Walk [Mon, 6 Aug 2018 15:41:06 +0000 (17:41 +0200)]
tests: qemuxml2argv: add CAPS_ARCH_LATEST macro

Testing with the latest capabilities is possible with the x86_64 centric
implemented macro CAPS_LATEST. The new macro CAPS_ARCH_LATEST provides
the user the ability to specify the desired architecture when testing with
the latest capabilities.

Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
6 years agodocs: formatdomain: fix spacing before parentheses
Ján Tomko [Mon, 6 Aug 2018 13:12:09 +0000 (15:12 +0200)]
docs: formatdomain: fix spacing before parentheses

Multiple cputune elements specified microseconds as the unit
without putting a space before the parenthesis.

There were also other occurrences.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Unify data structure for vircaps2xmltest
Andrea Bolognani [Thu, 2 Aug 2018 16:31:03 +0000 (18:31 +0200)]
tests: Unify data structure for vircaps2xmltest

If all we achieve is reducing the depth by one for a single
test case, the additional complexity (not to mention breaking
the principle of least surprise) is not worth it: let's use
simpler, more predictable code instead.

This basically reverts fec6e4c48c9c (with a few adjustments).

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 years agovirrandom: Avoid undefined behaviour in virRandomBits
Michal Privoznik [Thu, 2 Aug 2018 07:29:38 +0000 (09:29 +0200)]
virrandom: Avoid undefined behaviour in virRandomBits

If nbits is 64 (or greater) then shifting 1ULL left is undefined.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agonews: add storage pool iscsi-direct
Clementine Hayat [Tue, 31 Jul 2018 08:44:23 +0000 (10:44 +0200)]
news: add storage pool iscsi-direct

Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agostorage: add findPoolSources to iscsi_direct pool backend
Clementine Hayat [Thu, 2 Aug 2018 08:33:27 +0000 (10:33 +0200)]
storage: add findPoolSources to iscsi_direct pool backend

Change the SetContext function to be able to take the session type in
argument.
Took the function findPoolSources of iscsi backend and wired it to my
function since the formatting is essentially the same.

Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agostorage: Implement iscsi_direct pool backend
Clementine Hayat [Tue, 31 Jul 2018 08:44:22 +0000 (10:44 +0200)]
storage: Implement iscsi_direct pool backend

We need here libiscsi for the storgae pool backend.
For the iscsi-direct storage pool, only checkPool and refreshPool should
be necessary for basic support.
The pool is state-less and just need the informations within the volume
to work.

Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agostorage: Introduce iscsi_direct pool type
Clementine Hayat [Tue, 31 Jul 2018 08:44:21 +0000 (10:44 +0200)]
storage: Introduce iscsi_direct pool type

Introducing the pool as a noop. Integration inside the build
system. Implementation will be in the following commits.

Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoconfigure: Introduce libiscsi in build system
Clementine Hayat [Tue, 31 Jul 2018 08:44:20 +0000 (10:44 +0200)]
configure: Introduce libiscsi in build system

The minimal required version is 1.18.0 because the synchrounous function
needed were introduced here.

Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
6 years agoPost-release version bump to 4.7.0
Michal Privoznik [Mon, 6 Aug 2018 10:23:15 +0000 (12:23 +0200)]
Post-release version bump to 4.7.0

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoFix include for xattr.h
Martin Kletzander [Fri, 3 Aug 2018 14:35:53 +0000 (16:35 +0200)]
Fix include for xattr.h

The proper file that should be included is `sys/xattr.h` as that comes from
`glibc` and not `attr/xattr.h` which ships with the `attr` utility.

We're most probably not the only ones because `attr/xattr.h` added a #warning to
their include resulting in the following compilation errors:

In file included from securityselinuxlabeltest.c:31:0:
/usr/include/attr/xattr.h:5:2: error: #warning "Please change your <attr/xattr.h> includes to <sys/xattr.h>" [-Werror=cpp]
 #warning "Please change your <attr/xattr.h> includes to <sys/xattr.h>"
  ^~~~~~~

In file included from securityselinuxhelper.c:37:0:
/usr/include/attr/xattr.h:5:2: error: #warning "Please change your <attr/xattr.h> includes to <sys/xattr.h>" [-Werror=cpp]
 #warning "Please change your <attr/xattr.h> includes to <sys/xattr.h>"
  ^~~~~~~

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoRelease of libvirt-4.6.0
Daniel Veillard [Mon, 6 Aug 2018 09:38:57 +0000 (11:38 +0200)]
Release of libvirt-4.6.0

* docs/news.xml: updated for release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
6 years agoesx: Fix double-free and freeing static strings in esxDomainSetAutostart
Matthias Bolte [Thu, 2 Aug 2018 15:33:37 +0000 (17:33 +0200)]
esx: Fix double-free and freeing static strings in esxDomainSetAutostart

Since commit ae83e02f3dd7fe99fed5d8159a35b666fafeafd5#l3393 the
newPowerInfo pointer itself is used to track the ownership of the
AutoStartPowerInfo object to make Coverity understand the code better.
This broke the code that unset some members of the AutoStartPowerInfo
object that should not be freed the normal way.

Instead, transfer ownership of the AutoStartPowerInfo object to the
HostAutoStartManagerConfig object before filling in the values that
need special handling. This allows to free the AutoStartPowerInfo
directly without having to deal with the special values, or to let
the old (now restored) logic handle the special values again.

Signed-off-by: Matthias Bolte <matthias.bolte@googlemail.com>
Tested-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: mock virRandomBits to make it endian stable
Daniel P. Berrangé [Thu, 2 Aug 2018 11:32:07 +0000 (12:32 +0100)]
tests: mock virRandomBits to make it endian stable

virRandomBits is implemented in terms of virRandomBytes. Although we
mock virRandomBytes to give a stable value, this is not sufficient to
make virRandomBits give a stable value. The result of virRandomBits will
vary depending on endianness. Thus we mock virRandomBits to return a
stable value directly.

Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Tested-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotests: libxl: Fix a segfault when libxl configuration setup fails
Julio Faracco [Thu, 2 Aug 2018 04:06:39 +0000 (01:06 -0300)]
tests: libxl: Fix a segfault when libxl configuration setup fails

This commit fixes a segmentation fault caused by missing conditional to
check if libxl configuration was properly created by the test. If the
configuration was not properly created, libxlDriverConfigNew() function
will return NULL and cause a segfault at cfg->caps = NULL during the
cleanup.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoviriscsi: Request more random bits for interface name
Michal Privoznik [Wed, 1 Aug 2018 11:35:51 +0000 (13:35 +0200)]
viriscsi: Request more random bits for interface name

In virStorageBackendCreateIfaceIQN() the virRandomBits() is
called in order to use random bits to generate random name for
new interface. However, virAsprintf() is expecting 32 bits and we
are requesting only 30.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Pino Toscano <ptoscano@redhat.com>
6 years agoutil: Don't overflow in virRandomBits
Michal Privoznik [Wed, 1 Aug 2018 11:26:46 +0000 (13:26 +0200)]
util: Don't overflow in virRandomBits

The function is supposed to return up to 64bit long integer. In
order to do that it calls virRandomBytes() to fill the integer
with random bytes and then masks out everything but requested
bits. However, when doing that it shifts 1U and not 1ULL. So
effectively, requesting 32 random bis or more always return 0
which is not random enough.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Pino Toscano <ptoscano@redhat.com>
6 years agoremote: daemon: Make sure that JSON symbols are properly loaded at startup
Peter Krempa [Wed, 1 Aug 2018 10:51:10 +0000 (12:51 +0200)]
remote: daemon: Make sure that JSON symbols are properly loaded at startup

Explicitly call virJSONInitialize at startup of the libvirt daemon so
that we are sure that the symbols in the compat library are properly
loaded. This will prevent any random failure from happening later on
when the daemon would want to use the JSON parser.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
6 years agoutil: jsoncompat: Stub out virJSONInitialize when compiling without jansson
Peter Krempa [Wed, 1 Aug 2018 12:29:24 +0000 (14:29 +0200)]
util: jsoncompat: Stub out virJSONInitialize when compiling without jansson

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
6 years agotests: qemucapsprobe: Fix output after switching to jansson
Peter Krempa [Mon, 30 Jul 2018 14:49:39 +0000 (16:49 +0200)]
tests: qemucapsprobe: Fix output after switching to jansson

Jansson does not put a newline at the end of formatted JSON strings.
This breaks the qemucapsprobe utility as we need to keep the spacing so
that tests work. Add an explicit newline.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Fix incrementing of 'nstats' in qemuMonitorJSONBlockStatsCollectData
Peter Krempa [Wed, 1 Aug 2018 07:15:22 +0000 (09:15 +0200)]
qemu: monitor: Fix incrementing of 'nstats' in qemuMonitorJSONBlockStatsCollectData

commit 8d9ca6cdb3a5 refactored qemuMonitorJSONBlockStatsCollectData so
that the number of stats is passed back via a pointer. The commit failed
to fix the macro which increments the number of stats to increment the
actual pointee.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
6 years agoutil: avoid symbol clash between json libraries
Daniel P. Berrangé [Tue, 31 Jul 2018 14:51:47 +0000 (15:51 +0100)]
util: avoid symbol clash between json libraries

The jansson and json-glib libraries both export symbols with a json_
name prefix and json_object_iter_next() clashes between them.

Unfortunately json-glib is linked in by GTK, so any app using GTK and
libvirt will get a clash, resulting in SEGV. This also affects the NSS
module provided by libvirt

Instead of directly linking to jansson, use dlopen() with the RTLD_LOCAL
flag which allows us to hide the symbols from the application that loads
libvirt or the NSS module.

Some preprocessor black magic and wrapper functions are used to redirect
calls into the dlopen resolved symbols.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agopo: refresh translations from zanata
Daniel P. Berrangé [Tue, 31 Jul 2018 11:34:06 +0000 (12:34 +0100)]
po: refresh translations from zanata

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: Exempt video model 'none' from getting a PCI address on Q35
Erik Skultety [Mon, 30 Jul 2018 14:33:33 +0000 (16:33 +0200)]
qemu: Exempt video model 'none' from getting a PCI address on Q35

Commit d48813e8 made sure we wouldn't get one for i440fx, but not for Q35
machine type. If the primary video didn't get the assumed 0:0:1.0 PCI
address, the evaluation then failed with: "Cannot automatically add a
new PCI bus for a device with connect flags 00"

https://bugzilla.redhat.com/show_bug.cgi?id=1609087
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoRevert "util: cgroup: modify virCgroupFree to take virCgroupPtr"
Michal Privoznik [Mon, 30 Jul 2018 09:06:31 +0000 (11:06 +0200)]
Revert "util: cgroup: modify virCgroupFree to take virCgroupPtr"

This reverts commit 0f80c71822d82465d558d697d3be9af2d21e3675.

Turns out, our code relies on virCgroupFree(&var) setting
var = NULL.

Conflicts:
  src/util/vircgroup.c: context because 94f1855f099445d is not
  reverted.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoRevert "util: cgroup: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC"
Michal Privoznik [Mon, 30 Jul 2018 09:04:26 +0000 (11:04 +0200)]
Revert "util: cgroup: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC"

This reverts commit 4da4a9fe0c0956feefe3d592b4ba2b92b2a9a2f9.

Turns out, our code relies on virCgroupFree(&var) setting
var = NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoRevert "util: cgroup: use VIR_AUTOPTR for aggregate types"
Michal Privoznik [Mon, 30 Jul 2018 09:03:16 +0000 (11:03 +0200)]
Revert "util: cgroup: use VIR_AUTOPTR for aggregate types"

This reverts commit dd47145aaad780cde0f1d67cf6a85737c0292418.

Turns out, our code relies on virCgroupFree(&var) setting
var = NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoutil: clang is failing to compile due to unused variables.
Julio Faracco [Fri, 27 Jul 2018 21:17:34 +0000 (18:17 -0300)]
util: clang is failing to compile due to unused variables.

After some recent patches, clang is throwing some errors related to
unused variables. This is not happening when we use GCC with -Werror
enabled. Only clang reports this warning.

make[3]: Entering directory '/home/julio/Desktop/virt/libvirt/src'
  CC       util/libvirt_util_la-virscsivhost.lo
  CC       util/libvirt_util_la-virusb.lo
  CC       util/libvirt_util_la-virmdev.lo
util/virmdev.c:373:36: error: unused variable 'ret' [-Werror,-Wunused-variable]
    VIR_AUTOPTR(virMediatedDevice) ret = virMediatedDeviceListSteal(list, dev);
                                   ^
1 error generated.
Makefile:11579: recipe for target 'util/libvirt_util_la-virmdev.lo' failed
make[3]: *** [util/libvirt_util_la-virmdev.lo] Error 1
make[3]: *** Waiting for unfinished jobs....
util/virscsivhost.c:112:37: error: unused variable 'tmp' [-Werror,-Wunused-variable]
    VIR_AUTOPTR(virSCSIVHostDevice) tmp = virSCSIVHostDeviceListSteal(list, dev);
                                    ^
1 error generated.
Makefile:11411: recipe for target 'util/libvirt_util_la-virscsivhost.lo' failed
make[3]: *** [util/libvirt_util_la-virscsivhost.lo] Error 1
util/virusb.c:511:31: error: unused variable 'ret' [-Werror,-Wunused-variable]
    VIR_AUTOPTR(virUSBDevice) ret = virUSBDeviceListSteal(list, dev);

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoaudit: Share virtType fallback logic
Cole Robinson [Thu, 26 Jul 2018 17:57:31 +0000 (13:57 -0400)]
audit: Share virtType fallback logic

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agovirpci: Drop unused @ret in virPCIDeviceListDel
Michal Privoznik [Fri, 27 Jul 2018 16:07:38 +0000 (18:07 +0200)]
virpci: Drop unused @ret in virPCIDeviceListDel

So after 00dc991ca16730 the function is one line long and the
line is declaring a variable which is never used in fact. Replace
it with actual free() call instead of autofree.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoutil: lease: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:42 +0000 (21:22 +0530)]
util: lease: 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: lease: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:41 +0000 (21:22 +0530)]
util: lease: 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: kmod: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:40 +0000 (21:22 +0530)]
util: kmod: 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: kmod: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:39 +0000 (21:22 +0530)]
util: kmod: 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: iptables: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:36 +0000 (21:22 +0530)]
util: iptables: 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: hostmem: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:35 +0000 (21:22 +0530)]
util: hostmem: 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: hostdev: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:34 +0000 (21:22 +0530)]
util: hostdev: 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: hostdev: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:33 +0000 (21:22 +0530)]
util: hostdev: 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: netdevvlan: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:32 +0000 (21:22 +0530)]
util: netdevvlan: 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 virNetDevVlanPtr is declared using
VIR_AUTOPTR, the function virNetDevVlanFree 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: scsivhost: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:31 +0000 (21:22 +0530)]
util: scsivhost: 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: scsivhost: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:30 +0000 (21:22 +0530)]
util: scsivhost: 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 virSCSIVHostDevicePtr is declared using
VIR_AUTOPTR, the function virSCSIVHostDeviceFree 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: scsi: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:29 +0000 (21:22 +0530)]
util: scsi: 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: scsi: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:28 +0000 (21:22 +0530)]
util: scsi: 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: scsi: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:27 +0000 (21:22 +0530)]
util: scsi: 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 variables of type virSCSIDevicePtr and virUsedByInfoPtr
are declared using VIR_AUTOPTR, the functions virSCSIDeviceFree
and virSCSIDeviceUsedByInfoFree, respectively, will be run
automatically on them when they go out of scope.

This commit also adds an intermediate typedef for virUsedByInfo
type for use with the cleanup macros.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: usb: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:26 +0000 (21:22 +0530)]
util: usb: 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: usb: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:25 +0000 (21:22 +0530)]
util: usb: 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: usb: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:24 +0000 (21:22 +0530)]
util: usb: 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 virUSBDevicePtr is declared using
VIR_AUTOPTR, the function virUSBDeviceFree 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: usb: modify virUSBDeviceListAdd to take double pointer
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:23 +0000 (21:22 +0530)]
util: usb: modify virUSBDeviceListAdd to take double pointer

Modify virUSBDeviceListAdd to take a double pointer to
virUSBDevicePtr as the second argument. This will enable usage
of cleanup macros upon the virUSBDevicePtr item which is to be
added to the list as it will be cleared by virInsertElementsN
upon success.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: pci: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:22 +0000 (21:22 +0530)]
util: pci: 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: pci: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:21 +0000 (21:22 +0530)]
util: pci: 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: pci: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:20 +0000 (21:22 +0530)]
util: pci: 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 variables of types virPCIDevicePtr, virPCIDeviceAddressPtr
and virPCIEDeviceInfoPtr are declared using VIR_AUTOPTR, the functions
virPCIDeviceFree, virPCIDeviceAddressFree and virPCIEDeviceInfoFree,
respectively, will be run automatically on them when they go out of scope.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: hook: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:19 +0000 (21:22 +0530)]
util: hook: 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: hook: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:18 +0000 (21:22 +0530)]
util: hook: 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: firewall: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:17 +0000 (21:22 +0530)]
util: firewall: 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: firewall: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:16 +0000 (21:22 +0530)]
util: firewall: 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: firewall: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:15 +0000 (21:22 +0530)]
util: firewall: 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 virFirewallPtr is declared using
VIR_AUTOPTR, the function virFirewallFree 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: mdev: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:14 +0000 (21:22 +0530)]
util: mdev: 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: mdev: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:13 +0000 (21:22 +0530)]
util: mdev: 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: mdev: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:12 +0000 (21:22 +0530)]
util: mdev: 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 variables of type virMediatedDevicePtr and virMediatedDeviceTypePtr
are declared using VIR_AUTOPTR, the functions virMediatedDeviceFree
and virMediatedDeviceTypeFree, respectively, will be run automatically
on them when they go out of scope.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: cgroup: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:11 +0000 (21:22 +0530)]
util: cgroup: 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: cgroup: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:10 +0000 (21:22 +0530)]
util: cgroup: 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: cgroup: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:09 +0000 (21:22 +0530)]
util: cgroup: 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 virCgroupPtr is declared using
VIR_AUTOPTR, the function virCgroupFree will be run
automatically on it when it goes out of scope.

This commit also adds an intermediate typedef for virCgroup
type for use with the cleanup macros.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: cgroup: modify virCgroupFree to take virCgroupPtr
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:08 +0000 (21:22 +0530)]
util: cgroup: modify virCgroupFree to take virCgroupPtr

Modify virCgroupFree function signature to take a value of type
virCgroupPtr instead of virCgroupPtr * as the parameter.

Change the argument type in all calls to virCgroupFree function
from virCgroupPtr * to virCgroupPtr. This is a step towards
having consistent function signatures for Free helpers so that
they can be used with VIR_AUTOPTR cleanup macro.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: hash: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:07 +0000 (21:22 +0530)]
util: hash: 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 variables of type virHashTablePtr are declared using
VIR_AUTOPTR, the function virHashFree 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: buffer: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:06 +0000 (21:22 +0530)]
util: buffer: 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: buffer: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:05 +0000 (21:22 +0530)]
util: buffer: 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: buffer: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:04 +0000 (21:22 +0530)]
util: buffer: 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 variables of type virBufferPtr and virBufferEscapePairPtr
are declared using VIR_AUTOPTR, the functions virBufferFreeAndReset
and virBufferEscapePairFree, respectively, will be run automatically
on them when they go out of scope.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: buffer: Add struct _virBufferEscapePair typedefs
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:03 +0000 (21:22 +0530)]
util: buffer: Add struct _virBufferEscapePair typedefs

Add virBufferEscapePair and virBufferEscapePairPtr typedefs, mainly in
order to enable usage of cleanup macros for this type.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: error: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Tue, 24 Jul 2018 15:52:02 +0000 (21:22 +0530)]
util: error: 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 virErrorPtr is declared using
VIR_AUTOPTR, the function virFreeError 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 agolxc: Use VIR_AUTOPTR for @veths in virLXCProcessStart
Michal Privoznik [Thu, 26 Jul 2018 15:33:01 +0000 (17:33 +0200)]
lxc: Use VIR_AUTOPTR for @veths in virLXCProcessStart

Now that we have VIR_AUTOPTR and that @veths is a string list we
can use VIR_AUTOPTR to free it automagically.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agolxc: Turn @veths into a string list in virLXCProcessStart
Michal Privoznik [Thu, 26 Jul 2018 15:25:58 +0000 (17:25 +0200)]
lxc: Turn @veths into a string list in virLXCProcessStart

This way it will be easier to use autofree.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: Rework virStringListAdd
Michal Privoznik [Thu, 26 Jul 2018 14:10:10 +0000 (16:10 +0200)]
util: Rework virStringListAdd

So every caller does the same: they use virStringListAdd() to add
new item into the list and then free the old copy to replace it
with new list. It's not very memory effective, nor environmental
friendly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agovirtestmock: Track connect() too
Michal Privoznik [Sun, 8 Jul 2018 07:24:34 +0000 (09:24 +0200)]
virtestmock: Track connect() too

The aim of this mock is to track if a test doesn't touch anything
in live system. Well, connect() which definitely falls into that
category isn't tracked yet.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoForget last daemon/ dir artefacts
Michal Privoznik [Sat, 7 Jul 2018 11:57:30 +0000 (13:57 +0200)]
Forget last daemon/ dir artefacts

The most important part is LIBVIRTD_PATH env var fix. It is used
in virFileFindResourceFull() from tests. The libvirtd no longer
lives under daemon/.

Then, libvirtd-fail test was still failing (as expected) but not
because of missing config file but because it was trying to
execute (nonexistent) top_builddir/daemon/libvirtd which
fulfilled expected outcome and thus test did not fail.

Thirdly, lcov was told to generate coverage for daemon/ dir too.

Fourthly, our compiling documentation was still suggesting to run
daemonn/libvirtd.

And finally, some comments in a systemtap file and a probes file
were still referring to daemon/libvirtd.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agonews: Usb and sata for virsh attach-disk --address
Han Han [Thu, 26 Jul 2018 13:33:00 +0000 (21:33 +0800)]
news: Usb and sata for virsh attach-disk --address

Signed-off-by: Han Han <hhan@redhat.com>
6 years agolxc: Don't return early in virLXCProcessSetupInterfaces
Michal Privoznik [Fri, 27 Jul 2018 12:32:36 +0000 (14:32 +0200)]
lxc: Don't return early in virLXCProcessSetupInterfaces

There are two places in the loop body that just return instead of
jumping onto the cleanup label. The problem is the cleanup code
is not ran in those cases.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoconf: Add validation of input devices
Han Han [Thu, 26 Jul 2018 07:27:33 +0000 (15:27 +0800)]
conf: Add validation of input devices

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

Add function virDomainInputDefValidate to validate input devices.
Make sure evdev attribute of source element is not used by mouse,
keyboard, and tablet input device.

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_monitor: Fix regression in getting disk capacity
Michal Privoznik [Thu, 26 Jul 2018 14:37:27 +0000 (16:37 +0200)]
qemu_monitor: Fix regression in getting disk capacity

In dbf990fd31e8 the qemuMonitorJSONBlockStatsUpdateCapacityOne()
was split. However, due to a bug the return value was never set
to something meaningful.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: don't use virDomainVirtType in struct field
Daniel P. Berrangé [Thu, 26 Jul 2018 14:47:23 +0000 (15:47 +0100)]
conf: don't use virDomainVirtType in struct field

Use of enum types for struct fields is generally avoided since it causes
warnings if the compiler assumes the enum is unsigned. For example

  commit 8e2982b5767a25e5da6533c65bfdc648c95b3c69
  Author: Cole Robinson <crobinso@redhat.com>
  Date:   Tue Jul 24 16:27:54 2018 -0400

    conf: Clean up virDomainDefParseCaps

Introduced a line:

  if ((def->virtType = virDomainVirtTypeFromString(virttype)) < 0) {

which causes a build failure with CLang

  conf/domain_conf.c:19143:65: error: comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-compare]

as the compiler is free to optimize away the "< 0" check due to the
assumption that the enum type is unsigned and always in range.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoconf: Replace SKIP_OSTYPE_CHECKS with SKIP_VALIDATE
Cole Robinson [Tue, 24 Jul 2018 21:00:56 +0000 (17:00 -0400)]
conf: Replace SKIP_OSTYPE_CHECKS with SKIP_VALIDATE

SKIP_OSTYPE_CHECKS only hides some error reporting at this point,
so it can be foled into SKIP_VALIDATE

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: Remove redundant lxc test
Cole Robinson [Tue, 24 Jul 2018 21:07:09 +0000 (17:07 -0400)]
tests: Remove redundant lxc test

This test was added in 2d40e2da7ba to ensure LXC domains could be
defined correctly when caps probing was skipped due to SKIP_OSTYPE.
However we do caps probing unconditionally now, so this test case
is redundant

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: Sync caps data even when SKIP_OSTYPE_CHECKS
Cole Robinson [Tue, 24 Jul 2018 20:54:51 +0000 (16:54 -0400)]
conf: Sync caps data even when SKIP_OSTYPE_CHECKS

We should still make an effort to fill in data, just not raise
an error if say an ostype/virttype combo disappeared from caps.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: Drop unnecessary caps parsing logic
Cole Robinson [Thu, 29 Jun 2017 12:49:33 +0000 (08:49 -0400)]
conf: Drop unnecessary caps parsing logic

The comment says:

    /* If the logic here seems fairly arbitrary, that's because it is :)
     * This is duplicating how the code worked before
     * CapabilitiesDomainDataLookup was added. We can simplify this,
     * but it would take a bit of work because the test suite fails
     * in numerous minor ways. */

Nowadays the test suite changes appear quite simple, just extending
test capabilities data a bit so that we aren't trying to define
invalid arch/os/virtType/machine combos

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuhotplug: Fix segfault when XML loading fails
Cole Robinson [Thu, 29 Jun 2017 13:20:54 +0000 (09:20 -0400)]
tests: qemuhotplug: Fix segfault when XML loading fails

Some tests use the same VM state multiple times in a row. But if we
failed loading the VM XML, subsequent tests crash on the NULL def
pointer

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: Clean up virDomainDefParseCaps
Cole Robinson [Tue, 24 Jul 2018 20:27:54 +0000 (16:27 -0400)]
conf: Clean up virDomainDefParseCaps

- Convert to 'cleanup' label naming
- Use more than one 'tmp' string and do all freeing at the end
- Make the code easier to follow

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: Break out virDomainDefParseCaps
Cole Robinson [Tue, 24 Jul 2018 20:18:16 +0000 (16:18 -0400)]
conf: Break out virDomainDefParseCaps

Handles parse virtType, os.type, bootloader bits, arch, machine,
emulator

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: Fix a error msg typo in virDomainVideoDefValidate
Han Han [Thu, 26 Jul 2018 13:52:46 +0000 (21:52 +0800)]
conf: Fix a error msg typo in virDomainVideoDefValidate

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

Introduced by commit d48813e8.

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agonwfilter: Resolve SEGV for NWFilter Snoop processing
John Ferlan [Fri, 20 Jul 2018 21:44:08 +0000 (17:44 -0400)]
nwfilter: Resolve SEGV for NWFilter Snoop processing

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

Commit id fca9afa08 changed the @req->ifname to use
@req->binding->portdevname fillingin the @req->binding
in a similar way that @req->ifname would have been
filled in during virNWFilterDHCPSnoopReq processing.

However, in doing so it did not take into account some
code paths where the @req->binding should be checked
instead of @req->binding->portdevname. These checks
led to SEGVs in some cases during libvirtd reload
processing in virNWFilterSnoopRemAllReqIter (for
stop during nwfilterStateCleanup processing) and
virNWFilterSnoopReqLeaseDel (for start during
nwfilterStateInitialize processing).

In particular, when reading the nwfilter.leases file
a new @req is created, but the @req->binding is not
filled in. That's left to virNWFilterDHCPSnoopReq
processing which checks if the @req already exists
in the @virNWFilterSnoopState.snoopReqs hash table
after adding a virNWFilterSnoopState.ifnameToKey
entry for the @req->binding->portdevname by a
@ref->ikey value.

NB: virNWFilterSnoopIPLeaseInstallRule and
    virNWFilterDHCPSnoopThread do not need the
    req->binding check since they can only be called
    after the filter->binding is created/assigned.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agolxc: Don't mangle @cfg refs in virLXCProcessBuildControllerCmd
Michal Privoznik [Wed, 25 Jul 2018 12:48:13 +0000 (14:48 +0200)]
lxc: Don't mangle @cfg refs in virLXCProcessBuildControllerCmd

The config object is refed but unrefed only on error which leaves
refcount unbalanced on successful return.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agolxc: Don't leak @veths in virLXCProcessStart
Michal Privoznik [Wed, 25 Jul 2018 12:32:43 +0000 (14:32 +0200)]
lxc: Don't leak @veths in virLXCProcessStart

The individual strings are freed, but the array is never freed.

 8 bytes in 1 blocks are definitely lost in loss record 28 of 1,098
    at 0x4C2CE3F: malloc (vg_replace_malloc.c:298)
    by 0x4C2F1BF: realloc (vg_replace_malloc.c:785)
    by 0x52C9C92: virReallocN (viralloc.c:245)
    by 0x52C9D88: virExpandN (viralloc.c:294)
    by 0x23414D99: virLXCProcessSetupInterfaces (lxc_process.c:552)
    by 0x23417457: virLXCProcessStart (lxc_process.c:1356)
    by 0x2341F71C: lxcDomainCreateWithFiles (lxc_driver.c:1088)
    by 0x2341F805: lxcDomainCreate (lxc_driver.c:1123)
    by 0x55917EB: virDomainCreate (libvirt-domain.c:6534)
    by 0x1367D1: remoteDispatchDomainCreate (remote_daemon_dispatch_stubs.h:4434)
    by 0x1366EA: remoteDispatchDomainCreateHelper (remote_daemon_dispatch_stubs.h:4410)
    by 0x546FDF1: virNetServerProgramDispatchCall (virnetserverprogram.c:437)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agolxc: Enable under valgrind again
Michal Privoznik [Wed, 25 Jul 2018 12:25:01 +0000 (14:25 +0200)]
lxc: Enable under valgrind again

So we originally disabled LXC driver when libvirtd is running
under valgrind back in 05436ab7ff087 (which dates to beginning of
2009) as it was causing valgrind to crash. It's not the case
anymore. Valgrind works with LXC happily.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agolxc: Report supported huge pages
Michal Privoznik [Wed, 25 Jul 2018 12:12:09 +0000 (14:12 +0200)]
lxc: Report supported huge pages

There are two places where we report supported sizes of huge pages:

  /capabilities/host/cpu/pages
  /capabilities/host/topology/cells/cell/pages

The former aggregates sizes over all NUMA nodes while the latter
reports supported sizes only for given node. While we are
reporting per NUMA node sizes we are not reporting the aggregated
sizes. I've noticed this when wondering why doesn't allocpages
completer work.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agolxc: Refresh capabilities on virConnectGetCapabilities
Michal Privoznik [Wed, 25 Jul 2018 12:03:03 +0000 (14:03 +0200)]
lxc: Refresh capabilities on virConnectGetCapabilities

While not as critical as in qemu driver, there are still some
runtime information we report in capabilities XML that might
change throughout time. For instance, onlined CPUs (which affects
reported L3 cache sizes).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agonetworkGetDHCPLeases: Don't always report error if unable to read leases file
Michal Privoznik [Thu, 26 Jul 2018 07:49:43 +0000 (09:49 +0200)]
networkGetDHCPLeases: Don't always report error if unable to read leases file

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

If we are unable to read leases file (no matter what the reason
is), we return 0 - just like if there were no leases. However,
because we use virFileReadAll() an error is printed into the log.
Note that not all networks have leases file - only those for
which we start dnsmasq.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agorpc: treat EADDRNOTAVAIL as non-fatal when listening
Daniel P. Berrangé [Tue, 24 Jul 2018 14:15:14 +0000 (15:15 +0100)]
rpc: treat EADDRNOTAVAIL as non-fatal when listening

Consider creating a listener socket from a hostname that resolves to
multiple addresses. It might be the case that the hostname resolves to
both an IPv4 and IPv6 address because it is reachable over both
protocols, but the IPv6 connectivity is provided off-host. In such a
case no local NIC will have IPv6 and so bind() would fail with the
EADDRNOTAVAIL errno. Thus it should be treated as non-fatal as long as
at least one socket was succesfully bound.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agosocket: preserve real errno when socket/bind calls fail
Daniel P. Berrangé [Tue, 24 Jul 2018 14:12:15 +0000 (15:12 +0100)]
socket: preserve real errno when socket/bind calls fail

When reporting socket/bind failures we want to ensure any fatal error
reported is as accurate as possible. We'll prefer reporting a bind()
errno over a socket() errno, because if socket() works but bind() fails
that is a more significant event.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: Use the correct vm def on cold attach
John Ferlan [Tue, 12 Jun 2018 12:44:21 +0000 (08:44 -0400)]
qemu: Use the correct vm def on cold attach

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

When attaching a device to the domain we need to be sure
to use the correct domain definition (vm->def or vm->newDef)
when calling virDomainDeviceDefParse because the post parse
processing algorithms that may assign an address for the
device will use whatever domain definition was passed in.

Additionally, some devices (SCSI hostdev and SCSI disk) use
algorithms that rely on knowing what already exists of the
other type when generating the new device's address. Using
the wrong VM definition could result in duplicated addresses.

In the case of the bz, two hostdev's with no domain address
provided were added to the running domain's config only.
However, the parsing algorithm used the live domain in
order to figure out the host device address resulting in
the same address being used and a subsequent start failing
due to duplicate address.

Fix this by separating the checks/code into CONFIG and LIVE
processing using the correct definition for each block and
performing cleanup for both options as necessary.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>