]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agoutil: Remove 'externalDataStore' field from virStorageSource
Peter Krempa [Fri, 24 Apr 2020 09:12:27 +0000 (11:12 +0200)]
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>
5 years agosecurity: Remove labelling of 'externalDataStore'
Peter Krempa [Fri, 24 Apr 2020 09:08:04 +0000 (11:08 +0200)]
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>
5 years agonetwork: Remove memory leak caused by wrong initialization
Julio Faracco [Sat, 25 Apr 2020 16:35:37 +0000 (13:35 -0300)]
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>
5 years agoqemumonitortestutils: Enforce consumption of all items in test monitor
Peter Krempa [Thu, 23 Apr 2020 14:57:31 +0000 (16:57 +0200)]
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>
5 years agoqemumonitortestutils: Store a string identifying test monitor entry
Peter Krempa [Thu, 23 Apr 2020 14:52:12 +0000 (16:52 +0200)]
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>
5 years agoqemuhotplugtest: Remove 'drive_del' expectation from failed cases
Peter Krempa [Thu, 23 Apr 2020 14:38:30 +0000 (16:38 +0200)]
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>
5 years agoqemucapabilitiesdata: riscv: Remove call to 'query-machines'
Peter Krempa [Thu, 23 Apr 2020 14:23:00 +0000 (16:23 +0200)]
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>
5 years agoqemumonitortestutils: Make test monitor failures more prominent
Peter Krempa [Thu, 23 Apr 2020 09:57:14 +0000 (11:57 +0200)]
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>
5 years agoqemuhotplugtest: cpu: x86-modern-individual: Remove invalid test case
Peter Krempa [Thu, 23 Apr 2020 12:31:12 +0000 (14:31 +0200)]
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>
5 years agoqemuhotplugtest: detach: Add expected 'object-del' to disk-scsi-multipath case
Peter Krempa [Thu, 23 Apr 2020 10:03:21 +0000 (12:03 +0200)]
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>
5 years agotests: monitor: Rename qemuMonitorReportError to qemuMonitorTestAddErrorResponse
Peter Krempa [Thu, 23 Apr 2020 09:50:59 +0000 (11:50 +0200)]
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>
5 years agovirStorageSourceParseNBDColonString: Rewrite to match what qemu does
Peter Krempa [Fri, 24 Apr 2020 11:59:21 +0000 (13:59 +0200)]
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>
5 years agotravis: explicitly include gnutls to ensure it is updated
Daniel P. Berrangé [Fri, 24 Apr 2020 12:17:42 +0000 (13:17 +0100)]
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>
5 years agoschema: backup: Make 'exportname' and 'exportbitmap' independent
Peter Krempa [Fri, 24 Apr 2020 08:37:54 +0000 (10:37 +0200)]
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>
5 years agodocs: Document reserved PCI addresses for QEMU
Michal Privoznik [Tue, 21 Apr 2020 14:56:58 +0000 (16:56 +0200)]
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>
5 years agodocs: Add version info for 'backingStoreInput' in domaincaps
Sebastian Mitterle [Wed, 15 Apr 2020 11:34:06 +0000 (11:34 +0000)]
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>
5 years agokbase: improve disk image chains documentation
Sebastian Mitterle [Wed, 15 Apr 2020 11:34:05 +0000 (11:34 +0000)]
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>
5 years agonews: Include new DHCP network <lease/> feature
Julio Faracco [Thu, 23 Apr 2020 23:56:51 +0000 (20:56 -0300)]
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>
5 years agonews: qemu: support async IO mode 'io_uring'
Han Han [Tue, 21 Apr 2020 12:19:38 +0000 (20:19 +0800)]
news: qemu: support async IO mode 'io_uring'

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agotests: Tests for io mode io_uring
Han Han [Tue, 21 Apr 2020 12:19:37 +0000 (20:19 +0800)]
tests: Tests for io mode io_uring

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agodocs: Docs and rng schemas for io_uring
Han Han [Tue, 21 Apr 2020 12:19:36 +0000 (20:19 +0800)]
docs: Docs and rng schemas for io_uring

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: Implement the aio mode io_uring
Han Han [Tue, 21 Apr 2020 12:19:35 +0000 (20:19 +0800)]
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>
5 years agoqemu_capabilities: Introduce QEMU_CAPS_AIO_IO_URING
Han Han [Tue, 21 Apr 2020 12:19:34 +0000 (20:19 +0800)]
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>
5 years agoqemu: Move interlocking of blockjobs and checkpoints after liveness check
Peter Krempa [Fri, 17 Apr 2020 08:58:08 +0000 (10:58 +0200)]
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>
5 years agobackup: Store error message for failed backups
Peter Krempa [Thu, 16 Apr 2020 09:23:07 +0000 (11:23 +0200)]
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>
5 years agoqemu: domain: Add 'errmsg' field to qemuDomainJobInfo
Peter Krempa [Thu, 16 Apr 2020 09:21:51 +0000 (11:21 +0200)]
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>
5 years agoAPI: Add VIR_DOMAIN_JOB_ERRMSG domain job statistics field
Peter Krempa [Wed, 15 Apr 2020 10:27:53 +0000 (12:27 +0200)]
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>
5 years agoqemu: Add free and copy function for qemuDomainJobInfo and use it
Peter Krempa [Thu, 26 Mar 2020 16:55:00 +0000 (17:55 +0100)]
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>
5 years agoremote: remoteDispatchDomainGetJobStats: Encode typed parameter strings
Peter Krempa [Thu, 16 Apr 2020 09:14:00 +0000 (11:14 +0200)]
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>
5 years agoqemuhotplugtest: detach: Remove commands which are not issued
Peter Krempa [Thu, 23 Apr 2020 08:36:59 +0000 (10:36 +0200)]
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>
5 years agomock: qemuDomainGetUnplugTimeout: Decrease timeout
Peter Krempa [Thu, 23 Apr 2020 08:33:58 +0000 (10:33 +0200)]
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>
5 years agomock:qemuDomainGetUnplugTimeout: Remove unused attribute for '@vm'
Peter Krempa [Thu, 23 Apr 2020 08:32:22 +0000 (10:32 +0200)]
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>
5 years agoqemuDomainGetUnplugTimeout: Add G_GNUC_NO_INLINE
Peter Krempa [Thu, 23 Apr 2020 08:30:13 +0000 (10:30 +0200)]
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>
5 years agoqemucapstest: Refresh data for qemu 5.0 on x86_64
Peter Krempa [Wed, 22 Apr 2020 10:39:10 +0000 (12:39 +0200)]
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>
5 years agoqemuDomainSaveImageOpen: Refactor handling of errors
Peter Krempa [Wed, 22 Apr 2020 14:52:24 +0000 (16:52 +0200)]
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>
5 years agoqemuDomainSaveImageOpen: Use 'g_new0' instead of VIR_ALLOC(_N)
Peter Krempa [Wed, 22 Apr 2020 14:22:58 +0000 (16:22 +0200)]
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>
5 years agoqemuDomainSaveImageOpen: Automatically close 'fd' if unneeded
Peter Krempa [Wed, 22 Apr 2020 14:19:21 +0000 (16:19 +0200)]
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>
5 years agoqemuDomainSaveImageOpen: Use g_autoptr for 'def'
Peter Krempa [Wed, 22 Apr 2020 14:16:19 +0000 (16:16 +0200)]
qemuDomainSaveImageOpen: Use g_autoptr for 'def'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirQEMUSaveData: Register autoclear function and use it in qemuDomainSaveImageOpen
Peter Krempa [Wed, 22 Apr 2020 14:12:39 +0000 (16:12 +0200)]
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>
5 years agoqemu: fix domain start with corrupted save file
Peter Krempa [Wed, 22 Apr 2020 14:03:37 +0000 (16:03 +0200)]
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>
5 years agoutil: remove virRun
Ján Tomko [Wed, 22 Apr 2020 14:20:10 +0000 (16:20 +0200)]
util: remove virRun

