Commit Graph

4034 Commits

Author SHA1 Message Date
Martin Kletzander
2e5579a43b util: Introduce virBitmapNewString
Our bitmaps can be represented as data (raw bytes for which we have
virBitmapNewData() and virBitmapToData()), human representation (list
of numbers in a string for which we have virBitmapParse() and
virBitmapFormat()) and hexadecimal string (for which we have only
virBitmapToString()).  So let's add the missing complement for the
last one so that we can parse hexadecimal strings.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
5d893ed6ad util: Rename virBitmapDataToString to virBitmapDataFormat
It is literally only a wrapper around virBitmapNewData() and
virBitmapFormat(), only the naming was wrong since it was introduced.
And because we have virBitmap*String functions where the meaning of
the 'String' is constant, this might confuse someone.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
b8bbc23fea Only output initialized capabilities with VIR_TEST_DEBUG > 1
Currenty virTestInit() outputs all capabilities that it created when running
with VIR_TEST_DEBUG=1.  Since this is quite a lot of output for every call of
this function (and it is not needed until debugging a really deep-down issue)
let's just output the info when VIR_TEST_DEBUG is strictly greater than 1.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
e399641561 tests: Remove pointless _CFLAGS variables
If _CFLAGS for a binary is not specified it uses AM_CFLAGS.  So doing

  $binary_CFLAGS = $(AM_CFLAGS)

or

  $binary_CFLAGS = $(AM_CFLAGS) $(something_that_is_already_in_AM_CFLAGS)

is pointless.  So remove it for cleaner Makefile.am

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
74a13be4a4 build: Use XDR_CFLAGS in more places
Since update to glibc-2.26 removed the /usr/include/rpc/rpc.h we used until now,
it showed us a problem with not using XDR_CFLAGS properly.  On linux that
variable has usually -I/usr/include/tirpc because we already probe for it
properly, we just don't use it everywhere we need.  It is needed by wireshark
dissector as well as testutilsqemu.c (through includes) so the build fails with:

wireshark/src/packet-libvirt.c:33:10: fatal error: rpc/xdr.h: No such file or directory
 #include <rpc/xdr.h>
          ^~~~~~~~~~~

and

In file included from ../src/logging/log_manager.h:29:0,
                 from ../src/qemu/qemu_domain.h:40,
                 from testutilsqemu.c:11:
../src/logging/log_protocol.h:9:10: fatal error: rpc/rpc.h: No such file or directory
 #include <rpc/rpc.h>
          ^~~~~~~~~~~

Since lot of tests use testutilsqemu.c it is easier to add XDR_CFLAGS to
AM_CFLAGS than adding it to all $binary_CFLAGS.  It's just for tests and we
already have bunch of CFLAGS there anyway.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-11-18 10:45:10 +01:00
Andrea Bolognani
5e192a3620 tests: Add tests for configuration of HPT resizing
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-14 16:47:04 +01:00
Andrea Bolognani
85b2ae96df qemu: Enable configuration of HPT resizing for pSeries guests
Most of the time it's okay to leave this up to negotiation between
the guest and the host, but in some situations it can be useful to
manually decide the behavior, especially to enforce its availability.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-14 16:29:55 +01:00
Jiri Denemark
5f244e3161 vircapstest: Avoid (im)possible strcmp call with NULL argument
Some compilers may get confused and decide we are calling strcmp with
NULL argument from test_virCapsDomainDataLookupLXC. Although this does
not really happen since the call is guarded with
(data->machinetype != expect_machinetype), using STRNEQ_NULLABLE is
easier to understand, less fragile, and doing so makes sure strcmp is
never called with NULL argument.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-11-14 14:45:19 +01:00
Peter Krempa
19448a2561 conf: Properly parse <backingStore/>
The terminator would not be parsed properly since the XPath selector was
looking for an populated element, and also the code did not bother
assigning the terminating virStorageSourcePtr to the backingStore
property of the parent.

Some tests would catch it if there wasn't bigger fallout from the change
to backing store termination in a693fdba01. Fix them properly now.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1509110
2017-11-13 13:13:29 +01:00
Wim ten Have
1d358fa5c4 libxlxml2domconfigtest: add test for vNUMA config
Add tests to ensure the libxl_domain_config generator properly
handles vNUMA configuration.

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2017-11-12 19:39:57 -07:00
Wim ten Have
22098a49b9 xlconfigtest: add tests for vNUMA configuration
Add tests for conversion of domXML vNUMA config to/from
xen-xl native vNUMA config.

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2017-11-12 19:39:24 -07:00
Pino Toscano
ef5c8a91aa tests: fix TTY check in virTestUseTerminalColors()
Since colors would be used when writing to stdout, then check that
stdout is a TTY, instead of stdin.

