]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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>
6 years agonetwork: Use 'switch' control statement with virNetworkForwardType enum
Shi Lei [Tue, 24 Jul 2018 03:49:48 +0000 (11:49 +0800)]
network: Use 'switch' control statement with virNetworkForwardType enum

With 'switch' we can utilize the compile time enum checks which we can't
rely on with plain 'if' conditions.

Signed-off-by: Shi Lei <shilei.massclouds@gmx.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoesx storage: Fix typo lsilogic -> lsiLogic
Marcos Paulo de Souza [Tue, 24 Jul 2018 00:15:51 +0000 (00:15 +0000)]
esx storage: Fix typo lsilogic -> lsiLogic

Commit 77298458d027db4d3e082213355e2d792f65158d changed the esx storage
adapter from busLogic to lsilogic, introducing a typo. Changing it back
to lsiLogic (with capital L) solves the issue. With this change, libvirt can now
create volumes in ESX again.

Thanks to Jaroslav Suchanek who figured out what was the issue in the
first place.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1571759
Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agoutil: Fix virStorageBackendIQNFound() to work on FreeBSD
Andrea Bolognani [Wed, 25 Jul 2018 09:18:39 +0000 (11:18 +0200)]
util: Fix virStorageBackendIQNFound() to work on FreeBSD

Despite being standardized in POSIX.1-2008, the 'm'
sscanf() modifier is currently not available on FreeBSD.

Reimplement parsing without sscanf() to work around the
issue.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agonews: Add --alias to virsh attach-disk and attach-interface
Han Han [Mon, 23 Jul 2018 14:12:46 +0000 (22:12 +0800)]
news: Add --alias to virsh attach-disk and attach-interface

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemuDomainSaveMemory: Don't enforce dynamicOwnership
Michal Privoznik [Tue, 26 Jun 2018 13:34:21 +0000 (15:34 +0200)]
qemuDomainSaveMemory: Don't enforce dynamicOwnership

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

When doing a memory snapshot qemuOpenFile() is used. This means
that the file where memory is saved is firstly attempted to be
created under root:root (because that's what libvirtd is running
under) and if this fails the second attempt is done under
domain's uid:gid. This does not make much sense - qemu is given
opened FD so it does not need to access the file. Moreover, if
dynamicOwnership is set in qemu.conf and the file lives on a
squashed NFS this is deadly combination and very likely to fail.

The fix consists of using:

  qemuOpenFileAs(fallback_uid = cfg->user,
                 fallback_gid = cfg->group,
                 dynamicOwnership = false)

In other words, dynamicOwnership is turned off for memory
snapshot (chown() will still be attempted if the file does not
live on NFS) and instead of using domain DAC label, configured
user:group is set as fallback.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoviriscsitest: Extend virISCSIConnectionLogin test
Michal Privoznik [Wed, 4 Jul 2018 08:41:54 +0000 (10:41 +0200)]
viriscsitest: Extend virISCSIConnectionLogin test

Extend this existing test so that a case when IQN is provided is
tested too. Since a special iSCSI interface is created and its
name is randomly generated at runtime we need to link with
virrandommock to have predictable names.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoviriscsitest: Introduce testIscsiadmCbData struct
Michal Privoznik [Wed, 4 Jul 2018 08:47:07 +0000 (10:47 +0200)]
viriscsitest: Introduce testIscsiadmCbData struct

Some tests will want to pass their own callback data into the
testIscsiadmCbData callback. Introduce testIscsiadmCbData struct
to give this some form and order.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoviriscsitest: Move testSessionInfo struct
Michal Privoznik [Wed, 4 Jul 2018 08:43:36 +0000 (10:43 +0200)]
viriscsitest: Move testSessionInfo struct

This struct has nothing to do with testIscsiadmCb() rather than
testISCSIGetSession(). Move it closer to the latter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoviriscsitest: Test virISCSIConnectionLogin
Michal Privoznik [Wed, 4 Jul 2018 08:08:48 +0000 (10:08 +0200)]
viriscsitest: Test virISCSIConnectionLogin

Introduce one basic test that tests the simplest case:
logging into portal without any IQN.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirCommandWait: Propagate dryRunCallback return value properly
Michal Privoznik [Wed, 4 Jul 2018 07:57:05 +0000 (09:57 +0200)]
virCommandWait: Propagate dryRunCallback return value properly

The documentation to virCommandWait() function states that if
@exitstatus is NULL and command finished with error -1 is
returned. In other words, if @dryRunCallback is set and returns
an error (by setting its @status argument to a nonzero value) we
must propagate this error properly honouring the documentation
(and also regular run).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirISCSIScanTargets: Allow making targets persistent
Michal Privoznik [Fri, 29 Jun 2018 14:18:23 +0000 (16:18 +0200)]
virISCSIScanTargets: Allow making targets persistent