Everything is using virCommand now.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: remove references to virRun/virExec
Ján Tomko [Wed, 22 Apr 2020 14:10:17 +0000 (16:10 +0200)]
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>
5 years agoRemove all usage of virRun
Ján Tomko [Wed, 22 Apr 2020 14:25:24 +0000 (16:25 +0200)]
Remove all usage of virRun

Catch the individual usage not removed in previous commits.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovmware: use virCommand instead of virRun
Ján Tomko [Tue, 21 Apr 2020 17:17:59 +0000 (19:17 +0200)]
vmware: use virCommand instead of virRun

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoopenvz: switch from virRun to virCommand
Ján Tomko [Wed, 22 Apr 2020 14:25:19 +0000 (16:25 +0200)]
openvz: switch from virRun to virCommand

Construct the command in multiple steps instead of using a sentinel
in the args array.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonetworkxml2xmltest: Complete renaming of @actual
Michal Privoznik [Thu, 23 Apr 2020 10:28:43 +0000 (12:28 +0200)]
networkxml2xmltest: Complete renaming of @actual

In 97a0aa2467 the @actual variable was renamed to @confactual.
However, the commit missed non-Linux case resulting in a broken
build.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: Add tests for <lease/> to cover dnsmasq settings
Julio Faracco [Wed, 22 Apr 2020 20:05:58 +0000 (17:05 -0300)]
tests: Add tests for <lease/> to cover dnsmasq settings

