mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
cpu: Format <cpu/> properly
Well, not that we are not formatting invalid XML, rather than not as beautiful as we can: <cpu mode='host-passthrough'> </cpu> If there are no children, let's use the singleton element. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
33912cc03e
commit
0e69d97648
@ -435,6 +435,8 @@ virCPUDefFormatBufFull(virBufferPtr buf,
|
|||||||
bool updateCPU)
|
bool updateCPU)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
|
||||||
|
int indent = virBufferGetIndent(buf, false);
|
||||||
|
|
||||||
if (!def)
|
if (!def)
|
||||||
return 0;
|
return 0;
|
||||||
@ -464,23 +466,28 @@ virCPUDefFormatBufFull(virBufferPtr buf,
|
|||||||
virBufferAsprintf(buf, " match='%s'", tmp);
|
virBufferAsprintf(buf, " match='%s'", tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virBufferAddLit(buf, ">\n");
|
|
||||||
virBufferAdjustIndent(buf, 2);
|
|
||||||
|
|
||||||
|
virBufferAdjustIndent(&childrenBuf, indent + 2);
|
||||||
if (def->arch)
|
if (def->arch)
|
||||||
virBufferAsprintf(buf, "<arch>%s</arch>\n",
|
virBufferAsprintf(&childrenBuf, "<arch>%s</arch>\n",
|
||||||
virArchToString(def->arch));
|
virArchToString(def->arch));
|
||||||
if (virCPUDefFormatBuf(buf, def, updateCPU) < 0)
|
if (virCPUDefFormatBuf(&childrenBuf, def, updateCPU) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainNumaDefCPUFormat(buf, numa) < 0)
|
if (virDomainNumaDefCPUFormat(&childrenBuf, numa) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virBufferAdjustIndent(buf, -2);
|
if (virBufferUse(&childrenBuf)) {
|
||||||
virBufferAddLit(buf, "</cpu>\n");
|
virBufferAddLit(buf, ">\n");
|
||||||
|
virBufferAddBuffer(buf, &childrenBuf);
|
||||||
|
virBufferAddLit(buf, "</cpu>\n");
|
||||||
|
} else {
|
||||||
|
virBufferAddLit(buf, "/>\n");
|
||||||
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virBufferFreeAndReset(&childrenBuf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,7 @@
|
|||||||
<type arch='x86_64' machine='pc'>hvm</type>
|
<type arch='x86_64' machine='pc'>hvm</type>
|
||||||
<boot dev='network'/>
|
<boot dev='network'/>
|
||||||
</os>
|
</os>
|
||||||
<cpu mode='host-passthrough'>
|
<cpu mode='host-passthrough'/>
|
||||||
</cpu>
|
|
||||||
<clock offset='utc'>
|
<clock offset='utc'>
|
||||||
<timer name='kvmclock' present='no'/>
|
<timer name='kvmclock' present='no'/>
|
||||||
</clock>
|
</clock>
|
||||||
|
Loading…
Reference in New Issue
Block a user