Commit Graph

22053 Commits

Author SHA1 Message Date
Peter Krempa
c7b66f2a59 qemu: monitor: Add implementation for blockdev-add and blockdev-del
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
a6178a6610 qemu: monitor: Factor out and document code to format QMP command
Move formatting of the qemu command out of qemuMonitorJSONMakeCommandRaw
to qemuMonitorJSONMakeCommandInternal to allow greater reusability and
document the function better.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
e969af4cec qemu: caps: Add capability for blockdev-add/blockdev-del
The capability also represents that 'blockdev-add' is functional. It's
necessary to detect it via presence of 'blockdev-del' since blockdev-add
did not have the unsupported 'x-blockdev-add' version previously and
thus would be marked as present even if we could not use it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:25 +02:00
Peter Krempa
d4e57c6f04 qemu: migration: Don't access disk members without lock
The initiation of a synchronous block job in the NBD storage migration
code was placed after entering the monitor thus after the lock on the VM
object was unlocked. Thankfully nothing bad could happen in this
situation since the migration job prevents any disk detaches or other
modifications of the domain object.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:23 +02:00
Peter Krempa
082266bf27 conf: domain: Export virDomainStorageSourceParse
It will be used when parsing the migration private data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:23 +02:00
Peter Krempa
b8240fe704 qemu: block: Don't nest storage layer properties into format layer
Reference the storage via node name rather than inlining it. This is
the approach that will be used with -blockdev/blockdev-add since it
allows more control and is more future proof.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 13:18:23 +02:00
Filip Alac
3b8d050911 qemu: capabilities: Add 'hda-output' sound codec to capabilities
Signed-off-by: Filip Alac <filipalac@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-05-23 09:51:53 +02:00
Filip Alac
fcb53e8ee1 conf: Introduce codec type 'output'
Introduce support for codec type 'output' ('hda-output' in QEMU) for ich6
and ich9 sound devices, which only advertises a line-out in the guest.
This has been available in QEMU since 0.14.

Signed-off-by: Filip Alac <filipalac@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-05-23 09:51:53 +02:00
Ján Tomko
b87222a909 qemu: only pass -sandbox off if supported
This way we don't rely on QEMU supplying the -sandbox option
without CONFIG_SECCOMP.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 09:45:48 +02:00
Ján Tomko
6dbe7243f9 Reintroduce QEMU_CAPS_SECCOMP_SANDBOX
Commit 766d5c1b deprecated the capability, because we were assuming
it for every QEMU binary. At the time of the introduction, there
was no way to probe for this via QMP.

However since QEMU 1.5.0 (which is the earliest version we support)
we can rely on the query-command-line-options command to detect this
feature.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 09:45:34 +02:00
Michal Privoznik
fa6bdf6afa qemu: Deny hugepages for non-existent NUMA nodes
https://bugzilla.redhat.com/show_bug.cgi?id=1534418

Just like ec982f6d92 denies hugepages for non-existent
guest NUMA nodes in case there are some nodes configured.
Unfortunately, when there are none, qemuBuildNumaArgStr() is not
called and thus we have to have check in qemuBuildMemPathStr()
too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-23 09:00:20 +02:00
Daniel P. Berrangé
9267342206 cpu: define the 'virt-ssbd' CPUID feature bit (CVE-2018-3639)
Some AMD processors only support a non-architectural means of
enabling Speculative Store Bypass Disable. To allow simplified
handling in virtual environments, hypervisors will expose an
architectural definition through CPUID bit 0x80000008_EBX[25].
This needs to be exposed to guest OS running on AMD x86 hosts to
allow them to protect against CVE-2018-3639.

Note that since this CPUID bit won't be present in the host CPUID
results on physical hosts, it will not be enabled automatically
in guests configured with "host-model" CPU unless using QEMU
version >= 2.9.0. Thus for older versions of QEMU, this feature
must be manually enabled using policy=force. Guests using the
"host-passthrough" CPU mode do not need special handling.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-05-22 13:13:27 +02:00
Daniel P. Berrangé
1dbca2ecca cpu: define the 'ssbd' CPUID feature bit (CVE-2018-3639)
New microcode introduces the "Speculative Store Bypass Disable"
CPUID feature bit. This needs to be exposed to guest OS to allow
them to protect against CVE-2018-3639.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-05-22 13:13:26 +02:00
Daniel P. Berrangé
47a1ca6e2c qemu: clarify message about block peek format restriction
Include the actual disk format in the error message to help the user see
what is wrong.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-21 11:30:52 +01:00
Daniel P. Berrangé
bb57a6a6bc qemu: include kernel version in QEMU log file
We currently print the libvirt and qemu version strings into the
per-guest logfile. It would be useful to know what kernel is running
too, so add that.

Reviewed-by: Kashyap Chamarthy <kchamart@redhat.com>
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-21 10:32:52 +01:00
Ján Tomko
e565b9cd0c Remove type_sep parameter from qemuBuildHostNetStr
The last caller not passing a comma was removed by:
commit ad8a7c4f85
Author:     Ján Tomko <jtomko@redhat.com>
CommitDate: 2018-04-12 17:17:16 +0200

    qemu: deprecate QEMU_CAPS_NETDEV

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-21 09:35:32 +02:00
Peter Krempa
d3f4fc8684 qemu: command: Remove qemuBuildHasMasterKey
The thin wrapper is not necessary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-18 09:00:05 +02:00
Peter Krempa
50192e990f qemu: command: Fix formatting of TLS backend properties
The JSON property generator should not escape commas as we do on the
command line. The JSON->commandline generator already does that.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-18 09:00:01 +02:00
Peter Krempa
8f50120693 qemu: command: Optimize formatting of 'passwordid' in qemuBuildTLSx509BackendProps
Use the 'S' modifier for create the field optionally rather than calling
another JSON formatter function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-18 08:59:45 +02:00
Michal Privoznik
9a33776715 qemu: Implement multiple screen support for virDomainScreenshot
According to virDomainScreenshot() documentation, screens are
numbered sequentially.  e.g. having two graphics cards, both with
four heads, screen ID 5 addresses the second head on the second
card.

But apart from that, there's nothing special happening here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-17 17:13:11 +02:00
Michal Privoznik
04dcc6e0e0 qemu: Introduce QEMU_CAPS_SCREENDUMP_DEVICE
As of v2.12.0-rc0~32^2 QEMU is capable specifying which display
device and head should the screendump be taken from. Track this
capability so that we can use it later in our virDomainScreenshot
API.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-17 17:06:31 +02:00
Nikolay Shirokovskiy
a62bb9bee2 qemu: erase synchronous block job cancel mentions in comments
Commit [1] dropped support for synchronous block job cancel.
This patch erases remnants from comments.

[1] commit 2350d101 "qemu: Remove support for legacy block jobs"

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-17 14:04:33 +03:00
Daniel P. Berrangé
8fe30b2167 log: actually do substring matches with fnmatch
Historically we matched log filters with strstr(), and when switching to
fnmatch in cbb0fd3cfd, it was stated that
we would continue to match substrings, with "foo" being equivalent to
"*foo*". Unfortuntely I forget to provide the code to actually make that
happen. This fixes it to prepend and append "*". We don't bother to
check if the pattern already has a leading/trailing '*', because
"**foo**" will match the same as "*foo*".

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-16 17:48:17 +01:00
Ján Tomko
fe8a06798d Remove check for gnutls/crypto.h
Assume its presence for gnutls >= 3.2.

Check introduced by <commit 7d21d6b>.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-16 10:40:40 +02:00
Ján Tomko
504b4f2669 Fix indentation in virCryptoHaveCipher
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-16 10:40:40 +02:00
Ján Tomko
fbb07a757b Remove explicit check for gnutls_cipher_encrypt
Introduced in gnutls 2.10, and we assume >= 3.2.

Commit 1ce9c08a added this check.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-16 10:40:40 +02:00
Ján Tomko
ac9ad77303 Remove explicit check for gnutls_rnd
Introduced in gnutls 2.12, but we require gnutls >= 3.2
Check added by commit <2d23d14>.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-16 10:40:40 +02:00
Ján Tomko
279a27d4aa Deprecate GNUTLS_GCRYPT
Now that we assume GnuTLS >= 3.0, we can ditch gcrypt support.
Introduced by <commit 6094b1f>.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-16 10:40:40 +02:00
Ján Tomko
c25fbbec68 virCryptoHashBuf: return the length of the hash in bytes
virCryptoHashString also needs to know the size of the returned hash.
Return it if the hash conversion succeeded so the caller does not need
to access the hashinfo array.

This should make virCryptoHashString build without gnutls.
Also fixes the missing return value for the virCryptoHashBuf stub.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Suggested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-05-16 10:40:40 +02:00
Michal Privoznik
ed11d1662d virDomainMemoryDefParseXML: Don't leak discard
==1589== 7 bytes in 2 blocks are definitely lost in loss record 34 of 261
==1589==    at 0x4C2AF0F: malloc (vg_replace_malloc.c:299)
==1589==    by 0x8A82794: xmlStrndup (in /usr/lib64/libxml2.so.2.9.8)
==1589==    by 0x5DD8392: virXMLPropString (virxml.c:510)
==1589==    by 0x5E12427: virDomainMemoryDefParseXML (domain_conf.c:15704)
==1589==    by 0x5E207DE: virDomainDefParseXML (domain_conf.c:20351)
==1589==    by 0x5E2184F: virDomainDefParseNode (domain_conf.c:20636)
==1589==    by 0x5E216A1: virDomainDefParse (domain_conf.c:20580)
==1589==    by 0x5E21747: virDomainDefParseFile (domain_conf.c:20606)
==1589==    by 0x112F5F: testCompareXMLToArgv (qemuxml2argvtest.c:493)
==1589==    by 0x138780: virTestRun (testutils.c:180)
==1589==    by 0x117129: mymain (qemuxml2argvtest.c:937)
==1589==    by 0x13A83C: virTestMain (testutils.c:1120)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
2018-05-16 07:50:51 +02:00
Peter Krempa
9b3cbd33a7 qemu: hotplug: Replace qemuDomainDiskNeedRemovePR
The function can be replaced by much simpler logic.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-05-16 06:32:29 +02:00
Peter Krempa
8bebb2b735 util: storage: Store PR manager alias in the definition
Rather than always re-generating the alias store it in the definition
and in the status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-05-16 06:32:29 +02:00
Peter Krempa
26c72a76dc conf: domain: Add helper to check whether a domain def requires use of PR
Extract the lookup code so that it can be reused later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-05-16 06:32:29 +02:00
Peter Krempa
b4f113ee44 qemu: command: Move check whether PR manager object props need to be built
Move it out of the format function and let the caller decide this.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-05-16 06:32:29 +02:00
Peter Krempa
8f7c25ae39 qemu: process: Change semantics of functions starting PR daemon
Libvirt only manages one PR daemon. This means that we don't need to
pass the 'disk' object and also rename the functions dealing with this
so that it's obvious we only deal with the managed PR daemon.

Signed-off-by: Peter Krempa <pkrempa@redhat st.com>
2018-05-16 06:32:29 +02:00
Peter Krempa
b571e7bad0 qemu: Assign managed PR path when preparing storage source
Rather than always checking which path to use pre-assign it when
preparing storage source.

This reduces the need to pass 'vm' around too much. For later use the
path can be retrieved from the status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-05-16 06:32:28 +02:00
Peter Krempa
e31f490458 util: storage: Allow passing <source> also for managed PR case
To allow storing status information in the XML move the validation that
the 'path' is not valid for managed PR daemon case into
qemuDomainValidateStorageSource and allow parsing of the data even in
case when managed='yes'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-05-16 06:32:28 +02:00
Peter Krempa
900fc66121 util: storage: Drop virStoragePRDefIsEnabled
The function now does not do anything useful. Replace it by the pointer
check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-05-16 06:32:28 +02:00
Peter Krempa
e72b3f0bbe util: storage: Drop pointless 'enabled' form PR definition
Everything can be disabled by not using the parent element. There's no
need to store this explicitly. Additionally it does not add any value
since any configuration is dropped if enabled='no' is configured.

Drop the attribute and adjust the code accordingly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-05-16 06:32:28 +02:00
Peter Krempa
1efda36765 qemu: Move validation of PR manager support
Disk source definition should be validated in
qemuDomainValidateStorageSource rather than in individual generators of
command line arguments.

Change to the XML2XML test is required since now the definition is
actually validated at define time.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-05-16 06:32:28 +02:00
Peter Krempa
64e3ae0d51 qemu: command: Fix comment for qemuBuildPRManagerInfoProps
The comment did not accurately describe the arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-05-16 06:32:28 +02:00
Peter Krempa
b5aec60cc4 qemu: alias: Allow passing alias of parent when generating PR manager alias
For use with blockdev the PR manager will be bound to a virStorageSource
rather than a virDomainDiskDef, so we will need to use the correct
alias.

Allow passing a string rather than the whole disk.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-05-16 06:32:28 +02:00
Peter Krempa
90309bcdc5 qemu: hotplug: Fix spacing around addition operator
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-05-16 06:32:28 +02:00
John Ferlan
352e549450 storage_util: Introduce storageBackendDoCreateQemuImg
Extract out command line setup and run from storageBackendCreateQemuImg
as we'll need to run it twice soon.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:57:24 -04:00
John Ferlan
e1e1fcf769 storage_util: Introduce storageBackendCreateQemuImgSetInput
Split up virStorageBackendCreateQemuImgCmdFromVol into two parts.
It's too long anyway and virStorageBackendCreateQemuImgCmdFromVol
should just handle the command line processing.

