Commit Graph

37224 Commits

Author SHA1 Message Date
Daniel Henrique Barboza
2d5f7a49ae qemu: Implement the IBS pSeries feature
This patch adds the implementation of the IBS pSeries feature,
using the QEMU_CAPS_MACHINE_PSERIES_CAP_IBS capability added
in the previous patch.

IBS can have the following values: "broken", "workaround",
"fixed-ibs", "fixed-ccd" and "fixed-na".

This is the XML format for the cap:

<features>
  <ibs value='fixed-ibs'/>
</features>

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 14:43:13 +02:00
Daniel Henrique Barboza
199dd6f693 qemu: Add capability for IBS pSeries feature
IBS (Indirect Branch Speculation) is the last capability added
in QEMU 2.12 related to Spectre mitigation for Power. It was
added in commit 4be8d4e7d935.

This patch introduces it as QEMU_CAPS_MACHINE_PSERIES_CAP_IBS.
Like CFPC and SBBC, users might want to tune in IBS based on
their HW and guest OS requirements, and it's better to do it
so in a proper Libvirt feature than to put QEMU arguments
in the middle of the domain XML.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 14:43:10 +02:00
Daniel Henrique Barboza
104dadcff6 qemu: Implement the SBBC pSeries feature
This patch adds the implementation of the SBBC pSeries feature,
using the QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC capability added
in the previous patch.

Like the previously added CFPC feature, SBBC can have the values
"broken", "workaround" or "fixed". Extra code is required to handle
it since it's not a regular tristate capability.

This is the XML format for the cap:

<features>
  <sbbc value='workaround'/>
</features>

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 14:43:07 +02:00
Daniel Henrique Barboza
249a5c789e qemu: Add capability for SBBC pSeries feature
SBBC (Speculation Barrier Bounds Checking) is another capability
related to Spectre mitigation efforts in Power processors. It
was implemented in QEMU 2.12 by commit 09114fd81799.

This patch introduces it as QEMU_CAPS_MACHINE_PSERIES_CAP_SBBC to
be implemented in the next patch. Like the case with the now
implemented CFPC, exposing this feature in the XML allows for
a cleaner way for users to tune the SBBC accordingly, given
that not all hypervisor and guest setups supports this
Spectre mitigation.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 14:43:04 +02:00
Daniel Henrique Barboza
0280fc7270 qemu: Implement the CFPC pSeries feature
This patch adds the implementation of the CFPC pSeries feature,
using the QEMU_CAPS_MACHINE_PSERIES_CAP_CFPC capability added
in the previous patch.

CPFC can have the values "broken", "workaround" or "fixed". Extra
code is required to handle it since it's not a regular tristate
capability.

This is the XML format for the cap:

<features>
  <cfpc value='workaround'/>
</features>

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 14:43:00 +02:00
Daniel Henrique Barboza
a0a2c8ab73 qemu: Add capability for CFPC pSeries feature
CFPC (Cache Flush on Privilege Change) is one of the capabilities
added to QEMU to mitigate Spectre vulnerabilities in Power chips.
It was implemented in QEMU 2.12 by commit 6898aed77f46.

This capability is still used today due to differences in how
the host setup (hardware and firmware/kernel) can handle this
mitigation. Its default value also varies with the pseries machine
version of the time. There's also certain OSes, like AIX, that
might not support the default value of the pseries machine the
guest uses.

Exposing this in the Libvirt XML as a feature will allow users to tune
CFPC values in a cleaner way, instead of hacking parameters in
<qemu:commandline> elements.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 14:42:55 +02:00
Peter Krempa
606fb3979a util: qcow2GetExtensions: Remove support for 'data file' extension
The implementation was never finished in libvirt. Remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-27 10:31:40 +02:00
Peter Krempa
38757cb142 util: Remove 'externalDataStoreRaw' field from virStorageSource
It's not used for anything so we don't need to extract it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-27 10:31:40 +02:00
Peter Krempa
94d1cb25a0 util: Remove 'externalDataStore' field from virStorageSource
It's not used for anything so we don't need to extract it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-27 10:31:40 +02:00
Peter Krempa
062d8f0ebe security: Remove labelling of 'externalDataStore'
The feature was never completed and is not really being pursued. Remove
the storage driver integration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-27 10:31:40 +02:00
Julio Faracco
4aa1ab0e79 network: Remove memory leak caused by wrong initialization
This commit fix a wrong variable initialization. There is a variable
called `new_lease` which is being initialized with the content of
parameter `lease`. To avoid memory leak, the proper way is initialize
with NULL first. This wrong statement was added by commit 97a0aa24.
There are some other improvements also.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 09:50:15 +02:00
Peter Krempa
4e7f8ba0f3 qemumonitortestutils: Enforce consumption of all items in test monitor
To prevent unexpected situations where a change in code would stop
looking at some of the tested commands go unnoticed add a mechanism to
force consumption of all test items.