This avoids the usage of terminal color codes when the output is
directed to file.
2017-11-10 16:12:43 +01:00
Michal Privoznik
9324f67a57 qemuBuildDriveDevStr: Prefer default aliases for IDE bus
https://bugzilla.redhat.com/show_bug.cgi?id=1434451

When testing user aliases it was discovered that for 440fx
machine type which has default IDE bus builtin, domain cannot
start if IDE controller has the user provided alias. This is
because for 440fx we don't put the IDE controller onto the
command line (since it is builtin) and therefore any device that
is plugged onto the bus must use the default alias.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-11-10 15:23:55 +01:00
Jim Fehlig
299e97c4e8 virconf: properly set the end of content
There was a recent report of the xen-xl converter not handling
config files missing an ending newline

https://www.redhat.com/archives/libvir-list/2017-October/msg01353.html

Commit 3cc2a9e0 fixed a similar problem when parsing content of a
file but missed parsing in-memory content. But AFAICT, the better
fix is to properly set the end of the content when initializing the
virConfParserCtxt in virConfParse().

This commit reverts the part of 3cc2a9e0 that appends a newline to
files missing it, and fixes setting the end of content when
initializing virConfParserCtxt. A test is also added to check
parsing in-memory content missing an ending newline.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
2017-11-09 08:04:26 -07:00
Peter Krempa
0a3bae7d22 util: storage: Fix parsing of IPv6 portal address for iSCSI
Split on the last colon and avoid parsing port if the split remainder
contains the closing square bracket, so that IPv6 addresses are
interpreted correctly.
2017-11-08 13:10:40 +01:00
Andrea Bolognani
ab81dafe80 tests: Add caps for QEMU 2.10.0 on ppc64
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-08 10:47:40 +01:00
Andrea Bolognani
61ea70341a tests: Rename ppc64le caps to ppc64
The architecture itself is called ppc64, and it can run both in big
endian and little endian mode - the latter is known as ppc64le.

From the (virtual) hardware point of view, ppc64 is a more accurate
name so it should be used here.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-08 10:47:38 +01:00
Andrea Bolognani
8cf2cb8913 tests: Add caps for QEMU 2.10.0 on aarch64 (GICv3)
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-08 10:47:34 +01:00
Andrea Bolognani
92c3a6e0c4 tests: Add caps for QEMU 2.10.0 on aarch64 (GICv2)
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-08 10:47:23 +01:00
Michal Privoznik
fec8f9c49a qemu: Use predictable file names for memory-backend-file
In some cases management application needs to allocate memory for
qemu upfront and then just let qemu use that. Since we don't want
to expose path for memory-backend-file anywhere in the domain
XML, we can generate predictable paths. In this case:

  $memoryBackingDir/libvirt/qemu/$shortName/$alias

where $shortName is result of virDomainDefGetShortName().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-08 10:17:17 +01:00
Jiri Denemark
4ca81baa23 cputest: Add data for Intel(R) Core(TM) i7-7700 CPU
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-07 23:40:47 +01:00
Jiri Denemark
d85ae683e5 cputest: Add data for Intel(R) Xeon(R) CPU E5-2650 v4
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-07 23:40:47 +01:00
Jiri Denemark
6f10044d4f cputest: Do not drop v[0-9] from CPU names
Version is a significant part of some Xeon CPUs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-07 23:40:47 +01:00
Peter Krempa
96be3e72e8 tests: Add testing of storage backend JSON props formatter
Add a new test program called 'qemublocktest' to test the block layer
related stuff and test storage source to JSON generator by comparing it
to the JSON parser.
2017-11-07 16:18:14 +01:00
Peter Krempa
90521d0754 storage: Store RBD image name as pool and image name
Similarly to how we store gluster names, split the name into a pool and
image portions when paring the XML and store them separately.
2017-11-07 14:58:04 +01:00
Peter Krempa
bb14d9897b storage: Don't store leading '/' in image name when splitting out volume
Libvirt historically stores storage source path including the volume as
one string in the XML, but that is not really flexible enough when
dealing with the fields in the code. Previously we'd store the slash
separating the two as part of the image name. This was fine for gluster
but it's not necessary and does not scale well when converting other
protocols.

Don't store the slash as part of the path. The resulting change from
absolute to relative path within the gluster driver should be okay,
as the root directory is the default when accessing gluster.
2017-11-07 14:58:04 +01:00
Peter Krempa
bd37213786 qemu: block: Use proper type for servers for VxHS disks
Original implementation used 'SocketAddress' equivalent from qemu for
the disk server field, while qemu documentation specifies
'InetSocketAddress'. The backing store parser uses the correct parsing
function but the formatter used the incorrect one (and also with the
legacy mode enabled which was wrong).
2017-11-07 14:43:12 +01:00
Andrea Bolognani
3e7db8d3e8 Remove backslash alignment attempts
Right-aligning backslashes when defining macros or using complex
commands in Makefiles looks cute, but as soon as any changes is
required to the code you end up with either distractingly broken
alignment or unnecessarily big diffs where most of the changes
are just pushing all backslashes a few characters to one side.

