Commit Graph

595 Commits

Author SHA1 Message Date
Ilias Stamatis
6b9fe4e53a test_driver: implement virDomainGetBlockInfo
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-08-09 10:23:52 +02:00
Ilias Stamatis
7bc812000c test_driver: implement virDomainSetTime
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-08-07 14:18:16 +02:00
Ilias Stamatis
79dab9011b test_driver: make testDomainGetTime read time from vm-private data
Until now, testDomainGetTime would always return the same fixed values
everytime it was called. By using domain-private data we can make this
API return the values previously set with testDomainSetTime, or use the
same old fixed values in case testDomainSetTime hasn't been called at all.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-08-07 14:18:16 +02:00
Ilias Stamatis
76c4de66ad test_driver: implement virDomainReset
The qemu and vz implementations don't emit any signals when this API is
called, so we can do the same here for now and succeed by doing nothing.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-08-07 10:20:30 +02:00
Ilias Stamatis
94fe500162 test_driver: implement virDomainFSTrim
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-08-06 10:41:02 +02:00
Ilias Stamatis
12bb690224 test_driver: implement virDomainFSThaw
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-08-06 10:40:51 +02:00
Ilias Stamatis
8037637941 test_driver: implement virDomainFSFreeze
On success update the domain-private data. Consider / and /boot to be
the only mountpoints avaiable in order to be consistent with the other
FS-related calls.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-08-06 10:40:51 +02:00
Ilias Stamatis
9ebdb3b0aa test_driver: introduce domain-private data
vm-specific data can be used by APIs that need to preserve some state
between calls

Some of them are:
- FS-related APIs for remembering which mountpoints are frozen
- virDomainSetTime / virDomainGetTime for maintaining time information
- virDomainSetIOThreadParams for storing the I/O thread parameters
- virDomainManagedSaveDefineXML for internally storing the VM definition

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-08-06 10:40:43 +02:00
Ilias Stamatis
95631b8a16 test_driver: implement virDomainMemoryStats
The main value here is the current balloon value which taken from the
config. All the other values (except for period) are derived by 2^n
division so that compiler prefers bitwise operations. Period value was
kept fixed in order to produce predictable results in a test environment.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-08-06 09:25:33 +02:00
Ilias Stamatis
672dd83719 test_driver: add a memballoon device in the default config
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-08-06 09:25:25 +02:00
Ilias Stamatis
c466816ee2 test_driver: implement virDomainCreateXMLWithFile
This should just forward the call to testDomainCreateXML since we
can't do anything with the provided file descriptors in the test driver.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
2019-08-06 09:05:03 +02:00
Ilias Stamatis
dace3ed383 test_driver: implement virDomainCreateWithFiles
This should just forward the call to testDomainCreateWithFlags since we
can't do anything with the provided file descriptors in the test driver.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
2019-08-06 09:05:03 +02:00
Ilias Stamatis
adf50b57bd test_driver: implement virDomainGetCPUStats
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-29 15:56:46 +02:00
Eric Blake
7efe930ec3 backup: Prevent snapshots and checkpoints at same time
Earlier patches mentioned that the initial implementation will prevent
snapshots and checkpoints from being used on the same domain at once.
However, the actual restriction is done in this separate patch to make
it easier to lift that restriction via a revert, when we are finally
ready to tackle that integration in the future.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-07-29 08:22:29 -05:00
Eric Blake
a0efa67812 backup: test: Implement metadata tracking for checkpoint APIs
A lot of this work heavily copies from the existing snapshot APIs.
The test driver doesn't really have to do anything more than just
expose an interface into libvirt metadata, making it possible to test
saving and restoring XML, and tracking relations between multiple
checkpoints.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-07-26 16:48:58 -05:00
Ilias Stamatis
3e93d00d56 test_driver: implement virDomainPinEmulator
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
2019-07-26 13:14:36 +02:00
Ilias Stamatis
6328da0428 test_driver: implement virDomainGetEmulatorPinInfo
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
2019-07-26 13:14:36 +02:00
Erik Skultety
a1c04c27bd test_driver: Fix testDomainSetMemoryFlags' behaviour on config change
When commit 6ac402c456 added the API whenever VIR_DOMAIN_MEM_MAXIMUM
was passed the code always checked whether the domain was active and
therefore failed with an error even though only a config change was
requested. Fix the issue by replacing virDomainObjGetOneDef with
virDomainObjGetOneDefState which tells us what definition we're
performing the change on.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-07-25 10:44:13 +02:00
Eric Blake
ceb1019257 snapshot: Don't leak moment obj list metaroot to callers
virDomainSnapshotFindByName(list, NULL) should return NULL, rather
than the internal-use-only metaroot.  Most existing callers pass in a
non-NULL name; the few external callers that don't are immediately
calling virDomainMomentSetParent (which indeed needs the metaroot
rather than NULL if the parent name is NULL); but as the leaky
abstraction is ugly, it is worth instead making
virDomainMomentSetParent static and adding a new function for
resolving the parent link of a brand new moment within its list.  The
existing external uses of virDomainMomentSetParent always succeed
(either the new moment has parent_name of NULL to become a new root,
or has parent_name set to a strdup of the previous current moment);
hence, our new function does not need a return value (but it still has
a VIR_WARN in case future uses break our assumptions about failure
being impossible).