New tests are required to cover some new XML syntax entry for
<lease/> option. This includes schema testing and other features
like unit attribute and lease value. This commit includes hostsfile
checks adding new files for each test case that is manipulating <host/>
tag.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: Add <lease/> option for <dhcp/> settings
Julio Faracco [Wed, 22 Apr 2020 20:05:57 +0000 (17:05 -0300)]
conf: Add <lease/> option for <dhcp/> settings

If an user is trying to configure a dhcp neetwork settings, it is not
possible to change the leasetime of a range or a host entry. This is
available using dnsmasq extra options, but they are associated with
dhcp-range or dhcp-hosts fields. This patch implements a leasetime for
range and hosts tags. They can be defined under that settings:

    <dhcp>
      <range ...>
        <lease/>
      </range>
      <host ...>
        <lease/>
      </host>
    </dhcp>

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

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: drvqemu: trivial fix for qemu commands passthrough
Chen Hanxiao [Wed, 22 Apr 2020 16:02:20 +0000 (12:02 -0400)]
docs: drvqemu: trivial fix for qemu commands passthrough

element <qemu:commandline> should be the child of <domain>

Signed-off-by: Chen Hanxiao <chen_han_xiao@126.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agonews: Document new Xen hypervisor features
Jim Fehlig [Tue, 21 Apr 2020 22:05:40 +0000 (16:05 -0600)]
news: Document new Xen hypervisor features

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoudevHandleOneDevice: Remove old instance of device on "move"
Michal Privoznik [Mon, 20 Apr 2020 14:12:03 +0000 (16:12 +0200)]
udevHandleOneDevice: Remove old instance of device on "move"

When a device is "move"-d (this basically means it was renamed),
we add the new device onto our list but keep the old there too.
Fortunately, udev sets this DEVPATH_OLD property which points to
the old device path. We can use it to remove the old instance.

To test this try renaming an interface, for instance:

  # ip link set tunl0 name tunl1
  # ip link set tunl1 name tunl0

One problem with udev is that it sends old ifname in INTERFACE
property, which creates a problem for us, the property is where
we get the ifname from and use it then to query all kind of info
about the interface. Well, if it is non-existent then we can't
query anything. This happens if ifname rename is suppressed
(net.ifnames=0 on kernel cmd line for instance). Fortunately, we
can use "kernel" source for udev events which has always the
fresh info.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
5 years agonode_device_udev: Split udevRemoveOneDevice() into two
Michal Privoznik [Mon, 20 Apr 2020 13:59:19 +0000 (15:59 +0200)]
node_device_udev: Split udevRemoveOneDevice() into two

Move internals of udevRemoveOneDevice() into a separate function
which accepts sysfs path as an argument and actually removes the
device from the internal list. It will be reused later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
5 years agoudevRemoveOneDevice: Unlock node device obj upon return
Michal Privoznik [Mon, 20 Apr 2020 13:40:01 +0000 (15:40 +0200)]
udevRemoveOneDevice: Unlock node device obj upon return