After a new iSCSI interface is successfully set up, we issue a
sendtargets command. However, after 56057900dc53df490d we don't
update the host config which in turn makes login fail because
iscsiadm is unable to find any matching record for the interface.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirISCSIScanTargets: Honour iSCSI interface
Michal Privoznik [Fri, 29 Jun 2018 14:05:50 +0000 (16:05 +0200)]
virISCSIScanTargets: Honour iSCSI interface

When scanning for targets, iSCSI might give different results
depending on the interface used. This is basically just name of
config file under /etc/iscsi/ifaces to use. The file contains
initiator IQN thus different results claim.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirStorageBackendIQNFound: Rework iscsiadm output parsing
Michal Privoznik [Fri, 29 Jun 2018 09:34:23 +0000 (11:34 +0200)]
virStorageBackendIQNFound: Rework iscsiadm output parsing

Firstly, we can utilize virCommandSetOutputBuffer() API which
will collect the command output for us. Secondly, sscanf()-ing
through each line is easier to understand (and more robust) than
jumping over a string with strchr().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirStorageBackendIQNFound: Rename out label
Michal Privoznik [Fri, 29 Jun 2018 09:43:54 +0000 (11:43 +0200)]
virStorageBackendIQNFound: Rename out label

This is in fact 'cleanup' label and it should be named as such.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirStorageBackendIQNFound: Fix ret value assignment
Michal Privoznik [Fri, 29 Jun 2018 08:12:58 +0000 (10:12 +0200)]
virStorageBackendIQNFound: Fix ret value assignment

Perform some method clean-up to follow more accepted coding standards:

 * Initialize @ret to error value and prove otherwise.
 * Initialize *ifacename to NULL

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agorun: Fix LIBVIRTD_PATH
Cole Robinson [Tue, 24 Jul 2018 14:31:21 +0000 (10:31 -0400)]
run: Fix LIBVIRTD_PATH

It wasn't updated when libvirtd was moved from daemon/ to src/

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agostorage_util: Prefer generic FICLONE over btrfs/xfs defines
Michal Privoznik [Mon, 9 Jul 2018 10:59:20 +0000 (12:59 +0200)]
storage_util: Prefer generic FICLONE over btrfs/xfs defines

After my change to the original patch that resulted in commit
8ed874b39b3 it was brought to my attention that all three defines
are the same: FICLONE = BTRFS_IOC_CLONE = XFS_IOC_CLONE (as
documented in ioctl_ficlone(2)). Therefore we should prefer
generic FICLONE over 'specific' defines for btrfs/xfs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: hotplug: Don't leak saved error on failure in qemuHotplugRemoveManagedPR
Peter Krempa [Mon, 23 Jul 2018 13:38:02 +0000 (15:38 +0200)]
qemu: hotplug: Don't leak saved error on failure in qemuHotplugRemoveManagedPR

If we'd fail to enter or exit the monitor the saved error would be
leaked. Introduced in 8498a1e2221 .

Pointed out by coverity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirTypedParamsDeserialize: set nparams to 0 in case of an error
Marc Hartmayer [Tue, 17 Jul 2018 12:02:33 +0000 (14:02 +0200)]
virTypedParamsDeserialize: set nparams to 0 in case of an error

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirTypedParamsSerialize: set remote_params_len at the end
Marc Hartmayer [Tue, 17 Jul 2018 12:02:32 +0000 (14:02 +0200)]
virTypedParamsSerialize: set remote_params_len at the end

Update the length @remote_params_len only if the related
@remote_params_val has also been set.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: also skip qemuagenttest with old jansson
Ján Tomko [Mon, 23 Jul 2018 14:57:20 +0000 (16:57 +0200)]
tests: also skip qemuagenttest with old jansson

qemuagenttest also depends on JSON object key ordering:
Invalid value of argument 'vcpus' of command 'guest-set-vcpus':
expected '[{"logical-id":1,"online":false}]' got '[{"online":false,"logical-id":1}]'

Skip it as well.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Add CAPS_LATEST version of security-related tests
Peter Krempa [Thu, 19 Jul 2018 15:30:07 +0000 (17:30 +0200)]
tests: qemuxml2argv: Add CAPS_LATEST version of security-related tests

