Signed-off-by: Ilias Stamatis <stamatis.iliass(a)gmail.com>
---
src/test/test_driver.c | 85 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 7acde811ef..b4a883cb54 100755
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2963,6 +2963,90 @@ testDomainAddIOThread(virDomainPtr dom,
}
+static int
+testDomainDelIOThread(virDomainPtr dom,
+ unsigned int iothread_id,
+ unsigned int flags)
+{
+ virDomainObjPtr vm = NULL;
+ virDomainDefPtr def = NULL;
+ testDomainObjPrivatePtr priv;
+ size_t i, j;
+ 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 (!(def = virDomainObjGetOneDef(vm, flags)))
+ goto cleanup;
+
+ if (!virDomainIOThreadIDFind(def, iothread_id)) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("cannot find IOThread '%u' in iothreadids
list"),
+ iothread_id);
+ goto cleanup;
+ }
+
+ for (i = 0; i < def->ndisks; i++) {
+ if (def->disks[i]->iothread == iothread_id) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("cannot remove IOThread %u since it "
+ "is being used by disk '%s'"),
+ iothread_id, def->disks[i]->dst);
+ goto cleanup;
+ }
+ }
+
+ for (i = 0; i < def->ncontrollers; i++) {
+ if (def->controllers[i]->iothread == iothread_id) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("cannot remove IOThread '%u' since it "
+ "is being used by controller"),
+ iothread_id);
+ goto cleanup;
+ }
+ }
+
+ for (i = 0; i < def->niothreadids; i++) {
+ if (def->iothreadids[i]->iothread_id == iothread_id) {
+ for (j = i + 1; j < def->niothreadids; j++)
+ def->iothreadids[j]->autofill = false;
+
+ virDomainIOThreadIDDefFree(def->iothreadids[i]);
+ VIR_DELETE_ELEMENT(def->iothreadids, i, def->niothreadids);
+
+ break;
+ }
+ }
+
+ /* We have already deleted the iothread from the domain definition, now
+ * let's delete the info structure too from the domain-private data. */
+
+ priv = vm->privateData;
+
+ for (i = 0; i < priv->num_iothreads; i++) {
+ if (iothread_id == priv->iothreads[i]->id) {
+ VIR_DELETE_ELEMENT(priv->iothreads, i, priv->num_iothreads);
+ break;
+ }
+ }
+
+ ret = 0;
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
+
static int
testDomainSetUserPassword(virDomainPtr dom,
const char *user ATTRIBUTE_UNUSED,
@@ -9418,6 +9502,7 @@ static virHypervisorDriver testHypervisorDriver = {
.domainCoreDump = testDomainCoreDump, /* 0.3.2 */
.domainCoreDumpWithFormat = testDomainCoreDumpWithFormat, /* 1.2.3 */
.domainAddIOThread = testDomainAddIOThread, /* 5.7.0 */
+ .domainDelIOThread = testDomainDelIOThread, /* 5.7.0 */
.domainSetUserPassword = testDomainSetUserPassword, /* 5.6.0 */
.domainPinEmulator = testDomainPinEmulator, /* 5.6.0 */
.domainGetEmulatorPinInfo = testDomainGetEmulatorPinInfo, /* 5.6.0 */
--
2.22.0