Commit Graph

4640 Commits

Author SHA1 Message Date
Peter Krempa
33470896e5 tests: qemumonitorutils: Don't crash on wrong monitor command
virQEMUQAPISchemaPathGet returns success when a given schema path was
not found but the returned object is set to NULL. This meant that we'd
call testQEMUSchemaValidate with the schemaroot being NULL which lead to
a crash if a mistyped monitor command was tested.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-07-13 14:15:59 +02:00
Peter Krempa
e59dc14d1e tests: qemuschema: Add line break to debug message
Message stating which schema replies file is being used would be
squashed with other messages.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-07-13 14:15:59 +02:00
Peter Krempa
d682f90891 tests: qemuschema: Fix copy-paste error in function name
s/testQEMUSchemaValidateArrayBuiltin/testQEMUSchemaValidateBuiltin/

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-07-13 14:15:59 +02:00
Peter Krempa
bb4f3543bb qemu: command: Format rerror/werror with -device instead of -drive
Use the new proper location for the read/write error policy selection.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:37:51 +02:00
Peter Krempa
a087a8e60a qemu: capabilities: Add capability for werror/rerror for 'usb-device' frontend
Support for specifying it with the -device frontend was added recently.
Add a capability for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:37:51 +02:00
Peter Krempa
3cb1497dfc tests: qemuxml2argv: Add CAPS_LATEST version for the disk error policy test
Add output arguments generated with the latest qemu capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:37:51 +02:00
Peter Krempa
98ee8bcf6d tests: qemuxml2argv: Unify all tests for disk error policy
Add multiple drives with the various configurations rather than having
multiple tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:37:51 +02:00
Peter Krempa
1cb98a1fb3 qemu: block: Add support for RBD authentication for blockdev
To allow using -blockdev with RBD we need to support the recently added
RBD authentication.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:37:51 +02:00
Peter Krempa
8b4a31efc0 tests: qemucaps: Add test data for upcoming qemu 3.0.0
Based on qemu commit ab3257c281c1a1a91da1090ac9e38ddd8f860c63

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:37:51 +02:00
Peter Krempa
e1e04a0263 tests: remove qemuqapischema.json
We now take the schema from the qemucapabilitiestest data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:37:50 +02:00
Peter Krempa
92a18bb567 tests: qemu: Use qmp schema data from the qemucapabilities test
Add helpers that allow using the latest schema from the replies from an
actual qemu which are recorded for the purpose of the qemucapabilities
test instead of an unsynced copy stored in qemuqapischema.json.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:37:50 +02:00
Peter Krempa
d60c17b3d7 tests: Remove disk from 'serial-unix-chardev' test
We are testing character devices so the disk is not necessary. Minimize
the configuration. This will prevent changes when switching to blockdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-07-10 13:32:53 +02:00
Erik Skultety
ff767f083f qemu: command: Fix building of the SDL display command line
QEMU uses a shorthand '-sdl' which maps to '-display sdl'. However, if
there are any options to be passed to SDL, the full command version must
be used. Everything seemingly worked for us until commit 5038b30043
introduced OpenGL support for SDL and added ',gl=on/off' option which as
mentioned above could have never worked with the shorthand version of
the command. Indeed starting a domain with an SDL display and OpenGL
enabled, QEMU produces a rather cryptic error:

-sdl: Could not open 'gl=on': No such file or directory

This patch provides fixes to both the SDL cmdline generation and the
test suite.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-09 17:45:19 +02:00
Daniel P. Berrangé
1bc1a7e320 qemu: fix UNIX socket chardevs operating in client mode
When support was adding for passing a pre-opened listener socket to UNIX
chardevs, it accidentally passed the listener socket for client mode
chardevs too with predictable amounts of fail resulting. This affects
libvirt when using QEMU >= 2.12

Expand the unit test coverage to validate that we are only doing FD
passing when operating in server mode.

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

Tested-by: Richard W.M. Jones <rjones@redhat.com>
Reported-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-07-06 14:08:05 +01:00
Daniel P. Berrangé
ed5aa85f37 qemu: don't use chardev FD passing for vhostuser backend
QEMU chardevs have a bug which makes the vhostuser backend complain
about lack of support for FD passing when validating the chardev.
While this is ultimately QEMU's responsibility to fix, libvirt needs to
avoid tickling the bug.

Simply disabling chardev FD passing just for vhostuser's chardev is
the most prudent approach, avoiding need for a QEMU version number
check.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-07-06 10:07:47 +01:00
Daniel P. Berrangé
b340c6c614 qemu: format serial and geometry on frontend disk device
Currently we format the serial, geometry and error policy on the -drive
backend argument.

QEMU added the ability to set serial and geometry on the frontend in
the 1.2 release deprecating use of -drive, with support being deleted
from -drive in 3.0.

We keep formatting error policy on -drive for now, because we don't
ahve support for that with -device for usb-storage just yet.

Note that some disk buses (sd) still don't support -device. Although
QEMU allowed these properties to be set on -drive for if=sd, they
have been ignored so we now report an error in this case.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-07-03 16:32:42 +01:00
Andrea Bolognani
d4c1117107 qemu: Format the HTM pSeries feature
This makes the feature fully operational.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-03 09:47:01 +02:00
Andrea Bolognani
9f3b9100f3 conf: Parse and format the HTM pSeries feature
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-03 09:46:59 +02:00
Andrea Bolognani
755a5765ac qemu: Add capability for the HTM pSeries feature
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-07-03 09:46:52 +02:00
Peter Krempa
b4891e997c tests: qemumonitorjson: Fix name and call apropriate API
Call the internal version of qemuMonitorGetAllBlockStatsInfo API and
rename the test accordingly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-07-03 06:34:08 +02:00
Peter Krempa
dca4abc0e3 tests: qemumonitorjson: Add only required replies for blockstats test
testQemuMonitorJSONqemuMonitorJSONGetBlockStatsInfo added 4 replies but
only one was used. Additionally the comment stated that 7 replies are
going to be added.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-07-03 06:34:08 +02:00
John Ferlan
39cef12a95 storage: Add support for using inputvol for encryption
Starting with QEMU 2.9, encryption convert processing requires
a multi-step process in order to generate an encrypted image from
some non encrypted raw image.