'disk-network-source-auth' and 'disk-network-tlsx509'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Add CAPS_LATEST version of 'disk-network-sheepdog'
Peter Krempa [Thu, 19 Jul 2018 15:30:07 +0000 (17:30 +0200)]
tests: qemuxml2argv: Add CAPS_LATEST version of 'disk-network-sheepdog'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Add CAPS_LATEST version of 'disk-network-gluster'
Peter Krempa [Thu, 19 Jul 2018 15:30:07 +0000 (17:30 +0200)]
tests: qemuxml2argv: Add CAPS_LATEST version of 'disk-network-gluster'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Add CAPS_LATEST version of 'disk-readonly' and 'disk-shared'
Peter Krempa [Thu, 19 Jul 2018 15:30:07 +0000 (17:30 +0200)]
tests: qemuxml2argv: Add CAPS_LATEST version of 'disk-readonly' and 'disk-shared'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Add CAPS_LATEST version of 'disk-floppy' and 'floppy-drive-fat'
Peter Krempa [Thu, 19 Jul 2018 15:30:07 +0000 (17:30 +0200)]
tests: qemuxml2argv: Add CAPS_LATEST version of 'disk-floppy' and 'floppy-drive-fat'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemu: Remove pointless 'disk-many' test
Peter Krempa [Thu, 19 Jul 2018 15:22:09 +0000 (17:22 +0200)]
tests: qemu: Remove pointless 'disk-many' test

We have several cases when a VM has multiple disks in the test files so
having another one without any interesting configuration is not
necessary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Unify testing of 'disk-network-rbd'
Peter Krempa [Thu, 19 Jul 2018 15:07:45 +0000 (17:07 +0200)]
tests: qemuxml2argv: Unify testing of 'disk-network-rbd'

Move the authentication and ipv6 cases into the main test file. To allow
removal of the separate testing of the secure credential passing via the
'secret' object in qemu, use the DO_TEST_CAPS_VER macro with version
2.5.0 when the secret object is not supported by qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemu: Remove pointless 'disk-network-ceph-env' test
Peter Krempa [Thu, 19 Jul 2018 14:58:26 +0000 (16:58 +0200)]
tests: qemu: Remove pointless 'disk-network-ceph-env' test

The xml2argv variant was unused. The xml2xml variant is redundant in
other tests for RBD.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Add 'CAPS_LATEST' version of 'disk-network-nbd'
Peter Krempa [Thu, 19 Jul 2018 14:29:19 +0000 (16:29 +0200)]
tests: qemuxml2argv: Add 'CAPS_LATEST' version of 'disk-network-nbd'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemu: Unify nbd disk source testing
Peter Krempa [Thu, 19 Jul 2018 14:26:48 +0000 (16:26 +0200)]
tests: qemu: Unify nbd disk source testing

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Add 'CAPS_LATEST' version of 'disk-network-iscsi'
Peter Krempa [Thu, 19 Jul 2018 14:19:32 +0000 (16:19 +0200)]
tests: qemuxml2argv: Add 'CAPS_LATEST' version of 'disk-network-iscsi'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemu: Unify iscsi disk source testing
Peter Krempa [Thu, 19 Jul 2018 13:39:23 +0000 (15:39 +0200)]
tests: qemu: Unify iscsi disk source testing

Move various different iSCSI configuration into one test file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemu: Unify disk cache testing
Peter Krempa [Thu, 19 Jul 2018 13:00:50 +0000 (15:00 +0200)]
tests: qemu: Unify disk cache testing

Move the 'unsafe' cache test into 'disk-cache' and remove all the
individual cases for one cache mode each.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemu: Add xml2xml and minimal version of 'disk-cache' test
Peter Krempa [Thu, 19 Jul 2018 13:21:40 +0000 (15:21 +0200)]
tests: qemu: Add xml2xml and minimal version of 'disk-cache' test

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Rename disk-write-cache test do disk-cache
Peter Krempa [Thu, 19 Jul 2018 12:51:21 +0000 (14:51 +0200)]
tests: qemuxml2argv: Rename disk-write-cache test do disk-cache

We'll aggregate testing of all cache modes in this test later on.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Add 'CAPS_LATEST' version of 'disk-aio' test
Peter Krempa [Thu, 19 Jul 2018 12:14:11 +0000 (14:14 +0200)]
tests: qemuxml2argv: Add 'CAPS_LATEST' version of 'disk-aio' test

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Add 'CAPS_LATEST' version for 'disk-detect-zeroes'
Peter Krempa [Thu, 19 Jul 2018 12:12:19 +0000 (14:12 +0200)]
tests: qemuxml2argv: Add 'CAPS_LATEST' version for 'disk-detect-zeroes'

This test also excercises options of 'discard'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Add 'CAPS_LATEST' data for disk-cdrom* tests
Peter Krempa [Thu, 19 Jul 2018 12:07:17 +0000 (14:07 +0200)]
tests: qemuxml2argv: Add 'CAPS_LATEST' data for disk-cdrom* tests

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Unify testing of local cdroms
Peter Krempa [Thu, 19 Jul 2018 12:01:07 +0000 (14:01 +0200)]
tests: qemuxml2argv: Unify testing of local cdroms

