]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agoFix libvirt-driver-libxl check
Marek Marczykowski-Górecki [Sun, 5 Aug 2018 21:50:35 +0000 (23:50 +0200)]
Fix libvirt-driver-libxl check

Fix saving CFLAGS in LIBVIRT_DRIVER_CHECK_LIBXL - LIBVIRT_CHECK_LIB will
override old_CFLAGS, so use a different name.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agoqemu: domain: Fix machine type version check for 'isa-fdc' usage
Peter Krempa [Thu, 9 Aug 2018 10:35:41 +0000 (12:35 +0200)]
qemu: domain: Fix machine type version check for 'isa-fdc' usage

Starting from pc-q35-2.4 the floppy controller is not enabled by
default. Fix the version check so that it does not match 2.11 as being
2.1.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: command: Don't format -device isa-fdc,... twice with two floppy drives
Peter Krempa [Thu, 9 Aug 2018 11:50:22 +0000 (13:50 +0200)]
qemu: command: Don't format -device isa-fdc,... twice with two floppy drives

Fix regression introduced in <42fd5a58adb>. With q35 machine type which
requires the explicitly specified FDC we'd format twoisa-fdc
controllers to the command line as the code was moved to a place where
it's called per-disk.

Move the call back after formatting all disks and reiterate the disks to
find the floppy controllers.

This also moves the '-global' directive which sets up the default
ISA-FDC to the end after all the disks but since we are modifying the
properties it is safe to do so.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Add 2 floppy drive tests for q35 with 2.9 and 2.11 machine
Peter Krempa [Thu, 9 Aug 2018 10:28:56 +0000 (12:28 +0200)]
tests: qemuxml2argv: Add 2 floppy drive tests for q35 with 2.9 and 2.11 machine

The floppy drive command line is different on the q35 machine. Make sure
to test that both drives are supported and also multiple machine
versions as we generate the commandline differently.

Note that both output files show wrong command line which will be fixed
subsequently.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Remove unused argument 'bootable' from qemuBuildDriveStr
Peter Krempa [Thu, 9 Aug 2018 11:33:41 +0000 (13:33 +0200)]
qemu: Remove unused argument 'bootable' from qemuBuildDriveStr

Now that the argument is unused we can remove it transitively from all
the call graphs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: capabilities: Remove unused QEMU_CAPS_DRIVE_BOOT
Peter Krempa [Thu, 9 Aug 2018 11:28:16 +0000 (13:28 +0200)]
qemu: capabilities: Remove unused QEMU_CAPS_DRIVE_BOOT

The capability was never set except for (stale) tests. Remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: capabilities: Always assume QEMU_CAPS_BOOTINDEX
Peter Krempa [Thu, 9 Aug 2018 11:26:17 +0000 (13:26 +0200)]
qemu: capabilities: Always assume QEMU_CAPS_BOOTINDEX

The field was added in qemu v0.13.0-rc0-731-g1ca4d09ae0 so all supported
qemu versions now use it.

There's a LOT of test fallout as we did not use capabilities close
enough to upstream for many of our tests.

Several tests had a 'bootindex' variant. Since they'd become redundant
they are also removed here.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: tweak error message when skipping file
Daniel P. Berrangé [Mon, 30 Jul 2018 16:43:56 +0000 (17:43 +0100)]
storage: tweak error message when skipping file

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: emit error when trying to update blkiotune group_name in qemuDomainChangeDiskLive
Katerina Koukiou [Tue, 31 Jul 2018 07:36:26 +0000 (09:36 +0200)]
qemu: emit error when trying to update blkiotune group_name in qemuDomainChangeDiskLive

The rest of blkiotune parameters are not updatable through UpdateDeviceFlags API.

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

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoFix link errors in tools/nss and tests
Jim Fehlig [Wed, 8 Aug 2018 16:47:57 +0000 (10:47 -0600)]
Fix link errors in tools/nss and tests

While local builds succeed fine, a build worker building in a chroot
environment is encountering errors when linking some items in tools/nss
and tests, e.g.