NB: Requires changing info.* into info->* references.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:57:24 -04:00
John Ferlan
4b9055c930 storage_util: Move @type into _virStorageBackendQemuImgInfo
We're about to split up the code a bit more, so we'll need this
to be in the local struct.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:57:24 -04:00
John Ferlan
b5c8c547b7 storage_util: Split preallocate set in storageBackendCreateQemuImgOpts
The only way preallocate could be set is if the info->format was
not RAW (see storageBackendCreateQemuImgSetBacking), so let's just
extract it from the if/else surrounding the application of the
encryption options.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:57:24 -04:00
John Ferlan
c46fc572be storage_util: Split backing_fmt set in storageBackendCreateQemuImgOpts
The only way backing_fmts could be set is if the info->format was
not RAW (see storageBackendCreateQemuImgSetBacking), so let's just
extract it from the if/else surrounding the application of the
encryption options.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:57:24 -04:00
John Ferlan
3d14408c17 storage_util: Remove luks distinction from secret path and alias
Remove the "luks" distinction as the code is about to become more
generic and be able to support qcow encryption as well.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:57:24 -04:00
John Ferlan
9118e23f6d storage_util: Move secretPath generation
Move generation of secretPath to storageBackendGenerateSecretData
and simplify a bit since we know vol->target.encryption is set plus
we have a local @enc.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:57:24 -04:00
John Ferlan
3d1db851ca storage_util: Generate the qcow secret earlier
Rather than having storageBackendCreateQemuImgCheckEncryption
perform the virStorageGenerateQcowEncryption, let's just do that
earlier during storageBackendCreateQemuImg so that the check
helper is just a check helper rather doing something different
based on whether the format is qcow[2] or raw based encryption.

This fixes an issue in the storageBackendResizeQemuImg processing
for qcow encryption where if a secret was not available for a
volume, a new secret will not be generated and instead an error
message will be generated.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:55:09 -04:00
John Ferlan
9629fe258f storage_util: Rename virQEMUBuildLuksOpts
Rename to storageBackendCreateQemuImgOpts - which is what it's doing.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:54:58 -04:00
John Ferlan
8fc9949caa storage_util: Remove unnecessary check
Commit id 'a48c71411' altered the logic a bit and didn't
remove an unnecessary check as info.encryption is true when
vol->target.encryption != NULL, so if we enter the if segment
with info.format == VIR_STORAGE_FILE_RAW && vol->target.encryption
!= NULL, then there's no way info.encryption could be false.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:54:58 -04:00
John Ferlan
f78c814c5c storage_util: Cleanup usage of target.encryption
Remove the != NULL checks, use !! for setting info.encryption.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:54:58 -04:00
John Ferlan
9cfd507367 storage_util: Some code cleanup
Perform some code cleanup in areas that are about to be altered.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:54:58 -04:00
Maciej Wolny
5038b30043 qemu: Add gl option to SDL graphics command line
Support OpenGL when using SDL backend via -sdl,gl=on. Add associated
tests.

NB: Usage of DO_TEST_CAPS_LATEST in qemuxml2argv doesn't work in
this case because -sdl gl is not introspectable.

Signed-off-by: Maciej Wolny <maciej.wolny@codethink.co.uk>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:50:38 -04:00
Maciej Wolny
3278a7bb26 qemu: Add QEMU_CAPS_SDL_GL to qemu capabilities
Support OpenGL acceleration capability when using SDL graphics.

Signed-off-by: Maciej Wolny <maciej.wolny@codethink.co.uk>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:50:38 -04:00
Maciej Wolny
fff9e25a2b conf: Add gl property to graphics of type sdl in domain config
Support OpenGL accelerated rendering when using SDL graphics in the
domain config. Add associated test and documentation.

Signed-off-by: Maciej Wolny <maciej.wolny@codethink.co.uk>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:50:38 -04:00
Maciej Wolny
9ac74d44a5 qemu_command: Remove outdated comment
Signed-off-by: Maciej Wolny <maciej.wolny@codethink.co.uk>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:50:38 -04:00
Maciej Wolny
4d18727ffe qemu_command: Move SDL command line building into helper
Create a function called `qemuBuildGraphicsSDLCommandLine` which is
called from qemuBuildGraphicsCommandLine.

Signed-off-by: Maciej Wolny <maciej.wolny@codethink.co.uk>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-15 16:50:38 -04:00
Daniel P. Berrangé
45b98aaaa0 util: fix misleading comment for virObjectLock
It only accepts a virObjecLockable, not a virObjecRWLockable

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-15 18:43:01 +01:00
Jim Fehlig
ac4a12db71 libxl: don't set hasManagedSave when performing save
libxlDoDomainSave() is used in both the save and managedsave code
paths but was unconditionally setting hasManagedSave to true on
success. As a result, undefine would fail after a non-managed
save/restore operation. E.g.

virsh define; virsh start
virsh save; virsh restore
virsh shutdown
virsh undefine
error: Refusing to undefine while domain managed save image exists

Modify libxlDoDomainSave() to take an additional parameter to
specify managed vs non-managed save, and change callers to use it.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-15 11:03:04 -06:00
Filip Alac
656151bf5d xenconfig: xm: Fix checking for extra in parser
Parser assumed extra was always present when root was specified.
Fixed by handling root and extra separately.

Signed-off-by: Filip Alac <filipalac@gmail.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2018-05-14 17:07:30 -06:00
Shalini Chellathurai Saroja
21442874cf qemu: command line generation for vfio-ccw device
Generates the QEMU command line for the vfio-ccw device.

Adds various functionality testing for vfio-ccw in libvirt:

1. Generation of QEMU command line from domain xml file
2. Generation of dump xml from domain xml file
3. Checks duplicate/invalid addresses for vfio-ccw devices.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-14 12:27:46 -04:00
Shalini Chellathurai Saroja
7224144400 qemu: vfio-ccw device address generation
Introduces the vfio-ccw model for mediated devices and prime vfio-ccw
devices such that CCW address will be generated.

Alters the qemuxml2xmltest for testing a basic mdev device using vfio-ccw.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-14 12:27:44 -04:00
Shalini Chellathurai Saroja
2b9690b62d util: virhostdev: add virHostdevIsMdevDevice()
Add the function virHostdevIsMdevDevice() which detects whether a
hostdev is a mediated device or not. Also, replace all existing
conditionals.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-14 12:12:06 -04:00
Shalini Chellathurai Saroja
263e65fd20 qemu: introduce vfio-ccw capability
Let us introduce the capability vfio-ccw for supporting the basic
channel I/O passthrough, which have been introduced in QEMU 2.10. The
current focus is to support dasd-eckd (cu_type/dev_type = 0x3990/0x3390)
as the target device.

Let us also introduce the capability QEMU_CAPS_CCW_CSSID_UNRESTRICTED
for virtual-css-bridge. This capability is based on the
cssid-unrestricted property which exists if QEMU no longer enforces
cssid restrictions based on ccw device types.

Vfio-ccw capability is dependent on the hidden virtual-css-bridge, so
that we are able to probe for the cssid-unrestriced property to make
sure the devices are visible to non-mcss-e enabled guests.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-14 12:12:02 -04:00
Shalini Chellathurai Saroja
f245a9791c qemu: introduce capability for virtual-css-bridge
Let us introduce the capability QEMU_CAPS_CCW for virtual-css-bridge
and replace QEMU_CAPS_VIRTIO_CCW with QEMU_CAPS_CCW in code segments
which identify support for ccw devices.

The virtual-css-bridge is part of the ccw support introduced in QEMU 2.7.
The QEMU_CAPS_CCW capability is based on the existence of the QEMU type.

Let us also add the capability QEMU_CAPS_CCW to the tests which
require support for ccw devices.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-14 11:26:15 -04:00
Ján Tomko
799011bbe7 vircrypto: Rely on GnuTLS for hash functions
Ditch the use of gnulib's digest functions in favor of GnuTLS,
which might be more likely to get FIPS-certified.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 14:05:21 +02:00
Ján Tomko
c038a3cfed esx: Use VIR_CRYPTO_HASH_SIZE_MD5
Do not rely on gnulib's MD5_DIGEST_SIZE from md5.h.

Include vircrypto.h and use VIR_CRYPTO_HASH_SIZE_MD5.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 14:05:21 +02:00
Ján Tomko
3ec34fd7a3 esx: use virCryptoHashBuf
Instead of using md5_buffer from gnulib directly.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 14:05:21 +02:00
Ján Tomko
0eeedd61a9 Introduce virCryptoHashBuf
A function that keeps the hash in binary form instead of converting
it to human-readable hexadecimal form.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 13:57:45 +02:00
Ján Tomko
95ba1c2f6e vircrypto: provide constants for hash sizes
The callers needing to know the size of the resulting digest
rely on _DIGEST_SIZE constants from gnulib.

Introduce VIR_CRYPTO_HASH_SIZE_ constants to remove the dependency.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 13:55:47 +02:00
Michal Privoznik
2c4affd57e qemu: Implement memoryBacking/discard
https://bugzilla.redhat.com/show_bug.cgi?id=1480668

QEMU has this new feature memory-backend-file.discard-data=yes
which is a nifty optimization. Basically, when qemu is quitting
or on memory hotplug it calls munmap() and close() on the file
that is backing the memory. However, this does not mean kernel
won't stop touching that part of memory. It still might. With
this feature enabled we tell kernel: "we don't need this memory
nor data stored in it". This makes kernel drop the memory
immediately without trying to sync memory with the mapped file.

Unfortunately, this cannot be turned on by default because we
can't be sure when users really don't care about what happens to
data after qemu dies. So it has to be opt-in. As usual, there are
three places where one can configure memory attributes. This
patch adds the feature to all of them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 09:42:21 +02:00
Michal Privoznik
2300c92fe0 conf: Introduce memoryBacking/discard
QEMU has possibility to call madvise(.., MADV_REMOVE) in some
cases. Expose this feature to users by new element/attribute
discard.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 09:42:20 +02:00
Michal Privoznik
0329075733 conf: Move virDomainMemtune formatting into a separate function
At the same time convert the code to use virXMLFormatElement.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 09:42:20 +02:00
Michal Privoznik
72c1770aa0 qemu_capabilities: Introduce QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD
This capability tracks if memory-backend-file has discard-data
attribute or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 09:42:20 +02:00
Michal Privoznik
8a94501e8c qemu_capabilities: Introduce QEMU_CAPS_QOM_LIST_PROPERTIES
This capability tracks if qemu has "qom-list-properties" monitor
command.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 09:42:20 +02:00
Michal Privoznik
d81cf424ca qemu_monitor: Introduce qemuMonitorGetObjectProps
Now that we've gotten rid of misleading names we can introduce
qemuMonitorGetObjectProps() function which queries -object
properties. Again, some parts of code can be reused.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 09:42:20 +02:00
Michal Privoznik
036120209b qemuMonitorJSONGetDeviceProps: Separate props processing
The code that processes list of device properties is going to be
reused. Therefore put it into a separate function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 09:42:20 +02:00
Clementine Hayat
920a7d3336 bhyve: start using virDomainObjCheckActive
Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 08:58:33 +02:00
Clementine Hayat
3c311d7e9b lxc: start using virDomainObjCheckActive
Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 08:58:33 +02:00
Clementine Hayat
48d44efcc0 qemu: start using virDomainObjCheckActive
Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 08:58:33 +02:00
Ján Tomko
e8c0558414 virutil.c: do not include stdarg.h
Last functions using it were moved to virfile.c in commit <bfe7721>.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 08:41:58 +02:00
Ján Tomko
d80881db3f virutil.c: do not include ioctl.h
Added by commit 61674cc, but we have started using
set_nonblocking_flag from gnulib in commit da3c4714

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-14 08:41:49 +02:00
Fabian Freyer
b181e44d9f bhyve: add support for wiring memory
The <memoryBacking><locked/></memoryBacking> element will now pass the
wired (-S) flag to the bhyve command.

Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
2018-05-13 13:38:23 +04:00
Daniel P. Berrangé
8ccee910f5 log: update docs for daemons to improve user understanding
Strongly recommend against use of the log_levels setting since it
creates overly verbose logs and has a serious performance impact.

Describe the log filter syntax better and mention use of shell
glob syntax. Also provide more realistic example of good settings
to use. The libvirtd example is biased towards QEMU, but when the
drivers split off each daemon can get its own more appropriate
example.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-11 17:11:46 +01:00
Daniel P. Berrangé
cbb0fd3cfd log: support logging using shell wildcard syntax
Rather than specialcasing handling of the '*' character, use fnmatch()
to get normal shell wildcard syntax, as described in 'man glob(7)'.

To get an indication of the performance impact of using globs instead
of plain string matches, a test program was written. The list of all
260 log categories was extracted from the source. Then a typical log
filters setup was picked by creating an array of the strings "qemu",
"security", "util", "cgroup", "event", "object". Every filter string
was matched against every log category. Timing information showed that
using strstr() this took 8 microseconds, while fnmatch() took 114
microseconds.