Test empty cdroms along with cdroms with medium.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Unify network cdrom source testing
Peter Krempa [Thu, 19 Jul 2018 11:46:05 +0000 (13:46 +0200)]
tests: qemuxml2argv: Unify network cdrom source testing

Unify most of the tests into a common test named disk-cdrom-network by
adding multiple cdroms. The 'http' test is dropped since there can be
only 4 cdroms.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Remove tests obsoleted by assuming support for '-device'
Peter Krempa [Thu, 19 Jul 2018 11:38:29 +0000 (13:38 +0200)]
tests: qemuxml2argv: Remove tests obsoleted by assuming support for '-device'

Few disk tests were testing support for pure -drive command line
generation for disks now that we assume it for all qemu versions the
cases are obsolete.

Replacements:
disk-readonly-no-device -> disk-readonly-disk
disk-floppy-tray-no-device -> disk-floppy-tray
disk-cdrom-tray-no-device -> disk-cdrom-tray

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2argv: Add 'CAPS_LATEST' version of "disk-copy_on_read"
Peter Krempa [Thu, 19 Jul 2018 11:49:39 +0000 (13:49 +0200)]
tests: qemuxml2argv: Add 'CAPS_LATEST' version of "disk-copy_on_read"

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemuxml2xml: Remove duplicate test disk-copy-on-read.xml
Peter Krempa [Thu, 19 Jul 2018 11:21:28 +0000 (13:21 +0200)]
tests: qemuxml2xml: Remove duplicate test disk-copy-on-read.xml

We also have disk-copy_on_read.xml which also tests the command line.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemu: Drop 'drive' from disk tests
Peter Krempa [Thu, 19 Jul 2018 08:29:29 +0000 (10:29 +0200)]
tests: qemu: Drop 'drive' from disk tests

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Improve virStrncpy() implementation
Andrea Bolognani [Fri, 20 Jul 2018 11:00:44 +0000 (13:00 +0200)]
util: Improve virStrncpy() implementation

We finally get rid of the strncpy()-like semantics
and implement our own, more sensible ones instead.

As a bonus, this also fixes compilation on MinGW.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoesx: Use memcpy() in esxVI_CURL_Debug()
Andrea Bolognani [Fri, 20 Jul 2018 07:50:37 +0000 (09:50 +0200)]
esx: Use memcpy() in esxVI_CURL_Debug()

We're going to change virStrncpy() in a way that
requires the source string to be NULL-terminated, so
we'll no longer be able to use in this context.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agosrc: Make virStr*cpy*() functions return an int
Andrea Bolognani [Fri, 20 Jul 2018 07:50:37 +0000 (09:50 +0200)]
src: Make virStr*cpy*() functions return an int

Currently, the functions return a pointer to the
destination buffer on success or NULL on failure.

Not only does this kind of error handling look quite
alien in the context of libvirt, where most functions
return zero on success and a negative int on failure,
but it's also somewhat pointless because unless there's
been a failure the returned pointer will be the same
one passed in by the user, thus offering no additional
value.

Change the functions so that they return an int
instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agosrc: Don't rely on strncpy()-like behavior
Andrea Bolognani [Fri, 20 Jul 2018 12:15:09 +0000 (14:15 +0200)]
src: Don't rely on strncpy()-like behavior

The strncpy() function has this quirk where it will copy
*up* to the requested number of bytes, that is, it will
stop early if it encounters a NULL byte in the source
string.

This makes it legal to pass the size of the destination
buffer (minus one byte needed for the string terminator)
as the number of bytes to copy and still get something
somewhat reasonable out of the operation; unfortunately,
it also makes the function difficult to reason about
and way too easy to misuse.

We want to move away from the way strncpy() behaves and
towards better defined semantics, where virStrncpy()
will always copy *exactly* the number of bytes it's
been asked to copy; before we can do that, though, we
have to change a few of the callers.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agosrc: Use virStrcpy() wherever possible
Andrea Bolognani [Fri, 20 Jul 2018 11:00:34 +0000 (13:00 +0200)]
src: Use virStrcpy() wherever possible

virStrncpy() allows us to copy a substring, but if we're
going to copy the entire thing it's much more convenient
to use virStrcpy() instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agosrc: Use VIR_STRDUP() wherever possible
Andrea Bolognani [Fri, 20 Jul 2018 07:45:12 +0000 (09:45 +0200)]
src: Use VIR_STRDUP() wherever possible

virStrcpy() and friends are useful when the destination
buffer has already been allocated, eg. as part of a struct;
if we have to allocate it on the spot, VIR_STRDUP() is a
better choice.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>