[  469s] libtool: link: gcc -shared  -fPIC -DPIC  -Wl,--whole-archive nss/.libs/libnss_libvirt_impl.a -Wl,--no-whole-archive  -lpthread -lutil -ltirpc  -fstack-protector-strong -grecord-gcc-switches -O2 -fstack-protector-strong -g -Wl,--version-script=./nss/libvirt_nss.syms -Wl,-z -Wl,relro -Wl,-z -Wl,now -Wl,--no-copy-dt-needed-entries -Wl,-z -Wl,defs -grecord-gcc-switches -O2 -fstack-protector-strong -g   -pthread -Wl,-soname -Wl,libnss_libvirt.so.2 -o nss/.libs/libnss_libvirt.so.2
[  469s] nss/.libs/libnss_libvirt_impl.a(libvirt_nss_la-virjsoncompat.o): In function `virJSONJanssonOnce':
[  469s] /home/abuild/rpmbuild/BUILD/libvirt-4.6.0/src/util/virjsoncompat.c:63: undefined reference to `dlopen'
[  469s] /home/abuild/rpmbuild/BUILD/libvirt-4.6.0/src/util/virjsoncompat.c:79: undefined reference to `dlsym'
...

A similar problem was fixed in commit b018ada3 and inspires this fix.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu: add support for domain disk initiator IQN
Pavel Hrdina [Tue, 7 Aug 2018 12:57:43 +0000 (14:57 +0200)]
qemu: add support for domain disk initiator IQN

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agotests: introduce qemu disk-network-iscsi-modern test cases
Pavel Hrdina [Tue, 7 Aug 2018 13:32:20 +0000 (15:32 +0200)]
tests: introduce qemu disk-network-iscsi-modern test cases

This uses the new -drive options instead of iSCSI URI.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoconf: introduce initiator IQN support for domain disks
Pavel Hrdina [Tue, 7 Aug 2018 11:32:56 +0000 (13:32 +0200)]
conf: introduce initiator IQN support for domain disks

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agodocs: move storage initiator def into storagecommon.rng
Pavel Hrdina [Tue, 7 Aug 2018 11:28:24 +0000 (13:28 +0200)]
docs: move storage initiator def into storagecommon.rng

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoconf: use virStorageSourceInitiator functions
Pavel Hrdina [Tue, 7 Aug 2018 11:31:31 +0000 (13:31 +0200)]
conf: use virStorageSourceInitiator functions

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoutil: introduce virStorageSourceInitiator functions
Pavel Hrdina [Tue, 7 Aug 2018 11:01:40 +0000 (13:01 +0200)]
util: introduce virStorageSourceInitiator functions

The same code would be used for storage pools and domain disks.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoconf: rename and move virStoragePoolSourceInitiatorAttr
Pavel Hrdina [Tue, 7 Aug 2018 11:25:21 +0000 (13:25 +0200)]
conf: rename and move virStoragePoolSourceInitiatorAttr

This structure will be reused by domain disk images as well.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoconf: properly translate iscsi-direct storage pool
Pavel Hrdina [Mon, 6 Aug 2018 15:52:41 +0000 (17:52 +0200)]
conf: properly translate iscsi-direct storage pool

We cannot simply used the same code as for iscsi storage pool because
the default mode is 'host' which is not possible with iscsi-direct.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agodocs: fix iscsi-direct XML example
Pavel Hrdina [Mon, 6 Aug 2018 11:42:39 +0000 (13:42 +0200)]
docs: fix iscsi-direct XML example

The <initiator> element is part of <source> element.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agorpm: simplify applying of patches
Daniel P. Berrangé [Fri, 3 Aug 2018 09:34:32 +0000 (10:34 +0100)]
rpm: simplify applying of patches

The distros we support for RPM builds all have %autosetup support so we
can ditch the convoluted code for running git manually and use the RPM
defaults.

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agospec: Use %make_install
Cole Robinson [Tue, 31 Jul 2018 15:31:34 +0000 (11:31 -0400)]
spec: Use %make_install

It's on RHEL7, saves a bit of typing, and lets us drop the comment

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: virDomainDefValidateInternal prohibit some characters in shmem name
Simon Kobyda [Wed, 1 Aug 2018 15:50:03 +0000 (17:50 +0200)]
conf: virDomainDefValidateInternal prohibit some characters in shmem name

Validate that the provided XML shmem name is not directory specific to "."  or
".." as well as ensure that there is no path separator '/' in the name.

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

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
6 years agoFix the build on non-linux platforms after VIR_AUTOPTR related changes
Erik Skultety [Tue, 7 Aug 2018 16:40:11 +0000 (18:40 +0200)]
Fix the build on non-linux platforms after VIR_AUTOPTR related changes

Commits 7b706f33ac and 4acb7887e4 introduced some compound type *Free
wrappers in order to use them with VIR_DEFINE_AUTOPTR_FUNC. However,
since those were not used in the code right away, Clang complained about
unused functions (static ones that are defined by the macro above).
This patch puts the defined functions in use.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: virnetdevopenvswitch: Drop an unused variable @ovs_timeout
Erik Skultety [Tue, 7 Aug 2018 16:34:51 +0000 (18:34 +0200)]
util: virnetdevopenvswitch: Drop an unused variable @ovs_timeout

Technically, it was never used ever since commit @f4d06ca8fd9 introduced
it, but the fact that we called VIR_FREE on it was enough for Clang to
never complain about it.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: ensure default machine types don't change if QEMU changes
Daniel P. Berrangé [Fri, 3 Aug 2018 12:29:26 +0000 (13:29 +0100)]
qemu: ensure default machine types don't change if QEMU changes

It is increasingly likely that some distro is going to change the
default "x86" machine type in QEMU from "pc" to "q35". This will
certainly break existing applications which write their XML on the
assumption that it is using a "pc" machine by default. For example they'll
lack a IDE CDROM and get PCIe instead of PCI which changes the topology
radically.

Libvirt promises to isolate applications from hypervisor changes that
may cause incompatibilities, so we must ensure that we always use the
"pc" machine type if it is available. Only use QEMU's own reported
default machine type if "pc" does not exist.

This issue is not x86-only, other arches are liable to change their
default machine, while some arches don't report any default at all
causing libvirt to pick the first machine in the list. Thus to
guarantee stability to applications, declare a preferred default
machine for all architectures we currently support with QEMU.

Note this change assumes there will always be a "pc" alias as long as a
versioned "pc-XXX" machine type exists. If QEMU were to ship a "pc-XXX"
machine type but not provide the "pc" alias, it is too hard to decide
which to default so. Versioned machine types are supposed to be
considered opaque strings, so we can't apply any sensible ordering
ourselves and QEMU isn't reporting the list of machines in any sensible
ordering itself.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoutil: qemu: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:47 +0000 (23:31 +0530)]
util: qemu: 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: qemu: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:46 +0000 (23:31 +0530)]
util: qemu: 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: process: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:45 +0000 (23:31 +0530)]
util: process: 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: process: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:44 +0000 (23:31 +0530)]
util: process: 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: pidfile: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:43 +0000 (23:31 +0530)]
util: pidfile: 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: perf: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:42 +0000 (23:31 +0530)]
util: perf: 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: perf: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:41 +0000 (23:31 +0530)]
util: perf: 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 virPerfPtr is declared using VIR_AUTOPTR,
the function virPerfFree will be run automatically on it when it
goes out of scope.

This commit also adds an intermediate typedef for virPerf
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: numa: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:40 +0000 (23:31 +0530)]
util: numa: 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: numa: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:39 +0000 (23:31 +0530)]
util: numa: 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: netlink: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:37 +0000 (23:31 +0530)]
util: netlink: 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 virNetlinkHandle * is declared using
VIR_AUTOPTR, the function virNetlinkFree 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: netdevveth: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:36 +0000 (23:31 +0530)]
util: netdevveth: 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: netdevveth: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:35 +0000 (23:31 +0530)]
util: netdevveth: 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: netdevtap: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:34 +0000 (23:31 +0530)]
util: netdevtap: 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: netdevopenvswitch: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:32 +0000 (23:31 +0530)]
util: netdevopenvswitch: 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: Drop unused cleanup label in virNetDevOpenvswitchInterfaceGetMaster
Erik Skultety [Tue, 7 Aug 2018 13:00:22 +0000 (15:00 +0200)]
util: Drop unused cleanup label in virNetDevOpenvswitchInterfaceGetMaster

This was doing a plain "return".

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: netdevmacvlan: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:31 +0000 (23:31 +0530)]
util: netdevmacvlan: 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: netdevmacvlan: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:30 +0000 (23:31 +0530)]
util: netdevmacvlan: 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: netdevip: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:27 +0000 (23:31 +0530)]
util: netdevip: 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: netdevip: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:26 +0000 (23:31 +0530)]
util: netdevip: 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 virNetDevIPAddrPtr and virNetDevIPRoutePtr
are declared using VIR_AUTOPTR, the functions virNetDevIPAddrFree
and virNetDevIPRouteFree, 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: netdevip: Introduce virNetDevIPAddrFree helper
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:26 +0000 (23:31 +0530)]
util: netdevip: Introduce virNetDevIPAddrFree helper

This will not only help us in the future when adding more and more
VIR_AUTOPTR instances, we're also consistent in that a compound type
gets its own function which can easily be extended in the future if
necessary.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: socketaddr: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:24 +0000 (23:31 +0530)]
util: socketaddr: 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: socketaddr: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:23 +0000 (23:31 +0530)]
util: socketaddr: 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 virSocketAddrPtr is declared using
VIR_AUTOPTR, the function virSocketAddrFree 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: socketaddr: Introduce virSocketAddrFree helper
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:23 +0000 (23:31 +0530)]
util: socketaddr: Introduce virSocketAddrFree helper

This will not only help us in the future when adding more and more
VIR_AUTOPTR instances, we're also consistent in that a compound type
gets its own function which can easily be extended in the future if
necessary.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: netdev: Define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:20 +0000 (23:31 +0530)]
util: netdev: 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 virNetDevRxFilterPtr and virNetDevMcastEntryPtr
are declared using VIR_AUTOPTR, the functions virNetDevRxFilterFree
and virNetDevMcastEntryFree, 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: macaddr: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:19 +0000 (23:31 +0530)]
util: macaddr: 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 virMacAddrPtr is declared using VIR_AUTOPTR,
the function virMacAddrFree 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: macaddr: Introduce a new virMacAddrFree helper
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:19 +0000 (23:31 +0530)]
util: macaddr: Introduce a new virMacAddrFree helper

This will not only help us in the future when adding more and more
VIR_AUTOPTR instances, we're also consistent in that a compound type
gets its own function which can easily be extended in the future if
necessary.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: iscsi: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Sat, 28 Jul 2018 18:01:17 +0000 (23:31 +0530)]
util: iscsi: 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: 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>