Commit Graph

6906 Commits

Author SHA1 Message Date
Jonathon Jongsma
073862febe nodedev: Remove GetMdevctl*Command() wrappers
These per-command generator functions were only exposed in the header to
allow the commandline generation to be tested. Now that we have a
generic mdevctl command generator, we can get rid of the per-command
wrappers and reduce the noise in the header.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-04-19 10:24:13 -05:00
Erik Skultety
87b31fe8a2 nodedev: driver: Create a generic mdevctl command translator
Currently there are dedicated wrappers to construct mdevctl command.
These are mostly fine except for the one that translates both "start"
and "define" commands, only because mdevctl takes the same set of
arguments. Instead, keep the wrappers, but let them call a single
global translator that handles all the mdevctl command differences and
commonalities.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-04-19 10:24:13 -05:00
Erik Skultety
92fdc1f0cb nodedev: driver: Introduce internal mdevctl commands enum
This is not a 1:1 mapping to mdevctl commands because mdevctl doesn't
support a separate 'create' command. mdevctl uses 'start' for both
starting a pre-defined device as well as for creating and starting a new
transient device. The libvirt code will be more readable if we treat
these as separate commands. When we need to actually execute mdevctl,
the 'create' command will be translated into the appropriate 'mdevctl
start' command.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-04-19 10:24:13 -05:00
Jonathon Jongsma
123ea7d51c nodedev: Switch to using long options for mdevctl
rather than using short opentions (e.g. "-p 0000:00:02.0"), use long
options everywhere (e.g. "--parent=0000:00:02.0")

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-04-19 10:24:13 -05:00
Erik Skultety
963888f288 nodedev: driver: Swap virMdevctlStart and virMdevctlCreate
"start" in libvirt means - "take this object and create an
instance out of it"

"create" in libvirt most of the time means - "take and XML description,
make an object out of it and use it to create an instance"

This gets confusing with mdevctl which uses "start" for both. So, this
patch proposes to use virMdevctlStart in cases where from libvirt's POV
we're starting a defined device (unlike mdevctl). Similarly, use
virMdevctlCreate in scenarios where XML description is passed to
libvirt and a transient device is supposed to be created.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-04-19 10:24:13 -05:00
Jonathon Jongsma
94589d1dc8 tests: nodedev: switch all test macros to accept a filename
Rather than specifying a UUID string to some test macros, just pass a
filename to an xml definition. This helps work toward unifying the test
macros and making it more maintainable.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-04-19 10:24:13 -05:00
Peter Krempa
b528fffc6f vmx: Mark CDROM disk elements as read-only
Mark it explicitly as read only in accordance with the comment outlining
configuration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Luyao Zhong
2d37d8dbc9 qemu: Add support for 'restrictive' mode in numatune
Signed-off-by: Luyao Zhong <luyao.zhong@intel.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 11:39:21 +02:00
Luyao Zhong
6213d52384 conf, docs, schema: Add support for 'restrictive' mode in numatune
This allows users to restrict memory nodes without setting any specific
memory policy, then 'restrictive' mode is useful.

Signed-off-by: Luyao Zhong <luyao.zhong@intel.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 11:39:13 +02:00
Tim Wiederhake
5729d94917 Fix spelling
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-04-15 15:42:21 +02:00
Michal Privoznik
c8238579fb lib: Drop internal virXXXPtr typedefs
Historically, we declared pointer type to our types:

  typedef struct _virXXX virXXX;
  typedef virXXX *virXXXPtr;

But usefulness of such declaration is questionable, at best.
Unfortunately, we can't drop every such declaration - we have to
carry some over, because they are part of public API (e.g.
virDomainPtr). But for internal types - we can do drop them and
use what every other C project uses 'virXXX *'.

This change was generated by a very ugly shell script that
generated sed script which was then called over each file in the
repository. For the shell script refer to the cover letter:

https://listman.redhat.com/archives/libvir-list/2021-March/msg00537.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-13 17:00:38 +02:00
Tim Wiederhake
f0e1e31bf7 Remove references to deleted Makefile.am
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-13 11:21:00 +02:00
Peter Krempa
096ac87a1a tests: qemucapabilitiesdata: Fix wrong command identifier in caps_4.0.0.riscv64.replies
Commit cbd4ab4cc6 added a hunk with a broken reply ID.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-04-12 16:09:42 +02:00
Peter Krempa
aa21615ccb tests: qemucapabilitiesdata: Fix formatting of manually added hunk
Commit 66c5674e79 added a query for the device properties of 'usb-host'
but the command header isn't formated the same way as if it were
autogenerated. Reformat all the files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-04-12 16:09:42 +02:00
Peter Krempa
987644a9dc qemuxml2xmltest: Always include basic set of capabilities
Use virQEMUCapsInitQMPBasicArch to add the basic set of capabilities
which all qemu versions will get.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 16:09:42 +02:00
Peter Krempa
86c1fcf7cd qemuxml2argvtest: Parse 'arch' from XML early
If we want to provide correct (fake) caps already for the XML parser we
need to be able to parse the arch early so that we can properly
initialize the caps cache prior to calling the XML parser.