Processing requires to first create an encrypted image using the
sizing parameters from the input source and second to use the
--image-opts, -n, and --target-image-opts options along with inline
driver options to describe the input and output files, generating
two commands such as:

  $ qemu-img create -f luks \
      --object secret,id=demo.img_encrypt0,file=/path/to/secretFile \
      -o key-secret=demo.img_encrypt0 \
      demo.img 500K
  Formatting 'demo.img', fmt=luks size=512000 key-secret=demo.img_encrypt0
  $ qemu-img convert --image-opts -n --target-image-opts \
      --object secret,id=demo.img_encrypt0,file=/path/to/secretFile \
      driver=raw,file.filename=sparse.img \
      driver=luks,file.filename=demo.img,key-secret=demo.img_encrypt0
  $

This patch handles the convert processing by running the processing
in a do..while loop essentially reusing the existing create logic and
arguments to create the target vol from the inputvol and then converting
the inputvol using new arguments.

This then allows the following virsh command to work properly:

  virsh vol-create-from default encrypt1-luks.xml data.img --inputpool default

where encrypt1-luks.xml would provided the path and secret for
the new image, while data.img would be the source image.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-26 14:02:43 -04:00
John Ferlan
8f83af6823 storage: Disallow create/resize of qcow2 encrypted images
https://bugzilla.redhat.com/show_bug.cgi?id=1526382

Since commit c4eedd793 disallowed qcow2 encrypted images to be
used for domains, it no longer makes sense to allow a qcow2
encrypted volume to be created or resized.

Add a test that will exhibit the failure of creation as well
as the xml2xml validation of the format still being correct.

Update the documentation to note the removal of the capability
to create and use qcow/default encrypted volumes.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-26 14:02:43 -04:00
John Ferlan
a02d879858 tests: Remove qcow2 encryption from storagevol tests
We're about to disallow creation of a qcow2 encrypted storage
volume, so let's remove the qcow encryption element from the
tests which are testing whether other format='qcow2' related
features work properly.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-26 14:02:43 -04:00
John Ferlan
23e9aa7297 tests: Add luks creation examples to storagevolxml2argvtest
Add the storagevolxml2xmltest "luks" and "luks-cipher" tests
to the storagevolxml2argvtest.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-26 14:02:43 -04:00
John Ferlan
b056e09b28 storage: Don't allow encryption secretPath to be NULL
Allowing a NULL @secretPath for virStorageBackendCreateQemuImgCmdFromVol
would result in a generated command line with a dangling "file=" output.
So let's make sure the @secretPath exists before processing.

This means we should pass a dummy path from the storage test.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-26 14:02:43 -04:00
Anya Harter
c3427c4a85 qemu: Escape commas for qemuBuildSCSIiSCSIHostdevDrvStr
Add comma escaping for netsource. This is done here because
qemuBuildNetworkDriveStr has other external callers which
may not expect an escaped comma; however, this particular
command building path needs to perform the escaping for the
hostdev command line, so we do it now to ensure src->path
and src->host->name are covered.

Signed-off-by: Anya Harter <aharter@redhat.com>
2018-06-26 11:04:38 -04:00
Daniel P. Berrangé
41d619e99c schemas: add schema for nwfilter binding XML document
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Daniel P. Berrangé
17b1ebf4ec conf: add support for parsing/formatting virNWFilterBindingDefPtr
A typical XML representation of the virNWFilterBindingDefPtr struct
looks like this:

  <filterbinding>
    <owner>
      <name>f25arm7</name>
      <uuid>12ac8b8c-4f23-4248-ae42-fdcd50c400fd</uuid>
    </owner>
    <portdev name='vnet1'/>
    <mac address='52:54:00:9d:81:b1'/>
    <filterref filter='clean-traffic'>
      <parameter name='MAC' value='52:54:00:9d:81:b1'/>
    </filterref>
  </filterbinding>

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-26 11:22:07 +01:00
Andrea Bolognani
a12e7a3944 qemu: Format HPT maxpagesize on the command line
This makes the feature fully functional.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-06-26 10:15:56 +02:00
Andrea Bolognani
0ee6f885e0 conf: Parse and format HPT maxpagesize
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-06-26 10:15:52 +02:00
Andrea Bolognani
15f9db5303 conf: Tweak HPT feature parsing and formatting
This doesn't seem very useful at the moment, but it will make
sense once we introduce another HPT-related setting.

The output XML is decoupled from the input XML in preparation
of future changes as well; while doing so, we can shave a few
lines off the latter.

This commit is best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-06-26 10:15:50 +02:00
Andrea Bolognani
90e6e0fae8 qemu: Add capability for the HPT maxpagesize feature
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-06-26 10:15:44 +02:00
Andrea Bolognani
0a527017c4 tests: Add replies for QEMU 3.0.0 on ppc64
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-06-26 10:15:36 +02:00
Anya Harter
1136fd4ebe qemu: Escape commas for qemuBuildDiskThrottling
Add comma escaping for disk->blkdeviotune.group_name.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-21 17:49:15 -04:00
Laine Stump
17b4734288 schema: allow a <rule> element with no subelements in a nwfilter
This is a regression in behavior caused by commit 37359814. It was
intended to limit the schema to allow only a single subelement of
<rule>, but it is also acceptable for <rule> to have no subelement at
all.

