summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* util: virerror: Introduce virGetLastError{Code,Domain} public APIsramyelkest2018-06-053-0/+43
| | | | | | | | | | | | Many places in the code call virGetLastError() just to check the raised error code, or domain. However virGetLastError() can return NULL, so the code has to check for that first. This patch therefore introduces virGetLasError{Code,Domain} functions which always return a valid error code or domain respectively, thus dropping the need to perform any checks on the error object. Signed-off-by: Ramy Elkest <ramyelkest@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* util: Prefer virGetLastErrorMessage over direct err->message usageramyelkest2018-06-051-2/+1
| | | | | Signed-off-by: Ramy Elkest <ramyelkest@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* po: don't install gmo files when --disable-nls is givenDaniel P. Berrangé2018-06-052-0/+5
| | | | | | | | With --disable-nls is given we turn off use of gettext in the source code, but mistakenly still installed the gmo files. Reported-by: Olaf Hering <olaf@aepfle.de> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* qemu: remove pointless connect retry logic in agentDaniel P. Berrangé2018-06-051-77/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the agent code was first introduced back in commit c160ce3316852a797d7b06b4ee101233866e69a9 Author: Daniel P. Berrange <berrange@redhat.com> Date: Wed Oct 5 18:31:54 2011 +0100 QEMU guest agent support there was code that would loop and retry the connection when opening the agent socket. At this time, the only thing done in between the opening of the monitor socket & opening of the agent socket was a call to set the monitor capabilities. This was a no-op on non-QMP versions, so in theory there could be a race which let us connect to the monitor while the agent socket was still not created by QEMU. In the modern world, however, we long ago mandated the use of QMP for managing QEMU, so we're guaranteed to have a set capabilities QMP call. Once we've seen a reply to this, we're guaranteed that QEMU has fully initialized all backends and is in its event loop. We can thus be sure the QEMU agent socket is present and don't need to retry connections to it, even without having the chardev FD passing feature. Reviewed-by: John Ferlan <jferlan@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* qemu: don't retry connect() if doing FD passingDaniel P. Berrangé2018-06-055-30/+55
| | | | | | | | | | | | | | | Since libvirt called bind() and listen() on the UNIX socket, it is guaranteed that connect() will immediately succeed, if QEMU is running normally. It will only fail if QEMU has closed the monitor socket by mistake or if QEMU has exited, letting the kernel close it. With this in mind we can remove the retry loop and timeout when connecting to the QEMU monitor if we are doing FD passing. Libvirt can go straight to sending the QMP greeting and will simply block waiting for a reply until QEMU is ready. Reviewed-by: John Ferlan <jferlan@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* qemu: support passing pre-opened UNIX socket listen FDDaniel P. Berrangé2018-06-059-14/+91
| | | | | | | | | | | | | | | | | | | | | | | | | There is a race condition when spawning QEMU where libvirt has spawned QEMU but the monitor socket is not yet open. Libvirt has to repeatedly try to connect() to QEMU's monitor until eventually it succeeds, or times out. We use kill() to check if QEMU is still alive so we avoid waiting a long time if QEMU exited, but having a timeout at all is still unpleasant. With QEMU 2.12 we can pass in a pre-opened FD for UNIX domain or TCP sockets. If libvirt has called bind() and listen() on this FD, then we have a guarantee that libvirt can immediately call connect() and succeed without any race. Although we only really care about this for the monitor socket and agent socket, this patch does FD passing for all UNIX socket based character devices since there appears to be no downside to it. We don't do FD passing for TCP sockets, however, because it is only possible to pass a single FD, while some hostnames may require listening on multiple FDs to cover IPv4 and IPv6 concurrently. Reviewed-by: John Ferlan <jferlan@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* qemu: probe for -chardev 'fd' parameter for FD passingDaniel P. Berrangé2018-06-056-0/+7
| | | | | | | | QEMU >= 2.12 will support passing of pre-opened file descriptors for socket based character devices. Reviewed-by: John Ferlan <jferlan@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* qemu: Fix detaching from persistent def in ↵Peter Krempa2018-06-051-4/+3
| | | | | | | | | | | | | | | qemuDomainDetachDeviceAliasLiveAndConfig The code that detaches the device from persistent definition copies the persistent definition first so that it can easily be rolled back. The actual detaching is then made in the copy which is assigned back on success (if the live operation succeeded as well). This is not the case in qemuDomainDetachDeviceAliasLiveAndConfig where the definition was copied and put back, but the detaching happened from the other object which was overwritten. Signed-off-by: Peter Krempa <pkrempa@redhat.com>
* src: Drop most of #ifdef WITH_GNUTLSMichal Privoznik2018-06-0520-253/+27
| | | | | | | | | Now that GnuTLS is a requirement, we can drop a lot of conditionally built code. However, not all ifdef-s can go because we still want libvirt_setuid to build without gnutls. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* tests: Always build TLS related testsMichal Privoznik2018-06-051-10/+2
| | | | | | | | Since GnuTLS is required there is no way to go with !WITH_GNUTLS branch and just distribute these files. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* src: Dissolve libvirt_gnutls.syms in libvirt_remote.symsMichal Privoznik2018-06-053-37/+8
| | | | | | | | Now that GnuTLS is required these symbols are going to be present all the time. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* src: Always build virnettlscontext into libvirt-net-rpc.laMichal Privoznik2018-06-053-29/+19
| | | | | | | | Since GnuTLS is required there is no way to go with !WITH_GNUTLS branch and just distribute these files. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* configure: Require GnuTLSMichal Privoznik2018-06-052-6/+0
| | | | | | | | | We are building with GnuTLS everywhere because GnuTLS is widely available. Also, it is desirable to prefer cryptographically strong PRNG over "/dev/urandom" which is just a fallback. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* storage: Add specific check for LUKS encryption supportJohn Ferlan2018-06-051-2/+8
| | | | | | | | Modify virStorageBackendLogicalLVCreate to ensure if encryption is requested that only type LUKS is supported; otherwise, error. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* vircrypto: Drop virCryptoGenerateRandomMichal Privoznik2018-06-055-31/+3
| | | | | | | Now that virCryptoGenerateRandom() is plain wrapper over virRandomBytes() we can drop it in favour of the latter. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* virUUIDGenerate don't fall back to virRandomBitsMichal Privoznik2018-06-051-22/+3
| | | | | | | | If virRandomBytes() fails there is no point calling virRandomBits() because it uses virRandomBytes() internally again. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* virrandom: Make virRandomBits betterMichal Privoznik2018-06-052-62/+2
| | | | | | | | | | | | | | | | Now that we have strong PRNG generator implemented in virRandomBytes() let's use that instead of gnulib's random_r. Problem with the latter is in way we seed it: current UNIX time and libvirtd's PID are not that random as one might think. Imagine two hosts booting at the same time. There's a fair chance that those hosts spawn libvirtds at the same time and with the same PID. This will result in both daemons generating the same sequence of say MAC addresses [1]. 1: https://www.redhat.com/archives/libvirt-users/2018-May/msg00097.html Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* virRandomBytes: Use gnutls_rnd whenever possibleMichal Privoznik2018-06-052-19/+19
| | | | | | | | | | While /dev/urandom is not terrible source of random data gnutls_rnd is better. Prefer that one. Also, since nearly every platform we build on already has gnutls (if not all of them) this is going to be used by default. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* virRandomBytes: Report errorMichal Privoznik2018-06-052-9/+15
| | | | | | | | 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>
* virRandomBytes: Prefer saferead over plain readMichal Privoznik2018-06-051-3/+1
| | | | Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* virCryptoGenerateRandom: Don't allocate return bufferMichal Privoznik2018-06-054-32/+28
| | | | | | | | 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>
* virCryptoGenerateRandom: Explain gnults errorMichal Privoznik2018-06-051-2/+4
| | | | | | | | | 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>
* virCryptoGenerateRandom: rename retMichal Privoznik2018-06-051-5/+5
| | | | | | | | | | 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>
* virRandomBytes: Fix return valueMichal Privoznik2018-06-054-9/+9
| | | | | | | | | 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>
* travis: Install and use ccache on macOSAndrea Bolognani2018-06-051-2/+2
| | | | | | | | | | 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>
* travis: Move PATH to macOS-specific environmentAndrea Bolognani2018-06-051-3/+2
| | | | | | | | | 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>
* build: Don't install sysconfig files as scriptsJiri Denemark2018-06-051-1/+1
| | | | | | | | 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>
* qemu: Fix domain resume after failed migrationJiri Denemark2018-06-052-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* virDomainDefCopy: Skip ostype checksMichal Privoznik2018-06-051-2/+4
| | | | | | | | | | | | | | | | | | | 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>
* virFileAccessibleAs: Remove redundant forkRetRadostin Stoyanov2018-06-051-10/+0
| | | | | | | | 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>
* docs: news: Explain iommu_support improvementFilip Alac2018-06-051-0/+8
| | | | Signed-off-by: Filip Alac <filipalac@gmail.com>
* capabilities: Extend capabilities with iommu_supportFilip Alac2018-06-0515-0/+41
| | | | | Signed-off-by: Filip Alac <filipalac@gmail.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* qemu: hostdev: Move parts of qemuHostdevHostSupportsPassthroughVFIO() into ↵Filip Alac2018-06-054-24/+33
| | | | | | | separate function Signed-off-by: Filip Alac <filipalac@gmail.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* qemu: command: Refactor disk commandline formattingPeter Krempa2018-06-053-60/+40
| | | | | | | | | | | | | 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>
* qemu: command: Extract setup of one disk's command linePeter Krempa2018-06-051-44/+62
| | | | | Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* qemu: command: Rename qemuBuildDiskDriveCommandLinePeter Krempa2018-06-051-4/+4
| | | | | | | 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>
* qemu: hotplug: Extract hotplug of TLS into qemuBlockStorageSourceAttachApplyPeter Krempa2018-06-055-38/+23
| | | | | Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* qemu: hotplug: Extract hotplug of secrets into qemuBlockStorageSourceAttachApplyPeter Krempa2018-06-054-37/+40
| | | | | Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* qemu: hotplug: Extract hotplug of PR into qemuBlockStorageSourceAttachApplyPeter Krempa2018-06-055-14/+37
| | | | | | | | 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>
* qemu: Reuse qemuBlockStorageSourceAttachApply in disk hotplugPeter Krempa2018-06-055-22/+63
| | | | | | | | | | 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>
* qemu: alias: Rename qemuAliasFromDisk to qemuAliasDiskDriveFromDiskPeter Krempa2018-06-057-21/+21
| | | | | | | 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>
* qemu: hotplug: Remove qemuDomainDelDiskSrcTLSObjectPeter Krempa2018-06-051-10/+2
| | | | | | | 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>
* qemu: Split handling of managed and unmanaged persistent reservationsPeter Krempa2018-06-054-92/+130
| | | | | | | | | | 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>
* qemu: command: Return props as return value in qemuBuildPRManagerInfoPropsPeter Krempa2018-06-053-14/+16
| | | | | | | | 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>
* qemu: command: Pass in 'src' rather than 'disk' to qemuBuildPRManagerInfoPropsPeter Krempa2018-06-053-9/+7
| | | | | | | Everything is contained in the virStorageSourceStructure. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* util: storage: Add helper for determining whether a backing chain requires PRPeter Krempa2018-06-054-1/+19
| | | | | | | | | 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>
* tests: qemublock: Test NBD with TLS in the JSON generatorPeter Krempa2018-06-053-0/+38
| | | | | Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* qemu: domain: Add support for TLS for NBDPeter Krempa2018-06-058-5/+78
| | | | | | | 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>
* qemu: conf: Add qemu.conf knobs for setting up TLS for NBDPeter Krempa2018-06-055-0/+58
| | | | | Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* qemu: Remove code for setting up disk passphrasesPeter Krempa2018-06-056-154/+0
| | | | | | | | 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>