Generated using

  $ git grep -El '[[:blank:]][[:blank:]]\\$' | \
    grep -E '*\.([chx]|am|mk)$$' | \
    while read f; do \
      sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \
    done

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2017-11-03 13:24:12 +01:00
Jiri Denemark
a1e3e8ddbd qemu: Add support for block-incremental migration parameter
We handle incremental storage migration in a different way. The support
for this new (as of QEMU 2.10) parameter is only needed for full
coverage of migration parameters used by QEMU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-02 22:14:20 +01:00
Jiri Denemark
f6e2a70ae2 qemu: Add support for max-bandwidth migration parameter
We already support several ways of setting migration bandwidth and this
is not adding another one. With this patch we are able to read and write
this parameter using query-migrate-parameters and migrate-set-parameters
in one call with all other parameters.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-02 22:14:20 +01:00
Jiri Denemark
af1d2fe270 qemu: Rename TLS related migration parameters
The parameters used "migrate" prefix which is pretty redundant and
qemuMonitorMigrationParams structure is our internal representation of
QEMU migration parameters and it is supposed to use names which match
QEMU names.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-02 22:14:20 +01:00
Jiri Denemark
2384b6f019 qemu: Add support for setting downtime-limit migration parameter
We already support setting the maximum downtime with a dedicated
virDomainMigrateSetMaxDowntime API. This patch does not implement
another way of setting the downtime by adding a new public migration
parameter. It just makes sure any parameter we are able to get from a
QEMU monitor by query-migrate-parameters can be passed back to QEMU via
migrate-set-parameters.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-02 22:14:19 +01:00
Jiri Denemark
9b5d1bd2e3 qemumonitorjsontest: Rename 2nd CHECK macro in migration params test
The second CHECK macro was used for string parameters. Let's rename it
to CHECK_STR and move it up to have all checks in one place.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-02 22:14:19 +01:00
Jiri Denemark
cf0c87aacf qemumonitorjsontest: Rename 1st CHECK macro in migration params test
The first CHECK macro in the test is used for checking integer values.
Let's make it a bit more generic to be usable for any numeric type and
use it for a new CHECK_INT macro.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-02 22:14:19 +01:00
Jiri Denemark
49c945a6f5 cputest: Skip tests requiring JSON_MODELS if QEMU is disabled
Some tests require JSON_MODELS to be parsed into qemuCaps and applied
when computing CPU models and such test cannot succeed if QEMU driver is
disabled. Let's mark the tests with JSON_MODELS_REQUIRED and skip the
appropriate parts if building without QEMU.

On the other hand, CPU tests with JSON_MODELS should succeed even if
model definitions from QEMU are not parsed and applied. Let's explicitly
test this by repeating the tests without JSON_MODELS set.

This fixes the build with QEMU driver disabled, e.g., on some
architectures on RHEL/CentOS.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-02 10:49:13 +01:00
Michal Privoznik
dc162adb90 qemuhotplugtest: Test user supplied alias
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-10-27 14:43:21 +02:00
Christian Ehrhardt
0167e9c535 virt-aa-helper-test: only fails go to stdout by default
By Default (without -d) the tests will only print Failures.
So a log should follow general "no message is a good message" style.

But the testfw checks always emit the skip info to stdout. Instead
they should use the redirection that is controlled by -d.

This avoids mesages like the following to clutter the log:
  Skipping FW AAVMF32 test. Could not find /usr/share/AAVMF/AAVMF32_CODE.fd

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2017-10-27 10:32:02 +02:00
Christian Ehrhardt
a150b86c4c virt-aa-helper: apparmor wildcards to forbidden chars
Some globbing chars in the domain name could be used to break out of
apparmor rules, so lets forbid these when in virt-aa-helper.

