Commit Graph

6589 Commits

Author SHA1 Message Date
Brian Turek
1d446bd465 qemu: add 'fmode' and 'dmode' options
Expose QEMU's 9pfs 'fmode' and 'dmode' options via attributes on the
'filesystem' node in the domain XML. These options control the creation
mode of files and directories, respectively, when using
accessmode=mapped.

Signed-off-by: Brian Turek <brian.turek@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 18:25:55 +01:00
Brian Turek
b0f0e96cdd qemu: capabilities: add QEMU_CAPS_FSDEV_CREATEMODE
The QEMU 9pfs 'fmode' and 'dmode' options have existed since QEMU 2.10.
Probe QEMU's command line set to check whether these options are
available, and if yes, enable this new QEMU_CAPS_FSDEV_CREATEMODE
capability on libvirt side.

Signed-off-by: Brian Turek <brian.turek@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-11-04 18:25:53 +01:00
Roman Bolshakov
040de3fe46 storagepoolxml2argvtest: Reorder gluster arguments
Commit f00cde7f11 changed order of mount arguments in
virStorageBackendFileSystemMountGlusterArgs() and introduced per-OS
mount options and new test data. Old test data was left unmodified with
prior order of arguments. That causes a test failure on all OSes but
Linux and FreeBSD, i.e. on macOS:

  15) Storage Pool XML-2-argv pool-netfs-gluster
      ...
  In
  '/Users/roolebo/dev/libvirt/tests/storagepoolxml2argvdata/pool-netfs-gluster.argv':
  Offset 39
  Expect [-o direct-io-mode=1 /mnt/gluster]
  Actual [/mnt/gluster -o direct-io-mode=1]

Fixes: f00cde7f11 ("storage: Add default mount options for fs/netfs storage pools")
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-11-04 11:54:03 +01:00
Roman Bolshakov
beece2411d virpcimock: Enable on macOS
In general, it has little sense to use Linux pci mock on macOS but
virPCIDeviceAddressGetIOMMUGroupNum() is relying on the filesystem
layout mocked by virpcimock. And all tests that rely on correct
execution of virPCIDeviceAddressGetIOMMUGroupNum() fail.

The change fixes qemuhotplugtest, qemumemlocktest and qemuxml2xmltest.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-11-04 11:54:02 +01:00
Roman Bolshakov
31eb96358f virpcimock: Initialize real_close before using it
real_close() is not inialized by the first invocation of close(). That
causes an issue when the mock is used before others and a call of
real_close() results in a jump to NULL pointer.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-11-04 11:53:57 +01:00
Pavel Hrdina
99d2c6519a vircgroup: drop @create from virCgroupNewDomainPartition
All callers pass true.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Pavel Hrdina
c88b3712ca vircgroup: remove useless cgroup->path variable
It is only used for debug and error purposes which can be easily
replaced by @placement.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 21:26:32 +01:00
Laine Stump
85c8c29214 remove unnecessary cleanup labels and unused return variables
After converting all DIR* to g_autoptr(DIR), many cleanup: labels
ended up just having "return ret", and every place that set ret would
just immediately goto cleanup. Remove the cleanup label and its
return, and just return the set value immediately, thus eliminating
the need for the return variable itself.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-02 22:01:36 -05:00
Laine Stump
c0ae4919e3 change DIR* int g_autoptr(DIR) where appropriate
All of these conversions are trivial - VIR_DIR_CLOSE() (aka
virDirClose()) is called only once on the DIR*, and it happens just
before going out of scope.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-02 22:01:36 -05:00
Laine Stump
c40b673182 consistently use VIR_DIR_CLOSE() instead of virDirClose()
This will make it easier to review upcoming patches that use g_autoptr
to auto-close all DIRs.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-11-02 22:01:36 -05:00
Peter Krempa
42558a43f8 qemu: capabilities: Re-enable detection of QEMU_CAPS_BLOCK_EXPORT_ADD
Now that qemu stabilized it's interface and we've switched to the new
design we can re-enable use of 'block-export-add'

