conf: display all iothread ids in the XML if one of them is not generated

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2017-02-20 18:03:08 +01:00
parent 3fc6512a3d
commit a4a1ad2066
2 changed files with 17 additions and 8 deletions

View File

@ -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, "<iothreads>%lu</iothreads>\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, "<iothreadids>\n");
virBufferAdjustIndent(buf, 2);
for (i = 0; i < def->niothreadids; i++) {
if (def->iothreadids[i]->autofill)
continue;
virBufferAsprintf(buf, "<iothread id='%u'/>\n",
def->iothreadids[i]->iothread_id);
}

View File

@ -8,6 +8,8 @@
<iothreadids>
<iothread id='5'/>
<iothread id='6'/>
<iothread id='1'/>
<iothread id='2'/>
</iothreadids>
<os>
<type arch='i686' machine='pc'>hvm</type>