IOW, fnmatch is 14 times slower than our existing strstr check. These
numbers show a worst case scenario that will never be hit, because it
is rare that every log category would have data output. The log category
matches are cached, so each category is only checked once no matter how
many log statements are emitted. IOW despite being slower, this will
be lost in the noise and have no consequence on real world logging
performance.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-11 17:08:06 +01:00
Daniel P. Berrangé
4a239d1509 log: rename virLogFlags to virLogFilterFlags to match docs
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-11 17:06:55 +01:00
Michal Privoznik
ebad530e9f virbuffer: Set child buffer indent properly
There's this macro virBufferSetChildIndent which sets offset of
child buffer from given parent buffer. However, it is calling
virBufferAdjustIndent() which only adds adjustment instead of
calling virBufferSetIndent() which clears out any adjustment
previously set.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-11 17:04:12 +02:00
Ján Tomko
50b4e9afe2 virJSONValue: remove unused 'protect' property
The last usage was removed by commit <167028e>

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-11 13:23:06 +02:00
Julio Faracco
c9da6cbec9 rpc: replacing ssh_get_publickey() by ssh_get_server_publickey().
After version 0.7.5, libssh deprecated the function scope
ssh_get_publickey() and moved to ssh_get_server_publickey(). So, Libvirt
is failing to compile using this new function name.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-05-11 10:38:17 +02:00
Michal Privoznik
b0cd8045f0 qemu: Detect pr-manager-helper capability
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-11 09:26:47 +02:00
Michal Privoznik
eba6467fed qemu_hotplug: Hotunplug of reservations
If we are the last one to use pr-manager object we need to remove
it and also kill the qemu-pr-helper process.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-11 09:26:47 +02:00
Michal Privoznik
3f968fda7b qemu_hotplug: Hotplug of reservations
When attaching a disk that requires pr-manager we might need to
plug the pr-manager object and start the pr-helper process.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-11 09:26:47 +02:00
Michal Privoznik
053d9e30e7 qemu: Start PR daemon on domain startup
Before we exec() qemu we have to spawn pr-helper processes for
all managed reservations (well, technically there can only one).
The only caveat there is that we should place the process into
the same namespace and cgroup as qemu (so that it shares the same
view of the system). But we can do that only after we've forked.
That means calling the setup function between fork() and exec().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-11 09:26:38 +02:00
Michal Privoznik
8be74af168 qemu: Introduce pr_helper to qemu.conf
Just like we allow users overriding path to bridge-helper
detected at compile time we can allow them to override path to
qemu-pr-helper.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-11 09:02:56 +02:00
Michal Privoznik
d13179fe8d qemu_cgroup: Allow /dev/mapper/control for PR
Just like in previous commit, qemu-pr-helper might want to open
/dev/mapper/control under certain circumstances. Therefore we
have to allow it in cgroups.

The change virdevmapper.c might look spurious but it isn't. After
6dd84f6850 any path that we're allowing in deivces CGroup is
subject to virDevMapperGetTargets() inspection. And libdevmapper
returns ENXIO for the path from subject.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-11 09:02:56 +02:00
Michal Privoznik
5bf89434ff qemu_ns: Allow /dev/mapper/control for PR
If qemu-pr-helper is compiled with multipath support the first
thing it does is open /dev/mapper/control. Since we're going
to be running it inside qemu namespace we need to create it
there. Unfortunately, we don't know if it was compiled with or
without multipath so we have to create it anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-11 09:02:56 +02:00
Michal Privoznik
13fe558fb4 qemu: Generate pr cmd line at startup
For command line we need two things:

1) -object pr-manager-helper,id=$alias,path=$socketPath
2) -drive file.pr-manager=$alias

In -object pr-manager-helper we tell qemu which socket to connect
to, then in -drive file-pr-manager we just reference the object
the drive in question should use.

For managed PR helper the alias is always "pr-helper0" and socket
path "${vm->priv->libDir}/pr-helper0.sock".

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-11 09:02:56 +02:00
Michal Privoznik
3c28602759 qemu: Introduce pr-manager-helper capability
The capability tracks if qemu has pr-manager-helper object. At
this time don't actually detect if qemu has the capability. Not
just yet. Only after the code is written the feature will be
enabled.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-11 09:02:56 +02:00
Michal Privoznik
c7c9dea0a0 qemuDomainDiskChangeSupported: Deny changing reservations
Couple of reasons for that:

a) there's no monitor command to change path where the pr-helper
connects to, or
b) there's no monitor command to introduce a new pr-helper for a
disk that already exists.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-11 09:02:56 +02:00
Michal Privoznik
687730540e virstoragefile: Introduce virStoragePRDef
This is a definition that holds information on SCSI persistent
reservation settings. The XML part looks like this:

  <reservations enabled='yes' managed='no'>
    <source type='unix' path='/path/to/qemu-pr-helper.sock' mode='client'/>
  </reservations>

If @managed is set to 'yes' then the <source/> is not parsed.
This design was agreed on here:

https://www.redhat.com/archives/libvir-list/2017-November/msg01005.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-11 09:02:56 +02:00
John Ferlan
4a3d6ed5ee util: Clean up consumers of virJSONValueArraySize
Rather than have virJSONValueArraySize return a -1 when the input
is not an array and then splat an error message, let's check for
an array before calling and then change the return to be a size_t
instead of ssize_t.

That means using the helper virJSONValueIsArray as well as using a
more generic error message such as "Malformed <something> array".
In some cases we can remove stack variables and when we cannot,
those variables should be size_t not ssize_t. Alter a few references
of if (!value) to be if (value == 0) instead as well.

Some callers can already assume an array is being worked on based
on the previous call, so there's less to do.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-10 14:59:15 -04:00
Roland Schulz
91234b0573 qemu: Remove parameter 'driver' from qemuBlockJobUpdate
The pointer to the qemu driver is already included in domain object's
private data, so does not need to be passed as yet another parameter
when the domain object is already passed.

Also removes parameter 'driver' from functions which had it just because of
qemuBlockJobUpdate.

Signed-off-by: Roland Schulz <schullzroll@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-10 16:43:24 +02:00
Ján Tomko
6c6795b4d7 Deprecate QEMU_CAPS_NESTING
Unused since commit <a7424fa>.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-09 13:55:04 +02:00
Peter Krempa
fc66d24066 qemu: domain: Replace qemuDomainFilePathIsHostCDROM with virFileIsCDROM
Use the new helper when checking that the VM needs to be tainted as a
host-cdrom passthrough.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
2018-05-09 13:04:33 +02:00
David Kiarie
d894e49292 xenconfig: remove my name and email from files
Remove my name and email from these files

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: David Kiarie <davidkiarie4@gmail.com>
2018-05-08 13:45:51 +01:00
Peter Krempa
74fad50de4 util: file: Fix usage of STRPREFIX in virFileIsCDROM
STRPREFIX takes only two arguments, but the code it was adapted from
used function with 3 arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-05-07 17:12:26 +02:00
Peter Krempa
30a7721702 qemu: domain: Tolerate NULL 'cfg' in qemuDomainPrepareDiskSourceChain
The function will be reused in the test code where we don't care much
that the gluster debug level can't be populated from the qemu config.

Set the level only when 'cfg' is passed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:42:33 +02:00
Peter Krempa
1e81f198bf qemu: domain: Export qemuDomainDeviceDefValidateDisk
It will be used in the qemublocktest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:41:15 +02:00
Peter Krempa
e17193acd2 qemu: block: Add support for creating 'format' layer for blockdev-add
When using blockdev-add and friends, libvirt will need to create also
properties for the qcow2/raw/... format handler in qemu. This patch adds
the infrastructure and implements all formats known to libvirt including
all properties which are expressed at the format level in qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:38:03 +02:00
Peter Krempa
0e6b60dcac qemu: block: Always set discard for storage nodes
Enabling discard for the storage node allows the format drivers to
discard snapshots and other things, while configuration of the format
layer actually decides whether to actually discard data on request from
the host.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:36:53 +02:00
Peter Krempa
b51016c73c qemu: block: Format 'read-only' attribute for JSON disk protocol
This will be required when doing blockdev-add to conform with the
approach qemu choses to create the disks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:36:41 +02:00
Peter Krempa
de5a15bc3d qemu: block: Format cache modes for disk storage backends
When used directly with blockdev-add/-blockdev the cache mode will need
to be specified directly for every image rather than just for the disk
itself. This implements the backing options 'direct' and 'no-flush'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:34:11 +02:00
Peter Krempa
58505900c5 qemu: block: Validate node-names for use with qemu
qemu declares node-name as a 32 byte buffer and silently truncates
anything longer than that. This is unacceptable for libvirt, so we need
to make sure that we won't ever supply a node-name exceeding 31 chars.

Add a function which will do the validation and use it to validate
storage-protocol node names.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:33:38 +02:00
Peter Krempa
d94aa38ffb qemu: block: Propagate 'legacy' parameter when formatting disk backing
The gluster protocol in qemu uses two styles, one of which is legacy and
not covered by the QAPI schema.

To allow using of the new style in the blockdev-add code, add a
parameter for qemuBlockStorageSourceGetBackendProps which will switch
between the two modes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:31:48 +02:00
Peter Krempa
01455fe87b qemu: block: Properly handle block storage in JSON generator
Block storage should actually be passed to qemu via 'host_device' or
'host_cdrom' according to the device type. There were no users of this
behaviour so we thankfully can change it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:30:47 +02:00
Peter Krempa
e5dc760d0c qemu: domain: Store whether a virStorageSource is a host CDROM drive
Use virFileIsCDROM to detect whether a block device is a cdrom drive and
store it in virStorageSource. This will be necessary to correctly create
the 'host_cdrom' backend in qemu when using -blockdev.

We assume that host_cdrom makes only sense when used directly as a raw
image, but if a backing chain would be put in front of it, libvirt will
use 'host_device' in that case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:22:30 +02:00
Peter Krempa
f3282d1f9b util: file: Add helper to determine whether a path is a CDROM
Add detection mechanism which will allow to check whether a path to a
block device is a physical CDROM drive. This will be useful once we will
need to pass it to hypervisors.

The linux implementation uses an ioctl to do the detection, while the
fallback uses a simple string prefix match.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:17:06 +02:00
Peter Krempa
a33a3b1006 util: file: Use only one #ifdef for __linux__
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:07:33 +02:00
Peter Krempa
2b26ea1441 qemu: block: Add support for accessing directories via the 'vvfat' driver
Handle VIR_STORAGE_TYPE_DIR in qemuBlockStorageSourceGetBackendProps so
that a 'vvfat' driver is used, which emulates a FAT filesystem
containing the folders.

qemu requires us to add it as a storage layer, since a 'raw' layer is
usually put on top of it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:06:55 +02:00
Peter Krempa
c9b27af32d qemu: Move virtual FAT disk validation from command line builder
Move it to the validation callback and make it more robust. This will
also put the checks in the correct place to use with -blockdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 15:05:24 +02:00
Peter Krempa
043b9069c5 utils: storage: Mark that a virStorageSource is going to be used as a floppy
Add a flag denoting that a virStorageSource is going to be used as a
floppy image. This will be useful in cases where the user passes in
files which shall be exposed as an image to the guest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 14:52:43 +02:00
Peter Krempa
bbf204dab7 qemu: block: Handle iomode property for json 'file' driver
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 14:51:28 +02:00
Peter Krempa
0304e675c0 qemu: block: Extract formatting of props for 'file' backend
'file' backend in qemu supports few more options than the current
implementation. Extract it so that changes don't pollute the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 14:50:54 +02:00
Peter Krempa
8a78f88a1a qemu: domain: Carefuly transfer configuration from disk to storage source
Some properties don't make sense to be configured for every single layer
of the backing chain, but to avoid needing to pass the disk structure we
will copy them to the individual virStorageSource.

Zero detection is applied only for the top layer image, while caching
and iomode for all layers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 14:49:21 +02:00
Peter Krempa
d302b5896e util: storage: Add shadow copies of few disk properties to virStorageSource
Few things which are currently stored the virDomainDiskDef structure are
actually relevant for the storage source as well. Add the fields with a
note that they are just mirror of the values from the disk.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 14:47:43 +02:00
Peter Krempa
38fd7aec33 qemu: domain: Format storage source node names into private data
Save and restore node names if we know them or when we will be
generating them in the status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 14:45:11 +02:00
Peter Krempa
3817fa10c4 storage: Properly track that backing chain members are readonly
Everything besides the top of the chain is readonly. Track this when
parsing the XML and detecting the chain from the disk. Also fix the
state when taking snapshots.

All other cases where the top image is changed already preserve the
readonly state from the original image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 14:41:20 +02:00
Ján Tomko
5dbdd401e8 Deprecate QEMU_CAPS_TDF
This capability is unused since we stopped parsing -help output.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 10:33:13 +02:00
Ján Tomko
941c8b0d00 Deprecate QEMU_CAPS_NO_KVM_PIT
The -no-kvm-pit-reinjection option has been deprecated since
its introduction in QEMU 1.3. See commit <1569fa1>.

Drop the capability since all the QEMUs we support allow tuning
the kvm-pit properties via -global.

Also add the QEMU_CAPS_KVM_PIT_TICK_POLICY to the clock-catchup
tests, since expecting it to succeed with QEMU that does not
have kvm-pit makes no sense.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 10:33:13 +02:00
Ján Tomko
1c533759e1 qemuBuildMachineCommandLine: use a switch for virDomainVirtType
Enumerate all the cases and use virReportEnumRangeError.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 10:33:13 +02:00
Ján Tomko
a34f18cde0 qemu: remove qemuBuildObsoleteAccelArg
Since we started assuming QEMU_CAPS_MACHINE_OPT in
commit <69420756>, this function can only be reached
for unsupported virt types.