When removing a node device object from the internal list the
udevRemoveOneDevice() function does plain unref over the object.
This is not sufficient. If there is another thread that's waiting
for the object lock it will wait forever.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: split out virDomainFeaturesDefParse
Ján Tomko [Tue, 21 Apr 2020 16:35:59 +0000 (18:35 +0200)]
conf: split out virDomainFeaturesDefParse

The virDomainDefParseXML function has grown so large it broke the build:
../../src/conf/domain_conf.c:20362:1: error: stack frame size of 4168 bytes
in function 'virDomainDefParseXML' [-Werror,-Wframe-larger-than=]

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu-cgroup: remove unnecessary include
Marc-André Lureau [Wed, 8 Apr 2020 17:23:51 +0000 (19:23 +0200)]
qemu-cgroup: remove unnecessary include

The file doesn't use virSystemd functions directly.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu-dbus: register DBus bus to the VM cgroup
Marc-André Lureau [Wed, 8 Apr 2020 17:23:50 +0000 (19:23 +0200)]
qemu-dbus: register DBus bus to the VM cgroup

External devices are started before cgroup is created. Add the DBus
daemon to the VM cgroup with the rest of the external devices.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu-dbus: remove unused variable
Marc-André Lureau [Wed, 8 Apr 2020 17:23:49 +0000 (19:23 +0200)]
qemu-dbus: remove unused variable

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu-dbus: prevent double start of the bus daemon
Marc-André Lureau [Wed, 8 Apr 2020 17:23:48 +0000 (19:23 +0200)]
qemu-dbus: prevent double start of the bus daemon

Allow calling qemuDBusStart() multiple times (as may be done by
qemu-slirp already).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoslirp: add helper to VM cgroup
Marc-André Lureau [Wed, 8 Apr 2020 17:23:47 +0000 (19:23 +0200)]
slirp: add helper to VM cgroup

The slirp helper process should be associated with the VM cgroup, like
other helpers.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoslirp: leave the dbus daemon running on error
Marc-André Lureau [Wed, 8 Apr 2020 17:23:46 +0000 (19:23 +0200)]
slirp: leave the dbus daemon running on error

Don't stop the DBus daemon if a slirp helper failed to start, as it
may be shared with other helpers.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirsh: Fix return code for dump and migrate
Andrea Bolognani [Tue, 21 Apr 2020 17:06:16 +0000 (19:06 +0200)]
virsh: Fix return code for dump and migrate

When the job monitoring logic was refactored, these two commands
were not converted properly and the result is that a successful
dump or migration (char '0') would be reported as a failed one
(int 48) instead.

Fixes: dc0771cfa2e78ffecd7c8234538ee548748d7bef
Reported-by: Brian Rak <brak@gameservers.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: Remove stray parenthesis
Jim Fehlig [Tue, 21 Apr 2020 22:09:24 +0000 (16:09 -0600)]
docs: Remove stray parenthesis

Commit fadbaa2375 introduced a stray parenthesis in formatdomain.html.in.
Remove it.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
5 years agoCONTRIBUTING: Include information on build dependencies
Andrea Bolognani [Mon, 20 Apr 2020 10:49:09 +0000 (12:49 +0200)]
CONTRIBUTING: Include information on build dependencies

libvirt depends on a ton of packages, so trying to install them
all by using the classic approach of repeatedly running configure
and reacting to each failure by installing the corresponding
missing package will inevitably lead to frustration.

Luckily there's an easy solution to get most dependencies
installed in one fell swoop, and we just need to document it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
5 years agotests: check conversion of passthrough hypervisor feature
Jim Fehlig [Fri, 17 Apr 2020 20:19:16 +0000 (14:19 -0600)]
tests: check conversion of passthrough hypervisor feature

Add a new test to check the 'mode' attribute of the passthrough element
and augment an existing, related test to check enablement of the
passthrough element only.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoxenconfig: Add support for 'passthrough' hypervisor feature
Jim Fehlig [Thu, 16 Apr 2020 14:31:48 +0000 (08:31 -0600)]
xenconfig: Add support for 'passthrough' hypervisor feature

