Commit Graph

29839 Commits

Author SHA1 Message Date
Michal Privoznik
8981c750b1 virRandomBytes: Report error
Instead of having each caller report error move it into the
function. This way we can produce more accurate error messages
too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-05 10:31:19 +02:00
Michal Privoznik
a6be5a4ce1 virRandomBytes: Prefer saferead over plain read
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-05 10:31:19 +02:00
Michal Privoznik
c3320d6518 virCryptoGenerateRandom: Don't allocate return buffer
To unify our vir*Random() functions we need to make
virCryptoGenerateRandom NOT allocate return buffer. It should
just fill given buffer with random data.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-05 10:31:19 +02:00
Michal Privoznik
a5865cdbea virCryptoGenerateRandom: Explain gnults error
When generating random stream using gnults fails an error is
reported. However, the error is not helpful as it contains only
an integer error code (a negative number). Use gnutls_strerror()
to turn the error code into a string explaining what went wrong.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-05 10:31:19 +02:00
Michal Privoznik
d4e66f7639 virCryptoGenerateRandom: rename ret
This function allocates a buffer, fills it in with random bytes
and then returns it. However, the buffer is held in @buf
variable, therefore having @ret variable which does not hold
return value of the function is misleading.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2018-06-05 10:31:19 +02:00
Michal Privoznik
29592788f1 virRandomBytes: Fix return value
In libvirt when a function wants to return an error code it
should be a negative value. Returning a positive value (or zero)
means success. But virRandomBytes() does not follow this rule.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2018-06-05 10:31:19 +02:00
Andrea Bolognani
0d42fa688b travis: Install and use ccache on macOS
As documented in [1], ccache needs to be installed and
configured explicitly on macOS.

[1] https://docs.travis-ci.com/user/caching/#ccache-cache

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-05 09:59:35 +02:00
Andrea Bolognani
f3f7cb73b9 travis: Move PATH to macOS-specific environment
Now that we have separate sections for each build
configuration, there's no reason to set PATH in the global
environment.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-05 09:59:25 +02:00
Jiri Denemark
91038dfb3b build: Don't install sysconfig files as scripts
The files are not scripts and should not be executable.

Broken by v4.0.0-294-g5f998681df.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2018-06-05 09:39:24 +02:00
Jiri Denemark
4370ac84f8 qemu: Fix domain resume after failed migration
Libvirt relies on being able to kill the destination domain and resume
the source one during migration until we called "cont" on the
destination. Unfortunately, QEMU automatically activates block devices
at the end of migration even when it's called with -S. This wasn't a big
issue in the past since the guest is not running and thus no data are
written to the block devices. However, when QEMU introduced its internal
block device locks, we can no longer resume the source domain once the
destination domain already activated the block devices (and thus
acquired all locks) unless the destination domain is killed first.

Since it's impossible to synchronize the destination and the source
libvirt daemons after a failed migration, QEMU introduced a new
migration capability called "late-block-activate" which ensures QEMU
won't activate block devices until it gets "cont". The only thing we
need to do is to enable this capability whenever QEMU supports it.

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

QEMU commit implementing the capability: v2.12.0-952-g0f073f44df

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 09:39:24 +02:00
Michal Privoznik
968aaff77a virDomainDefCopy: Skip ostype checks
When parsing domain XML the virCapsDomainData lookup is performed
in order to fill in missing def->os.arch and def->os.machine
strings. Well, when doing copy of already existing virDomainDef
we don't want any automagic fill in of defaults (and those two
strings are going to be provided at this point anyway by first
parse of the domain XML).

What is even worse is that we do not look up capabilities for
parsed emulator path rather some generic capabilities for parsed
arch. Therefore, if emulator points to qemu under non-default
path (say $HOME/qemu-system-arm) but there's no such qemu under
the default path (say /usr/bin/qemu-system-arm) the capabilities
lookup fails and creating the copy is denied.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 09:21:35 +02:00
Radostin Stoyanov
4e9d0ad7a0 virFileAccessibleAs: Remove redundant forkRet
The variable forkRet is not used after commit 25f8781

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 09:18:47 +02:00
Filip Alac
6549c3a4d1 docs: news: Explain iommu_support improvement
Signed-off-by: Filip Alac <filipalac@gmail.com>
2018-06-05 09:11:29 +02:00
Filip Alac
dc34e78e21 capabilities: Extend capabilities with iommu_support
Signed-off-by: Filip Alac <filipalac@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-05 08:33:13 +02:00
Filip Alac
1597e155b2 qemu: hostdev: Move parts of qemuHostdevHostSupportsPassthroughVFIO() into separate function
Signed-off-by: Filip Alac <filipalac@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-05 08:33:13 +02:00
Peter Krempa
134c3ddb43 qemu: command: Refactor disk commandline formatting
Now that we have one place that sets up all disk-related objects to
qemuBlockStorageSourceAttachDataPtr we can easily reuse the data in the
command-line formatter by implementing a worker which will convert the
data.