Since there are a few tests which would be hard to fix add also a
mechanism to opt-out of the check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 08:30:27 +02:00
Peter Krempa
0274e1b452 qemumonitortestutils: Store a string identifying test monitor entry
For each test monitor entry store an optional string which will allow to
identify it. This will be used later when checking that all registered
monitor commands were used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 08:13:52 +02:00
Peter Krempa
0bb29de6ba qemuhotplugtest: Remove 'drive_del' expectation from failed cases
On failure 'drive_del' is not issued.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 08:13:52 +02:00
Peter Krempa
b4ee473578 qemucapabilitiesdata: riscv: Remove call to 'query-machines'
The riscv capabilities code doesn't use the data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 08:13:52 +02:00
Peter Krempa
84a20fe8e3 qemumonitortestutils: Make test monitor failures more prominent
Until now we've tried to report errors from the test monitor code by
passing them back as failures from the qemu we simulate. This doesn't
work well in cases when the monitor logic does not detect failures or
has fallback code. Additionally there isn't much use for continuing the
test execution after first failure as in most cases the test data will
be misaligned and all other calls will fail as well.

To make the errors more obvious this patch moves away from reporting
them via the simulated monitor to reporting them to stderr and
exit()ing afterwards. While this might be less convenient
when developing tests it actually makes failures in the test suite
really obvious and doesn't require any opt-in from the tests themselves.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 08:13:48 +02:00
Peter Krempa
1f3ce96e70 qemuhotplugtest: cpu: x86-modern-individual: Remove invalid test case
One of the test cases attempted to use test data meant for modern qemu
without asserting the 'modern' flag. Since that changes the commands
used to query state it won't work with data meant for the modern case.

Remove the invalid test case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 08:12:48 +02:00
Peter Krempa
3e9784a01b qemuhotplugtest: detach: Add expected 'object-del' to disk-scsi-multipath case
The test verifies unplug of a disk with the persistent reservations
helper. The 'object-del' used to remove the helper was not mentioned in
the list of expected commands.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 08:12:48 +02:00
Peter Krempa
3fb999e20d tests: monitor: Rename qemuMonitorReportError to qemuMonitorTestAddErrorResponse
It's a method of the test monitor and it adds a response to the monitor
output. The original qemuMonitorTestAddErrorResponse method is renamed
to qemuMonitorTestAddErrorResponseInternal

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-27 08:12:48 +02:00
Peter Krempa
f8d6b319a6 virStorageSourceParseNBDColonString: Rewrite to match what qemu does
Our implementation wasn't quite able to parse everything that qemu does.
This patch rewrites the parser to a code that semantically resembles the
combination of 'nbd_parse_filename' and 'inet_parse' methods in qemu to
be able to parse the strings in an equivalent manner.

The only thing that libvirt doesn't do is to check the lengths of
various components in the nbd string in places where qemu uses constant
size buffers.

The test cases validate that some of the corner cases involving colons
are parsed properly.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-04-27 08:05:49 +02:00
Daniel P. Berrangé
6ebb00cd78 travis: explicitly include gnutls to ensure it is updated
Travis includes gnutls in the default package set, but it is
an outdated version linkng to an incompatible libffi version.
The 'update: true' stanza causes the brew toolchain to be
updated but not the installed formula. It is possible to
run 'brew upgrade' to update installed formula, but this is
very slow adding more than 5 minutes to the build time.
Listing the gnutls package explicitly causes it to be updated
without extending the build time.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-24 15:00:58 +01:00
Peter Krempa
c3ace7e234 schema: backup: Make 'exportname' and 'exportbitmap' independent
Both are optional but don't have to be specified together. Fix the
schema.

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