Add support for xl.cfg(5) 'passthrough' option in the domXML-to-xenconfig
configuration converter.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolibxl: refactor cpu and hypervisor feature parser/formatter
Jim Fehlig [Thu, 16 Apr 2020 03:48:42 +0000 (21:48 -0600)]
libxl: refactor cpu and hypervisor feature parser/formatter

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolibxl: make use of passthrough hypervisor feature
Jim Fehlig [Wed, 15 Apr 2020 23:18:25 +0000 (17:18 -0600)]
libxl: make use of passthrough hypervisor feature

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: add xen hypervisor feature 'passthrough'
Jim Fehlig [Wed, 15 Apr 2020 22:34:54 +0000 (16:34 -0600)]
conf: add xen hypervisor feature 'passthrough'

'passthrough' is Xen-Specific guest configuration option new to Xen 4.13
that enables IOMMU mappings for a guest and hence whether it supports PCI
passthrough. The default is disabled. See the xl.cfg(5) man page and
xen.git commit babde47a3fe for more details.

The default state of disabled prevents hotlugging PCI devices. However,
if the guest configuration contains a PCI passthrough device at time of
creation, libxl will automatically enable 'passthrough' and subsequent
hotplugging of PCI devices will also be possible. It is not possible to
unconditionally enable 'passthrough' since it would introduce a migration
incompatibility due to guest ABI change. Instead, introduce another Xen
hypervisor feature that can be used to enable guest PCI passthrough

  <features>
    <xen>
      <passthrough state='on'/>
    </xen>
  </features>

To allow finer control over how IOMMU maps to guest P2M table, the
passthrough element also supports a 'mode' attribute with values
restricted to snyc_pt and share_pt, similar to xl.cfg(5) 'passthrough'
setting .

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: check e820_host option handling
Marek Marczykowski-Górecki [Tue, 14 Apr 2020 02:37:07 +0000 (04:37 +0200)]
tests: check e820_host option handling

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agoxenconfig: parse e820_host option
Marek Marczykowski-Górecki [Tue, 14 Apr 2020 02:37:06 +0000 (04:37 +0200)]
xenconfig: parse e820_host option

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agolibxl: make use of e820_host feature
Marek Marczykowski-Górecki [Tue, 14 Apr 2020 02:37:05 +0000 (04:37 +0200)]
libxl: make use of e820_host feature

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agoconf: add xen specific feature: e820_host
Marek Marczykowski-Górecki [Tue, 14 Apr 2020 02:37:04 +0000 (04:37 +0200)]
conf: add xen specific feature: e820_host

e820_host is a Xen-specific option, only available for PV domains, that
provides the domain a virtual e820 memory map based on the host one. It
is enabled with a new Xen hypervisor feature, e.g.

  <features>
    <xen>
      <e820_host state='on'/>
    </xen>
  </features>

e820_host is required when using PCI passthrough and is generally
considered safe for any PV kernel. e820_host is silently ignored if set
in HVM domain configuration. See xl.cfg(5) man page in the Xen
documentation for more details.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agoREADME: Add GitLab CI badge
Andrea Bolognani [Tue, 14 Apr 2020 13:19:54 +0000 (15:19 +0200)]
README: Add GitLab CI badge

We've moved most of our CI jobs to GitLab, so we should display
the corresponding badge prominently.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoCONTRIBUTING: Include in release archives
Andrea Bolognani [Tue, 14 Apr 2020 11:56:36 +0000 (13:56 +0200)]
CONTRIBUTING: Include in release archives

The file, added with commit

  commit 874952f80c6d68c1a7a75e71c11a576f96f75dc2
  Author: Andrea Bolognani <abologna@redhat.com>
  Date:   Mon Apr 6 11:56:58 2020 +0200

    CONTRIBUTING: Add entry point for new contributors

should be included in release archives.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoAvoid unnecessary error messages handling udev events
Mark Asselstine [Thu, 16 Apr 2020 15:57:46 +0000 (11:57 -0400)]
Avoid unnecessary error messages handling udev events

The udev monitor thread "udevEventHandleThread()" will lag the
actual/real view of devices in sysfs as it serially processes udev
monitor events. So for instance if you were to run the following cmd
to create a new veth pair and rename one of the veth endpoints