To prevent the same error from reoccurring in the future, the
examples/xml/nwfilter directory was added to the list of nwfilter
schema test directories.

Resolves: https://bugzilla.redhat.com/1593549

Signed-off-by: Laine Stump <laine@laine.org>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-21 04:04:49 -04:00
Cole Robinson
14781dcde6 qemu_command: replace vlan= with netdev= for legacy nic
VMs with hardcoded platform network devices are forced to use old
style '-net nic' command line config. Current we use qemu's vlan
option to hook this with the '-netdev' host side of things.

However since qemu 1.2 there is '-net nic,netdev=X' option for
explicitly referencing a netdev ID, which is more inline with
typical VM commandlines, so let's switch to that

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-06-20 14:26:21 -04:00
Andrea Bolognani
b1acfaaf89 tests: Fix qemucapsfixreplies
Since e6be524508 we include the executed command along
with the reply in *.replies files, which breaks the
renumbering logic implemented in qemucapsfixreplies.

Adapt the script so that it works with the new format.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2018-06-19 14:01:14 +02:00
Anya Harter
23f55840f5 qemu: Escape commas for qemuBuildGrapicsSPICECommandLine
Add comma escaping for cfg->spiceTLSx509certdir and
graphics->data.spice.rendernode.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-18 19:39:13 -04:00
Anya Harter
0234a2754b qemu: Escape commas for qemuBuildSmartcardCommandLine
Add comma escaping for smartcard->data.cert.file[i] and
smartcard->data.cert.database.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-18 19:39:08 -04:00
Anya Harter
97975bef32 qemu: Escape commas for qemuBuildChrChardevFileStr
Add comma escaping for fileval.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-18 19:39:02 -04:00
Anya Harter
452dac71cd qemu: Escape commas for qemuBuildChrChardevStr
Add comma escaping for dev->data.file.path in cases
VIR_DOMAIN_CHR_TYPE_DEV and VIR_DOMAIN_CHR_TYPE_PIPE.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-18 19:38:54 -04:00
Anya Harter
22b7247d48 tests: add test file for smartcard database
Add test case explicitly defining a smartcard host certificates
database via the following xml:

    <smartcard mode='host-certificates'>
      <database>/tmp/foo</database>
    </smartcard>

This case is not currently covered in the test suite.

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-18 19:27:49 -04:00
Erik Skultety
6688393c6b conf: Fix formatting of <sev> element in domain capabilities XML
We only formatted the <sev> element when QEMU supported the feature when
in fact we should always format the element to make clear that libvirt
knows about the feature and the fact whether it is or isn't supported
depends on QEMU version, in other words if QEMU doesn't support the
feature we're going to format the following into the domain capabilities
XML:

<sev supported='no'/>

This patch also adjusts the RNG schema accordingly in order to reflect
the proposed change.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-15 10:49:13 +02:00
Michal Privoznik
a02526a045 qemuxml2argvtest: Don't leak TPM unix path
When testing a domain XML with TPM we overwrite UNIX socket path
to mimic what qemuTPMEmulatorPrepareHost() is doing (because
*PrepareHost() functions are not called from the test). But we
are not doing it fully - we need to set the chardev's type too so
that virDomainTPMDefFree() can free the path.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-06-14 14:25:42 +02:00
Ján Tomko
e56ff8bc72 conf: prefer camelCase for launchSecurity
Adjust the documentation, parser and tests to change:
launch-security -> launchSecurity
reduced-phys-bits -> reducedPhysBits
dh-cert -> dhCert

Also fix the headline in formatdomain.html to be more generic,
and some leftover closing elements in the documentation.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-13 14:42:17 +02:00
Peter Krempa
e6be524508 tests: qemucapabilities: Test commands used to query capabilities
Use qemuMonitorTestNewFromFileFull which allows to test commands used
along with providing replies. This has two advantages:

1) It's easier to see which command was used when looking at the files
2) We check that the used commands are actually in the correct order

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-12 10:27:50 +02:00
Peter Krempa
e00ecd1bed tests: qemucapsprobemock: Prepare 'qemucapsprobe' for the new format
Change the output of qemucapsprobe to record the commands used for
querying. This allows to easily identify which reply belongs to which
command and also will allow to test whether we use stable queries.

This change includes changing dropping of the QMP greeting from the file
and reformatting of the query and output to stdout.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-12 10:27:50 +02:00
Peter Krempa
9369348eb8 tests: qemucapsprobemock: Fail if JSON reply from qemu can't be reformatted
Rather than skipping output on failure fail loudly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-12 10:27:50 +02:00
Peter Krempa
0ed2716531 tests: qemucapsprobemock: Simplify and extract skipping of empty lines
The prettyfied output may sometimes contain empty lines which would
desynchonize the test monitor workers. The skipping code can be much
simplified though. Also a extract it so so that it's obvious what
it's doing and can be reused.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-12 10:27:50 +02:00
Peter Krempa
1025264ec5 tests: qemumonitor: Optimize control flow when concatenating replies
The test file can be broken up by newlines and is automatically
concatenated back. Fix the control flow so that the concatenation code
'continues' the loop rather than branching out.

