Commit Graph

33241 Commits

Author SHA1 Message Date
Jonathon Jongsma
e31f3df7ca src/interface: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:09 +02:00
Jonathon Jongsma
07729eedf3 src/hyperv: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:09 +02:00
Jonathon Jongsma
a037259055 src/esx: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:09 +02:00
Jonathon Jongsma
d293ff8efc src/datatypes.h: use #pragma once
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:09 +02:00
Jonathon Jongsma
b7779b2938 src/cpu: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:09 +02:00
Jonathon Jongsma
222e0f0f08 conf: misc: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:09 +02:00
Jonathon Jongsma
5ef190a4d2 conf: storage: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:09 +02:00
Jonathon Jongsma
787be820f3 conf: node device: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:09 +02:00
Jonathon Jongsma
44dc50ec23 conf: nwfilter: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:09 +02:00
Jonathon Jongsma
54c5224e75 conf: network: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:09 +02:00
Jonathon Jongsma
b268e87319 conf: domain: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:08 +02:00
Jonathon Jongsma
b7356e826c src/bhyve: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:08 +02:00
Jonathon Jongsma
99527e9e0c src/admin: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:08 +02:00
Jonathon Jongsma
bed1143ff5 src/access: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:08 +02:00
Jonathon Jongsma
e97f8228b9 Use #pragma once in driver headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:08 +02:00
Peter Krempa
e6635c626a qemu: domain: Log some useful data in qemuDomainStorageSourceAccessModify
Log the flags passed to the function in a exploded state so that it's
easily visible what's happening to the image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 09:43:02 +02:00
Andrea Bolognani
73cfc36211 tests: Include LDADDS in qemu_LDADDS
At this point, all test programs that use qemu_LDADDS also
use LDADDS, so we can remove a bunch of repetition by simply
including the latter in the former.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2019-06-12 20:31:23 +02:00
Andrea Bolognani
6b8048b48d tests: Tweak vircapstest_LDADD
We optionally include QEMU and LXC support in this test and
depending on which is enabled (if either is enabled at all) we
need to link in different objects.

Right now we implicitly depend on the fact that qemu_LDADDS is
empty when QEMU is not enabled to get the correct set of objects,
but it's better to be explicit about it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2019-06-12 20:31:18 +02:00
Andrea Bolognani
74d8909f76 tests: Tweak cputest_LDADDS
We want all test programs using qemu_LDADDS to also use LDADDS,
and cputest is the only existing exception.