you might see the following monitor events and real world that looks like

                                     time
              |    create v0 sysfs entry
wake udevEventHandleThread            |    create v1 sysfs entry
udev_monitor_receive_device(v1-add)   |    move v0 sysfs to v2
udevHandleOneDevice(v1)               |
udev_monitor_receive_device(v0-add)   |
udevHandleOneDevice(v0)               | <--- error msgs in virNetDevGetLinkInfo()
udev_monitor_receive_device(v2-move)  |      as v0 no longer exists
udevHandleOneDevice(v2)               |
                                     \/

As you can see the changes in sysfs can take place well before we get
to act on the events in the udevEventHandleThread(), so by the time we
get around to processing the v0 add event, the sysfs entry has been
moved to v2.

To work around this we check if the sysfs entry is valid before
attempting to read it and don't bother trying to read link info if
not. This is safe since we will never read sysfs entries earlier than
it existing, ie. if the entry is not there it has either been removed
in the time since we enumerated the device or something bigger is
busted, in either case, no sysfs entry, no link info. In the case
described above we will eventually get the link info as we work
through the queue of monitor events and get to the 'move' event.

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

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonode_device_udev: handle move events
Mark Asselstine [Thu, 16 Apr 2020 15:57:45 +0000 (11:57 -0400)]
node_device_udev: handle move events

It is possible and common to rename some devices, this is especially
true for ethernet devices such as veth pairs.

In the udevEventHandleThread() we will be notified of this change but
currently we only process "add", "change" and "remove"
events. Renaming a device such as above results in a "move" event, not
a "remove" followed by and "add" or vise versa. This change will add
the new/destination device to our records but unfortunately there is
no usable mechanism to identify the old/source device to remove it
from the records. So this is admittedly only a partial fix.

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodoc/python: Update to Python 3
Philipp Hahn [Mon, 20 Apr 2020 13:01:11 +0000 (15:01 +0200)]
doc/python: Update to Python 3

Convert the simple example to Python 3 syntax:
- print() is a function
- do not use bare except
- libvirt.open*() does not return None but raises an exception

The referenced source for the example was removed with
5bb2a245abbde4c0a407f631660e2f2c81bc4c02

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Philipp Hahn <hahn@univention.de>
5 years agodocs: add news about virtualbox version support changes
Daniel P. Berrangé [Fri, 17 Apr 2020 11:56:25 +0000 (12:56 +0100)]
docs: add news about virtualbox version support changes

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: add support for version 6.1 SDK
Daniel P. Berrangé [Fri, 17 Apr 2020 10:57:54 +0000 (11:57 +0100)]
vbox: add support for version 6.1 SDK

Changes in the API:

 - APIs related to the graphics adapter are no longer on the
   IMachine interface, but on a IGraphicsAdapter interface
 - The LaunchVMProcess method takes a list of env variables
   instead of a single variable containing a concatenated
   list. Since we only ever pass a single env variable, we
   can simply stuff it straight into a list.
 - The DHCP server start method no longer needs the network
   name

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: add version 6.1 CAPI header
Daniel P. Berrangé [Fri, 17 Apr 2020 11:16:41 +0000 (12:16 +0100)]
vbox: add version 6.1 CAPI header

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: add support for version 6.0 SDK
Daniel P. Berrangé [Fri, 17 Apr 2020 10:57:54 +0000 (11:57 +0100)]
vbox: add support for version 6.0 SDK

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: add version 6.0 CAPI header
Daniel P. Berrangé [Fri, 17 Apr 2020 11:16:41 +0000 (12:16 +0100)]
vbox: add version 6.0 CAPI header

Changes in the API:

 - The CreatedSharedFolder method now accepts a target mount
   point. Since we don't request automount, we're just passing
   NULL. We could, however, use this to pass the desired
   mount target from the XML config in future.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: remove unused support for Windows MSCOM
Daniel P. Berrangé [Fri, 17 Apr 2020 11:12:09 +0000 (12:12 +0100)]
vbox: remove unused support for Windows MSCOM