This patch adds code which parses the arch and updates the caps cache
prior to the parse step.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 16:09:42 +02:00
Peter Krempa
75d18dbd03 qemuxml2argvtest: Rewrite parsing of XMLs to provide earlier parsing
In upcoming patches we'll need to parse a certain bit of XML before
calling the full XML parser. This effectively open-codes what
virDomainDefParseFile to reach virDomainDefParseNode.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 16:09:42 +02:00
Peter Krempa
a842de3ef7 qemuxml2(argv|xml)test: Don't exit early when testQemuInfoSetArgs fails
Set the return code to failure and continue testing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-04-12 16:09:41 +02:00
Peter Krempa
e4332faf39 qemuxml2xmltest: testInfoSetPaths: Remove return value
The function doesn't fail. Remove the return value and checks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-04-12 16:09:41 +02:00
Peter Krempa
76d722d3d5 Remove test 'args' file rewrapping infrastructure
All tests which use files with 'ldargs' and 'args' suffix as output now
use the internal and better line splitting.

Remove the test-wrap-argv.py script, the syntax check which used it and
the helper rewrapping the output when regenerating test output.

For any further use, we require code to use virCommand anyways and thus
it has internal wrapping now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
d146b193e2 nodedevmdevctltest: Use internal linewrapping and variable command path stripping
Remove `nodedevCompareToFile` which was stripping the path to mdevctl
since it's no longer needed if we use the new features of
virCommandSetDryRun.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
2dcbdc7f4b bhyvexml2argvtest: Use internal wrapping of command line arguments
virCommandToString has the possibility to return an already wrapped
string with better format than what we get from the test wrapper script.

The main advantage is that arguments for an option are always on the
same line which makes it more easy to see what changed in a diff and
prevents re-wrapping of the line if a wrapping point moves over the
threshold.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
13ffa48d2f nwfilterxml2firewalldata: Use internal wrapping to wrap output files
As with previous commits use virCommandSetDryRun to invoke
virCommandToString so that it returns pre-wrapped string.

Since virCommand is better aware of where the arguments terminate we can
see an improvement where comments are no longer line-wrapped.

The changes to the 'commonRules' strings were done with the following
regex:

 s/ -/ \\\\\\n-/

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
49c505a2e0 networkxml2firewalltest: Use internal wrapping of command line arguments
virCommandSetDryRun allows to invoke virCommandToString so that the
command string is already wrapped.

We now also need to load the base arguments file without unwrapping the
arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
19d7f60133 storagevolxml2argvtest: Use internal wrapping of command line arguments
virCommandToString has the possibility to return an already wrapped
string with better format than what we get from the test wrapper script.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
eba7491c59 storagepoolxml2argvtest: Use internal wrapping of command line arguments
virCommandToString has the possibility to return an already wrapped
string with better format than what we get from the test wrapper script.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
06d7151664 storage: Format mount options before positional arguments
Move calls to virStorageBackendFileSystemMountAddOptions earlier so that
the options are formatted before the positional arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
0046e0b1c2 qemuxml2argvtest: Use internal wrapping of command line arguments
virCommandToString has the possibility to return an already wrapped
string with better format than what we get from the test wrapper script.

The main advantage is that arguments for an option are always on the
same line which makes it more easy to see what changed in a diff and
prevents re-wrapping of the line if a wrapping point moves over the
threshold.