Replace the call with a virReportError.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 10:33:13 +02:00
Ján Tomko
e5261d8fe3 storage: remove qemu-img help scraping
We have been checking whether qemu-img supports the -o compat
option by scraping the -help output.

Since we require QEMU 1.5.0 now and this option was introduced in 1.1,
assume we support it and ditch the help parsing code along with the
extra qemu-img invocation.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-07 10:23:20 +02:00
Prafullkumar Tale
40b5c99a5b lxc: convert to typesafe virConf accessors in lxc_native.c
Signed-off-by: Prafullkumar Tale <talep158@gmail.com>
2018-05-04 17:49:05 +02:00
John Ferlan
b04629b629 conf: Clean up object referencing for Add and Remove
When adding a new object to the domain object list, there should
have been 2 virObjectRef calls made one for each list into which
the object was placed to match the 2 virObjectUnref calls that
would occur during Remove as part of virHashRemoveEntry when
virObjectFreeHashData is called when the element is removed from
the hash table as set up in virDomainObjListNew.

Some drivers (libxl, lxc, qemu, and vz) handled this inconsistency
by calling virObjectRef upon successful return from virDomainObjListAdd
in order to use virDomainObjEndAPI when done with the returned @vm.
While others (bhyve, openvz, test, and vmware) handled this via only
calling virObjectUnlock upon successful return from virDomainObjListAdd.

This patch will "unify" the approach to use virDomainObjEndAPI
for any @vm successfully returned from virDomainObjListAdd.

Because list removal is so tightly coupled with list addition,
this patch fixes the list removal algorithm to return the object
as entered - "locked and reffed".  This way, the callers can then
decide how to uniformly handle add/remove success and failure.
This removes the onus on the caller to "specially handle" the
@vm during removal processing.

The Add/Remove logic allows for some logic simplification such
as in libxl where we can Remove the @vm directly rather than
needing to set a @remove_dom boolean and removing after the
libxlDomainObjEndJob completes as the @vm is locked/reffed.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-05-03 19:09:03 -04:00
John Ferlan
faa148bc5d libxl: Add refcnt for args->conn during migration
Since the @dconn reference via args->conn will be used via a thread
or callback, let's make sure memory associated with it isn't free'd
unexpectedly before we use it. The Unref will be done when the object
is Dispose'd.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-05-03 19:09:03 -04:00
John Ferlan
8369ddfd1b libxl: Add refcnt for args->vm during migration
When adding the @vm to the @args for usage during a thread or
callback, let's add the reference to it at the time of adding to
ensure nothing else deletes it. The corresponding Unref is then
added to the Dispose function.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-05-03 19:09:03 -04:00
John Ferlan
2d2ed7b6f6 conf: Move and use virDomainObjListRemoveLocked
Rather than open code within virDomainObjListRemove, just call
the *Locked function.

Additionally, add comments to virDomainObjListRemove to describe
the usage model.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-05-03 19:09:03 -04:00
John Ferlan
7ae289203a conf: Use virDomainObjListFindBy*Locked for virDomainObjListAdd
Use the FindBy{UUID|Name}Locked helpers which will return a locked
and ref counted object rather than the direct virHashLookup and
virObjectLock of the returned object. We'll need to temporarily
virObjectUnref when we assign a new domain @def, but that will
change shortly when virDomainObjListAddObjLocked returns the
correct reference counted object.

Use the virDomainObjEndAPI in the error path to Unref/Unlock for
the corresponding Unref/Unlock of either the FindBy* return or
the virDomainObjNew since both return a reffed/locked object.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-05-03 19:09:03 -04:00
John Ferlan
cf5184d1e1 conf: Split FindBy{UUID|Name} into locked helpers
Create helpers virDomainObjListFindByUUIDLocked and
virDomainObjListFindByNameLocked to avoid the need
to lock the domain object list leaving that task
for the caller.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-05-03 19:09:03 -04:00
Cole Robinson
33455bc4ce domain_capabilities: Report <vmcoreinfo> support
Report <features><vmcoreinfo supported='yes'/> if the guest config
accepts <features><vmcoreinfo state='on'/>

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-05-03 16:37:41 -04:00
Cole Robinson
217d2656a5 conf: Add a comment warning about boolean feature XML
This is the old style and we really shouldn't be adding any more
examples like this. Add a comment to warn devs away

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-05-03 16:37:41 -04:00
Cole Robinson
c84be08156 conf: format/parse <vmcoreinfo> as tristate
<features><vmcoreinfo/> is a bare boolean XML property. We don't really
use this format anymore and instead prefer tristate <X state=on|off/>
since it's required for modeling on/off/default. If for example future
qemu started enabling vmcoreinfo by default we wouldn't have any way
for the user to turn this off.

Convert it to tristate. For writing XML this is semanticly the same,
<vmcoreinfo/> is processed as <vmcoreinfo state='on'/>.

For apps reading guest XML this is technically an API change,
as they might misinterpret <vmcoreinfo state='off'/>, however this
has only been present in libvirt since 3.10.0 and I don't think any
apps are dependent on this yet

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-05-03 16:37:41 -04:00
Martin Kletzander
8525b9694e qemu: Add I/O thread support info into domain capabilities
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-05-03 22:31:37 +02:00
Martin Kletzander
25f4ee5179 xenconfig/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:37 +02:00
Martin Kletzander
4c7315b4ab vz/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:37 +02:00
Martin Kletzander
5298a202ca vmx/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:37 +02:00
Martin Kletzander
8aece9bc9c uml/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:37 +02:00
Martin Kletzander
86137d7135 test/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:37 +02:00
Martin Kletzander
d80b84c68b storage/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:37 +02:00
Martin Kletzander
156f03ec59 security/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:37 +02:00
Martin Kletzander
b63d30d601 rpc/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:37 +02:00
Martin Kletzander
5b912664c6 qemu/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:37 +02:00
Martin Kletzander
221090dbda phyp/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:37 +02:00
Martin Kletzander
cf057fbefb nwfilter/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:37 +02:00
Martin Kletzander
6f8ec35aa1 network/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:37 +02:00
Martin Kletzander
aa2c1a16ba lxc/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:36 +02:00
Martin Kletzander
4d9114f70a hyperv/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:36 +02:00
Martin Kletzander
9f8d3afdca esx/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:36 +02:00
Martin Kletzander
76f253d866 access/: Remove spaces after casts
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-03 22:31:36 +02:00
Andrea Bolognani
00d465bb4d syntax-check: Prohibit canonicalize_file_name()
We want to make sure our wrapper is used instead in order
to keep the test suite working.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 18:23:30 +02:00
Andrea Bolognani
4267393198 all: Use virFileCanonicalizePath() instead of canonicalize_file_name()
The latter is impossible to mock on platforms that use the
gnulib implementation, such as FreeBSD, while the former
doesn't suffer from this limitation.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 18:23:30 +02:00
Andrea Bolognani
026606caf2 util: Introduce virFileCanonicalizePath()
It's a trivial wrapper around canonicalize_file_name(),
which we need in order to fully mock file access on non-Linux
platforms.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 18:23:29 +02:00
Daniel P. Berrangé
23ed8eb21d nwfilter: pass vm name in when instantiating filters
The vm name is not needed for any functional requirement, but it will be
useful when debugging problems to identify which VM is associated with a
filter, since UUID is not human friendly.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 17:00:57 +01:00
Daniel P. Berrangé
593ba43f1f nwfilter: introduce virNWFilterBinding to decouple from virDomainNet
The virDomainNet struct contains everything related to configuring a
guest network device. Out of all of this info, only 5 fields are
relevant to configuring network filters. It will be more convenient for
future changes to the nwfilter driver if the relevant fields are kept in
a dedicated struct. Thus the virNWFilterBinding struct is created to
track this information.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 17:00:57 +01:00
Daniel P. Berrangé
1c425d735d nwfilter: fix leaking of filter parameters upon error
The filter parameters were not correctly free'd when an error hits while
adding to the hash table.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 17:00:57 +01:00
Daniel P. Berrangé
94d31e7c0e nwfilter: remove obsolete code related to firewalld
There is a bunch of left over code in the nwfilter driver related to
monitoring firewalld over dbus, that is no longer used since the
conversion to use virFirewall APIs.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 17:00:57 +01:00
Daniel P. Berrangé
fdc7ebfb54 nwfilter: make virNWFilterIPAddrLearnReq type private
The virNWFilterIPAddrLearnReq type should only be used by the IP address
learning code, so can live in the implementation file instead of header
file.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 17:00:57 +01:00
Daniel P. Berrangé
b6ac5a82b9 nwfilter: change methods returning virNWFilterIPAddrLearnReq to use bool
Various methods return a virNWFilterIPAddrLearnReq struct, but the
callers are only interested in whether the return value is non-NULL.
It is thus preferrable to just return a bool.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 17:00:57 +01:00
Daniel P. Berrangé
d60896321b nwfilter: remove virNWFilterHashTable typedefs entirely
All the code now just uses the virHashTablePtr type directly.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 17:00:57 +01:00
Daniel P. Berrangé
1cf16d755e nwfilter: remove methods that are trivial wrappers for virHash APIs
This removes the virNWFilterHashTableFree, virNWFilterHashTablePut
and virNWFilterHashTableRemove methods, in favour of just calling
the virHash APIs directly.

The virNWFilterHashTablePut method was unreasonably complex because
the virHashUpdateEntry already knows how to create the entry if it
does not currently exist.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 17:00:57 +01:00
Daniel P. Berrangé
77646d9478 nwfilter: remove pointless virNWFilterHashTable struct
The virNWFilterHashTable struct only contains a single virHashTable
member since

  commit 293d4fe2f1
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Mon Mar 24 16:35:23 2014 +0000

    Remove pointless storage of var names in virNWFilterHashTable

Thus, this struct wrapper adds no real value over just using the
virHashTable directly, but brings the complexity of needing to derefence
the hashtable to call virHash* APIs, and adds extra memory allocation
step.

To minimize code churn this just turns virNWFilterHashTable into a
typedef aliases virHashTable.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 17:00:57 +01:00
Stefan Berger
81cb05b7e8 qemu: Add tpm-crb QEMU device to the command line
Alter qemuBuildTPMDevStr to format the tpm-crb on the command line
and use the enum range checking for valid model.

Add a test case for the formation of the tpm-crb QEMU device
command line. The qemuxml2argvtest changes cannot use the newer
DO_TEST_CAPS_LATEST since building of the command line involves
calling qemuBuildTPMBackendStr which attempts to open the
path to the device (e.g. /dev/tmp0).

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-03 11:28:42 -04:00
Stefan Berger
9323c4bb88 qemu: Extend the capabilities with tpm-crb device
QEMU on x86_64 (since v2.12) can support tpm-crb devices.
Introduce qemu capabilities for this device.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-03 11:28:42 -04:00
Stefan Berger
fead27f4b3 conf: Enable TPM CRB interface in the domain XML
Enable the TPM CRB to be specified in the domain XML. This
now allows to describe the TPM device like this:

  <tpm model='tpm-crb'>
    <backend type='passthrough'>
      <device path='/dev/tpm0'/>
    </backend>
  </tpm>