Long ago we switched the vbox driver to run inside libvirtd to avoid
libvirt.so being polluted with GPLv2-only code. Since libvirtd is not
built on Windows, we disabled vbox on Windows builds. Thus the MSCOM
glue code is not required.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: remove version 5.1 CAPI header
Daniel P. Berrangé [Fri, 17 Apr 2020 11:05:36 +0000 (12:05 +0100)]
vbox: remove version 5.1 CAPI header

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: remove support for version 5.1 API
Daniel P. Berrangé [Fri, 17 Apr 2020 11:03:50 +0000 (12:03 +0100)]
vbox: remove support for version 5.1 API

This is no longer supported since 2018/04

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: remove version 5.0 CAPI header
Daniel P. Berrangé [Fri, 17 Apr 2020 11:05:36 +0000 (12:05 +0100)]
vbox: remove version 5.0 CAPI header

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: remove support for version 5.0 API
Daniel P. Berrangé [Fri, 17 Apr 2020 11:03:50 +0000 (12:03 +0100)]
vbox: remove support for version 5.0 API

This is no longer supported since 2017/05

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirnetdev.c: Use g_auto*()
Michal Privoznik [Sun, 19 Apr 2020 05:24:40 +0000 (07:24 +0200)]
virnetdev.c: Use g_auto*()

While I'm at it, use more g_autofree and g_autoptr() in this
file. This also fixes a possible mem-leak in
virNetDevGetVirtualFunctions().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirNetDevSwitchdevFeature: Make failure to get 'family_id' non-fatal
Michal Privoznik [Sun, 19 Apr 2020 05:25:34 +0000 (07:25 +0200)]
virNetDevSwitchdevFeature: Make failure to get 'family_id' non-fatal

I've just got a new machine and I'm still converging on the
kernel config. Anyway, since I don't have enabled any of SRIO-V
drivers, my kernel doesn't have NET_DEVLINK enabled (i.e.
virNetDevGetFamilyId() returns 0). But this makes nodedev driver
ignore all interfaces, because when enumerating all devices via
udev, the control reaches virNetDevSwitchdevFeature() eventually
and subsequently virNetDevGetFamilyId() which 'fails'. Well, it's
not really a failure - the virNetDevSwitchdevFeature() stub
simply returns 0.

Also, move the call a few lines below, just around the place
where it's needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirNetDevGetFamilyId: Change signature
Michal Privoznik [Sun, 19 Apr 2020 06:26:04 +0000 (08:26 +0200)]
virNetDevGetFamilyId: Change signature

Introduced in v3.8.0-rc1~96, the virNetDevGetFamilyId() gets
netlink family ID for passed family name (even though it's used
only for getting "devlink" ID). Nevertheless, the function
returns 0 on an error or if no family ID was found. This makes it
harder for a caller to distinguish these two. Change the retval
so that a negative value is returned upon error, zero is no ID
found (but no error encountered) and a positive value is returned
on successful translation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: Do not include sys/wait.h on Win32
Jiri Denemark [Fri, 17 Apr 2020 18:27:00 +0000 (20:27 +0200)]
util: Do not include sys/wait.h on Win32

This fixes build on mingw broken by my previous commit 36e125296a.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu: Label restore path outside of secdriver transactions
Michal Privoznik [Fri, 3 Apr 2020 08:28:17 +0000 (10:28 +0200)]
qemu: Label restore path outside of secdriver transactions

As explained in the previous commit, we need to relabel the file
we are restoring the domain from. That is the FD that is passed
to QEMU. If the file is not under /dev then the file inside the
namespace is the very same as the one in the host. And regardless
of using transactions, the file will be relabeled. But, if the
file is under /dev then when using transactions only the copy
inside the namespace is relabeled and the one in the host is not.
But QEMU is reading from the one in the host, actually.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agosecurity: Introduce virSecurityManagerDomainSetPathLabelRO
Michal Privoznik [Fri, 3 Apr 2020 12:31:35 +0000 (14:31 +0200)]
security: Introduce virSecurityManagerDomainSetPathLabelRO