Also add an anotation to the concatenation code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-12 10:27:50 +02:00
Peter Krempa
dcea889b13 tests: qemumonitor: Simplify handling of end of file in full file test
On EOF, the loop can be terminated right away since most of it is
skipped anyways and the handling of the last command is repeated after
the loop.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-12 10:27:50 +02:00
Peter Krempa
215167042a tests: qemucapabilities: Reset command sequence before second probe
The test data for capabilities is obtained from two consecutive qemu
runs when the regular monitor object will be reset. Do the same for the
test monitor object which is not disposed between runs by calling
qemuMonitorResetCommandID.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-12 10:27:50 +02:00
Brijesh Singh
11ab77fe88 qemu: Add support to launch an SEV guest
QEMU >= 2.12 provides 'sev-guest' object which is used to launch encrypted
VMs on AMD platform using SEV feature. The various inputs required to
launch SEV guest is provided through the <launch-security> tag. A typical
SEV guest launch command line looks like this:

  -object sev-guest,id=sev0,cbitpos=47,reduced-phys-bits=5 ...\
  -machine memory-encryption=sev0 \

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-06-12 10:00:49 +02:00
Brijesh Singh
e5791a0306 conf: Introduce launch-security element in domain
The launch-security element can be used to define the security
model to use when launching a domain. Currently we support 'sev'.

When 'sev' is used, the VM will be launched with AMD SEV feature enabled.
SEV feature supports running encrypted VM under the control of KVM.
Encrypted VMs have their pages (code and data) secured such that only the
guest itself has access to the unencrypted version. Each encrypted VM is
associated with a unique encryption key; if its data is accessed to a
different entity using a different key the encrypted guests data will be
incorrectly decrypted, leading to unintelligible data.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-06-12 10:00:49 +02:00
Brijesh Singh
d4005609f3 qemu: Provide support to query the SEV capability
QEMU version >= 2.12 provides support for launching an encrypted VMs on
AMD x86 platform using Secure Encrypted Virtualization (SEV) feature.
This patch adds support to query the SEV capability from the qemu.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-06-12 09:51:59 +02:00
John Ferlan
05c41f4f1d test: Check return status for libxlxml2domconfigtest
Commit id d8e8b63d introduced the test, but neglected to check for
error from virTestLoadFile in testCompareXMLToDomConfig.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>
2018-06-11 18:33:13 -04:00
John Ferlan
30b2ebb284 test: Fix resource leak in qemumonitorjsontest
Introduced by commmit id 37bd4571c. Need to goto cleanup and
not return directly.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Katerina Koukiou <kkoukiou@redhat.com>
2018-06-11 18:33:13 -04:00
Roman Bogorodskiy
057a78ea31 bhyve: tests: Add missing data files
Add missing data files for bhyve cpu topology tests that should have been
added in b66fda0a74.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
2018-06-08 21:53:36 +04:00
Martin Kletzander
d60b730b48 qemu: Add support for setting the TSEG size
The default is stable per machine type so there should be no need to keep that.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-08 10:28:46 +02:00
Martin Kletzander
3ea32b635d qemu: Add capability flag for setting the extended tseg size
For getting the reply I queried the newest and oldest QEMU using
test/qemucapsprobe.  From the differences I only extracted the reply to the new
QMP command and discarded the rest.  For all the versions below the one which
added support for the new option I used the output from the oldest QEMU release
and for those that support it I used the output from the newest one.

In order to make doubly sure the reply is where it is supposed to be (the
replies files are very forgiving) I added the property to all the replies files,
reran the tests again and fixed the order in replies files so that all the
versions are reporting the new capability.  Then removed that one property.

After that I used test/qemucapsfixreplies to fix the reply IDs.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-08 10:28:46 +02:00
Martin Kletzander
1bd5a08d38 conf, schema, docs: Add support for TSEG size setting
TSEG (Top of Memory Segment) is one of many regions that SMM (System Management
Mode) can occupy.  This one, however is special, because a) most of the SMM code
lives in TSEG nowadays and b) QEMU just (well, some time ago) added support for
so called 'extended' TSEG.  The difference to the TSEG implemented in real q35's
MCH (Memory Controller Hub) is that it can offer one extra size to the guest OS
apart from the standard TSEG's 1, 2, and 8 MiB and that size can be selected in
1 MiB increments.  Maximum may vary based on QEMU and is way too big, so we
don't need to check for the maximum here.  Similarly to the memory size we'll
leave it to the hypervisor to try satisfying that and giving us an error message
in case it is not possible.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-08 10:28:46 +02:00
Peter Krempa
e546785dce tests: qemuxml2argv: Make tests based on DO_TEST_CAPS_LATEST stable
To avoid problems with test cases specifying an alias machine type which
would change once capabilities for a newer version are added strip all
alias machine types for the DO_TEST_CAPS_LATEST based tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-08 09:28:58 +02:00
Peter Krempa
e1e8d0a9b7 util: storage: remove 'allow_probe' from virStorageFileGetMetadata
All callers pass 'false' now so it's no longer needed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-08 09:26:38 +02:00
Peter Krempa
e0f8839b88 tests: storage: Drop duplicate tests with TEST_CHAIN
Now that all test cases with TEST_CHAIN were testing the same thing
twice drop one of them. Note that some of the cases were duplicate even
before dropping the image format probing tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-08 09:26:38 +02:00
Peter Krempa
655b95a01d tests: storage: Drop format probing from tests
Storage drivers now don't allow it so there's no need to test it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-08 09:26:38 +02:00
Peter Krempa
67d7d41615 tests: storage: Absorb ALLOW_PROBE flag into the TEST_CHAIN macro
The second set of arguments for TEST_CHAIN always specifies the
'ALLOW_PROBE' flag. Make it part of the macro.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-08 09:26:38 +02:00
Peter Krempa
300515b414 tests: virstoragetest: Add complementary test case for QED format
We have a test case for QED disk image with autodetection but not with
the format explicitly specified.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-08 09:26:38 +02:00
Peter Krempa
18d94e17f8 tests: Drop tests enabling allowDiskFormatProbing
Format probing will be dropped so remove the tests which will become
obsolete.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-08 09:26:37 +02:00
Roman Bogorodskiy
b66fda0a74 bhyve: Add CPU topology support
Recently, bhyve started supporting specifying guest CPU topology.
It looks this way:

  bhyve -c cpus=C,sockets=S,cores=C,threads=T ...

