Commit Graph

6316 Commits

Author SHA1 Message Date
Pavel Hrdina
7b16f6df28 meson: tests: add libxl specific tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
fc55e48d5b meson: tests: add libvirtd specific tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
53481f65d7 meson: tests: add ESX specific tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
41fa1a4f63 meson: tests: add dbus specific tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
13d02fbec0 meson: tests: add bhyve specific tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
1dced6d450 meson: tests: add linux specific tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
a69e945d54 meson: tests: introduce generic tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
d11bf90f90 meson: tests: add test binaries build support
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
096c1bbf2a meson: tests: build shared libraries
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
affd500895 meson: tests: add test environment variables
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
9d8887fc80 meson: tests: build fake ssh binary
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
8fe8df4b20 meson: tests: build commandhelper binary
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
401aa32fdb meson: tests: built utils static libraries
With the old build system we just list the source files directly for
each test, but this would not work as expected with Meson.

For every binary there is a separate directory with its object files
which would mean all the utils sources would be compiled repeatedly
for every test using them.

Having static libraries ensures that the utils sources are compiled
only once.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
8885a3c135 meson: tests: build mock shared modules
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
76dbda15f1 meson: introduce tests directory
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:05 +02:00
Pavel Hrdina
018f7fa8dc meson: remove '.libs' from all relevant paths
Meson doesn't use .libs directory, everything is placed directly into
directories where meson.build file is used.

In order to have working tests and running libvirt directly from GIT we
need to fix all the paths pointing '.libs' directory.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:27:00 +02:00
Pavel Hrdina
1ba97d7f6b meson: tests: virmockstathelpers: replace check for _FILE_OFFSET_BITS
Meson always defines _FILE_OFFSET_BITS=64 which effectively makes
mocking of non 64-bit stat functions dead code.

On linux it was not an issue because we use the 64-bit versions but
on FreeBSD there are not 64-bit versions, there is only stat & lstat.

We cannot simply drop the check as that would resolve to compilation
error on 64-bit linux:

{standard input}: Assembler messages:
{standard input}:11468: Error: symbol `__xstat64' is already defined
{standard input}:11679: Error: symbol `__xstat64.cold' is already defined
{standard input}:12034: Error: symbol `__lxstat64' is already defined
{standard input}:12245: Error: symbol `__lxstat64.cold' is already defined

So we have to replace the _FILE_OFFSET_BITS with a check if the
corresponding 64-bit version of the stat function exists.

Replicate the meson behavior by always defining _FILE_OFFSET_BITS
instead of using AC_SYS_LARGEFILE otherwise this change would break
our tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:26:36 +02:00
Pavel Hrdina
2298b42878 meson: src/util/virfile: rewrite virFileActivateDirOverrideForProg
With meson we no longer have .libs directory with the actual binary so
we have to take a different approach to detect if running from build
directory.

This is not as robust as for autotools because if you select --prefix
in the build directory it will incorrectly enable the override as well
but nobody should do that.

We have to modify some of the tests to not add current build path into
PATH variable and use the full path for virsh instead. Otherwise it
would be impossible to figure out that we are running virsh from build
directory.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:26:36 +02:00
Pavel Hrdina
f988ce2fd5 meson: drop test_suite configure argument
With autoconf this option controlled if the test suite is compiled by
default or not with the fact that it will be compiled later when
running `make check`.

With meson it is not possible to compile it later when running
`ninja test` as it will be always compiled if referenced by `test()`
function in meson.build files.

Since we cannot postpone compilation of the test suite drop this option
as it will not be converted to meson.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:26:31 +02:00
Pavel Hrdina
b63c979fc9 meson: remove automake specific directives
EXTRA_DIST is not relevant because meson makes a git copy when creating
dist archive so everything tracked by git is part of dist tarball.