This API allows drivers to separate out handling of @stdin_path
of virSecurityManagerSetAllLabel(). The thing is, the QEMU driver
uses transactions for virSecurityManagerSetAllLabel() which
relabels devices from inside of domain's namespace. This is what
we usually want. Except when resuming domain from a file. The
file is opened before any namespace is set up and the FD is
passed to QEMU to read the migration stream from. Because of
this, the file lives outside of the namespace and if it so
happens that the file is a block device (i.e. it lives under
/dev) its copy will be created in the namespace. But the FD that
is passed to QEMU points to the original living in the host and
not in the namespace. So relabeling the file inside the namespace
helps nothing.

But if we have a separate API for relabeling the restore file
then the QEMU driver can continue calling
virSecurityManagerSetAllLabel() with transactions enabled and
call this new API without transactions.

We already have an API for relabeling a single file
(virSecurityManagerDomainSetPathLabel()) but in case of SELinux
it uses @imagelabel (which allows RW access) and we want to use
@content_context (which allows RO access).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoutil: Fix virDaemonForkIntoBackground
Jiri Denemark [Thu, 16 Apr 2020 13:11:06 +0000 (15:11 +0200)]
util: Fix virDaemonForkIntoBackground

This commit partially reverts

    commit c360ea28dc267802690e129fbad08ca2f22a44e9
    Refs: v6.2.0-rc1-1-gc360ea28dc
    Author:     Rafael Fonseca <r4f4rfs@gmail.com>
    AuthorDate: Fri Mar 27 18:40:47 2020 +0100
    Commit:     Michal Prívozník <mprivozn@redhat.com>
    CommitDate: Mon Mar 30 09:48:22 2020 +0200

    util: virdaemon: fix compilation on mingw

    The daemons are not supported on Win32 and therefore were not compiled
    in that platform. However, with the daemon code sharing, all the code in
    utils *is* compiled and it failed because `waitpid`, `fork`, and
    `setsid` are not available. So, as before, let's not build them on
    Win32 and make the code more portable by using existing vir* wrappers.

Not compiling virDaemonForkIntoBackground on Win32 is good, but the
second part of the original patch incorrectly replaced waitpid and fork
with our virProcessWait and virFork APIs. These APIs are more than just
simple wrappers and we don't want any of the extra functionality.
Especially virFork would reset any setup made before
virDaemonForkIntoBackground is called, such as logging, signal handling,
etc.

As a result of the change the additional fix in v6.2.0-67-ga87e4788d2
(util: virdaemon: fix waiting for child processes) is no longer
needed and it is effectively reverted by this commit.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: Improve zPCI section in pci-addresses.rst
Boris Fiuczynski [Fri, 17 Apr 2020 12:27:34 +0000 (14:27 +0200)]
docs: Improve zPCI section in pci-addresses.rst

Improving the zPCI example by choosing more distinct values and
adding explanation for fid.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: Update introduction in pci-addresses.rst
Andrea Bolognani [Fri, 17 Apr 2020 12:27:33 +0000 (14:27 +0200)]
docs: Update introduction in pci-addresses.rst

Changing the introduction to bring the idea of this document better across.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
5 years agodocs: Add section about code blocks to styleguide.rst
Andrea Bolognani [Thu, 16 Apr 2020 16:36:48 +0000 (18:36 +0200)]
docs: Add section about code blocks to styleguide.rst

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: fix mistaken description of the read-only socket units
Daniel P. Berrangé [Thu, 16 Apr 2020 13:18:42 +0000 (14:18 +0100)]
docs: fix mistaken description of the read-only socket units

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: remove old unused favicon file
Daniel P. Berrangé [Thu, 16 Apr 2020 11:52:13 +0000 (12:52 +0100)]
docs: remove old unused favicon file

The use of 32favicon.png was removed when the new favicons were
introduced in

  commit 40cb5581c4ace6c4a5b68990aaac4dff1b656054
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Wed Jul 26 18:22:11 2017 +0100

    docs: add full set of "favicon" files to support modern clients

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: add missing files to static asset list
Daniel P. Berrangé [Thu, 16 Apr 2020 11:49:29 +0000 (12:49 +0100)]
docs: add missing files to static asset list

The various favicon files were missing from the favicon list, so never
installed, as was an example code diagram.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>