A huge advantage is that it will be way easier to integrate this with
-blockdev later on.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:01 +02:00
Peter Krempa
006293afd0 qemu: command: Extract setup of one disk's command line
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:01 +02:00
Peter Krempa
fa028bd857 qemu: command: Rename qemuBuildDiskDriveCommandLine
It prepares all disk so use the plural form.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:01 +02:00
Peter Krempa
99239432d3 qemu: hotplug: Extract hotplug of TLS into qemuBlockStorageSourceAttachApply
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:01 +02:00
Peter Krempa
191780e856 qemu: hotplug: Extract hotplug of secrets into qemuBlockStorageSourceAttachApply
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:01 +02:00
Peter Krempa
1990a01e6e qemu: hotplug: Extract hotplug of PR into qemuBlockStorageSourceAttachApply
Introduce a new setup function for all the related configuration and
move the setup and attachment of the PR code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
ca174424ba qemu: Reuse qemuBlockStorageSourceAttachApply in disk hotplug
Create a new "Prepare" function and move the drive add code into the new
helpers. This will eventually allow to simplify and unify the attaching
code for use with blockdev at the same time as providing compatibility
with older qemus.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
d5c5c841e0 qemu: alias: Rename qemuAliasFromDisk to qemuAliasDiskDriveFromDisk
Emphasize that it's for the 'drive' part of the disk.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
389d966abf qemu: hotplug: Remove qemuDomainDelDiskSrcTLSObject
Replace access via wrapper by direct call to monitor API.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
6e6d84163e qemu: Split handling of managed and unmanaged persistent reservations
Add code that will handle the managed persistent reservations object
separately from the unmanaged one. There is only one managed object so
handling it with disks is awkward and does not scale well when backing
chains come into view.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
b3286a51de qemu: command: Return props as return value in qemuBuildPRManagerInfoProps
Also since we don't do any conditional formatting, fix the comment for
the function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
00bf6cc169 qemu: command: Pass in 'src' rather than 'disk' to qemuBuildPRManagerInfoProps
Everything is contained in the virStorageSourceStructure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
8ac8301366 util: storage: Add helper for determining whether a backing chain requires PR
With blockdev support we will need to introspect whether any of the
backing chain members requires PR rather just one of them. Add a helper
and reuse it in virDomainDefHasManagedPR.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
3875459235 tests: qemublock: Test NBD with TLS in the JSON generator
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
8ac9db0e54 qemu: domain: Add support for TLS for NBD
https://bugzilla.redhat.com/show_bug.cgi?id=1544869

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
ca108ab789 qemu: conf: Add qemu.conf knobs for setting up TLS for NBD
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
776d9bc3e8 qemu: Remove code for setting up disk passphrases
Now that the old qcow2 encryption is removed we can safely delete all
this code since it's not needed any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
c4eedd7930 qemu: domain: Forbid storage with old QCOW2 encryption
The encryption was buggy and qemu actually dropped it upstream. Forbid
it for all versions since it would cause other problems too.

Problems with the old encryption include weak crypto, corruption of
images with blockjobs and a lot of usability problems.

This requires changing of the encryption type for the encrypted disk
tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
c495905bff qemu: hotplug: Fix TLS setup on disk hotplug
We need to check if TLS is enabled as the variable is a tristate.
Currently we'd setup TLS even if it was explicitly turned off.
Thankfully TLS for disks was only used with the vxhs protocol so hardly
anybody would ever be able to hit the problem.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-06-05 08:14:00 +02:00
Peter Krempa
0b9451f9d6 util: storage: remove virStorageSource->tlsVerify
Disks are client-only so we don't need to have this variable. We also
always pass false for 'isListen' to qemuBuildTLSx509BackendProps for all
disk-related code-paths so the 'tlsVerify' is ignored anyways.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
f18771d41c qemu: block: Add support for 'pr-manager' in qemuBlockStorageSourceGetFileProps
To keep feature parity, we need to be able to format the PR manager
alias when using blockdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
d766021c60 qemu: Delete old unused code for adding objects to qemu
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
805da1d577 qemu: Convert iothread hotplug to qemuMonitorCreateObjectProps
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
c2f71bb295 qemu: hotplug: Refactor 'secret' props formatting to qemuMonitorCreateObjectProps
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
9374c6e0a1 qemu: hotplug: Refactor tls-credential props formatting to qemuMonitorCreateObjectProps
Note that it's okay to pass NULL to qemuDomainDelTLSObjects in
qemuDomainAddTLSObjects as the tls-creds-x509 object was either not
created or qemu crashed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
80e301cd39 qemu: hotplug: Refactor shmem props formatting to qemuMonitorCreateObjectProps
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
e50daa6331 qemu: hotplug: Refactor memory props formatting to qemuMonitorCreateObjectProps
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
6ab7fd16d1 qemu: hotplug: Refactor RNG props formatting to use qemuMonitorCreateObjectProps
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
e4a2bfe264 qemu: hotplug: Refactor PR props formatting to use qemuMonitorCreateObjectProps
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
efd32528d0 util: qemu: Introduce helper for formatting command line from new object props
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
f0a23c0c35 qemu: monitor: Add better APIs for adding of objects to qemu
Use the new monitor command internal API to allow wrapping of the object
name and alias into the JSON props so that they don't have to be passed
out of band.

The new API also takes a double pointer so that it can be cleared when
the value is consumed so that it does not need to happen in every single
caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
bf26dd222f qemu: Rename virQEMUBuildObjectCommandlineFromJSON
s/virQEMUBuildObjectCommandlineFromJSON/virQEMUBuildObjectCommandlineFromJSONType/

The function adds the object of a certain type. Change the name so that
we make room for the generic function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
a47508d991 qemu: monitor: Rename qemuMonitorAddObject to qemuMonitorAddObjectType
The function adds the object of a certain type. Change the name so that
we make room for the generic function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
7317a83f60 qemu: command: Fix name of qemuBuildMemoryBackendStr
The function generates JSON properties rather than a string so rename
it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
07119a2a6a tests: qemu: Rename disk-drive-network-tlsx509-vxhs test
Drop the 'vxhs' suffix so other network protocols using TLS can be
put into the same test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00