Suggested-by: Yi Sun <yisun@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2020-04-24 11:02:48 +02:00
Michal Privoznik
c144486479 docs: Document reserved PCI addresses for QEMU
From time to time we are asked which PCI addresses are reserved
in QEMU. Let's document them in one place, it's easier than
reconstructing the list from the code each time.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-04-24 09:55:29 +02:00
Sebastian Mitterle
5eaa9a1cc3 docs: Add version info for 'backingStoreInput' in domaincaps
Add 'since 5.10' as commonly used in formatdomain to avoid
misunderstandings if element is not present (Is it not supported
because of my version or because of my environment?)

Signed-off-by: Sebastian Mitterle <smitterl@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-04-24 09:52:32 +02:00
Sebastian Mitterle
3ea711b9ec kbase: improve disk image chains documentation
1. Use 'setup' consistently as noun, 'set up' as verb
2. Use path variables like '$IMAGE_PATH' consistently
   like in Troubleshooting to improve readability
3. Remove ':' from field names
4. Change phrasing in sentences I stumbled upon several
   times to improve readability.
5. Minor grammar/vocab fixes.

Signed-off-by: Sebastian Mitterle <smitterl@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-04-24 09:52:32 +02:00
Julio Faracco
dc432f4ab7 news: Include new DHCP network <lease/> feature
This commit includes an entry for new network DHCP lease time
information inside news.xml.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-24 09:27:18 +02:00
Han Han
ce0ce320aa news: qemu: support async IO mode 'io_uring'
Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-04-24 09:17:06 +02:00
Han Han
94eaba0aef tests: Tests for io mode io_uring
Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-04-24 09:17:06 +02:00
Han Han
9bb39a2a88 docs: Docs and rng schemas for io_uring
Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-04-24 09:17:06 +02:00
Han Han
4e30afafa7 qemu: Implement the aio mode io_uring
This aio mode was added since Linux 5.1[1], QEMU 5.0.0[2], which will
deliever faster and more efficient I/O operations for the file,
host_device, host_cdrom backends.

Reference:
[1]: https://lwn.net/Articles/810414/
[2]: https://lists.gnu.org/archive/html/qemu-devel/2020-01/msg07686.html

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-04-24 09:17:05 +02:00
Han Han
cbdd6c4df4 qemu_capabilities: Introduce QEMU_CAPS_AIO_IO_URING
Add io_uring value to capability replies.

The capability QEMU_CAPS_AIO_IO_URING will be used for io_uring aio mode,
introduced from QEMU 5.0, linux 5.1.

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-04-24 09:17:05 +02:00
Peter Krempa
bef10f6eaa qemu: Move interlocking of blockjobs and checkpoints after liveness check
qemuDomainSupportsCheckpointsBlockjobs checks if the
QEMU_CAPS_INCREMENTAL_BACKUP capability is supported to do the
interlocking. Capabilities are not present when the VM isn't running
though which would create false errors.

Move the checks after the liveness check in block job implementations.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
2020-04-24 08:57:14 +02:00
Peter Krempa
b37fdfb9d4 backup: Store error message for failed backups
If a backup job fails midway it's hard to figure out what happened as
it's running asynchronous. Use the VIR_DOMAIN_JOB_ERRMSG job statistics
field to pass through the error from the first failed backup-blockjob
so that both the consumer of the virDomainGetJobStats and the
corresponding event can see the error.

event 'job-completed' for domain backup-test:
	operation: 9
	time_elapsed: 46
	disk_total: 104857600
	disk_processed: 10158080
	disk_remaining: 94699520
	success: 0
	errmsg: No space left on device

virsh domjobinfo backup-test --completed --anystats
Job type:         Failed
Operation:        Backup
Time elapsed:     46           ms
File processed:   9.688 MiB
File remaining:   90.312 MiB
File total:       100.000 MiB
Error message:    No space left on device

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-04-24 08:56:57 +02:00
Peter Krempa
75a66f1076 qemu: domain: Add 'errmsg' field to qemuDomainJobInfo
The field can be used by jobs to add an optional error message to a
completed (failed) job.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-04-24 08:56:57 +02:00
Peter Krempa
4f39774610 API: Add VIR_DOMAIN_JOB_ERRMSG domain job statistics field
In some cases it's useful to report the error which caused the domain
job to fail. Add an optional field for holding the error message so that
it can be later retrieved from statistics of a completed job.