The remaining ones are not converted to meson files as they are
automatically tracked by meson.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-08-03 09:26:25 +02:00
Ján Tomko
7f9b214711 tests: bhyve: remove unnecessary labels
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
2020-08-03 07:23:46 +02:00
Ján Tomko
aeb5951aa4 tests: bhyve: use g_autoptr where possible
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
2020-08-03 07:23:46 +02:00
Ján Tomko
a7d3d925a7 tests: bhyve: use g_autofree where possible
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
2020-08-03 07:23:46 +02:00
Ján Tomko
7b4a8995a0 tests: bhyve: split variable declarations
One variable per line.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
2020-08-03 07:23:46 +02:00
Ján Tomko
d43f393134 tests: qemu: remove unnecessary labels
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:46 +02:00
Ján Tomko
51be622d76 tests: qemu: use VIR_AUTOSTRINGLIST where possible
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:46 +02:00
Ján Tomko
bcbb026993 tests: qemu: use g_autoptr where possible
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:46 +02:00
Ján Tomko
845fee02c1 tests: qemu: use g_autofree where possible
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:46 +02:00
Ján Tomko
9669287e85 tests: qemucapsxml2xmltest: split variable declaration
One variable per line.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:46 +02:00
Ján Tomko
871544520f tests: qemu: reduce scope of some variables
Reduce the scope of some variables and mark them as
g_autofree.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:45 +02:00
Ján Tomko
63c14318ce tests: commandtest: drop unnecessary labels
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:45 +02:00
Ján Tomko
dac017862b tests: commandtest: use VIR_AUTOCLOSE
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:45 +02:00
Ján Tomko
e2929598db tests: commandtest: use g_autoptr for virCommand
Except for a few cases where freeing it explicitly
seems to be done on purpose.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:45 +02:00
Ján Tomko
363dd1b5e5 tests: commandtest: use g_autofree
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:45 +02:00
Ján Tomko
ad8d52909c tests: commandtest: remove unused 'prefix' parameter
The 'checkoutput' function does have a parameter for a possible
prefix, but it is now unused.

Introduced-by: 241ac07124
Used-by: 62f263a73e
Unused-since: 2dfacbffea

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-08-03 07:23:45 +02:00
Peter Krempa
7877e0d2e4 tests: qemucapabitilies: Bump for 5.1 caps to rc2 for x86_64
Note that 'numa-mem-supported' turned off for certain machine types
which in turn forced us to generate a newer command line in certain
tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-07-31 10:27:51 +02:00
Peter Krempa
bfe82ec142 tests: qemuxml2argv: Lock in "disk-network-tlsx509-vxhs" case to qemu-5.0.0
QEMU 5.1 will drop the vxhs driver.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-07-31 10:27:51 +02:00
Peter Krempa
e34097750a tests: qemu: Split NBD and VXHS protocol tests
QEMU is going to drop 'vxhs' in the upcoming release so we'll need to
track these separately to prevent test suite breakage.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-07-31 10:27:50 +02:00
Peter Krempa
4a2cbf2108 tests: qemuxml2argv: Use only modern versions of 'disk-network-tlsx509' test
We already test with real caps so there's no real need for this special
case. While it technically tested the state without TLS encryption key
secrets, it doesn't really matter that much.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-07-31 10:27:50 +02:00
Peter Krempa
6ae53a1509 tests: commandtest: Make 'test4' checking daemonization more reliable
The 'commandhelper' checks effectively whether the parent process is
still around to report whether it was daemonized or not.

This creates a unlikely race condition in cases when we do actually
daemonize the process as the intermediate process used for the
daemonization might not have terminated yet which would report wrong
result leading to test failure.

For now there's just 'test4' which actually daemonizes the process.

Add an argument '--check-daemonize' which asks for retries of the
daemonization check in cases where we expect that the commandhelper is
going to be daemonized and use it in 'test4' to make the test more
reliable.

I've observed the test failure sporadically when my box is under load
e.g. while building two trees at once.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-27 15:44:38 +02:00
Daniel P. Berrangé
bb8ccb050d conf: add control over COW for storage pool directories
The storage pool code now attempts to disable COW by default on btrfs,
but management applications may wish to override this behaviour. Thus we
introduce a concept of storage pool features:

  <features>
    <cow state='yes|no'/>
  </features>