Extend the XML schema to also allow tpm-crb.
Extend the documentation.
Add a test case for testing the XML parser and formatter.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-03 11:28:42 -04:00
Julio Faracco
054a66037d test: avoid slash characters to the new domain name.
As QEMU driver, test driver does not accept slashes inside domain names.
This commit fixes this problem checking slashes inside the new name when
'domrename' is executed.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-03 11:25:01 -04:00
Julio Faracco
4e1a970219 qemu: avoid slash characters to the new domain name.
The 'domrename' command needs to check if the new domain name contains
the slash character. This character is not accepted by libvirt XML
definition because it is an invalid char (see Cole's commit b1fc6a7b7).
This commit enhace the 'domrename' command adding this check.

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

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-03 11:25:01 -04:00
Daniel P. Berrangé
d2f5bb714f storagefile: conditional build of virStorageFileLoadBackendModule
The virStorageFileLoadBackendModule method is only used if either
fs or gluster storage is built in, which doesn't happen on mingw
leading to warning of an unused static function.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 15:42:59 +01:00
Daniel P. Berrangé
01888af0e2 storage: create separate loadable modules for storage file drivers
The storage file drivers are currently loaded as a side effect of
loading the storage driver. This is a bogus dependancy because the
storage file code has no interaction with the storage drivers, and
even ultimately be running in a completely separate daemon.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 13:17:59 +01:00
Daniel P. Berrangé
1421e7168c util: refactor storage file checks to allow error reporting
The virStorageFileSupportsSecurityDriver and
virStorageFileSupportsAccess currently just return a boolean
value. This is ok because they don't have any failure scenarios
but a subsequent patch is going to introduce potential failure
scenario. This changes their return type from a boolean to an
int with values -1, 0, 1.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 13:16:00 +01:00
Daniel P. Berrangé
c444505c99 util: fix virStorageFileGetBackingStoreStr error handling
The virStorageFileGetBackingStoreStr method has overloaded the NULL
return value to indicate both no backing available and a fatal
error dealing with it.

The caller is thus not able to correctly propagate the error
messages.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 13:15:51 +01:00
Daniel P. Berrangé
dbf28572c8 storage: split fs storage file code from storage driver backend
The storage file code needs to be run in the hypervisor drivers, while
the storage backend code needs to be run in the storage driver. Split
the source code as a preparatory step for creating separate loadable
modules.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 12:51:38 +01:00
Daniel P. Berrangé
f78cbe9424 storage: remove unused imports of libxml headers
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 12:49:57 +01:00
Daniel P. Berrangé
7568fc730f storage: split gluster storage file code from storage driver backend
The storage file code needs to be run in the hypervisor drivers, while
the storage backend code needs to be run in the storage driver. Split
the source code as a preparatory step for creating separate loadable
modules.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 12:49:22 +01:00
Daniel P. Berrangé
8b0f721f2e util: create new virmodule.{c,h} files for dlopen support code
The driver.{c,h} files are primarily targetted at loading hypervisor
drivers and some helper functions in that area. It also, however,
contains a generically useful function for loading extension modules
that is called by the storage driver. Split that functionality off
into a new virmodule.{c,h} file to isolate it.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-05-03 12:47:43 +01:00
Ján Tomko
bf70a48e22 conf: remove unused VIR_DOMAIN_FS_RAM_DEFAULT_USAGE
Unused since its introduction in commit <76b644c>.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-02 16:03:00 +02:00
Ján Tomko
538a7d30c2 Makefile: fix typo
s/atttribute/attribute/

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-02 14:47:46 +02:00
Peter Krempa
9cee8f3f7e qemu: migration: Use TLS environment for NBD server if requested
Use the TLS env for migration when starting the NBD server if TLS is
enabled for migration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-30 14:58:05 +02:00
Peter Krempa
17d34b482b qemu: monitor: Add 'tls-creds' parameter to 'nbd-server-start' command
To allow encryption of the non-shared storage migration NBD connection
we will need to instantiated the NBD server with the TLS env.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-30 14:57:53 +02:00
Peter Krempa
51541809b8 qemu: caps: Add capability for TLS transport in the NBD server
The NBD server in qemu supports TLS transport. Detect this capability.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-30 14:57:38 +02:00
Peter Krempa
ed1c45b0ba qemu: migration: Don't crash on access to 'current' job
When a VM is destroyed while being migrated (waiting in
qemuMigrationSrcWaitForCompletion) the private object cleanup code frees
the 'current' job info. Since the migration code attempts to setup
various aspects of the current job even on failure this results into a
crash.

Job data is cleared in qemuDomainObjPrivateDataClear since commit
888aa4b6b9

Fix this by skipping all of the code which requires the qemu process to
be alive if the VM is not active any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-04-30 14:43:42 +02:00
Peter Krempa
b2b2998a4b qemu: migration: Forbid 'nbd' migration of non-shared storage if TLS is requested
Since libvirt is currently not able to setup the NBD migration stream
secured by TLS we should not allow such migration since data would be
transferred unencrypted.

This will break compatibility of TLS migration if non-shared storage is
requested but the security implications are more severe.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-30 07:44:39 +02:00
Laine Stump
ce5aebeacd nwfilter: increase pcap buffer size to be compatible with TPACKET_V3
When an nwfilter rule sets the parameter CTRL_IP_LEARNING to "dhcp",
this turns on the "dhcpsnoop" thread, which uses libpcap to monitor
traffic on the domain's tap device and extract the IP address from the
DHCP response.

If libpcap on the host is built with HAVE_TPACKET3 defined (to enable
support for TPACKET_V3), the dhcpsnoop code's initialization of the
libpcap socket would fail with the following error:

  virNWFilterSnoopDHCPOpen:1134 : internal error: pcap_setfilter: can't remove kernel filter: Bad file descriptor

It turns out that this was because TPACKET_V3 requires a larger buffer
size than libvirt was setting (we were setting it to 128k). Changing
the buffer size to 256k eliminates the error, and the dhcpsnoop thread
once again works properly.

A fuller explanation of why TPACKET_V3 requires such a large buffer,
for future git spelunkers:

libpcap calls setsockopt(... SOL_PACKET, PACKET_RX_RING...) to setup a
ring buffer for receiving packets; two of the attributes sent to this
API are called tp_frame_size, and tp_frame_nr. If libpcap was built
with HAVE_TPACKET3 defined, tp_trame_size is set to MAXIMUM_SNAPLEN
(defined in libpcap sources as 262144) and tp_frame_nr is set to:

 [the buffer size we set, i.e. PCAP_BUFFERSIZE i.e. 262144] / tp_frame_size.

So if PCAP_BUFFERSIZE < MAXIMUM_SNAPLEN, then tp_frame_nr (the number
of frames in the ring buffer) is 0, which is nonsensical. This same
value is later used as a multiplier to determine the size for a call
to malloc() (which would also fail).

(NB: if HAVE_TPACKET3 is *not* defined, then tp_frame_size is set to
the snaplen set by the user (in our case 576) plus a small amount to
account for ethernet headers, so 256k is far more than adequate)

Since the TPACKET_V3 code in libpcap actually reads multiple packets
into each frame, it's not a problem to have only a single frame
(especially when we are monitoring such infrequent traffic), so it's
okay to set this relatively small buffer size (in comparison to the
default, which is 2MB), which is important since every guest using
dhcp snooping in a nwfilter rule will hold 2 of these buffers for the
entire life of the guest.

Thanks to Christian Ehrhardt for discovering that buffer size was the
problem (this was not at all obvious from the error that was logged!)

Resolves: https://bugzilla.redhat.com/1547237
Fixes: https://bugs.launchpad.net/libvirt/+bug/1758037

Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com> (V1)
Reviewed-by: John Ferlan <jferlan@redhat.com>
Tested-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2018-04-27 17:38:53 -04:00
Daniel P. Berrangé
d32c0f9afe Revert "util: virlog: Introduce wildcard to log filters"
This reverts commit 8daa593b07.

There are two undesirable aspects to the impl

  - Only a bare wildcard is permitted
  - The wildcard match is not performed in the order listed

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-27 16:26:56 +01:00
Peter Krempa
96fc9fc509 qemu: migration: Set the 'set' boolean in qemuMigrationParamsSetString
The code setting TLS parameters verifies that TLS is supported by
looking at the dump of parameters which will be reset after migration,
but sets the parameters in the list of new parameters. As
qemuMigrationParamsSetString did not set the 'set' property, the TLS
parameters would not be used.

This is a regression after the series refactoring migration parameters
and it resulted into TLS not being used even when requested.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-27 15:14:05 +02:00
Peter Krempa
d49c6e4623 qemu: migration: Move and unexport qemuMigrationParamsSetString
The function is not used outside of the src/qemu/qemu_migration_params.c
file so unexport it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-27 15:14:02 +02:00
Martin Kletzander
f94e5b2157 logging: Don't inhibit shutdown in system daemon
That is a job of libvirtd and virtlogd has a dependency on it, so that will
prevent it properly.  Doing it one extra time in virtlogd might also cause AVC
denials because it is not allowed to call that dbus method.

Caused by commit df34363d58.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-26 17:40:57 +02:00
Ján Tomko
8fa4131814 syntax-check: check QEMU caps grouping
Introduce a perl script that is able to regroup both
the QEMU_CAPS constants and the capability strings.

Check correct grouping as a part of syntax check.

For in-place regrouping after a rebase, just run:
  tests/group-qemu-caps.pl
without any parameters.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-26 07:42:36 +02:00
Daniel P. Berrangé
a762701791 remote: disable unused function on win32 platform build
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 19:31:02 +01:00
Roman Bogorodskiy
3b90d0dc1a util: improve virNetDevTapGetRealDeviceName
virNetDevTapGetRealDeviceName() is used on FreeBSD because interface
names (such as one sees in output of tools like ifconfig(8)) might not
match their /dev entity names, and for bhyve we need the latter.

Current implementation is not very efficient because in order to find
/dev name, it goes through all /dev/tap* entries and tries to issue
TAPGIFNAME ioctl on it. Not only this is slow, but also there's a bug in
this implementation when more than one NIC is passed to a VM: once we
find the tap interface we're looking for, we set its state to UP because
opening it for issuing ioctl sets it DOWN, even if it was UP before.
When we have more than 1 NIC for a VM, we have only last one UP because
others remain DOWN after unsuccessful attempts to match interface name.

New implementation just uses sysctl(3), so it should be faster and
won't make interfaces go down to get name.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2018-04-24 21:08:19 +04:00
Daniel P. Berrangé
5cca0cb6a0 remote: refactor code for building UNIX socket paths
The code for building UNIX socket paths will be getting more complex to
cope with accessing various different daemons. Refactor it to eliminate
the code duplication and isolation the logic for constructing paths.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 17:01:51 +01:00
Daniel P. Berrangé
12a2024b12 remote: split URI scheme into driver and transport upfront
Currently the remote driver extracts the transport from URI scheme and
plays games to temporarily hide the driver part when formatting URIs.
Refactor the code to split the URI scheme upfront so the two pieces are
easily available where needed.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 17:01:50 +01:00
Daniel P. Berrangé
a91eaec152 remote: honour errors from virDriverLoadModule
The libvirtd daemon currently ignores the return status of
virDriverLoadModule entirely. This is way too loose, resulting in many
important problems going undiagnosed, resulting in a libvirtd that may
never work correctly. We should only ignore a non-existant module, and
pass back any fatal errors.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 17:01:49 +01:00
Daniel P. Berrangé
8a062f5fe3 driver: add option to make missing drivers a fatal problem
Currently the driver module loading code does not report an error if the
driver module is physically missing on disk. This is useful for distro
packaging optional pieces. When the daemons are split up into one daemon
per driver, we will expect module loading to always succeed. If a driver
is not desired, the entire daemon should not be installed.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 17:01:48 +01:00
Daniel P. Berrangé
078d168d15 driver: use normal error reporting APIs when loading modules
The driver module loading code is one of the few places that still uses
VIR_ERROR for reporting failures. Convert it to normal error reporting
APIs.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 17:00:51 +01:00
Daniel P. Berrangé
d94640ddad driver: tighten check for whether loadable module exists or not
Currently we do a access(R_OK) check to see whether a loadable module
exists, treating failure as non-fatal. This is unreasonably loose, as a
module which exists but has had incorrect permissions set will turn into
a silent skip. We only want to skip loading if the module genuinely does
not exist on disk, due to the optional package not being installed.

Furthermore, checking the return value of virDriverLoadModuleFile() is
not a suitable witness that the module does not exist. This method can
return NULL if dlopen() fails, for example due to being unable to
resolve symbols in the library. This is should always be reported as an
error because it is a sign of the bad installation where either the
module build doesn't match the libvirtd build, or where some 3rd party
libraries are missing or broken.

Both these problems can be fixed by using virFileExists in the caller
instead.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 17:00:50 +01:00
Daniel P. Berrangé
2902b76472 driver: fix handling of error return from finding resource
The virFileFindResource method merely builds up the expected fully
qualified path to the resource. It does not actually check if it exists
on disk. The loadable module callers were mistakenly thinking a NULL
indicates the file doesn't exist on disk, whereas it in fact indicates
an out of memory error.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 17:00:49 +01:00
Daniel P. Berrangé
96a72f3444 driver: don't keep a pointer to the loaded library handle
Now that we've activated two hacks to prevent unloading of modules,
there is no point passing back a pointer to the loaded library handle.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 17:00:47 +01:00
Daniel P. Berrangé
71feef9226 build: prevent unloading of dlopen'd modules
We previously added "-z nodelete" to the build of libvirt.so to prevent
crashes when thread local destructors run which point to a code that
has been dlclose()d:

  commit 8e44e5593e
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Thu Sep 1 17:57:06 2011 +0100

      Prevent crash from dlclose() of libvirt.so

The libvirtd loadable modules can suffer from the same problem if they
were ever unloaded. Fortunately we don't ever call dlclose() on them,
but lets add a second layer of protection by linking them with the
"-z nodelete" flag. While we're doing this, lets add a third layer of
protection by passing RTLD_NODELETE to dlopen().

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 16:59:45 +01:00
Daniel P. Berrangé
87680332a3 remote: stop trying to load Xen driver module
The Xen driver was recently deleted, but libvirtd has left over code
that tries to use it. Fortunately this is dead code because WITH_XEN
will never be defined anymore.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 16:58:40 +01:00
Daniel P. Berrangé
419607c478 build: prevent unloading of all public libraries
We previously added "-z nodelete" to the build of libvirt.so to prevent
crashes when thread local destructors run which point to a code that
has been dlclose()d:

  commit 8e44e5593e
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Thu Sep 1 17:57:06 2011 +0100

      Prevent crash from dlclose() of libvirt.so

We forgot to copy this protection into the libvirt-qemu.so, libvirt-lxc.so
and libvirt-admin.so libraries when we introduced them.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 16:58:03 +01:00
John Ferlan
da613819e9 Check return status for virUUIDGenerate
Although legal, a few paths were not checking a return value < 0
for failure instead they checked a non zero failure.

Clean them all up to be consistent.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-04-24 08:52:59 -04:00
Michal Privoznik
31daccf5a5 virNumaGetHugePageInfo: Return page_avail and page_free as ULL
https://bugzilla.redhat.com/show_bug.cgi?id=1569678

On some large systems (with ~400GB of RAM) it is possible for
unsigned int to overflow in which case we report invalid number
of 4K pages pool size. Switch to unsigned long long.

We hit overflow in virNumaGetPages when doing:

    huge_page_sum += 1024 * page_size * page_avail;

because although 'huge_page_sum' is an unsigned long long, the
page_size and page_avail are both unsigned int, so the promotion
to unsigned long long doesn't happen until the sum has been
calculated, by which time we've already overflowed.

Turning page_avail into a unsigned long long is not strictly
needed until we need ability to represent more than 2^32
4k pages, which equates to 16 TB of RAM. That's not
outside the realm of possibility, so makes sense that we
change it to unsigned long long to avoid future problems.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-24 11:02:28 +02:00
Andrea Bolognani
4d11d9a292 qemu: Format rom.enabled attribute for PCI devices
The attribute can be used to disable ROM loading completely
for a device.

This might be needed because, even when the guest is configured
such that the PCI ROM will not be loaded in the PCI BAR, some
hypervisors (eg. QEMU) might still make it available to the
guest in a form (eg. fw_cfg) that some firmwares (eg. SeaBIOS)
will consume, thus not achieving the desired result.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-04-23 15:20:54 +02:00
Andrea Bolognani
c4466179f4 conf: Add rom.enabled attribute for PCI devices
The attribute can be used to disable ROM loading completely
for a device.

This might be needed because, even when the guest is configured
such that the PCI ROM will not be loaded in the PCI BAR, some
hypervisors (eg. QEMU) might still make it available to the
guest in a form (eg. fw_cfg) that some firmwares (eg. SeaBIOS)
will consume, thus not achieving the desired result.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-04-23 15:20:54 +02:00
John Ferlan
868136624f conf: Rework/rename virDomainObjListFindByIDRef
Rework the code such that virDomainObjListFindByID will always
return a locked/ref counted object so that the callers can
always do the same cleanup logic to call virDomainObjEndAPI.
Makes accessing the objects much more consistent.

NB:
There were 2 callers (lxcDomainLookupByID and qemuDomainLookupByID)
that were already using the ByID name, but not virDomainObjEndAPI -
these were changed as well in this update/patch.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2018-04-23 06:41:45 -04:00
John Ferlan
fd9ef3b31e conf: Rework/rename virDomainObjListFindByUUIDRef
Now that every caller is using virDomainObjListFindByUUIDRef,
let's just remove it and keep the name as virDomainObjListFindByUUID.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2018-04-23 06:41:45 -04:00
John Ferlan
3c66d5108f vz: Use virDomainObjListFindBy{UUID|ID}Ref
For vzDomainLookupByID and vzDomainLookupByUUID let's
return a locked and referenced @vm object so that callers
can then use the common and more consistent virDomainObjEndAPI
in order to handle cleanup rather than needing to know that the
returned object is locked and calling virObjectUnlock.

The LookupByName already returns the ref counted and locked object,
so this will make things more consistent.

Also adjust the prlsdkHandle{VmState|VmRemoved|Perf}Event APIs
in the same manner.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2018-04-20 08:11:14 -04:00
John Ferlan
d758374de2 vz: Unify vzDomObjFromDomain{Ref}
Rather than have two API's doing different things for different
callers, let's make one API that will always return a locked and
ref counted object. That way, the callers will always know that
they must call virDomainObjEndAPI and not have to decide whether
they should call virObjectUnlock instead.

This will make things consistent with LookupByName which returns
the locked and ref counted object.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2018-04-20 08:11:14 -04:00
John Ferlan
19d5529fc1 vmware: Use virDomainObjListFindBy{UUID|ID}Ref
For vmwareDomObjFromDomainLocked and vmwareDomainLookupByID
let's return a locked and referenced @vm object so that callers
can then use the common and more consistent virDomainObjEndAPI
in order to handle cleanup rather than needing to know that the
returned object is locked and calling virObjectUnlock.

The LookupByName already returns the ref counted and locked object,
so this will make things more consistent.

For vmwareDomainUndefineFlags and vmwareDomainShutdownFlags since
virDomainObjListRemove will return an unlocked object, we need to
relock before making the EndAPI call.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2018-04-20 07:50:41 -04:00
John Ferlan
7b324eedb7 vmware: Add more descriptive error message on Find failure
If vmwareDomainLookupByID or vmwareDomainLookupByName fails
to find a vm, let's be a bit more descriptive by providing
the failing id or name in the error message.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2018-04-20 07:50:35 -04:00
John Ferlan
68a6861902 vmware: Create accessors to virDomainObjListFindByUUID
Rather than repeat code throughout, create and use a couple of
accessors in order to lookup by UUID.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2018-04-20 07:50:30 -04:00
John Ferlan
950ca9e736 vmware: Properly clean up in vmwareDomainLookupByName
The virDomainObjListFindByName returns a locked and reffed
domain object, all we did was unlock it, leaving an extra
ref. Use the virDomainObjEndAPI to cleanup instead.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2018-04-20 07:50:24 -04:00
Daniel P. Berrangé
6b06f35942 remote: always build generated source files
The generated source files for dispatching libvirtd RPC messages contain
translations and are thus listed in POTFILES. This means they are
required in order to build libvirt.pot. Rather than changing the files
that go into libvirt.pot dynamically, just unconditionally build the
remote driver sources so they are always available for building
libvirt.pot. This ensures we don't silently loose translation messages
based on configure args.

This fixes the mingw build which needs to create libvirt.pot but has
libvirtd disabled.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-20 11:48:30 +01:00
Pino Toscano
f10a1a95a2 vmx: write cpuid.coresPerSocket back from CPU topology
When writing the VMX file from the domain XML, write
cpuid.coresPerSocket if there is a specified CPU topology in the guest.

Use the domain XML of esx-in-the-wild-9 in vmx2xml as testcase for
xml2vmxtest.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-04-20 09:11:01 +02:00
Pino Toscano
5cceadcbac vmx: convert cpuid.coresPerSocket for CPU topology
Convert the cpuid.coresPerSocket key as both number of CPU sockets, and
cores per socket.

Add the VMX file attached to RHBZ#1568148 as testcase esx-in-the-wild-9;
adapt the resulting XML of testcase esx-in-the-wild-8 to the CPU
topology present in that VMX.

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

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-04-20 09:09:29 +02:00
John Ferlan
6477dcc88e uml: Use virDomainObjListFindBy{UUID|ID}Ref
For umlDomObjFromDomainLocked and umlDomainLookupByID let's
return a locked and referenced @vm object so that callers
can then use the common and more consistent virDomainObjEndAPI
in order to handle cleanup rather than needing to know that the
returned object is locked and calling virObjectUnlock. This
means for some consumers we need to relock the @dom after a
virDomainObjListRemove, but before calling virDomainObjEndAPI.

The LookupByName already returns the ref counted and locked object,
so this will make things more consistent.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-19 14:44:51 -04:00
John Ferlan
7e134bd377 uml: Add more specific error message on failed FindBy call
Rather than an empty failed to find, let's provide a bit more
knowledge about what we failed to find by using the name string
or the id value.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-19 14:44:46 -04:00
John Ferlan
ff619e0ee7 uml: Create accessors to virDomainObjListFindByUUID
Rather than repeat code throughout, create and use a couple of
accessors in order to lookup by UUID. This will also generate
a common error message including the failed uuidstr for lookup
rather than just returning nothing in some instances.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-19 14:44:40 -04:00
John Ferlan
ee3a86d721 uml: Fix umlInotifyEvent dom object handling
The virDomainObjListFindByName will return a locked and reffed
object. If we call virDomainObjListRemove that will unlock the
object upon return, thus we need to relock the object before
making the call to virDomainObjEndAPI.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-19 14:44:35 -04:00
John Ferlan
a39427be49 uml: Fix umlProcessAutoDestroyDom dom processing
There's no need to check if @dom exists before trying to
call virDomainObjListRemove since it must exist due to
prior checks.

Additionally, if we do remove the @dom, then set it to NULL
so that the virObjectUnlock isn't referencing something that
is deleted.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-19 14:42:59 -04:00
John Ferlan
6a6a5463af qemu: Fix possible memory leak in migration param processing
If virJSONValueArraySize(caps) <= 0, then we will still need to
virJSONValueFree(caps) because qemuMonitorSetMigrationCapabilities
won't consume it.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-04-19 14:25:11 -04:00
John Ferlan
4f995eab83 remote: Fix usage of ATTRIBUTE_FALLTHROUGH
Move to within the #if since the #else portion ends with a goto
and that raised concern by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-04-19 14:23:39 -04:00
John Ferlan
c028c71930 conf: Add error checking to virDomainSnapshotDiskDefFormat
Commit id '43f2ccdc' called virDomainDiskSourceDefFormatInternal
rather than formatting the the disk source inline. However, it
did not handle the case where the helper failed. Over time the
helper has been renamed to virDomainDiskSourceFormat. Similar to
other consumers, if virDomainDiskSourceFormat fails, then the
formatting could be off, so it's better to fail than to continue
on with some possibly bad data. Alter the function and the caller
to check status and jump to error in that case.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-04-19 14:23:39 -04:00
Michal Privoznik
fb1fae94a1 qemu_capabilities: Separate out device props fetching
The code is generic enough to be reused. Move it into a
separate function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-19 18:11:56 +02:00
Michal Privoznik
c2047c5c9f qemu_capabilities: s/ObjectProps/DeviceProps/g
So far all the properties we are trying to fetch are device
properties, i.e. -device $dev on qemu command line. Change
misleading variable names to express what's queried for better.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-19 18:11:56 +02:00
Andrea Bolognani
931144858f qemu: Figure out nodeset bitmap size correctly
The current private XML parsing code relies on the assumption
that NUMA node IDs start from 0 and are densely allocated,
neither of which is necessarily the case.

Change it so that the bitmap size is dynamically calculated by
looking at NUMA node IDs instead, which ensures all nodes will
be able to fit and thus the bitmap will be parsed successfully.

Update one of the test cases so that it would fail with the
previous approach, but passes with the new one.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-19 17:57:54 +02:00
Michal Privoznik
888aa4b6b9 qemuDomainObjPrivateDataClear: Don't leak @migParams
Allocated in qemuMigrationParamsNew() we need to free
priv->job.migParams when no longer needed.

==8061== 234 (192 direct, 42 indirect) bytes in 1 blocks are definitely lost in loss record 112 of 123
==8061==    at 0x4C2CF26: calloc (vg_replace_malloc.c:711)
==8061==    by 0x5325D05: virAlloc (viralloc.c:144)
==8061==    by 0x1984F9: qemuMigrationParamsNew (qemu_migration_params.c:218)
==8061==    by 0x19A352: qemuMigrationParamsParse (qemu_migration_params.c:1185)
==8061==    by 0x1604D8: qemuDomainObjPrivateXMLParseJob (qemu_domain.c:2390)
==8061==    by 0x160AE9: qemuDomainObjPrivateXMLParse (qemu_domain.c:2517)
==8061==    by 0x5419EAE: virDomainObjParseXML (domain_conf.c:20442)
==8061==    by 0x541A25E: virDomainObjParseNode (domain_conf.c:20555)
==8061==    by 0x541A2FC: virDomainObjParseFile (domain_conf.c:20574)
==8061==    by 0x13607D: testCompareStatusXMLToXMLFiles (qemuxml2xmltest.c:75)
==8061==    by 0x14F3E8: virTestRun (testutils.c:180)
==8061==    by 0x14DCD0: mymain (qemuxml2xmltest.c:1200)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-19 17:09:52 +02:00
Daniel P. Berrangé
c0a8ea450d po: provide custom make rules for po file management
Historically we have relied on autopoint/gettextize to install a
standard po/Makefile.in.in. There is very limited scope for customizing
this and it also causes a bunch of extra stuff to be pulled into
configure.ac which potentially clashes with gnulib. Writing make rules
for po file management is no more difficult than any other rules libvirt
has, so stop using autopoint/gettextize.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-19 10:35:58 +01:00
Peter Krempa
327430fcfc qemu: Format 'write-cache' parameter for disk frontends
The disk cache mode translates to various frontend and backend
attributes for the qemu block layer. For the frontend device the
'writeback' parameter is used and provided as 'write-cache'. Implement
this so that we can later switch to using -blockdev where we will not
pass the cachemode directly any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-19 11:20:34 +02:00
Peter Krempa
955df88de6 qemu: caps: Add capability for 'write-cache' parameter of disk frontends
QEMU translates the cache mode of a disk internally into 3 flags.
'write-cache' is a flag of the frontend while others are flag of the
backing storage. Add capability which will allow expressing it via the
frontend attribute.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-19 11:20:34 +02:00
Peter Krempa
e2244abc60 qemu: domain: Add helper for translating disk cachemode to qemu flags
Add helper which will map values of disk cache mode to the flags which
are accepted by various parts of the qemu block layer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-19 11:20:34 +02:00
Nikolay Shirokovskiy
1ccaf39402 check scripts: handle unintialized driver vars in check-driverimpls.pl
Current script confuses on lines like this:

static virHypervisorDriver parallelsHypervisorDriver;

It interprets next lines as if there is open brace.

Let's filter this case from matches.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-19 11:05:00 +03:00
Nikolay Shirokovskiy
489c4c688d vz: build fix
Broken by [1] commit - trailing comma instead of semicolon. Fortunately
the issue did not get sneak in released 4.2 version. Note that uriSchemes
for parallelsConnectDriver should not be allocated on stack.

[1] 8e4f9a27: "driver: declare supported URI schemes in virConnectDriver struct"

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-19 11:05:00 +03:00
Peter Krempa
e8da1a61ca qemu: driver: Fix error message in qemuDomainBlockCommit
When qemu does not support changing of the backing store string, we'd
reaport that block pull is not supported instead of block commit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-18 16:20:12 +02:00
Peter Krempa
18ba54c015 conf: Disk 'shared' state is not guest ABI
Drop the checking of 'shared' from the ABI stability check. This
property controls whether the hypervisor allows concurrent access to the
same file, but this fact does not influence guest ABI.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-18 16:19:37 +02:00
Peter Krempa
4fdcf67a63 conf: Move 'driverName' back to disk definition structure
Currently it is not used in backing chains and does not seem that we
will need to use it so return it back to the disk definition. Thankfully
most accesses are done via the accessors.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-18 16:19:12 +02:00
Peter Krempa
b2e54a3377 conf, qemu: Replace access to disk driver name with accessors
Replace direct usage of disk->src->driverName with the existing
accessors. The parser code where we assign the driver from XML is
intentionally not fixed to save an allocation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-18 16:16:48 +02:00
Peter Krempa
ca2943ad9a qemu: Move disk driver name validation into disk validation callback
There were two places where we'd check this independently. Move it to
the disk definition validation callback. This also fixes possible use of
NULL in a printf for network storage.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-18 16:14:13 +02:00
Peter Krempa
97a467b3c4 conf: Make argument of virDomainDiskGetDriver const
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-18 16:10:39 +02:00
Jiri Denemark
71872d8224 conf: Reindent virDomainObjCheckActive
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2018-04-18 11:40:37 +02:00
Nikolay Shirokovskiy
49fb4769e1 qemu: cpu: fix "full" CPU to include all "reported" CPU features
On Core i5 650 x86_64 kvm guest fail to start with error [1] for next cpu config:

  <cpu mode='host-model' check='partial'>
    <model fallback='allow'/>
    <feature policy='require' name='x2apic'/>
  </cpu>

The problem is in full CPU calculation in virQEMUCapsInitHostCPUModel.
It is supposed to include features emulated by qemu and missed on host. Some of
such features may be not included however.

For Core i5 650  host CPU is detected as Westmere and reported CPU as
SandyBridge. x2apic is missed on host and provided by installed qemu. The
feature is not mentioned in reported CPU features explicitly because SandyBridge
model include it. As a result full CPU does not include x2apic too.

Solution is to expand guest cpu features before updating fullCPU features.

[1] error: the CPU is incompatible with host CPU: \
       Host CPU does not provide required features: x2apic

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-04-18 11:39:53 +02:00
Clementine Hayat
5bf4ffc1f8 vz: start using virDomainObjCheckActive
Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-04-18 10:22:07 +02:00
Clementine Hayat
b5997e3707 uml: start using virDomainObjCheckActive
Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-04-18 10:22:07 +02:00
Clementine Hayat
7987780779 openvz: start using virDomainObjCheckActive
Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-04-18 10:22:07 +02:00
Clementine Hayat
1e68a86454 libxl: start using virDomainObjCheckActive
Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-04-18 10:22:07 +02:00
Clementine Hayat
7b0caca4ea test: start using virDomainObjCheckActive
Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-04-18 10:22:07 +02:00
Clementine Hayat
749282d400 Add function that raises error if domain is not active
Add a function named virDomainObjCheckIsActive in src/conf/domain_conf.c.
It calls virDomainObjIsActive, raises error if necessary and returns.

There is a lot of occurence of this pattern and it will save 3 lines on
each call.

Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-04-18 10:22:07 +02:00
Michal Privoznik
76ae74b1d1 virobject: Check if @parent is the first member in class
Our virObject code relies heavily on the fact that the first
member of the class struct is type of virObject (or some
derivation of if). Let's check for that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-18 10:04:55 +02:00
Michal Privoznik
10f94828ea virobject: Introduce VIR_CLASS_NEW() macro
So far we are repeating the following lines over and over:

  if (!(virSomeObjectClass = virClassNew(virClassForObject(),
                             "virSomeObject",
                             sizeof(virSomeObject),
                             virSomeObjectDispose)))
      return -1;

While this works, it is impossible to do some checking. Firstly,
the class name (the 2nd argument) doesn't match the name in the
code in all cases (the 3rd argument). Secondly, the current style
is needlessly verbose. This commit turns example into following:

  if (!(VIR_CLASS_NEW(virSomeObject,
                      virClassForObject)))
      return -1;

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-18 10:04:55 +02:00
Michal Privoznik
4e42981b36 src: Unify virObject member name
Whenever we declare a new object the first member of the struct
has to be virObject (or any other member of that family). Now, up
until now we did not care about the name of the struct member.
But lets unify it so that we can do some checks at compile time
later.

The unified name is 'parent'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-18 10:04:55 +02:00
Michal Privoznik
cbbbe7b448 datatypes: Rename @parent to @parentName in virNodeDevice
In next patches this name will be needed for a different memeber.
Also, it makes sense to rename the variable because it does not
contain reference to parent device, just its name.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-18 10:04:55 +02:00
Marek Marczykowski-Górecki
f5fe381da6 xenconfig: add CPUID handling to domXML <-> xl.cfg conversion
Only "libxl" format supported for now. Special care needed around
vmx/svm, because those two are translated into "nestedhvm" setting.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-17 21:15:27 -06:00
Marek Marczykowski-Górecki
cc9af5631d libxl: add support for CPUID features policy
Convert CPU features policy into libxl cpuid policy settings. Use new
("libxl") syntax, which allow to enable/disable specific bits, using
host CPU as a base. For this reason, only "host-passthrough" mode is
accepted.
Libxl do not have distinction between "force" and "required" policy
(there is only "force") and also between "forbid" and "disable" (there
is only "disable"). So, merge them appropriately. If anything, "require"
and "forbid" should be enforced outside of specific driver.
Nested HVM (vmx and svm features) is handled separately, so exclude it
from translation.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-17 21:15:27 -06:00
Marek Marczykowski-Górecki
69eded56b8 xenconfig: do not override def->cpu if already set elsewhere
This will help with adding cpuid support.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-17 21:15:27 -06:00
Marek Marczykowski-Górecki
c686f67f9c libxl: do not enable nested HVM unless global nested_hvm option enabled
Introduce global libxl option for enabling nested HVM feature, similar
to kvm module parameter. This will prevent enabling experimental feature
by mere presence of <cpu mode='host-passthrough'> element in domain
config, unless explicitly enabled. <cpu mode='host-passthrough'> element
may be used to configure other features, like NUMA, or CPUID.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2018-04-17 21:15:27 -06:00
Marek Marczykowski-Górecki
8c49e04ecd libxl: warn about ignored CPU mode=custom
When support for mode=custom will be added in the future, semantics of
current config will change. Reduce the surprise by emitting a warning.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-17 21:15:27 -06:00
Marek Marczykowski-Górecki
446d091498 libxl: pass driver config to libxlMakeDomBuildInfo
Preparation for global nestedhvm configuration - libxlMakeDomBuildInfo
needs access to libxlDriverConfig.
No functional change.

Adjusting tests require slightly more mockup functions, because of
libxlDriverConfigNew() call.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2018-04-17 21:15:27 -06:00
Marek Marczykowski-Górecki
13019ba8e1 libxl: fix libxlDriverConfigDispose for partially constructed object
libxlDriverConfigNew() use libxlDriverConfigDispose() for cleanup in
case of errors. Do not call libxlLoggerFree() on not allocated logger
(NULL).

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-17 21:15:27 -06:00
Sukrit Bhatnagar
5ecccf9d27 qemu: Escape commas for qemuBuildDomainLoaderCommandLine
Add comma escaping for loader->path and loader->nvram.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-17 13:26:56 -04:00
Sukrit Bhatnagar
785f9340f6 qemu: Escape commas for qemuBuildGraphicsVNCCommandLine
Add comma escaping for cfg->vncTLSx509certdir.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-17 13:26:51 -04:00
Sukrit Bhatnagar
10823b78bb qemu: Escape commas for qemuBuildFSStr and qemuBuildFSDevStr
Add comma escaping for fs->src->path and fs->dst.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-17 13:26:44 -04:00
Sukrit Bhatnagar
2234777dd0 qemu: Escape commas for qemuBuildDriveDevStr
Add comma escaping for disk->vendor and disk->product when being
built for the command line (and not from hotplug).

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-17 13:26:36 -04:00
Sukrit Bhatnagar
a55cd7193a qemu: Escape commas for qemuBuildRomStr
Add comma escaping for info->romfile.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-17 13:26:21 -04:00
Rainer Müller
ace6528ae1 vmware: Failures in cache info init are non-fatal
This is also not fatal on other drivers.

Signed-off-by: Rainer Müller <raimue@codingfarm.de>
2018-04-17 13:11:29 -04:00
Rainer Müller
84095e1ecc vmware: Fix initialization of VMware Fusion
The vmware driver wants to execute vmware-vmx from the same directory in
which vmrun was found. However, on VMware Fusion 10 vmrun at
/Applications/VMware Fusion.app/Contents/Public/vmrun is a symlink
pointing to ../Library/vmrun. vmware-vmx cannot be found, as
it is not in PATH, but only in this Library directory.

Therefore, follow the vmrun symlink and use the resulting path. Then the
assumption that vmware-vmx is right next to it will still work.

Signed-off-by: Rainer Müller <raimue@codingfarm.de>
2018-04-17 13:11:29 -04:00
Viktor Mihajlovski
d8f17e6052 qemu: refresh vcpu halted state only via query-cpus-fast
In order to not affect running VMs, refreshing the halted state
is only performed if QEMU supports the query-cpus-fast QAPI.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-17 12:45:26 -04:00
Viktor Mihajlovski
87ce22247d qemu: add architecture-specific CPU info handling
Extract architecture specific data from query-cpus[-fast] if
available. A new function qemuMonitorJSONExtractCPUArchInfo()
can then call architecture-specific extraction handlers.

Initially, there's a handler for s390 cpu info to
set the halted property depending on the s390 cpu state
returned by QEMU. With this it's still possible to report
the halted condition even when using query-cpus-fast.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-17 12:45:26 -04:00
Viktor Mihajlovski
41e335f99b qemu: use query-cpus-fast in JSON monitor
Use query-cpus-fast instead of query-cpus if supported by QEMU.
Based on the QEMU_CAPS_QUERY_CPUS_FAST capability.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-04-17 12:45:26 -04:00
Viktor Mihajlovski
5cff7b7db7 qemu: add capability detection for query-cpus-fast
Detect whether QEMU supports the QMP query-cpus-fast API
and set QEMU_CAPS_QUERY_CPUS_FAST in this case.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2018-04-17 12:45:25 -04:00
Ján Tomko
3527f9dde6 qemu: deny privilege elevation and spawn in seccomp
If QEMU uses a seccomp blacklist (since 2.11), -sandbox on
no longer tries to whitelist all the calls, but uses sets
of blacklists:
default (always blacklisted with -sandbox on)
obsolete (defaults to deny)
elevateprivileges (setuid & co, default: allow)
spawn (fork & execve, default: allow)
resourcecontrol (setaffinity, setscheduler, default: allow)

If these are supported, default to sandbox with all four
categories blacklisted.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-17 16:29:38 +02:00
Ján Tomko
31ca6a542e Introduce QEMU_CAPS_SECCOMP_BLACKLIST
QEMU commit 1bd6152 changed the default behavior from whitelist
to blacklist and introduced a few sets of system calls.

Use the 'elevateprivileges' parameter of -sandbox as a witness
of this change.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-17 16:29:38 +02:00
Ján Tomko
88fe165e14 Refactor qemuBuildSeccompSandboxCommandLine
Exit early if possible to simplify the logic.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-17 16:29:38 +02:00
Ján Tomko
ee0ea8b12d Introduce qemuBuildSeccompSandboxCommandLine
Move the building of -sandbox command line into a separate function.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-17 16:29:38 +02:00
Ján Tomko
53fa2edb62 qemu: deprecate QEMU_CAPS_MACHINE_USB_OPT
Implied by QEMU >= 1.3.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 14:50:25 +02:00
Ján Tomko
5a41bd6df2 qemu: deprecate QEMU_CAPS_DISPLAY
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 14:49:21 +02:00
Ján Tomko
4a42ece13a qemu: deprecate QEMU_CAPS_HOST_PCI_MULTIDOMAIN
Implied by QEMU >= 1.2.0.
Delete the negative test cases now that they always pass.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 14:40:38 +02:00
Ján Tomko
027b7f9edf qemu: deprecate QEMU_CAPS_VNC_SHARE_POLICY
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 14:37:50 +02:00
Ján Tomko
84b40886f2 qemu: deprecate QEMU_CAPS_DUMP_GUEST_CORE
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 14:35:09 +02:00
Ján Tomko
69420756b2 qemu: deprecate QEMU_CAPS_MACHINE_OPT
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 14:24:09 +02:00
Ján Tomko
fd247f8fe7 qemu: deprecate QEMU_CAPS_IPV6_MIGRATION
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 13:01:28 +02:00
Ján Tomko
2089a801ba qemu: deprecate QEMU_CAPS_DTB
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 13:01:10 +02:00
Ján Tomko
766d5c1b5a qemu: deprecate QEMU_CAPS_SECCOMP_SANDBOX
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 13:00:53 +02:00
Ján Tomko
d91890f30c qemu: deprecate QEMU_CAPS_NETDEV_BRIDGE
Unused since commit <2d80fbb1>.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 13:00:35 +02:00
Ján Tomko
da6df1be8c qemu: deprecate QEMU_CAPS_WAKEUP
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 13:00:18 +02:00
Ján Tomko
47b12ecfdf qemu: deprecate QEMU_CAPS_DRIVE_IOTUNE
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 13:00:06 +02:00
Ján Tomko
b6389394e0 qemu: deprecate QEMU_CAPS_FSDEV_WRITEOUT
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 12:57:14 +02:00
Ján Tomko
08ad06ca68 qemu: deprecate QEMU_CAPS_DRIVE_COPY_ON_READ
Implied by QEMU >= 1.2.0.

Also delete the now redundant disk-drive-copy-on-read test.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 12:56:49 +02:00
Ján Tomko
dd924fb05c qemu: deprecate QEMU_CAPS_FSDEV_READONLY
Implied by QEMU >= 1.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-04-17 12:33:00 +02:00
Michal Privoznik
0de90bd710 qemu: Rename qemuMonitorGetObjectProps to qemuMonitorGetDeviceProps
This function is indeed getting -device properties and not
-object properties. The current name is misleading.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-04-17 11:30:12 +02:00
Jiri Denemark
8a159dfb66 qemu: Don't delete TLS objects unless TLS migration was requested
Trying to delete the non-existent TLS objects results in ugly error
messages in the log, which could easily confuse users. Let's avoid this
confusion by not trying to delete the objects if we were not asked to
enable TLS migration and thus we didn't created the objects anyway.

This patch restores the behavior to the state before "qemu: Reset all
migration parameters".

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
82a2123699 qemu: Store API flags for async jobs in status XML
This will help us decide what to do when libvirtd is restarted while an
async job is running.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
ea9aab3828 qemu: Drop priv->job.postcopyEnabled bool
We store the flags passed to the API which started the migration. Let's
use them instead of a separate bool to check if post-copy migration was
requested.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
ceb4ff664b qemu: Drop priv->job.dump_memory_only bool
We store the flags passed to the API which started QEMU_ASYNC_JOB_DUMP
and we can use them to check whether a memory-only dump is running.
There's no need for a specific bool flag.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
a5bc7130f3 qemu: Properly avoid cancelling memory-only dump
migrate_cancel QMP command cannot be used for cancelling memory-only
dumps and priv->job.dump_memory_only is used for reporting an error if
someone calls virDomainAbortJob when memory-only dump job is running.

Since commit 150930e309 the dump_memory_only flag is set only if
dump-guest-memory command was called without the detach parameter. This
would incorrectly allow libvirt to send migrate_cancel while the
detached memory-only dump is running.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
d634f7d759 qemu: Store API flags for async jobs in qemuDomainJobObj
When an async job is running, we sometimes need to know how it was
started to distinguish between several types of the job, e.g., post-copy
vs. normal migration. So far we added a specific bool item to
qemuDomainJobObj for such cases, which doesn't scale very well and
storing such bools in status XML would be painful so we didn't do it.

A better approach is to store the flags passed to the API which started
the async job, which can be easily stored in status XML.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
923565aa7e qemu: Properly reset migration params when libvirtd restarts
To be able to restore all migration parameters when libvirtd is
restarting during an active migration job, we need to store the original
values of all parameters (stored in priv->job.migParams) in the status
XML.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
a1db79fd73 qemu: Set migration parameters automatically
Most QEMU migration parameters directly correspond to
VIR_MIGRATE_PARAM_* typed parameters and qemuMigrationParamsFromFlags
can automatically set them according to a static mapping between libvirt
and QEMU parameters.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
3ba68865f3 qemu: Generalize qemuMigrationParamsGetDowntimeLimit
The API is renamed as qemuMigrationParamsGetULL and it can be used with
any migration parameter stored as unsigned long long.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
9d7321bde9 qemu: Check remote caps when enabling always-on capabilities
When an always-on migration capability is supposed to be enabled on both
sides of migration, each side can only enable the feature if it is
enabled by the other side.

Thus the source host sends a list of supported migration capabilities in
the migration cookie generated in the Begin phase. The destination host
consumes the list in the Prepare phase and decides what capabilities can
be enabled when starting a QEMU process for incoming migration. Once
done the destination sends the list of supported capabilities back to
the source where it is used during the Perform phase to determine what
capabilities can be automatically enabled.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
40ced93b01 qemu: Add support for sending capabilities in migration cookie
Some migration capabilities may be enabled automatically, but only if
both sides of migration support them. Thus we need to be able transfer
the list of supported migration capabilities in migration cookie.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
0cd77cd18b qemu: Move qemuMonitorMigrationCaps enum
Since the monitor code no longer needs to see this enum, we move it
to the place where migration parameters are defined and drop the
"monitor" reference from the name.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
03edcd0752 qemu: Move migration capabilities JSON formatting
We want to have all migration capabilities parsing and formatting at one
place, i.e., in qemu_migration_params.c. The parsing is already there in
qemuMigrationCapsCheck.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
d384a88b30 qemu: Refactor qemuMigrationParams
Adding support for new migration parameter requires a lot of places to
be changed (most likely by copy&paste engineering): new variables to
store the parameter value and the associated *_set bool, JSON formatter
and parser, XML formatter and parser (to be added soon), and the actual
code to set the parameter. It's pretty easy to forget about some of the
places which need to be updated and end up with incorrect support. The
goal of this patch is to let most of the places do their job without any
modifications when new parameters are added.

To achieve the goal, a new qemuMigrationParam enum is introduced and all
parameters are stored in an array indexed by the items of this enum.
This will also allow us to automatically set the migration parameters
which directly correspond to libvirt's typed parameters accepted by
virDomainMigrate* APIs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
b57c98509b qemu: Move qemuMonitorMigrationParams structure
It's no longer used by the monitor code so we can hide it inside
qemu_migration_params.c.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
11e214369f qemu: Export qemuMigrationParams{To,From}JSON for tests
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
fa0a1467c5 qemu: Move migration parameters JSON formatting
We want to have all migration parameters parsing and formatting at one
place, i.e., in qemu_migration_params.c.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
abe06c279b qemu: Move migration parameters JSON parsing
We want to have all migration parameters parsing and formatting at once
place, i.e., in qemu_migration_params.c.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
bf856b6054 util: Introduce virJSONValueObjectStealObject
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
90807b104e qemu: Limit usage of qemuMonitorMigrationParams
Use this internal structure only in qemu_migration_params.c and change
other non-test users to use the high level qemuMigrationParams struct.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
252bf24376 qemu: Introduce qemuMigrationParamsFetch
Let's separate the code which queries QEMU for migration parameters from
qemuMigrationParamsCheck into a dedicated function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
8a83181c90 qemu: Drop qemuMigrationCompression structure
By merging qemuMigrationAnyCompressionParse into
qemuMigrationParamsSetCompression we can drop the useless intermediate
qemuMigrationCompression structure and parse compression related typed
parameters and flags directly into qemuMigrationParams.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
dbf399caac qemu: Replace qemuMigrationAnyCompressionDump
Since every parameter or capability set in qemuMigrationCompression
structure is now reflected in qemuMigrationParams structure, we can
replace qemuMigrationAnyCompressionDump with a new API which will work
on qemuMigrationParams.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
ebd1e3ff18 qemu: Hide qemuMigrationParamsSetCompression
There's no need to call this API explicitly in the migration code. We
can pass the compression parameters to qemuMigrationParamsFromFlags and
it can internally call qemuMigrationParamsSetCompression to apply them
to the qemuMigrationParams structure.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
4087d312d2 qemu: Move qemuMigrationAnyCompression*
The code really belongs to qemu_migration_params.c.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
1c35387cc2 qemu: Move qemuMigrationParamsSetCompression
The API will soon be called from qemuMigrationParamsFromFlags. Let's
move it to avoid the need to add a forward declaration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
0809f1bac4 qemu: Drop qemuMigrationParamsSetCapability
It's become only a tiny wrapper around virBitmapSetBit, which can easily
be called directly. We don't need to call virBitmapClearBit since
migParams->caps bitmap is initialized with zeros.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
1b392a1cbf qemu: Generalize macro for getting VIR_MIGRATE_* typed params
So far it's used only for CPU throttling parameters which are all ints,
but we'll soon want to use it for more parameters with different types.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
ffe6da2db3 qemu: Call qemuMigrationAnyCompressionParse only from driver
Propagate the calls up the stack to the point where
qemuMigrationParamsFromFlags is called. The end goal achieved in the
following few patches is to merge compression parameters into the
general migration parameters code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
a1b0557e47 qemu: Set migration capabilities automatically
Most migration capabilities are directly connected with
virDomainMigrateFlags so qemuMigrationParamsFromFlags can automatically
enable them.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
78bd047075 qemu: Set always-on migration caps in ParamsCheck
Some migration capabilities are always enabled if QEMU supports them. We
can just drop the explicit code for them and let
qemuMigrationParamsCheck automatically set such capabilities.

QEMU_MONITOR_MIGRATION_CAPS_EVENTS would normally be one of the always
on features, but it is the only feature we want to enable even for other
jobs which internally use migration (such as save and snapshot). Hence
this capability is set very early after libvirtd connects to QEMU
monitor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
1034418b54 qemu: Drop qemuMigrationParamsSetPostCopy
It's just a tiny wrapper around qemuMigrationParamsSetCapability and
setting priv->job.postcopyEnabled is not something qemuMigrationParams
code should be doing anyway so let the callers do it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
0d9752e589 qemu: Hide qemuMigrationParamsNew
It is no longer used outside qemu_migration_params.c.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
111debd61c qemu: Use qemuMigrationParamsFromFlags everywhere
Every migration entry point in qemu_driver is supposed to call
qemuMigrationParamsFromFlags to transform flags and parameters into
qemuMigrationParams structure and pass the result to qemuMigration*
APIs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
b51415513c qemu: Introduce qemuMigrationParty enum
Some migration parameters and capabilities are supposed to be set on
both sides of migration while others should only be set on one side. For
example, CPU throttling parameters make no sense on the destination and
they can be used even if the destination is too old to support them.

To make qemuMigrationParamsFromFlags more general and usable on both
sides of migration, we need to tell it what side it's been called on.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
657980693c qemu: Check supported caps in qemuMigrationParamsCheck
Instead of checking each capability at the time we want to set it in
qemuMigrationParamsSetCapability we can check all of them at once in
qemuMigrationParamsCheck.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
2943c52e39 qemu: Move ParamsCheck closer to ParamsApply on Src side
We reached the point when qemuMigrationParamsApply is the only API which
sends migration parameters and capabilities to QEMU. Thus all but the
TLS parameters can be set before we ask QEMU for the current values of
all parameters in qemuMigrationParamsCheck.

Supported migration capabilities are queried as soon as libvirt connects
to QEMU monitor so we can check them anytime.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
38c6189d41 qemu: Move ParamsCheck closer to ParamsApply on Dst side
We reached the point when qemuMigrationParamsApply is the only API which
sends migration parameters and capabilities to QEMU. Thus all but the
TLS parameters can be set before we ask QEMU for the current values of
all parameters in qemuMigrationParamsCheck.

Supported migration capabilities are queried as soon as libvirt connects
to QEMU monitor so we can check them anytime.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
0911dac853 qemu: Set XBZRLE cache size via migration parameters
Prefer xbzrle-cache-size migration parameter over the special
migrate-set-cache-size QMP command.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
323567a6fa qemu: Add support for xbzrle-cache-size migration parameter
Originally QEMU provided query-migrate-cache-size and
migrate-set-cache-size QMP commands for querying/setting XBZRLE cache
size. In version 2.11 QEMU added support for XBZRLE cache size to the
general migration paramaters commands.

This patch adds support for this parameter to libvirt to make sure it is
properly restored to its original value after a failed or aborted
migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
d6d6e2e903 qemu: Drop unused qemuMonitorSetMigrationCapability
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
1f8a1a9511 qemu: Do not use qemuMonitorSetMigrationCapability
Rework all remaining callers of qemuMonitorSetMigrationCapability to use
the new qemuMonitorSetMigrationCapabilities API.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
0801e0e375 qemu: Set migration caps via migration params APIs
Migration capabilities are closely related to migration parameters and
it makes sense to keep them in a single data structure. Similarly to
migration parameters the capabilities are all send to QEMU at once in
qemuMigrationParamsApply, all other APIs operate on the
qemuMigrationParams structure.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
23f173d1e1 qemu: Introduce qemuMonitorSetMigrationCapabilities
Our current monitor API forces the caller to call
migrate-set-capabilities QMP command for each capability separately,
which is quite suboptimal. Let's add a new API for setting all
capabilities at once.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
7b559ad373 qemu: Hide internals of qemuMigrationParams struct
All users of migration parameters are supposed to use APIs provided by
qemu_migration_params.c without having to worry about the internals.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
4bac1879ce qemu: Rename qemuMigrationParamsSet
The new name is qemuMigrationParamsApply and it will soon become the
only API which will send all requested migration parameters and
capabilities to QEMU. All other qemuMigrationParams* APIs will just
operate on the qemuMigrationParams structure.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
0beaadfa6e qemu: Hide cfg inside qemuMigrationParamsEnableTLS
There's no real reason for qemuMigrationParamsEnableTLS to require the
callers to pass a valid virQEMUDriverConfigPtr, it can just call
virQEMUDriverGetConfig.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00
Jiri Denemark
312fe9ccca qemu: Set tlsHostname inside qemuMigrationParamsEnableTLS
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-04-17 10:46:23 +02:00