mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
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>
This commit is contained in:
parent
4faaaa8b27
commit
89320788ac
@ -3046,6 +3046,43 @@ static int testDomainSetAutostart(virDomainPtr domain,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int testDomainGetDiskErrors(virDomainPtr dom,
|
||||||
|
virDomainDiskErrorPtr errors,
|
||||||
|
unsigned int maxerrors,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
virDomainObjPtr vm = NULL;
|
||||||
|
int ret = -1;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
if (!(vm = testDomObjFromDomain(dom)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (errors) {
|
||||||
|
for (i = 0; i < MIN(vm->def->ndisks, maxerrors); i++) {
|
||||||
|
if (VIR_STRDUP(errors[i].disk, vm->def->disks[i]->dst) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
errors[i].error = i % VIR_DOMAIN_DISK_ERROR_LAST;
|
||||||
|
}
|
||||||
|
ret = i;
|
||||||
|
} else {
|
||||||
|
ret = vm->def->ndisks;
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virDomainObjEndAPI(&vm);
|
||||||
|
if (ret < 0) {
|
||||||
|
for (i = 0; i < MIN(vm->def->ndisks, maxerrors); i++)
|
||||||
|
VIR_FREE(errors[i].disk);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static char *testDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED,
|
static char *testDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED,
|
||||||
int *nparams)
|
int *nparams)
|
||||||
{
|
{
|
||||||
@ -6832,6 +6869,7 @@ static virHypervisorDriver testHypervisorDriver = {
|
|||||||
.domainUndefineFlags = testDomainUndefineFlags, /* 0.9.4 */
|
.domainUndefineFlags = testDomainUndefineFlags, /* 0.9.4 */
|
||||||
.domainGetAutostart = testDomainGetAutostart, /* 0.3.2 */
|
.domainGetAutostart = testDomainGetAutostart, /* 0.3.2 */
|
||||||
.domainSetAutostart = testDomainSetAutostart, /* 0.3.2 */
|
.domainSetAutostart = testDomainSetAutostart, /* 0.3.2 */
|
||||||
|
.domainGetDiskErrors = testDomainGetDiskErrors, /* 5.4.0 */
|
||||||
.domainGetSchedulerType = testDomainGetSchedulerType, /* 0.3.2 */
|
.domainGetSchedulerType = testDomainGetSchedulerType, /* 0.3.2 */
|
||||||
.domainGetSchedulerParameters = testDomainGetSchedulerParameters, /* 0.3.2 */
|
.domainGetSchedulerParameters = testDomainGetSchedulerParameters, /* 0.3.2 */
|
||||||
.domainGetSchedulerParametersFlags = testDomainGetSchedulerParametersFlags, /* 0.9.2 */
|
.domainGetSchedulerParametersFlags = testDomainGetSchedulerParametersFlags, /* 0.9.2 */
|
||||||
|
Loading…
Reference in New Issue
Block a user