The old behaviour was bhyve -c C, where C is a number of vCPUs, is
still supported.

So if we have CPU topology in the domain XML, use the new syntax,
otherwise keep the old behaviour.

Also, document this feature in the bhyve driver page.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-07 19:26:26 +04:00
Stefan Berger
8737578d11 conf: Add support for choosing emulation of a TPM 2.0
This patch extends the TPM's device XML with TPM 2.0 support. This only works
for the emulator type backend and looks as follows:

    <tpm model='tpm-tis'>
      <backend type='emulator' version='2.0'/>
    </tpm>

The swtpm process now has --tpm2 as an additional parameter:

system_u:system_r:svirt_t:s0:c597,c632 tss 18477 11.8  0.0 28364  3868 ?        Rs   11:13  13:50 /usr/bin/swtpm socket --daemon --ctrl type=unixio,path=/var/run/libvirt/qemu/swtpm/testvm-swtpm.sock,mode=0660 --tpmstate dir=/var/lib/libvirt/swtpm/testvm/tpm2,mode=0640 --log file=/var/log/swtpm/libvirt/qemu/testvm-swtpm.log --tpm2 --pid file=/var/run/libvirt/qemu/swtpm/testvm-swtpm.pid

The version of the TPM can be changed and the state of the TPM is preserved.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-06 10:48:41 -04:00
Stefan Berger
f264df2d9e tests: Add test cases for external swtpm TPM emulator
This patch adds extensions to existing test cases and specific test cases
for the tpm-emulator.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-06 10:48:41 -04:00
Stefan Berger
b50edcd894 qemu: Extend QEMU capabilities with 'tpm-emulator'
Extend the QEMU capabilities with tpm-emulator support.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-06 10:48:41 -04:00
Stefan Berger
33af0b2b7c conf: Add support for external swtpm TPM emulator to domain XML
This patch adds support for an external swtpm TPM emulator. The XML for
this type of TPM looks as follows:

 <tpm model='tpm-tis'>
   <backend type='emulator'/>
 </tpm>

The XML will currently only define a TPM 1.2.

Extend the documentation.

Add a test case testing the XML parser and formatter.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-06 10:48:41 -04:00
Michal Privoznik
d0498881a0 virQEMUCapsFreeHostCPUModel: Don't always free host cpuData
This function exists because of 5276ec712a. But it is
missing initial check just like virQEMUCapsInitHostCPUModel()
has.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-06 13:27:18 +02:00
Daniel P. Berrangé
a9884d7062 tests: use a fixed NBD TLS certificate path
The default NBD TLS certificate path varies based on prefix given to
configure, causing tests to fail depending on build options.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-05 18:29:55 +01:00
ramyelkest
2b6667abbf all: Replace virGetLastError with virGetLastErrorCode where we can
Replace instances where we previously called virGetLastError just to
either get the code or to check if an error exists with
virGetLastErrorCode to avoid a validity pre-check.

Signed-off-by: Ramy Elkest <ramyelkest@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-06-05 18:44:05 +02:00
Daniel P. Berrangé
7ef0471bf7 qemu: don't retry connect() if doing FD passing
Since libvirt called bind() and listen() on the UNIX socket, it is
guaranteed that connect() will immediately succeed, if QEMU is running
normally. It will only fail if QEMU has closed the monitor socket by
mistake or if QEMU has exited, letting the kernel close it.

With this in mind we can remove the retry loop and timeout when
connecting to the QEMU monitor if we are doing FD passing. Libvirt can
go straight to sending the QMP greeting and will simply block waiting
for a reply until QEMU is ready.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-05 17:30:57 +01:00
Daniel P. Berrangé
30fb2276d8 qemu: support passing pre-opened UNIX socket listen FD
There is a race condition when spawning QEMU where libvirt has spawned
QEMU but the monitor socket is not yet open. Libvirt has to repeatedly
try to connect() to QEMU's monitor until eventually it succeeds, or
times out. We use kill() to check if QEMU is still alive so we avoid
waiting a long time if QEMU exited, but having a timeout at all is still
unpleasant.

With QEMU 2.12 we can pass in a pre-opened FD for UNIX domain or TCP
sockets. If libvirt has called bind() and listen() on this FD, then we
have a guarantee that libvirt can immediately call connect() and
succeed without any race.

Although we only really care about this for the monitor socket and agent
socket, this patch does FD passing for all UNIX socket based character
devices since there appears to be no downside to it.