This reverts commit b87cfc957f

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-11-02 14:40:48 +01:00
Peter Krempa
1c2314b938 qemu: Update to new design of 'block-export-add'
qemu decided to modify the arguments of 'block-export-add' to include an
array of bitmaps rather than a single bitmap.

Since we've added the code prior to qemu setting the interface in stone
and thus it will be changed incompatibly and we already have tests for
the new interface we need to update the code and qemu capabilities data
at the same time.

Use a array of bitmaps as the 'bitmaps' argument instead of 'bitmap' and
bump qemu capabilities for the upcoming 5.2.0 release to
v5.1.0-2827-g2c6605389c

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-11-02 14:39:41 +01:00
Peter Krempa
8bcda6e260 qemu: Add test cases for 'host_cdrom' blockdev backend via <disk>
Simulate that the device is a cdrom when the path equals to /dev/cdrom
to provide testing for the 'host_cdrom' backend.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-02 14:14:51 +01:00
Daniel P. Berrangé
e9cfbd36c5 tests: fix stat mocking with Fedora rawhide
GLibC has a really complicated way of dealing with the 'stat' function
historically, which means our mocks in turn have to look at four
different possible functions to replace, stat, stat64, __xstat,
__xstat64.

In Fedora 33 and earlier:

 - libvirt.so links to __xstat64
 - libc.so library exports stat, stat64, __xstat, __xstat64
 - sys/stat.h header exposes stat and __xstat

In Fedora 34 rawhide:

 - libvirt.so links to stat64
 - libc.so library exports stat, stat64, __xstat, __xstat64
 - sys/stat.h header exposes stat

Historically we only looked at the exported symbols from libc.so to
decide which to mock.

In F34 though we must not consider __xstat / __xstat64 though because
they only existance for binary compatibility. Newly built binaries
won't reference them.

Thus we must introduce a header file check into our logic for deciding
which symbol to mock. We must ignore the __xstat / __xstat64 symbols
if they don't appear in the sys/stat.h header, even if they appear
in libc.so

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-29 19:52:07 +01:00
Peter Krempa
b87cfc957f qemu: capabilities: Disable detection of QEMU_CAPS_BLOCK_EXPORT_ADD
We use the capability to switch to using 'block-export-add' in the
upcoming qemu release instead of the at the same time deprecated
'nbd-server-add'.

Unfortunately qemu wants to change the interface of 'block-export-add'
before the release. Since we've tried to stay up to date and added the
code before it was written in stone, we need to disable the use of the
new interface for the upcoming libvirt release so that we don't have a
version of libvirt which would not work with the upcoming qemu version.

Remove the detection of 'block-export-add' until we are more sure how
the qemu interface will look.