Additionally the used output is the same we have in the VM log file when
a VM is starting.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
1f61d7129f virCommandToStringFull: Improve linebreaking behaviour
Put multiple values for an option if followed by another option as used
in certain iptables arguments.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
e5124770db virTestLoadFileJSON: Don't try to unwrap JSON documents
Use virFileReadAll to load the file instead of virTestLoadFile which
tries to unwrap the file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
19659d839c virTestCompareToFile: Add possibility to skip unwrapping of input file
In some cases we might want to compare already wrapped data against a
wrapped file. Introduce virTestCompareToFileFull with a 'unwrap' boolean
which will control the unwrapping.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
3b0e264aa8 testutils: Remove unused virTestClearCommandPath
virCommand(ToString) now provides the functionality internally so we
don't have to keep the string-munging function around.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
cf32c7d8c0 nwfilterebiptablestest: Strip path from test output via virCommandSetDryRun
Enable the internal path clearing instead of using
virTestClearCommandPath.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
17a8d82791 nwfilterxml2firewalltest: Strip path from test output via virCommandSetDryRun
Enable the internal path clearing instead of using
virTestClearCommandPath.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
76af07c278 networkxml2firewalltest: Strip path from test output via virCommandSetDryRun
Enable the internal path clearing instead of using
virTestClearCommandPath.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
01c357a4c9 virCommandSetDryRun: Add flags to linebreak and strip prefix from the command buffer
virCommandToStringFull used internally when virCommandSetDryRun is
requested allows to strip command path and wrap lines nicely. Expose
these via virCommandSetDryRun so that tests can use those features
instead of local hacks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
0dffca8f95 virCommandSetDryRun: Rework resetting of the dry run data
While virCommandSetDryRun is used in tests only, there were some cases
when error paths would not call the function with NULL arguments to
reset the dry run infrastructure.

Introduce virCommandDryRunToken type which must be allocated via
virCommandDryRunTokenNew and passed to virCommandSetDryRun.

This way we can use automatic variable cleaning to trigger the cleanup
of virCommandSetDryRun parameters and also the use of the token variable
ensures that all callers of virCommandSetDryRun clean up after
themselves and also that the token isn't left unused in the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
070cc66d16 tests: storagepoolxml2argvtest: Use integrated command path stripping
Replace virTestClearCommandPath by virCommandToStringFull which allows
to strip the command prefix internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
d8f2027a79 qemuxml2xmloutdata: Remove unused symlinks to test XML files
The symlinks are not used by the test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
3f31c4e506 qemuxml2xmloutdata: Remove unused output XML files
The files are no longer referenced by existing test cases. Remove them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
8b82c1675b qemuxml2argvdata: Remove unused 'xml' files
The files are no longer referenced by either qemuxml2argvtest or
qemuxml2xmltest. Remove them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
b06332242f qemuxml2argvdata: Remove unused 'args' files
The files were added in error (audio-*) for test cases which produce an
error, left over after converting to DO_TEST_CAPS_LATEST
(disk-detect-zeroes), or left over after splitting test cases
(disk-network-tlsx509).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
529564aba4 tests: string: Remove pointless test for virStringListFreeCount
It's way more useful to run valgrind against the rest of the code than
this test to see whether virStringListFreeCount works. Remove the test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-04-12 15:55:10 +02:00
Peter Krempa
887d747dbe tests: Remove testing of virStorageFileCanonicalizePath
Remove the last code using the function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-04-12 15:55:09 +02:00
Peter Krempa
a43c8763bf virStorageSourceGetMetadata: Use depth limit instead of unique path checking
Prevent unbounded chains by limiting the recursion depth of
virStorageSourceGetMetadataRecurse to the maximum number of image layers
we limit anyways.

This removes the last use of virStorageSourceGetUniqueIdentifier which
will allow us to delete some crusty old infrastructure which isn't
really needed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-04-12 15:55:09 +02:00
Jonathon Jongsma
62a73c525c nodedev: add ability to specify UUID for new mdevs
Use the new <uuid> element in the mdev caps to define and start devices
with a specific UUID.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-04-07 15:24:17 -05:00
Jonathon Jongsma
07666e292e nodedev: add <uuid> element to mdev caps
It will be useful to be able to specify a particular UUID for a mediated
device when defining the node device. To accomodate that, allow this to
be specified in the xml schema. This patch also parses and formats that
value to the xml, but does not yet use it.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-04-07 15:14:01 -05:00
Jonathon Jongsma
c0db1af2f8 api: add virNodeDeviceCreate()
This new API function provides a way to start a persistently-defined
mediate device that was defined by virNodeDeviceDefineXML() (or one that
was defined externally via mdevctl)

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-04-07 15:14:01 -05:00
Jonathon Jongsma
bb311cede7 api: add virNodeDeviceUndefine()
This interface allows you to undefine a persistently defined (but
inactive) mediated devices. It is implemented via 'mdevctl'

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-04-07 15:13:32 -05:00
Jonathon Jongsma
f98c415f8a nodedev: refactor tests to support mdev undefine
mdevctl 'stop' and 'undefine' commands take the same uuid parameter, so
refactor the test infrastructure to share common implementation for both
of these commands. The 'undefine' command will be introduced in a
following patch.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-04-07 15:11:17 -05:00