We don't do FD passing for TCP sockets, however, because it is only
possible to pass a single FD, while some hostnames may require listening
on multiple FDs to cover IPv4 and IPv6 concurrently.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-05 17:30:28 +01:00
Daniel P. Berrangé
7cef131efe qemu: probe for -chardev 'fd' parameter for FD passing
QEMU >= 2.12 will support passing of pre-opened file descriptors for
socket based character devices.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-05 17:16:47 +01:00
Michal Privoznik
234ce7d02f src: Drop most of #ifdef WITH_GNUTLS
Now that GnuTLS is a requirement, we can drop a lot of
conditionally built code. However, not all ifdef-s can go because
we still want libvirt_setuid to build without gnutls.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-05 14:32:36 +02:00
Michal Privoznik
fe9f235a4c tests: Always build TLS related tests
Since GnuTLS is required there is no way to go with !WITH_GNUTLS
branch and just distribute these files.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-05 14:32:32 +02:00
Michal Privoznik
f785aa6c2b vircrypto: Drop virCryptoGenerateRandom
Now that virCryptoGenerateRandom() is plain wrapper over
virRandomBytes() we can drop it in favour of the latter.

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

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2018-06-05 10:31:19 +02:00
Filip Alac
dc34e78e21 capabilities: Extend capabilities with iommu_support
Signed-off-by: Filip Alac <filipalac@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-06-05 08:33:13 +02:00
Peter Krempa
6e6d84163e qemu: Split handling of managed and unmanaged persistent reservations
Add code that will handle the managed persistent reservations object
separately from the unmanaged one. There is only one managed object so
handling it with disks is awkward and does not scale well when backing
chains come into view.

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

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

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

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

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

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

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:59 +02:00
Peter Krempa
88860bb9d9 qemu: domain: Split validation and setup of the virStorageSource
Remove the call to the validating function from the function which sets
stuff up.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:58 +02:00
Peter Krempa
9b6a636d49 qemu: domain: don't loop through images in qemuDomainPrepareDiskSourceChain
Convert the function to just prepare data for the disk. Callers need to
do the looping since there's more to do than just copy the data around.

The code path in qemuDomainPrepareDiskSource doesn't need to loop over
the chain yet, since there currently is no chain at this point. This
will be addressed later in the blockdev series where we will setup much
more stuff.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:58 +02:00
Peter Krempa
3b5181b731 qemu: domain: Regenerate alias for the TLS x509 credential object
When restarting libvirt would previously lose the alias of the x509
certificate object. Upon unplug we would then not delete the
corresponding objects.

Restore the alias if we know it should be there.

Luckily for disks we don't support encrypted TLS environment, so there's
no need to regenerate the 'secret' alias for decryption.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:57 +02:00
Peter Krempa
1f1aa21cb9 qemu: domain: Store and restore TLS object alias of a disk
Libvirt uses the stored alias to detach the TLS x509 object on disk
unplug. As the alias was not stored, the object would not be detached
if unplugging disks after libvirtd restart.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:57 +02:00
Peter Krempa
7c6b00b8fe qemu: domain: Regenerate auth/enc secret aliases when restoring status XML
Previously we did not store the aliases but rather re-generated them
when unplug was necessary. This is very cumbersome since the knowledge
when and which alias to use needs to be stored in the hotplug code as
well.

While this patch will not strictly improve this situation since there
still will be two places containing this code it at least will allow to
remove the mess from the disk-unplug code and will prevent introducing
more mess when adding blockdev support.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:57 +02:00
Peter Krempa
ecd785dd84 tests: qemustatusxml2xml: Add test data for re-generating LUKS/auth aliases
Add tests for upcoming re-generation of aliases for the secret objects
used by qemu when upgrading libvirt.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:57 +02:00
Peter Krempa
f95baa3813 qemu: Store and parse disk authentication and encryption secret alias
Rather than trying to figure out which alias was used, store it in the
status XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:13:49 +02:00
Peter Krempa
538703ba6f tests: qemublock: Switch to qcow2+luks in test files
The next patch will forbid the old qcow2 encryption completely. Remove
it from the tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:11:12 +02:00
Peter Krempa
3bf1959524 tests: qemuxml2argv: Verify that disk secret alias is correct with user-aliases
Change the disk encryption type to qcow2+luks so that the appropriate
secret objects are generated. This tests that the proper alias is used
for the passphrase secret object.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:11:12 +02:00
Peter Krempa
e1b0c4bf65 tests: qemuxml2argv: Drop disk encryption from 'interface-server' test
The disk encryption part is no way relevant to the rest of the test so
drop it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-05 08:11:12 +02:00
Jim Fehlig
076a2b4096 tests: xmconfigtest: add tests for cmdline formating
Commit 656151bf fixed formatting of the <cmdline> element. Perhaps it
would have been noticed and fixed earlier if we had a test. With this
change, all possible cases of formatting <cmdline> from xmconfig are
covered

1. no 'extra=' or 'root=' in xm.cfg
2. 'extra=' but no 'root=' in xm.cfg
3. 'root=' but no 'extra=' in xm.cfg
4. both 'root=' and 'extra=' in xm.cfg

Case 1 is covered by all existing paravirt tests since they have no
'extra=' or 'root='. Case 2 is covered by adding 'extra=' to a few
of the existing paravirt tests. Cases 3 and 4 are covered by new
tests that only test conversion of xm.cfg to xml.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-06-04 20:59:16 -06:00
Ján Tomko
8a7003f669 qemu: check for QEMU_CAPS_DEVICE_VHOST_VSOCK
My commit b8b42ca added support for formatting the vsock
command line without actually checking if it's supported.

Add it to the per-device validation function.

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

Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-06-04 21:42:40 +02:00
Ján Tomko
023ea2a869 conf: rename <vsock><source> to <vsock><cid>
To avoid the <source> vs. <target> confusion,
change <source auto='no' cid='3'/> to:
<cid auto='no' address='3'/>

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-06-01 14:31:19 +02:00
Michal Privoznik
5276ec712a testUpdateQEMUCaps: Don't leak host cpuData
When preparing qemuCaps for test cases the following is
happening:

qemuTestParseCapabilitiesArch() is called, which calls
virQEMUCapsLoadCache() which in turn calls
virQEMUCapsInitHostCPUModel() which sets qemuCaps->kvmCPU and
qemuCaps->tcgCPU.

But then the code tries to update the capabilities:

