From a4a1ad2066fb772b7d22c38907bb0bbf258e4842 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Mon, 20 Feb 2017 18:03:08 +0100 Subject: [PATCH] conf: display all iothread ids in the XML if one of them is not generated Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 23 ++++++++++++------- .../qemuxml2xmlout-iothreads-ids-partial.xml | 2 ++ 2 files changed, 17 insertions(+), 8 deletions(-) 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