Signed-off-by: Luke Yue <lukedyue@xxxxxxxxx> --- src/test/test_driver.c | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 3cabd6dc46..99d5d5b67b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9393,6 +9393,7 @@ testDomainCheckpointDelete(virDomainCheckpointPtr checkpoint, typedef enum { VIR_DOMAIN_IOTHREAD_ACTION_ADD, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, } virDomainIOThreadAction; static int @@ -9417,6 +9418,14 @@ testDomainChgIOThread(virDomainObj *vm, return ret; break; + + case VIR_DOMAIN_IOTHREAD_ACTION_DEL: + if (virDomainDriverDelIOThreadCheck(def, iothread_id) < 0) + return ret; + + virDomainIOThreadIDDel(def, iothread_id); + + break; } } @@ -9466,6 +9475,51 @@ testDomainAddIOThread(virDomainPtr dom, virDomainObjEndAPI(&vm); return ret; } + +static int +testDomainDelIOThread(virDomainPtr dom, + unsigned int iothread_id, + unsigned int flags) +{ + virDomainObj *vm = NULL; + testDomainObjPrivate *priv; + size_t i; + int ret = -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (iothread_id == 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("invalid value of 0 for iothread_id")); + return -1; + } + + if (!(vm = testDomObjFromDomain(dom))) + goto cleanup; + + if (testDomainChgIOThread(vm, iothread_id, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, flags) < 0) + goto cleanup; + + priv = vm->privateData; + + for (i = 0; i < priv->iothreads->len; i++) { + testIOThreadInfo iothread = g_array_index(priv->iothreads, + testIOThreadInfo, i); + if (iothread.iothread_id == iothread_id) { + g_array_remove_index(priv->iothreads, i); + break; + } + } + + ret = 0; + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + /* * Test driver */ @@ -9533,6 +9587,7 @@ static virHypervisorDriver testHypervisorDriver = { .domainGetVcpuPinInfo = testDomainGetVcpuPinInfo, /* 1.2.18 */ .domainGetMaxVcpus = testDomainGetMaxVcpus, /* 0.7.3 */ .domainAddIOThread = testDomainAddIOThread, /* 7.7.0 */ + .domainDelIOThread = testDomainDelIOThread, /* 7.7.0 */ .domainGetSecurityLabel = testDomainGetSecurityLabel, /* 7.5.0 */ .nodeGetSecurityModel = testNodeGetSecurityModel, /* 7.5.0 */ .domainGetXMLDesc = testDomainGetXMLDesc, /* 0.1.4 */ -- 2.32.0