testCompareXMLToArgv() calls testUpdateQEMUCaps() which calls
virQEMUCapsInitHostCPUModel() again overwriting previously
allocated memory. The solution is to free host cpuData in
testUpdateQEMUCaps().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-05-31 15:20:57 +02:00
Michal Privoznik
879cff55ac qemuxml2argvtest: Don't initialize qemuCaps twice
There's no point in calling testInitQEMUCaps() (which sets
info.qemuCaps) only to overwrite (and leak) it on the very next
line.

==12962== 296 (208 direct, 88 indirect) bytes in 1 blocks are definitely lost in loss record 265 of 331
==12962==    at 0x4C2CF26: calloc (vg_replace_malloc.c:711)
==12962==    by 0x5D28D9F: virAllocVar (viralloc.c:560)
==12962==    by 0x5D96AB4: virObjectNew (virobject.c:239)
==12962==    by 0x56DB7C7: virQEMUCapsNew (qemu_capabilities.c:1480)
==12962==    by 0x112A5B: testInitQEMUCaps (qemuxml2argvtest.c:361)
==12962==    by 0x1371C8: mymain (qemuxml2argvtest.c:2871)
==12962==    by 0x13AD0B: virTestMain (testutils.c:1120)
==12962==    by 0x1372FD: main (qemuxml2argvtest.c:2883)

Removing the function call renders @gic argument unused therefore
it's removed from the macro (and all its callers).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-31 11:33:45 +02:00
Ján Tomko
f8c4868a52 tests: initialize some variables
Found by cppcheck:
[tests/metadatatest.c:284]: (error) Uninitialized variable: test
[tests/objecteventtest.c:855]: (error) Uninitialized variable: test

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2018-05-30 15:54:58 +02:00
Ján Tomko
b8b42ca036 qemu: add support for vhost-vsock-pci
Create a new vsock endpoint by opening /dev/vhost-vsock,
set the requested CID via ioctl (or assign a free one if auto='yes'),
pass the file descriptor to QEMU and build the command line.

https://bugzilla.redhat.com/show_bug.cgi?id=1291851
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-29 15:42:04 +02:00
Ján Tomko
f672fa3b1d Introduce QEMU_CAPS_DEVICE_VHOST_VSOCK
Add a new capability flag for vhost-vsock-device

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-29 15:42:03 +02:00
Ján Tomko
d4abb7b45d conf: introduce <vsock> element
Add a new 'vsock' element for the vsock device.
The 'model' attribute is optional.
A <source cid> subelement should be used to specify the guest cid,
or <source auto='yes'/> should be used.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-29 15:42:03 +02:00
Ján Tomko
5b75a4a80d conf: introduce virDomainDefBootOrderPostParse
Move the check for boot elements into a separate function
and remove its dependency on the parser-supplied bootHash table.

Reconstructing the hash table from the domain definition
effectively duplicates the check for duplicate boot order
values, also present in virDomainDeviceBootParseXML.

Now it will also be run on domains created by other means than XML
parsing, since it will be run even for code paths that did not supply
the bootHash table before.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-29 10:22:08 +02:00
Jiri Denemark
7fb950958a cpu: Add optional list of allowed features to virCPUBaseline
When computing a baseline CPU for a specific hypervisor we have to make
sure to include only CPU features supported by the hypervisor. Otherwise
the computed CPU could not be used for starting a new domain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Collin Walling <walling@linux.ibm.com>
2018-05-28 15:59:11 +02:00
Jiri Denemark
f8c9f6ea2d cpu: Add explicit arch parameter for virCPUBaseline
This is required for virCPUBaseline to accept a list of guest CPU
definitions since they do not have arch set.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Collin Walling <walling@linux.ibm.com>
2018-05-28 15:59:10 +02:00
Jiri Denemark
5ed6cf96bc cpu: Rename cpuBaseline as virCPUBaseline
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 15:59:10 +02:00
Michal Privoznik
5c81c342a7 qemu_hotplug: Allow asynchronous detach
The virDomainDetachDeviceAlias API is designed so that it only
sends detach request to qemu. It's user's responsibility to wait
for DEVICE_DELETED event, not libvirt's. Add @async flag to
qemuDomainDetach*Device() functions so that caller can chose if
detach is semi-synchronous (old virDomainDetachDeviceFlags()) or
fully asynchronous (new virDomainDetachDeviceFlags()).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-28 13:08:52 +02:00
John Ferlan
4804a4db33 schema: Add missing block data for nodedev
https://bugzilla.redhat.com/show_bug.cgi?id=1566416

Commit id 'fe2af45b' added output for logical_block_size and
num_blocks for both removeable and fixed storage, but did not
update the nodedev capability causing virt-xml-validate to fail.
It's listed as optional only because it only prints if the
sizes are > 0. For a CDROM drive the values won't be formatted.

Update the nodedevxml2xmltest in order to output the values
for storage based on the logic from udevProcessRemoveableMedia
and udevProcessSD with respect to the logical_blocksize and
num_blocks calculations.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by Michal Privoznik <mprivozn@redhat.com>
2018-05-25 09:36:42 -04:00
John Ferlan
c1a0601deb schema: Fix capability grammar for pagesElem
https://bugzilla.redhat.com/show_bug.cgi?id=1572491

Commit id '02129b7c0' added a single pagesElem for slightly
different purposes. One usage was an output for host page size
listing and the other for NUMA supported page sizes. For the
former, only the pages unit and size are formatted, while for
the latter the pages unit, size, and availability data is formatted.

The virt-xml-validate would fail because it expected something
extra in the host page size output. So split up pagesElem a bit
and create pagesHost and pagesNuma for the differences.