Add the field name macro and code for extracting it in virsh.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-04-24 08:56:57 +02:00
Peter Krempa
72186f9c8c qemu: Add free and copy function for qemuDomainJobInfo and use it
In order to add a string to qemuDomainJobInfo we must ensure that it's
freed and copied properly. Add helpers to copy and free the structure
and adjust the code to use them properly for the new semantics.

Additionally also allocation is changed to g_new0 as it includes the
type and thus it's very easy to grep for all the allocations of a given
type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-04-24 08:56:57 +02:00
Peter Krempa
e77a094141 remote: remoteDispatchDomainGetJobStats: Encode typed parameter strings
String typed parameter values were introduced in v0.9.7-30-g40624d32fb.
virDomainGetJobStats was introduced in v1.0.2-239-g4dd00f4238 so all
clients already support typed parameter stings at that time thus we can
enable it unconditionally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-04-24 08:56:57 +02:00
Peter Krempa
e2f1e2687f qemuhotplugtest: detach: Remove commands which are not issued
The 'human-monitor-command' equates to the 'drive-del' command issued by
the hotplug code on successful detach of a device. This means that it's
not issued for failed attempts and thus should not be added to the
expected list. Unfortunately our test monitor doesn't ensure that all
expected commands were consumed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 15:57:36 +02:00
Peter Krempa
b8c02497b3 mock: qemuDomainGetUnplugTimeout: Decrease timeout
We always queue the DEVICE_DELETED events before successful return from
the command so that tests are reliable. This means we can decrease the
unplug timeout as it's guaranteed to be executed in correct order.

According to my testing it shaves off ~450ms of test run:

real	0m0.721s

vs.

real	0m0.259s

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 15:57:36 +02:00
Peter Krempa
f1ac096ea6 mock:qemuDomainGetUnplugTimeout: Remove unused attribute for '@vm'
'@vm' is used to use a different timeout for ppc64 guests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 15:57:36 +02:00
Peter Krempa
2ab8dba58c qemuDomainGetUnplugTimeout: Add G_GNUC_NO_INLINE
The function is mocked in qemuhotplugmock.so. Recent clang versions
decided to inline it so the mock stopped working resulting in
qemuhotplugtest wasting 15 seconds waiting for timeouts.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 15:57:36 +02:00
Peter Krempa
6ed1219244 qemucapstest: Refresh data for qemu 5.0 on x86_64
Bump to v5.0.0-rc3-8-g3119154db0 and make sure that 'liburing' is picked
up by qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-23 15:56:32 +02:00
Peter Krempa
d9792233ec qemuDomainSaveImageOpen: Refactor handling of errors
Return error codes directly and fix weird reporting of errors via
temporary variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-23 15:36:53 +02:00
Peter Krempa
9219424f56 qemuDomainSaveImageOpen: Use 'g_new0' instead of VIR_ALLOC(_N)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-23 15:36:53 +02:00
Peter Krempa
db907a4d9c qemuDomainSaveImageOpen: Automatically close 'fd' if unneeded
Use VIR_AUTOCLOSE to declare it and remove all internal closing of the
filedescriptor. This will allow getting rid of 'error' completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-23 15:36:53 +02:00
Peter Krempa
3850add603 qemuDomainSaveImageOpen: Use g_autoptr for 'def'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-23 15:36:48 +02:00
Peter Krempa
92b9657986 virQEMUSaveData: Register autoclear function and use it in qemuDomainSaveImageOpen
In an attempt to simplify qemuDomainSaveImageOpen we need to add
automatic pointer clearing for virQEMUSaveData.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-23 15:36:48 +02:00
Peter Krempa
f76a571820 qemu: fix domain start with corrupted save file
Commit 21ad56e932 introduced a regression where a VM with a corrupted
save image file would fail to start on the first attempt. This was
caused by returning a wrong return code as 'fd' was abused to also hold
the return code.

Since it's easy to miss this nuance, introduce a 'ret' variable for the
return code and return it' value in the error section.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
2020-04-23 15:35:39 +02:00
Ján Tomko
d016a64de2 util: remove virRun
Everything is using virCommand now.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 12:49:30 +02:00
Ján Tomko
7e5580a2a0 util: remove references to virRun/virExec
virCommand is now used everywhere.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Suggested-by: Sebastian Mitterle <smitterl@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 12:49:30 +02:00