We can't just replace GNULIB_LIBS with LDADDS though, even though
the latter is a superset of the former, because that would result
in a linking error due to including the same object twice:

  /usr/bin/ld:
  ../src/libvirt_probes.o:.../src/libvirt_probes.o.dtrace-temp.c:141:
  multiple definition of `libvirt_object_new_semaphore';
  ../src/libvirt_probes.o:.../src/libvirt_probes.o.dtrace-temp.c:141:
  first defined here

To work around this, we include both qemu_LDADDS and LDADDS when
QEMU support is enabled, and just LDADDS otherwise.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2019-06-12 20:30:46 +02:00
Ilias Stamatis
072390cbf0 test_driver: Implement virDomainGetLaunchSecurityInfo
Since the behaviour of launch security is heavily dependent on 3rd party
vendors (e.g. AMD SEV) where the data returned can be essentially
anything, the most reasonable approach here in the test driver is not to
try return any data.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-06-12 12:37:03 +02:00
Peter Krempa
56c6893ff5 qemu: Use proper block job name when reconnecting to VM
The hash table returned by qemuMonitorGetAllBlockJobInfo is organized by
the frontend name (which skipps the 'drive-' prefix). While our code
properly matches the jobs to the disk, qemu needs the full job name
including the 'drive-' prefix to be able to identify jobs.

Fix this by adding an argument to qemuMonitorGetAllBlockJobInfo which
does not modify the job name before filling the hash.

This fixes a regression where users would not be able to cancel/pivot
block jobs after restarting libvirtd while a blockjob is running.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-12 09:40:02 +02:00
Peter Krempa
4c4953fb37 qemu: domain: Allow forcing images to read-write in qemuDomainStorageSourceAccessAllow
In commit 76b9aba2ba I refactored how the function treats the readonly
flag which introduced a bug when we'd not allow to force read-write
state for an image.

This created problems with blockjobs where we need to temporarily
force images to have read-write permissions.

Rename QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_READ_ONLY to
QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY and also introduce
a complement QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_WRITE which
will allow to force write access.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-12 09:40:02 +02:00
Peter Krempa
9961e7799a qemu: domain: Fix logic bug in qemuDomainStorageSourceAccessAllow
In commit 76b9aba2ba I tried to refactor qemuDomainStorageSourceAccessAllow
but used wrong operators for adding bitwise flags.

This way the flags would result in 0 if any of them would be applied.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-12 09:40:02 +02:00
Peter Krempa
10e12c4009 tests: uri: Add test for urlencoded URIs
When specifying extra params for spcie TLS verification, it's necessary
to pass a weird URI to it. Let's add a test for this case where the TLS
string contains a space.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-12 09:26:25 +02:00
Peter Krempa
4977f19c54 tests: uri: Run all test cases on a single URI
Determine whether the test has failed after running all the cases so
that we don't need to rerun it multiple times to see all problems.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-12 09:26:25 +02:00
Peter Krempa
cd99bcf298 tests: uri: Use VIR_TEST_DEBUG instead of VIR_DEBUG
VIR_TEST_DEBUG can be easily made verbose in the tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-12 09:26:25 +02:00
Peter Krempa
b872422a9c tests: qemumonitorjson: Replace use of virReportError
Use VIR_TEST_VERBOSE instead. This fixes the following syntax check
problem:

tests/qemumonitorjsontest.c:1409:        virReportError(VIR_ERR_INTERNAL_ERROR, "arr should have been cleared");

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 09:19:25 +02:00
Ilias Stamatis
49df9205f2 test_driver: implement virDomainSaveImageGetXMLDesc
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-06-12 08:52:46 +02:00
Ilias Stamatis
4d39a99142 test_driver: implement virDomainSaveImageDefineXML
Updates the existing image stored in @path, in case @dxml contains valid
XML supported by the fake host.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-06-12 08:52:46 +02:00
Ilias Stamatis
d6650b2620 test_driver: extract image loading code into a separate function
Extracting the code logic for opening and parsing a test image from
testDomainRestoreFlags into a separate function, allows us to reuse this
code in other functions such as testDomainSaveImageGetXMLDesc.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-06-12 08:52:46 +02:00
Ilias Stamatis
1dfa29f806 test_driver: extract image saving code into a separate function
Extracting the code logic for writing a test image to disk from
testDomainSaveFlags into a separate function, allows us to reuse this
code in other functions such as testDomainSaveImageDefineXML.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-06-12 08:52:46 +02:00
Eric Blake
fbb5271c78 backup: Add new parameters to qemu monitor nbd-server-add
The upcoming virDomainBackup() API needs to take advantage of the
ability to expose a bitmap as part of nbd-server-add for a pull-mode
backup (this is the recently-added QEMU_CAPS_NBD_BITMAP capability).

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 21:47:13 -05:00
Eric Blake
ad1c17c8d5 backup: Add new qemu monitor bitmap
The upcoming virDomainBackup() API needs to take advantage of various
qcow2 bitmap manipulations as the basis to virDomainCheckpoints and
incremental backups.  Add four functions to expose
block-dirty-bitmap-{add,enable,disable,merge} (this is the
recently-added QEMU_CAPS_BITMAP_MERGE capability).

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 21:47:10 -05:00
Eric Blake
6abda7a445 backup: Add two new qemu capabilities
Add two capabilities for testing features required for the upcoming
virDomainBackupBegin: use block-dirty-bitmap-merge as the generic
witness of bitmap support needed for checkpoints (since all of the
bitmap management functionalities were finalized in the same qemu 4.0
release), and the bitmap parameter to nbd-server-add for pull-mode
backup support.  Even though both capabilities are likely to be
present or absent together (that is, it is unlikely to encounter a
qemu that backports only one of the two), it still makes sense to keep
two capabilities as the two uses are orthogonal (full backups don't
require checkpoints, push mode backups don't require NBD bitmap
support, and checkpoints can be used for more than just incremental
backups).

Existing code is not affected by the new capabilities.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 21:42:57 -05:00
Eric Blake
73bf0a9c28 backup: Prepare for Unix sockets in QMP nbd-server-start
Migration always uses a TCP socket for NBD servers, because we don't
support same-host migration. But upcoming pull-mode incremental backup
needs to also support a Unix socket, for retrieving the backup from
the same host. Support this by plumbing virStorageNetHostDef through
the monitor calls, since that is a nice reusable struct that can track
both TCP and Unix sockets.

Update qemumonitorjsontest to verify both forms of the QMP command.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 21:41:42 -05:00
Eric Blake
1ddc7e0363 qemumonitorjsontest: Simplify returns
Time to remove the cleanup labels rendered useless in the previous
patch.  There are still plenty of other tests that could be further
simplified, but I've already spent enough time in this file for now.

Signed-off-by: Eric Blake <eblake@redhat.com>
2019-06-11 21:35:39 -05:00
Eric Blake
4b658bfe4b qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.

In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.

Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:

| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
|      if (reason)
|          *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| -    if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| +    if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| +                                           "s:garbage", "foo", NULL)))
|          return -1;
|
|      if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)

Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 21:35:24 -05:00
Eric Blake
09083437ff qemumonitorjsontest: Use VIR_AUTOPTR support
Simplify the GEN_TEST_FUNC() and target of the DO_TEST_SIMPLE() macros
by using autoptr support.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 21:30:12 -05:00
Eric Blake
2ea60b6f7e qemumonitortestutils: Add VIR_AUTOPTR support
Upcoming tests are going to use VIR_AUTOPTR to simplify test cleanup.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-11 20:53:50 -05:00
Johannes Holmberg
1134fd6289 virt-xml-validate: Allow input to be read from stdin
Signed-off-by: Johannes Holmberg <johannes.holmberg@dataductus.se>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2019-06-10 15:39:16 +02:00
Peter Krempa
143c2de113 qemu: snapshot: Remove unnecessary 'do_transaction' logic in qemuDomainSnapshotCreateDiskActive
Now that we never get to the actual snapshot code if there's nothing to
do we can remove the variable and surrounding logic.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-10 14:01:09 +02:00
Peter Krempa
0491128f2a qemu: snapshot: Return early if there's nothing to snapshot
Skip actual snapshot creation code if we have 0 disks to snapshot.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-10 14:01:09 +02:00
Peter Krempa
0325d42668 qemu: snapshot: Unify 'cleanup' and 'error' in qemuDomainSnapshotCreateDiskActive
All cases taking the 'cleanup' path can take the original 'error' path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-10 14:01:09 +02:00
Peter Krempa
46da762669 qemu: snapshot: Don't overload 'ret' in qemuDomainSnapshotCreateDiskActive
Introduce 'rc' for collecting state from monitor commands so that we can
initialize 'ret' to -1. This also fixes few cases which could return 0
from the function despite an error condition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-10 14:01:09 +02:00
Peter Krempa
a7087c929e qemu: snapshot: Move all cleanup of snapshot disk data to qemuDomainSnapshotDiskDataFree
qemuDomainSnapshotDiskDataFree also removes the resources associated
with the disk data. Move the unlinking of the just-created file so that
we can unify the cleanup paths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-10 14:01:09 +02:00
Peter Krempa
acda184236 qemu: Rename qemuDomainSnapshotDiskDataFree to qemuDomainSnapshotDiskDataCleanup
In commit cbb4d229de I named the function with 'free' suffix, but at
that time it already did some non-freeing tasks. Rename it to make it
obvious that it's not just memory managemet.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-10 14:01:08 +02:00
Peter Krempa
f34397e51c qemu: snapshot: Densely pack data in qemuDomainSnapshotDiskDataCollect
The function skips disks which are not selected for snapshot. Rather
than creating a sparse array and check whether the given field is filled
compress the entries.

Note that this does not allocate a smaller array, but the memory
allocation is short-lived.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-10 14:01:08 +02:00
Peter Krempa
9678503088 qemu: snapshot: Always save config XML after qemuDomainSnapshotCreateDiskActive
If there's an offline config definition save it unconditionally even if
it was not modified.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-10 14:01:08 +02:00
Peter Krempa
999e450c26 qemu: snapshot: Always save status and config after qemuDomainSnapshotCreateDiskActive
The error path is unlikely thus saving the status XML even if we didn't
modify it does not add much burden.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-10 14:01:08 +02:00
Peter Krempa
7b8c319d9c qemu: snapshot: Remove unused cleanup section in qemuDomainSnapshotCreateSingleDiskActive
After getting rid of pre-transaction qemu support the cleanup section is
unused.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-06-10 14:01:08 +02:00