All the code for formatting machine type data was moved to a standalone
virQEMUCapsFormatMachines function.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
Notes:
Version 3:
- new patch
src/qemu/qemu_capabilities.c | 37 ++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 4c0cba6a62..52a7248574 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4023,6 +4023,28 @@ virQEMUCapsFormatCPUModels(virQEMUCapsAccelPtr caps,
}
+static void
+virQEMUCapsFormatMachines(virQEMUCapsPtr qemuCaps,
+ virBufferPtr buf)
+{
+ size_t i;
+
+ for (i = 0; i < qemuCaps->nmachineTypes; i++) {
+ virBufferEscapeString(buf, "<machine name='%s'",
+ qemuCaps->machineTypes[i].name);
+ virBufferEscapeString(buf, " alias='%s'",
+ qemuCaps->machineTypes[i].alias);
+ if (qemuCaps->machineTypes[i].hotplugCpus)
+ virBufferAddLit(buf, " hotplugCpus='yes'");
+ virBufferAsprintf(buf, " maxCpus='%u'",
+ qemuCaps->machineTypes[i].maxCpus);
+ if (qemuCaps->machineTypes[i].qemuDefault)
+ virBufferAddLit(buf, " default='yes'");
+ virBufferAddLit(buf, "/>\n");
+ }
+}
+
+
static void
virQEMUCapsFormatAccel(virQEMUCapsPtr qemuCaps,
virBufferPtr buf,
@@ -4101,20 +4123,7 @@ virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps)
virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM);
virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_QEMU);
- for (i = 0; i < qemuCaps->nmachineTypes; i++) {
- virBufferEscapeString(&buf, "<machine name='%s'",
- qemuCaps->machineTypes[i].name);
- if (qemuCaps->machineTypes[i].alias)
- virBufferEscapeString(&buf, " alias='%s'",
- qemuCaps->machineTypes[i].alias);
- if (qemuCaps->machineTypes[i].hotplugCpus)
- virBufferAddLit(&buf, " hotplugCpus='yes'");
- virBufferAsprintf(&buf, " maxCpus='%u'",
- qemuCaps->machineTypes[i].maxCpus);
- if (qemuCaps->machineTypes[i].qemuDefault)
- virBufferAddLit(&buf, " default='yes'");
- virBufferAddLit(&buf, "/>\n");
- }
+ virQEMUCapsFormatMachines(qemuCaps, &buf);
for (i = 0; i < qemuCaps->ngicCapabilities; i++) {
virGICCapabilityPtr cap;
--
2.23.0