Modify some capabilityschemadata output to have the output - even
though the results may not be realistic with respect to the
original incarnation of the data.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by Michal Privoznik <mprivozn@redhat.com>
2018-05-25 09:36:42 -04:00
John Ferlan
f97c4cc5e1 schema: Add microcode element to capability grammar
https://bugzilla.redhat.com/show_bug.cgi?id=1572491

Commit id 'd2440f3b5' added printing the <microcode> for the
capabilities, but didn't update the capabilities schema.

While at it, update capabilityschemadata for caps-test2
and caps-test3 to output some value for validation.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by Michal Privoznik <mprivozn@redhat.com>
2018-05-25 09:36:32 -04:00
John Ferlan
4cfa9309dc schema: Add rdma for host migrate transport capability
https://bugzilla.redhat.com/show_bug.cgi?id=1572491

Commit id 'b3fd95e36' added rdma as a valid option for
virCapabilitiesAddHostMigrateTransport, but didn't update
the capabilities schema resulting in possible virt-xml-validate
failure.

While at it, update the capabilityschemadata for caps-qemu-kvm

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by Michal Privoznik <mprivozn@redhat.com>
2018-05-25 09:33:44 -04:00
John Ferlan
dcd9db75fe schema,tests: Use vpxmigr for host migrate transport capability
Commit id 'e4938ce2f' changed the esx_driver to use 'vpxmigr'
instead of esx for virCapabilitiesAddHostMigrateTransport, so
update the capabilities to allow virt-xml-validate to pass and
update the test to use the newer name.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by Michal Privoznik <mprivozn@redhat.com>
2018-05-25 09:33:39 -04:00
John Ferlan
39d76c6856 schema: Add physical sizing element for storagevol grammar
https://bugzilla.redhat.com/show_bug.cgi?id=1572491

Commit id '78661cb' added a physical output, but failed to update
the schema resulting in a failure from virt-xml-validate.

While at it - update the storagevolschemadata for the output.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by Michal Privoznik <mprivozn@redhat.com>
2018-05-25 09:32:37 -04:00
John Ferlan
0f358fcdca domcaps: Add 'genid' to domain capabilities
Report domaincaps <features><genid supported='yes'/> if the guest
config accepts <genid/> or <genid>$GUID</genid>.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-25 08:15:58 -04:00
John Ferlan
87973a45f9 qemu: Add VM Generation ID to qemu command line
https://bugzilla.redhat.com/show_bug.cgi?id=1149445

If the domain requests usage of the genid functionality,
then add the QEMU '-device vmgenid' to the command line
providing either the supplied or generated GUID value.

Add tests for both a generated and supplied GUID value.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-25 08:15:58 -04:00
John Ferlan
3005002e0e qemu: Add VM Generation ID device capability
Add the query of the device objects for the vmgenid device

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-25 08:04:57 -04:00
John Ferlan
b50efe97ad conf: Add VM Generation ID parse/format support
The VM Generation ID is a mechanism to provide a unique 128-bit,
cryptographically random, and integer value identifier known as
the GUID (Globally Unique Identifier) to the guest OS. The value
is used to help notify the guest operating system when the virtual
machine is executed with a different configuration.

This patch adds support for a new "genid" XML element similar to
the "uuid" element. The "genid" element can have two forms "<genid/>"
or "<genid>$GUID</genid>". If the $GUID is not provided, libvirt
will generate one and save it in the XML.

Since adding support for a generated GUID (or UUID like) value to
be displayed modifying the xml2xml test to include virrandommock.so
is necessary since it will generate a "known" value.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-05-25 08:04:34 -04:00
Peter Krempa
83da9832c2 tests: Drop qemumonitortest
We don't use the text monitor since we dropped support for pre-JSON
qemus. Drop the test so that we can later delete the text monitor
support.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-23 15:43:34 +02:00
Peter Krempa
99223c8cca test: Add status XML test for NBD tls storage migration
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
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
8dd3a63184 tests: qemu: Extend the test suite with the 'output' sound codec
Affects qemuxml2xmltest and qemuxml2argvtest.

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
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
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
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
82ca8ad6c1 tests: qemuxml2argv: Test TLS certificate path containing a comma
We have to escape commas when formatting them on the command line. Add a
test case of a TLS path containing a comma.

Note that the output is wrong, this test case is to prove there's a bug.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-05-18 08:59:57 +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
Shalini Chellathurai Saroja
c6e605dc0e tests: Update caps for QEMU 2.12.0 on s390x
Let us update the existing xml and replies files for QEMU 2.12.0 on
s390x.

Used a z14 using a QEMU 2.12 GA build and the following sequence:

  tests/qemucapsprobe /usr/bin/qemu-system-s390x > \
         tests/qemucapabilitiesdata/caps_2.12.0.s390x.replies

  VIR_TEST_REGENERATE_OUTPUT=1 tests/qemucapabilitiestest
  VIR_TEST_REGENERATE_OUTPUT=1 tests/domaincapstest

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-16 14:19:57 -04: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
698af20af2 Skip vircryptotest and virfilecachetest without gnutls
Fix make check without gnutls.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-05-16 10:40:40 +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
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
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
Michal Privoznik
f50ad2ff63 tests: Link mocks with libvirt.so
In a lot of our mocks (if not all of them) we use our internal
APIs (e.g. VIR_ALLOC). So far, we're relying on test binary that
links with the mock to drag in libvirt.so. Well, this works only
partially. Firstly, whatever binary we execute from tests will
fail (e.g. as Martin reported on the list ./qemucapsprobe fails
to execute qemu). Secondly, if there's a program that tries to
validate linking (like valgrind is doing) it fails because of
unresolved symbols.

Because of that we have to link our mocks with libvirt.so.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-05-15 14:02:52 +02: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