This patch partially reverts commit adb9f7123a

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-10-29 18:08:39 +01:00
Roman Bolshakov
c8c6991169 tests: Use flat namespace for qemu test driver
The change re-introduces f6d6086dbf ("tests: Make references to global
symbols indirect in test drivers") that got lost during meson
conversion.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-23 13:19:48 +02:00
Roman Bolshakov
ad0b56b64c tests: Re-introduce stat/lstat mocks on macOS
Commit d6b17edd51 ("tests: Lookup extended stat/lstat in mocks")
adds support for mocking of stat() and lstat() on macOS.

The change was broken because virmockstathelpers.c only follows glibc
logic and MOCK_STAT and MOCK_LSTAT are not getting defined on macOS.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-23 13:19:42 +02:00
Roman Bolshakov
2c0b3db3c7 tests: Fix lstat() mock initialization on macOS
There is a typo that prevents initialization of real_lstat.

Fixes: d6b17edd51 ("tests: Lookup extended stat/lstat in mocks")
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-23 13:19:34 +02:00
Peter Krempa
d6d4c08daf util: hash: Change type of hash table name/key to 'char'
All users of virHashTable pass strings as the name/key of the entry.
Make this an official requirement by turning the variables to 'const
char *'.

For any other case it's better to use glib's GHashTable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
8824fc8474 util: hash: Remove virHashValueFree
Use 'g_free' directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
b82dfe3ba7 Replace all instances of 'virHashCreate' with 'virHashNew'
It doesn't make much sense to configure the bucket count in the hash
table for each case specifically. Replace all calls of virHashCreate
with virHashNew which has a pre-set size and remove virHashCreate
completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
aa99658b06 qemuDomainObjPrivateAlloc: Use virHashNew instead of virHashCreate
virHashCreate will be removed in upcoming patches. This change has an
impact on ordering of the blockjob entries in one of the status XML->XML
tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
afc4139136 tests: hash: Prepare for replacement of virHashCreate
Most callers pass a random number. We have virHashNew which doesn't give
the callers the option to configure the table. Since we are going to
switch to virHashNew replace it in tests and remove multiple instances
of the 'testHashGrow' case as it doesn't make sense with the new
semantics.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
e12324d2af conf: nwfilter: Replace 'virNWFilterHashTableCreate' with 'virHashNew'
Export the freeing function rather than having a wrapper for the hash
creation function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Peter Krempa
2751b9757b util: virhash: Remove virHashTableSize
It's used only in one place in tests which isn't even automatically
evaluated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Daniel P. Berrangé
7b1ed1cd73 qemu: stop passing -enable-fips to QEMU >= 5.2.0
Use of the -enable-fips option is being deprecated in QEMU >= 5.2.0. If
FIPS compliance is required, QEMU must be built with libcrypt which will
unconditionally enforce it.

Thus there is no need for libvirt to pass -enable-fips to modern QEMU.
Unfortunately there was never any way to probe for -enable-fips in the
first instance, it was enabled by libvirt based on version number
originally, and then later unconditionally enabled when libvirt dropped
support for older QEMU. Similarly we now use a version number check to
decide when to stop passing -enable-fips.

Note that the qemu-5.2 capabilities are currently from the pre-release
version and will be updated once qemu-5.2 is released.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-22 09:03:33 +02:00
Peter Krempa
ca8f7b8a02 qemuxml2argvtest: Sanitize testing of '-enable-fips'
Rename 'FLAG_FIPS' to 'FLAG_FIPS_HOST' to signify that we are simulating
a host supporting fips mode and use the flag to assert 'enabeFips'
argument of 'qemuProcessCreatePretendCmdBuild' rather than passing it
via QEMU_CAPS_ENABLE_FIPS.

This prepares the testsuite for testing of -enable-fips deprecation in
qemu-5.2.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-22 09:03:28 +02:00
Jonathon Jongsma
b79abf9c3c qemu: support hotplug of vdpa devices
By using the new qemu monitor functions to handle passing and removing
file descriptors, we can support hotplug of vdpa devices.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2020-10-20 15:15:06 -04:00
Jonathon Jongsma
0b1a05ffb5 qemu: add vdpa support
Enable <interface type='vdpa'> for qemu domains. This provides basic
support and does not support hotplug or migration.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-10-20 14:48:02 -04:00
Jonathon Jongsma
9825f71b53 qemu: add vhost-vdpa capability
Recent versions of qemu added the -netdev vhost-vdpa device. This
capability allows libvirt to know whether this is supported.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-10-20 14:47:20 -04:00
Peter Krempa
b6fea3f5d8 qemuxml2argvmock: Remove mocking of 'virSCSIDeviceGetSgName'
Hostdev setup code no longer resolves hostdev name in the commandline
formatter but we mock it directly in the monitor code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 15:08:22 +02:00
Peter Krempa
7b0ced89e7 qemu: Prepare hostdev data which depends on the host state separately
SCSI hostdev setup requires querying the host os for the actual path of
the configured hostdev. This was historically done in the command line
formatter. Our new approach is to split out this part into
'qemuProcessPrepareHost' which is designed to be skipped in tests.

Refactor the hostdev code to use this new semantics, and add appropriate
handlers filling in the data for tests and the qemuConnectDomainXMLToNative
users.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 15:08:22 +02:00
Peter Krempa
9ff3ad9058 qemuProcessCreatePretendCmd: Split up preparation and command building
Host preparation steps which are deliberately skipped when
pretend-creating a commandline are normally executed after VM object
preparation. In the test code we are faking some of the host
preparation steps, but we were doing that prior to the call to
qemuProcessPrepareDomain embedded in qemuProcessCreatePretendCmd.

By splitting up qemuProcessCreatePretendCmd into two functions we can
ensure that the ordering of the prepare steps stays consistent.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 15:08:22 +02:00
Peter Krempa
e257493441 virschematest: Validate schema in tests/cputestdata
We now have a schema file for the 'cpu' elements. Use it to validate
files in 'tests/cputestdata'

Unfortunately the files in the directory are too disorganised and not
easy to split up to do something more straightforward.

The -baseline- input files are tested by the test internally and the
rest of the files are internal data feeding the tests so they don't
need validation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 09:05:11 +02:00
Peter Krempa
f3bbaf3169 virschematest: Validate more XMLs
We weren't validating certain directories containing nwfilter, network
and capability XML test files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 09:05:10 +02:00
Peter Krempa
67214de5bb virschematest: Add directories containing domain XMLs
Validate additional XML documents we use for internal testing.
Specifically there's a lot of them belonging to the vmx and bhyve test
suite which were not validated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 09:05:10 +02:00
Peter Krempa
d504297993 tests: vmx: Add <name> element for all domain XMLs
<name> is mandatory for a domain XML. Add 'displayName' for all the test
cases which were missing them so that <name> is parsed correctly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 09:05:10 +02:00
Peter Krempa
37208d9d17 nwfilterxml2xmltest: Rename cases with XMLs not conforming to schema
There's quite a few negative tests. In anticipation of schema testing of
the 'nwfilterxml2xmlin' directory rename all negative/non-conformant
XMLs with the -invalid suffix.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 09:05:10 +02:00
Peter Krempa
f4aa549ea8 nwfilterxml2firewall: Fix schema compilance of 'tcp' test case
Fix the 'flags' of the last rule to conform to the RNG schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 09:05:10 +02:00
Peter Krempa
59d847b578 domainconfdata/getfilesystem.xml: Remove <init> element
The element is not needed for the test and doesn't conform to the domain
XML schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 09:05:10 +02:00
Peter Krempa
2dce8109f9 virschematest: Fix testing of 'nwfilter' xmls
The files are under 'src/nwfilter/xml'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 09:05:10 +02:00
Peter Krempa
57f1d5bb3b virschematest: Add coverage for 'examples/xml/test'
Add all appropriate file from our test driver example XML directory.

Note that the two 'node.*' files are actually custom for the test driver
to load full state. We don't have a schema for them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 09:05:10 +02:00
Peter Krempa
933b4b9980 virschematest: Add coverage for 'examples/xml/storage'
Match the correct subsets of the files via the 'dirRegex' property.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 09:05:10 +02:00
Peter Krempa
873d484190 virschematest: Add regex filtering for directory contents
In some cases we have directories with mixed XML files in the test
suite. Adding regex filtering will allow testing subsets of the XML
files against schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 09:05:10 +02:00
Peter Krempa
837633afb9 virschematest: Rewrite internals to allow increasing XML test coverage
To allow greater variablitity of XML schema validation tests without
needlessly reparsing the schema we need to refactor the internals to
pass in structs rather than just paths to directory.

This allows to directly implement testing of single files and will
simplify further additions such as filtering of the list of XML files in
a directory.

The list of tested paths is directly ported for now and will be improved
in follow-up patches.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 09:05:10 +02:00
Peter Krempa
8c67e389d6 qemuBlockExportAddNBD: Use 'block-export-add' when available
Switch to the new QMP command once it becomes available. Since the code
was refactored to have just one central location to do this we can
contain the ugly bits to just this one function.

Since we now use the replacement for 'nbd-server-add' mark the test case
as being OK with removal of the command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-19 13:36:58 +02:00
Peter Krempa
f70e9c6cb8 qemu: Add infrastructure for 'block-export-add' to export NBD
Add the monitor code, corresponding generator of properties for NBD and
tests validating it against the schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-19 13:36:58 +02:00
Peter Krempa
adb9f7123a qemu: capabilities: Add QEMU_CAPS_BLOCK_EXPORT_ADD
The 'block-export-add' QMP command is a replacement for 'nbd-server-add'
and will allow greater flexibility. Add a capability so that we can
switch to it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-19 13:36:58 +02:00
Peter Krempa
2f451d8114 tests: qemucapabilities: Update capabilities for qemu-5.2 dev cycle
Update to commit v5.1.0-2207-g96292515c0

Recent changes include deprecation of 'nbd-server-add' and addition of
'block-export-add'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-19 13:36:58 +02:00
Peter Krempa
917d8a5390 qemumonitorjsontest: Allow deprecation of 'nbd-server-add' QMP command
qemu is going to deprecate this command in the next release. Allow this
as later patches will implement the use of replacement.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-19 13:36:58 +02:00
Peter Krempa
77064438d4 bhyve: parse: Set video device model when parsing bhyve commandline
Add the proper video device type when parsing bhyve's commandline into a
XML.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
2020-10-19 11:50:49 +02:00
Peter Krempa
296598ea40 bhyveargv2xmldata: Remove XML files for console2/3/4 test case
The test case is invoked using DO_TEST_FAIL so the XML files are
actually unexpected, unused and actually don't even conform to the RNG
schema for <domain>.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
2020-10-19 11:50:37 +02:00
Erik Skultety
2508d10f67 conf: domain: sev: Make 'cbitpos' & 'reducedPhysBits' attrs optional
These XML attributes have been mandatory since the introduction of SEV
support to libvirt. This design decision was based on QEMU's
requirement for these to be mandatory for migration purposes, as
differences in these values across platforms must result in the
pre-migration checks failing (not that migration with SEV works at the
time of this patch).

Expecting the user to specify these is cumbersome and the same XML
cannot be re-used across different revisions of SEV. Since
we have SEV platform information saved in QEMU capabilities, we can
make the attributes optional and should fill them in automatically
in the QEMU driver right before starting it.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/57

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-19 11:03:39 +02:00
Daniel Henrique Barboza
27371bd517 qemu_command.c: move QEMU_CAPS_DEVICE_NVDIMM_UNARMED check to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:54:33 -03:00
Daniel Henrique Barboza
0bf8dfb02a qemu_command.c: move 'panic' validation to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:54:33 -03:00
Daniel Henrique Barboza
d3dad77dd6 qemu_command.c: move usb_redir validations to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:54:33 -03:00
Daniel Henrique Barboza
eb42c1313f qemu_command.c: move SHMEM validation to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:54:33 -03:00
Daniel Henrique Barboza
c47b013992 qemu_command.c: move NUMA memory backing check to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:54:33 -03:00
Daniel Henrique Barboza
4b42c27ee7 qemu_command.c: move CPU mode check to qemu_validate.c
All but VIR_CPU_MODE_HOST_MODEL were moved. 'host_model' mode
has nuances that forbid the verification to be moved to parse
time.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:54:33 -03:00
Daniel Henrique Barboza
2d8a60fab1 qemu_command.c: move QEMU_CAPS_FW_CFG validation to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:54:27 -03:00
Daniel Henrique Barboza
f800aa3ee7 qemu_command.c: move RNG backend validation to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:50:34 -03:00
Daniel Henrique Barboza
03e4e4b21e qemu_command.c: move QEMU_CAPS_DEVICE_USB_KBD check to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:50:34 -03:00
Daniel Henrique Barboza
edee4290c9 qemu_command.c: move QEMU_CAPS_VIRTIO_NET_HOST_MTU check to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:50:34 -03:00
Daniel Henrique Barboza
53fa517082 qemu_command.c: move QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE check to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:50:34 -03:00
Daniel Henrique Barboza
78c6507473 qemu_command.c: move QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE check to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:50:26 -03:00
Daniel Henrique Barboza
37c6d4a62c qemu_command.c: move QEMU_CAPS_VIRTIO_TX_ALG check to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:01:49 -03:00
Daniel Henrique Barboza
a40659eb82 qemu_command.c: move DISK_BUS_USB validation to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 10:01:49 -03:00
Daniel Henrique Barboza
da1748cab1 qemu_command.c: move DISK_BUS_SATA validation to qemu_validate.c
A few tweaks were made during the move:

- the error messages were changed to mention 'sata controller'
instead of 'ide controller';

- a check for address type 'drive' was added like it is done
with other bus types. The error message of qemuxml2argdata was
updated to reflect that now, instead of erroring it out from the
common code in virDomainDiskDefValidate(), we're failing earlier
with a different error message.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 09:55:37 -03:00
Daniel Henrique Barboza
c9fbb07bab qemu_command.c: move LUN and IDE checks to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 09:45:34 -03:00
Daniel Henrique Barboza
ccb08c3818 qemu_command.c: move wwn validation to qemu_validate.c
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-15 09:45:17 -03:00
Michal Privoznik
76db9e8bcd lib: s/free-page-reporting/freePageReporting/
In fee8a61d29 a new attribute to <memballoon/> was introduced:
free-page-reporting. We don't really like hyphens in attribute
names. Use camelCase instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-15 10:57:11 +02:00
Michal Privoznik
9ba99180b3 tests: Turn virtio-options-memballoon-freepage-reporting.xml into a symlink
The output virtio-options-memballoon-freepage-reporting.xml of
xml2xmlout is the same as the input. Make it as symlink to save
space.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-10-15 10:51:07 +02:00
Pino Toscano
2214fe9044 vmx: start parsing SATA disks
Always reverse-engineering VMX files, attempt to support SATA disks in
guests, and their controllers.

The esx-in-the-wild-10 test case is taken from RHBZ#1883588, while the
result of esx-in-the-wild-8 is updated with SATA disks.

Fixes (hopefully):
https://bugzilla.redhat.com/show_bug.cgi?id=1677608
https://bugzilla.redhat.com/show_bug.cgi?id=1883588

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-14 11:23:30 +02:00
Nico Pache
4cb5f34905 provide testing for free-page-reporting feature in QEMU
This provides basic testing for the free-page-reporting feature that is
introduced in qemu 5.1.

Signed-off-by: Nico Pache <npache@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-13 17:02:48 +02:00
Nico Pache
5032b247e9 QEMU: declare qemu capabilities for the Virtio Free page reporting feature
This patch will introduce the free-page-reporting feature capabilities
that are in qemu 5.1

Signed-off-by: Nico Pache <npache@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-13 17:02:42 +02:00
Michal Privoznik
0b66196d86 qemu: Set noqueue qdisc for TAP devices
By default, pfifo_fast queueing discipline (qdisc) is set on
newly created interfaces (including TAPs). This qdisc has three
queues and packets that want to be sent through given NIC are
placed into one of the queues based on TOS field. Queues are then
emptied based on their priority allowing interactive sessions
stay interactive whilst something else is downloading a large
file.

Obviously, this means that kernel has to be involved and some
locking has to happen (when placing packets into queues). If
virtualization is taken into account then the above algorithm
happens twice - once in the guest and the second time in the
host.

This is arguably not optimal as it burns host CPU cycles
needlessly. Guest already made it choice and sent packets in the
order it wants.

To resolve this, Linux kernel offers 'noqueue' qdisc which can be
applied on virtual interfaces and in fact for 'lo' it is by
default:

  lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue

Set it for other TAP devices we create for domains too. With this
change I was able to squeeze 1Mbps more from a macvtap attached
to a guest and to my 1Gbps LAN (as measured by iperf3).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1329644
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-13 16:31:29 +02:00
Roman Bogorodskiy
476bf54e86 bhyve: fix virtio-9p src/dst order
For the virtio-9p bhyve command line argument, the proper order
is mount_tag=/path/to/host/dir, not the opposite.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-12 15:24:21 +04:00
Roman Bogorodskiy
7382a7c2be bhyve: implement virtio-9p support
Recently virtio-9p support was added to bhyve.

On the host side it looks this way:

  bhyve .... -s 25:0,virtio-9p,sharename=/path/to/shared/dir

It could also have ",ro" suffix to make share read-only.

In the Linux guest, this share is mounted with:

  mount -t 9p sharename /mnt/sharename

In the guest user will see the same permissions and ownership
information for this directory as on the host. No uid/gid remapping is
supported, so those could resolve to wrong user or group names.

The same applies to the other side: chowning/chmodding in the guest will
set specified ownership and permissions on the host.

In libvirt domain XML it's modeled using the 'filesystem' element:

  <filesystem type='mount'>
    <source dir='/path/to/shared/dir'/>
    <target dir='sharename'/>
  </filesystem>

Optional 'readonly' sub-element enables read-only mode.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-09 18:46:04 +04:00
Pavel Hrdina
a9932fc292 tests: use g_autoptr for virCgroup
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2020-10-09 16:24:49 +02:00
Pavel Hrdina
5ad8272888 util: vircgroup: change virCgroupFree to take only virCgroupPtr
As preparation for g_autoptr() we need to change the function to take
only virCgroupPtr.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2020-10-09 16:24:35 +02:00
Tim Wiederhake
470dd74027 tests: Remove references to "cpu_map.xml" in the code
"cpu_map.xml" was moved to a directory "cpu_map" and split up into
several files.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-10-09 15:38:05 +02:00
Ján Tomko
19c7b50c94 tests: delete VIR_ALLOC tests cases
There are no more users of VIR_ALLOC or VIR_ALLOC_N.
Delete their test cases.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-08 19:19:22 +02:00
Ján Tomko
173e2e73bf tests: use g_new0 instead of VIR_ALLOC
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-08 19:19:22 +02:00
Roman Bolshakov
c3d02040ac tests: commandhelper: Accept POLLNVAL on macOS
commandhelper hangs indefinitely in poll() on macOS on commandtest test2
and later because POLLNVAL is returned on revents for input file
descriptor opened from /dev/null, i.e this hangs:

  $ tests/commandhelper < /dev/null
  BEGIN STDOUT
  BEGIN STDERR
  ^C

But it works fine with regular stdin:

  $ tests/commandhelper <<< test
  BEGIN STDOUT
  BEGIN STDERR
  test
  test
  END STDOUT
  END STDERR

The issue is mentioned in poll(2):

  BUGS
    The poll() system call currently does not support devices.

With the change all 28 cases in commandtest pass.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-10-08 17:04:08 +02:00
Michal Privoznik
0c8ab47847 qemu: Don't generate '-machine memory-backend' and '-numa memdev'
In 88957116c9 I've switched to -machine memory-backend=ID and
-object memory-backend-* because QEMU is obsoleting -mem-path
and -mem-prealloc. However, what I did not foresee was that using
-machine memory-backend in combination with -numa is not allowed
in QEMU. This was reported upstream and fortunately not released
yet.

The problem is that if domain has NUMA nodes then we will
generate memory-backend-* objects for NUMA nodes (because if QEMU
is new enough to expose default RAM ID it also supports -numa
memdev=) and adding non-NUMA memory backend is wrong.

Reported-by: Masayoshi Mizuma <msys.mizuma@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-10-08 12:55:10 +02:00
Jiri Denemark
3bf6f9fe22 cpu_map: Remove monitor feature from EPYC-Rome
The feature is filtered by KVM and never automatically enabled. So even
though QEMU definition of EPYC-Rome contains this feature, the guest
won't see it. Also domain capabilities will show it as disabled for KVM
domains. Thus the feature should not really be included in our
definition of EPYC-Rome.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-08 09:58:44 +02:00
Jiri Denemark
736b8637f6 cputest: Update QEMU data for Ryzen 9 3900X
The CPU should be identified as EPYC-Rome, but the QEMU binary used to
gather the original test data did not support this model. Let's update
the supported models to QEMU 5.1.0.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-07 18:42:17 +02:00
Markus Schade
f941639f86 cpu_map: Defined and enable EPYC-Rome model
Signed-off-by: Markus Schade <markus.schade@hetzner.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-10-07 17:30:54 +02:00
Markus Schade
e06590f170 Add testdata for AMD EPYC 7502
Signed-off-by: Markus Schade <markus.schade@hetzner.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2020-10-07 17:25:02 +02:00
Tim Wiederhake
676396ba5b tests: Rename some test files in cputestdata
The files contained the "-invalid" marker in their filename, marking
them as test cases that are supposed to fail in the virschematest.
Unfortunately, the "-invalid" marker does not discriminate between
different tests the files might be used in.

A later patch will introduce a new test validating the XML. This
test is not supposed to fail, as the files contain valid XML.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-07 11:26:37 +02:00
Tim Wiederhake
4c3ed3b84e cpu: Wire in XML validation
This adds a new value to virConnectCompareCPUFlags,
"VIR_CONNECT_CPU_VALIDATE_XML", that governs XML document validation in
virCPUDefParseXML.

In src/conf/cpu_conf.c, include configmake.h for PKGDATADIR and
virfile.h for virFileFindResource.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-07 11:26:27 +02:00
Cole Robinson
14f877e8d0 tests: cover disk, interface <backenddomain>
There is present no XML test coverage for this.
Add genericxml parse + formatting coverage.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-10-05 12:43:00 -04:00
Peter Krempa
cb6fdb0125 virBitmapNew: Don't check return value
Remove return value check from all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 15:38:47 +02:00
Peter Krempa
bab5a79d6a util: bitamp: Remove virBitmapNewEmpty
It can be replaced by virBitmapNew(0).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 15:38:47 +02:00
Peter Krempa
f054317a0b virbitmaptest: Remove unnecessary error/cleanup labels
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 15:38:47 +02:00
Peter Krempa
05e82621e0 virbitmaptest: Use g_auto(free) for cleanup
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 15:38:47 +02:00
Peter Krempa
297fc39a2d virbitmaptest: Refactor checks in 'test6'
The 'checkBitmap' helper uses 'virBitmapFormat' internally and also
reports better errors. Use it instead of the open-coded checks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 15:38:47 +02:00
Peter Krempa
0128fe1411 virbitmaptest: Turn 'TEST_MAP' macro into a helper function
The function will also be reusable in other places of the code by making
the size check optional. For now only test12* is refactored since it
used TEST_MAP directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 15:38:47 +02:00
Peter Krempa
7a1bc02be9 virbitmaptest: Use separate output strings in 'test5'
The test validates two outputs. Don't reuse 'str' for both.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 15:38:47 +02:00
Peter Krempa
5e309e82a7 virbitmaptest: Split up test4
'test4' was testing three distinct operations on separate instances of a
bitmap. Split it up into 'test4a', 'test4b' and 'test4c' so that the
'bitmap' variable is not reused.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-10-05 15:38:47 +02:00