If the <cow> feature policy is set, it will be enforced. It will always
return an hard error if COW cannot be explicitly set or unset.

Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-07-23 16:18:09 +01:00
Bastien Orivel
d3aa28925f Add a check attribute on the mac address element
This is only used in the ESX driver where, when set to "no", it will
ignore all the checks libvirt does about the origin of the MAC address
(whether or not it's in a VMWare OUI) and forward the original one to
the ESX server telling it not to check it either.

This allows keeping a deterministic MAC address which can be useful for
licensed software which might dislike changes.

Signed-off-by: Bastien Orivel <bastien.orivel@diateam.net>

VMX conversion parts rewritten to apply on top of previously merged
support for type='generated|static'

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-07-23 16:11:39 +01:00
Daniel P. Berrangé
80975c3c84 vmx: support outputing the type attribute for MAC addresses
When support for MAC addresses having a type='static|generated'
attribute was added in:

  commit 454e5961ab
  Author: Bastien Orivel <bastien.orivel@diateam.net>
  Date:   Mon Jul 13 16:28:53 2020 +0200

    Add a type attribute on the mac address element

the VMX -> XML parser was not updated. As a result while we
accept the 'type' attribute on input, we never show it again
on 'output', so we loose information during the roundtrip.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-07-23 16:11:35 +01:00
Daniel P. Berrangé
6d3cb071b4 vmx: fix logic handling mac address type
With the current formatter, the XML snippets:

    <interface type='bridge'>
      <mac address='00:0c:29:dd:ee:fe' type='static'/>
      <source bridge='br1'/>
    </interface>
    <interface type='bridge'>
      <mac address='aa:bb:cc:dd:ee:fd' type='generated'/>
      <source bridge='br2'/>
    </interface>

result in

 ethernet1.present = "true"
 ethernet1.networkName = "br1"
 ethernet1.connectionType = "bridged"
 ethernet1.addressType = "static"
 ethernet1.address = "00:0c:29:dd:ee:fe"
 ethernet1.checkMACAddress = "false"

 ethernet2.present = "true"
 ethernet2.networkName = "br2"
 ethernet2.connectionType = "bridged"
 ethernet2.addressType = "static"
 ethernet2.address = "aa:bb:cc:dd:ee:fd"
 ethernet2.checkMACAddress = "false"

which is flawed, as both type='static' and type='generated' in the XML
turn into 'static' in the VMX config.

The existence of the 'static' attribute is further overriding whether
the checkMACAddress config option is set as a side effect.

Both these pieces of flawed logic were introduced in

  commit 454e5961ab
  Author: Bastien Orivel <bastien.orivel@diateam.net>
  Date:   Mon Jul 13 16:28:53 2020 +0200

    Add a type attribute on the mac address element

which intentionally added the 'checkMACAddress' side effect based on
the 'type' attribute.

With this change, we're reverting the handling of checkMACAddress
to match what existed historically. The 'type' attribute now directly
maps to the addressType attribute, so the above config becomes:

 ethernet1.present = "true"
 ethernet1.networkName = "br1"
 ethernet1.connectionType = "bridged"
 ethernet1.addressType = "static"
 ethernet1.address = "00:0c:29:dd:ee:fe"

 ethernet2.present = "true"
 ethernet2.networkName = "br2"
 ethernet2.connectionType = "bridged"
 ethernet2.addressType = "generated"
 ethernet2.generatedAddress = "aa:bb:cc:dd:ee:fd"
 ethernet2.generatedAddressOffset = "0"

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-07-23 16:11:31 +01:00
Daniel P. Berrangé
5e9d6b3a46 tests: don't mock the time() function on mingw
The mingw header define time() as a static inline function and this
causes a duplicate definition build failure. Since we're not using the
LD_PRELOAD at all on Mingw, we ideally wouldn't compile any of the
mock libraries. Rather than change the build system now though, this
just stubs out the offending function.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-07-23 14:58:16 +01:00
Peter Krempa
9d039863e2 qemu: block: Remove 'active-write' bitmap even if there are no bitmaps to merge
The 'libvirt-tmp-activewrite' bitmap is added during the 'pivot'
operation of block copy and active layer block commit operations
regardless of whether there are any bitmaps to merge, but was not
removed unless a bitmap was merged. This meant that subsequent attempts
to merge into the same image would fail.

Fix it by checking whether the 'libvirt-tmp-activewrite' would be used
by the code and don't skip the code which would delete it.

This is a regression introduced when we switched to the new code for
block commit in <20a7abc2d2d> and for block copy in <7bfff40fdfe5>. The
actual bug originates from <4fa8654ece>.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-21 09:52:59 +02:00
Laine Stump
cc5da62bbd replace g_new() with g_new0() for consistency
g_new() is used in only 3 places. Switching them to g_new0() will do
no harm, reduces confusion, and helps me sleep better at night knowing
that all allocated memory is initialized to 0 :-) (Yes, I *know* that
in all three cases the associated memory is immediately assigned some
other value. Today.)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-20 19:08:07 -04:00
Peter Krempa
30932473e1 qemu: caps: Enable QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI
Enable it when regular QEMU_CAPS_BLOCKDEV is present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-17 07:41:21 +02:00
Peter Krempa
dd339e86db qemu: domain: Regenerate hostdev source private data
When upgrading from a libvirt which didn't format private data of a
virStorageSource representing an iSCSI hostdev source, we might need to
generate some internal data so that the code still works as if it was
present in the status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-17 07:41:20 +02:00
Peter Krempa
6306f88df0 qemustatusxml2xmltest: Add tests for iSCSI hostdev private data handling
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-07-17 07:41:20 +02:00