Missed when commit 02c4e24d refactored things to attempt to remove
direct metaroot manipulations out of the qemu and test drivers into
internal-only details, and made more obvious when commit dc8d3dc6
factored it out into a separate file.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-07-24 17:03:34 -05:00
Ilias Stamatis
4837328d68 test_driver: testDomainSetMaxMemory should simply forward the call
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-24 17:28:47 +02:00
Ilias Stamatis
c8a46e0a1d test_driver: testDomainSetMemory should forward the call with VIR_DOMAIN_AFFECT_LIVE
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-24 17:28:47 +02:00
Ilias Stamatis
6ac402c456 test_driver: consider flags in testDomainSetMemoryFlags
Update the current or max memory, on the persistent or live definition
depending on the flags which are currently ignored.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-24 17:28:41 +02:00
Ilias Stamatis
7afa8be0d5 test_driver: implement virDomainSetNumaParameters
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-24 17:09:37 +02:00
Ilias Stamatis
fb275b7673 test_driver: implement virConnectSupportsFeature
Make the test driver only support the VIR_TYPED_PARAM_STRING flag for
now.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-24 17:09:32 +02:00
Ilias Stamatis
bfd18389d0 test_driver: implement virDomainSetInterfaceParameters
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-24 16:53:14 +02:00
Ilias Stamatis
6ccf128a3a test_driver: implement virDomainInjectNMI
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-24 14:56:33 +02:00
Ilias Stamatis
9deacfadfb test_driver: implement virDomainSetMemoryStatsPeriod
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-24 13:17:31 +02:00
Cole Robinson
8911d843f3 conf: Add network xmlopt argument
Pass an xmlopt argument through all the needed network conf
functions, like is done for domain XML handling. No functional
change for now

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-07-17 17:18:56 -04:00
Ilias Stamatis
cbfc84f7bc test_driver: implement virDomainSetMemoryParameters
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-15 15:24:53 +02:00
Ilias Stamatis
38e9e7e0d7 test_driver: implement virDomainSetUserPassword
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-15 14:26:29 +02:00
Eric Blake
95f8e3237e snapshot: Add VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE flag
We've been doing a terrible job of performing XML validation in our
various API that parse XML with a corresponding schema (we started
with domains back in commit dd69a14f, v1.2.12, but didn't catch all
domain-related APIs, didn't document the use of the flag, and didn't
cover other XML). New APIs (like checkpoints) should do the validation
unconditionally, but it doesn't hurt to continue retrofitting existing
APIs to at least allow the option.

While there are many APIs that could be improved, this patch focuses
on wiring up a new snapshot XML creation flag through all the
hypervisors that support snapshots, as well as exposing it in 'virsh
snapshot-create'.  For 'virsh snapshot-create-as', we blindly set the
flag without a command-line option, since the XML we create from the
command line should generally always comply (note that validation
might cause failures where it used to succeed, such as if we tighten
the RNG to reject a name of '../\n'); but blindly passing the flag
means we also have to add in fallback code to disable validation if
the server is too old to understand the flag.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-07-10 17:34:58 -05:00
Eric Blake
667ac11e10 test: Add various vir*Flags API
Even though we don't accept any flags, it is unfriendly to callers
that use the modern API to have to fall back to the flag-free API.

