diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d437fbf020..f39e9ec465 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23658,6 +23658,20 @@ virDomainCpuDefFormat(virBufferPtr buf, } +static bool +virDomainDefIothreadShouldFormat(virDomainDefPtr def) +{ + size_t i; + + for (i = 0; i < def->niothreadids; i++) { + if (!def->iothreadids[i]->autofill) + return true; + } + + return false; +} + + /* This internal version appends to an existing buffer * (possibly with auto-indent), rather than flattening * to string. @@ -23851,17 +23865,10 @@ virDomainDefFormatInternal(virDomainDefPtr def, if (def->niothreadids > 0) { virBufferAsprintf(buf, "%lu\n", def->niothreadids); - /* Only print out iothreadids if we read at least one */ - for (i = 0; i < def->niothreadids; i++) { - if (!def->iothreadids[i]->autofill) - break; - } - if (i < def->niothreadids) { + if (virDomainDefIothreadShouldFormat(def)) { virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); for (i = 0; i < def->niothreadids; i++) { - if (def->iothreadids[i]->autofill) - continue; virBufferAsprintf(buf, "\n", def->iothreadids[i]->iothread_id); } diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-ids-partial.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-ids-partial.xml index d6deced96a..276b6a61a2 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-ids-partial.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-ids-partial.xml @@ -8,6 +8,8 @@ + + hvm