diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index add857cb97df7fb903e062e28b60d59fb39dd07e..68cac1de01c974cb3c0599befd3d2edc8573531b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17476,12 +17476,21 @@ void virDomainIOThreadIDDel(virDomainDefPtr def, unsigned int iothread_id) { - int n; + size_t i, j; + + for (i = 0; i < def->niothreadids; i++) { + if (def->iothreadids[i]->iothread_id == iothread_id) { + /* If we were sequential and removed a threadid in the + * beginning or middle of the list, then unconditionally + * clear the autofill flag so we don't lose these + * definitions for XML formatting. + */ + 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); - for (n = 0; n < def->niothreadids; n++) { - if (def->iothreadids[n]->iothread_id == iothread_id) { - virDomainIOThreadIDDefFree(def->iothreadids[n]); - VIR_DELETE_ELEMENT(def->iothreadids, n, def->niothreadids); return; } }