Note that virDomainBlockStats does not trivially forward to
virDomainBlockStatsFlags, so that one is omitted for now.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-07-09 08:23:02 -05:00
Eric Blake
2503763ee1 snapshot: Refactor test to utilize virDomainMoment more
Similar to commit a487890d for qemu, a little bit of refactoring in
the snapshot delete code will make it easier to reuse functionality
for checkpoints.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-07-05 21:18:53 -05:00
Ilias Stamatis
586cc43760 test_driver: implement testDomainGetInterfaceParameters
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-04 16:50:08 +02:00
Ilias Stamatis
0d3436efba test_driver: implement virDomainGetNumaParameters
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-04 16:50:06 +02:00
Ilias Stamatis
7064fd6270 test_driver: implement virDomainGetMemoryParameters
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-04 16:50:04 +02:00
Daniel P. Berrangé
80b71b2c85 test: ensure nerrors variable is initialized
There is an error path that jumps over the initialization of
nerrors, and the jump target reads the variable contents.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-07-04 14:20:35 +01:00
Ilias Stamatis
613c8eeaa2 test_driver: Implement virDomainSetPerfEvents
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-04 14:22:00 +02:00
Ilias Stamatis
c67cf079f7 test_driver: sanitize user-provided array in testDomainGetDiskErrors
Zero out the user provided memory in order to avoid potentially freeing
uninitialized memory.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-04 14:13:31 +02:00
Ilias Stamatis
791e20142a test_driver: Implement virDomainGetPerfEvents
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-03 10:04:05 +02:00
Ilias Stamatis
b0ea31af52 test_driver: Call virCheckFlags in testDomainReboot
Currently the flags argument is completely ignored, but it should be
checked for any unsupported flags that might have been passed.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-03 09:57:30 +02:00
Ilias Stamatis
d754a5cc1d test_driver: Implement virDomainGetFSInfo
Always return / and /boot as the mount points imitating the default
Fedora installation. Use the first disk found, otherwise if no disk
device of type VIR_DOMAIN_DISK_DEVICE_DISK is present, return 0 mount
points.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
2019-07-03 09:57:30 +02:00
Ilias Stamatis
4d61181d1f test_driver: Add a disk device in the default config
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-07-03 09:57:30 +02:00
Michal Privoznik
0ff84542a5 test_driver: Don't report VIR_DOMAIN_DISK_ERROR_NONE
In my review of 89320788ac I've simplified assigning disk errors
too much as the code I've changed it to will set
VIR_DOMAIN_DISK_ERROR_NONE. This is in contradiction with our
documentation which specifies that disks with no errors are not
reported.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2019-07-03 09:06:41 +02:00
Michal Privoznik
3b1a5dde79 test_driver: Don't access @vm after it was set to NULL
If something goes wrong in testDomainGetDiskErrors() then we try
to free any strings that were previously allocated in return
array. Problem is, in my review of original patch (89320788ac)
I've mistakenly did some changes which result in possible NULL
dereference (@vm is set to NULL as the first thing under cleanup
label).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2019-07-03 09:06:41 +02:00
Andrea Bolognani
df1b5cf02e test_driver: Fix permissions for test_driver.c
Introduced in commit 4a6ee53581.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-07-01 17:02:05 +02:00
Ilias Stamatis
fcf1b2c70f test_driver: properly handle DHCP ranges and IPv6 networks in testDomainInterfaceAddresses
testDomainInterfaceAddresses always returns the same hard-coded
addresses. Change the behavior such as if there is a DHCP range defined,
addresses are returned from that pool.

The specific address returned depends on both the domain id and the
specific guest interface in an attempt to return unique addresses *most
of the time*.

Additionally, properly handle IPv6 networks which were previously
ignored completely.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-06-20 17:54:02 +02:00
Ilias Stamatis
37cca33403 test_driver: check that the domain is running in testDomainGetTime
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-06-20 15:38:58 +02:00
Jonathon Jongsma
6bbc6269c1 src/test: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-19 17:12:31 +02:00
Ilias Stamatis
0d8079e913 test_driver: validate @source in testDomainInterfaceAddresses
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-06-19 15:48:50 +02:00