Commit Graph

578 Commits

Author SHA1 Message Date
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
Ilias Stamatis
4a6ee53581 test_driver: implement virDomainSendProcessSignal
Only succeed when @pid_value is 1, since according to the docs this is
the minimum requirement for any driver to implement this API.
Since this is test driver, we assume that any signal from the supported
list can be sent to pid 1 and we therefore succeed every time.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-06-19 15:13:39 +02:00
Ilias Stamatis
072390cbf0 test_driver: Implement virDomainGetLaunchSecurityInfo
Since the behaviour of launch security is heavily dependent on 3rd party
vendors (e.g. AMD SEV) where the data returned can be essentially
anything, the most reasonable approach here in the test driver is not to
try return any data.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-06-12 12:37:03 +02:00
Ilias Stamatis
49df9205f2 test_driver: implement virDomainSaveImageGetXMLDesc
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-06-12 08:52:46 +02:00
Ilias Stamatis
4d39a99142 test_driver: implement virDomainSaveImageDefineXML
Updates the existing image stored in @path, in case @dxml contains valid
XML supported by the fake host.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-06-12 08:52:46 +02:00
Ilias Stamatis
d6650b2620 test_driver: extract image loading code into a separate function
Extracting the code logic for opening and parsing a test image from
testDomainRestoreFlags into a separate function, allows us to reuse this
code in other functions such as testDomainSaveImageGetXMLDesc.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-06-12 08:52:46 +02:00
Ilias Stamatis
1dfa29f806 test_driver: extract image saving code into a separate function
Extracting the code logic for writing a test image to disk from
testDomainSaveFlags into a separate function, allows us to reuse this
code in other functions such as testDomainSaveImageDefineXML.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-06-12 08:52:46 +02:00
Ilias Stamatis
8ad2f8cc43 test_driver: implement virDomainSendKey
Validate @keycodes before successfully returning. Since this is test
driver, @holdtime is being unused here.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-06-07 12:32:48 +02:00
Ilias Stamatis
cd3aebe9f2 test_driver: implement virDomainGetHostname
Always return "domain_name" + "host".

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-06-04 08:15:04 +02:00
Ilias Stamatis
b3908d2efb test_driver: implement virDomainMemoryPeek
Begins by writing a @start byte in the first position of @buffer and
then for every next byte it stores the value of its previous one
incremented by one.

Behaves the same for both supported flags.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-05-27 15:29:13 +02:00
Erik Skultety
ab48fe7991 driver: test: Fix the mingw build caused by wrong printf format specifier
Caused by commit 326c3f54.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2019-05-24 14:24:18 +02:00
Ilias Stamatis
326c3f54f2 test_driver: implement virDomainInterfaceAddresses
Ignore @source in the case of the test driver and return fixed private
IPv4 addresses for all the interfaces defined in the domain.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-05-24 10:01:05 +02:00
Ilias Stamatis
057b12d62a test_driver: add a guest interface in the default config
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-05-24 10:01:05 +02:00
Ilias Stamatis
89320788ac test_driver: implement virDomainGetDiskErrors
Return the number of disks present in the configuration of the test
domain when called with @errors as NULL and @maxerrors as 0.

Otherwise report an error for every second disk, assigning available
error codes in a cyclic order.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-05-13 14:34:11 +02:00
Eric Blake
57387ff54b snapshot: Make virDomainSnapshotDef a virObject
This brings about a couple of benefits:
- use of VIR_AUTOUNREF() simplifies several callers
- Fixes a todo about virDomainMomentObjList not being polymorphic enough

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-05-09 10:02:53 -05:00
Eric Blake
098043eddd snapshot: s/current/parent/ as prep for virObject
VIR_CLASS_NEW insists that descendents of virObject have 'parent' as
the name of their inherited base class member at offset 0. While it
would be possible to write a new class-creation macro that takes the
actual field name 'current', and rewrite VIR_CLASS_NEW to call the new
macro with the hard-coded name 'parent', it seems less confusing if
all object code uses similar naming. Thus, this is a mechanical rename
in preparation of making virDomainSnapshotDef a descendent of
virObject.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-05-09 09:48:07 -05:00
Eric Blake
36603bc568 snapshot: s/parent/parent_name/ as prep for virObject
VIR_CLASS_NEW insists that descendents of virObject have 'parent' as
the name of their inherited base class member at offset 0. While it
would be possible to write a new class-creation macro that takes the
actual field name, and rewrite VIR_CLASS_NEW to call the new macro
with the hard-coded name 'parent', so that we could make
virDomainMomentDef use a custom name for its base class, it seems less
confusing if all object code uses similar naming. Thus, this is a
mechanical rename in preparation of making virDomainSnapshotDef a
descendent of virObject, when we can no longer use 'parent' for a
different purpose than the base class.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-05-09 09:43:41 -05:00
Ilias Stamatis
63a960c725 test_driver: provide virDomainGetTime implementation
Implement testDomainGetTime by returning a fixed timestamp.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-05-04 23:39:35 +02:00