Also adding a test to ensure all those cases were detected as bad char.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2017-10-27 10:32:02 +02:00
Michal Privoznik
7e939394b2 tests: Test user set aliases for qemu
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-10-23 09:02:30 +02:00
Michal Privoznik
821b0b295d qemuhotplugtest: Load active XML
The point of this test is to load live XML and test hotplug. But
even though the XMLs we are parsing are live, the parsing is done
with VIR_DOMAIN_DEF_PARSE_INACTIVE flag.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-10-23 08:53:51 +02:00
Michal Privoznik
a15c97f5e4 qemuxml2argvdata: Drop device aliases
The qemuxml2argvtest expects the domain XMLs to be inactive ones.
Therefore we should pass inactive XMLs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-10-23 08:52:50 +02:00
Jiri Denemark
38b0e4f58f qemu: Drop qemuMonitorGetMigrationCapability
The only remaining user of qemuMonitorGetMigrationCapability is our test
suite. Let's replace qemuMonitorGetMigrationCapability with
qemuMonitorGetMigrationCapabilities there and drop the unused function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-10-20 13:37:03 +02:00
John Ferlan
37537a7c64 conf: Add/Allow parsing the encryption in the disk source
Since the virStorageEncryptionPtr encryption; is a member of
 _virStorageSource it really should be allowed to be a subelement
of the disk <source> for various disk formats:

   Source{File|Dir|Block|Volume}
   SourceProtocol{RBD|ISCSI|NBD|Gluster|Simple|HTTP}

NB: Simple includes sheepdog, ftp, ftps, tftp

That way we can set up to allow the <encryption> element to be
formatted within the disk source, but we still need to be wary
from whence the element was read - see keep track and when it
comes to format the data, ensure it's written in the correct place.

Modify the qemuxml2argvtest to add a parse failure when there is an
<encryption> as a child of <disk> *and* an <encryption> as a child
of <source>.

The virschematest will read the new test files and validate from a
RNG viewpoint things are fine.
2017-10-19 15:32:50 -04:00
John Ferlan
8002d3cb1b conf: Add/Allow parsing the auth in the disk source
Since the virStorageAuthDefPtr auth; is a member of _virStorageSource
it really should be allowed to be a subelement of the disk <source>
for the RBD and iSCSI prototcols. That way we can set up to allow
the <auth> element to be formatted within the disk source.

Since we've allowed the <auth> to be a child of <disk>, we'll need
to keep track of how it was read so that when writing out we'll know
whether to format as child of <disk> or <source>. For the argv2xml
parsing, let's format under <source> as a preference. Do not allow
<auth> to be both a child of <disk> and <source>.

Modify the qemuxml2argvtest to add a parse failure when there is an
<auth> as a child of <disk> *and* an <auth> as a child of <source>.

Add tests to validate that if the <auth> was found in <source>, then
the resulting xml2xml and xml2arg works just fine.  The two new .args
file are exact copies of the non "-source" version of the file.

The virschematest will read the new test files and validate from a
RNG viewpoint things are fine

Update the virstoragefile, virstoragetest, and args2xml file to show
the "preference" to place <auth> as a child of <source>.
2017-10-19 15:26:49 -04:00
Pavel Hrdina
a9d637e71e qemu: move detection whether to use -no-reboot to qemu_domain
This will be used later on in implementation of new API
virDomainSetLifecycleAction().  In order to use it, we need to store
the value in status XML to not lose the information if libvirtd is
restarted.

If some guest was started by old libvirt where it was not possible
to change the lifecycle action for running guest, we can safely
detect it based on the current actions from the status XML.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-10-19 11:52:30 +02:00
Jiri Denemark
c7d27105cb cputest: Add query-cpu-definitions reply for Xeon-E7-8890
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-10-17 22:37:04 +02:00
Jiri Denemark
637d2ce91a cputest: Update Xeon-E7-8890 data
Without the fix in the previous patch the JSON data from QEMU would be
interpreted as Haswell-noTSX because x86DataFilterTSX would filter rtm
and hle features as a result of

    family == 6 && model == 63 && stepping < 4

test even though this CPU has stepping == 4.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-10-17 22:37:04 +02:00
Jiri Denemark
e1ca8ecb46 qemu: Check QEMU error on failed migration
When migration fails, QEMU may provide a description of the error in
the reply to query-migrate QMP command. We can fetch this error and use
it instead of the generic "unexpectedly failed" message.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-10-17 10:41:45 +02:00
Peter Krempa
a693fdba01 Terminate backing chains explicitly
Express a properly terminated backing chain by putting a
virStorageSource of type VIR_STORAGE_TYPE_NONE in the chain. The newly
used helpers simplify this greatly.

The change fixes a bug as formatting an incomplete backing chain and
parsing it back would end up in expressing a terminated chain since
src->backingStoreRaw was not populated. By relying on the terminator
object this can be now processed appropriately.
2017-10-17 06:19:18 +02:00
Peter Krempa
0a294a8e28 util: storagefile: Add helpers to check presence of backing store
Add helpers that will simplify checking if a backing file is valid or
whether it has backing store. The helper virStorageSourceIsBacking
returns true if the given virStorageSource is a valid backing store
member. virStorageSourceHasBacking returns true if the virStorageSource
has a backing store child.

Adding these functions creates a central points for further refactors.
2017-10-17 06:19:18 +02:00