[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2 09/33] qemu: Introduce virQEMUCapsFormatHostCPUModelInfo



The CPU model info formating code in virQEMUCapsFormatCache will get
more complicated soon. Separating the code in
virQEMUCapsFormatHostCPUModelInfo will make the result easier to read.

Signed-off-by: Jiri Denemark <jdenemar redhat com>
---

Notes:
    Version 2:
    - no change

 src/qemu/qemu_capabilities.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index c511248bd..688d19504 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3542,6 +3542,27 @@ virQEMUCapsLoadCache(virCapsPtr caps,
 
 
 static void
+virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsPtr qemuCaps,
+                                  virBufferPtr buf)
+{
+    qemuMonitorCPUModelInfoPtr model = qemuCaps->hostCPUModelInfo;
+    size_t i;
+
+    virBufferAsprintf(buf, "<hostCPU model='%s'>\n", model->name);
+    virBufferAdjustIndent(buf, 2);
+
+    for (i = 0; i < model->nprops; i++) {
+        virBufferAsprintf(buf, "<feature name='%s' supported='%s'/>\n",
+                          model->props[i].name,
+                          model->props[i].supported ? "yes" : "no");
+    }
+
+    virBufferAdjustIndent(buf, -2);
+    virBufferAddLit(buf, "</hostCPU>\n");
+}
+
+
+static void
 virQEMUCapsFormatCPUModels(virQEMUCapsPtr qemuCaps,
                            virBufferPtr buf,
                            virDomainVirtType type)
@@ -3617,19 +3638,8 @@ virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps,
     virBufferAsprintf(&buf, "<arch>%s</arch>\n",
                       virArchToString(qemuCaps->arch));
 
-    if (qemuCaps->hostCPUModelInfo) {
-        virBufferAsprintf(&buf, "<hostCPU model='%s'>\n",
-                          qemuCaps->hostCPUModelInfo->name);
-        virBufferAdjustIndent(&buf, 2);
-        for (i = 0; i < qemuCaps->hostCPUModelInfo->nprops; i++) {
-            virBufferAsprintf(&buf, "<feature name='%s' supported='%s'/>\n",
-                              qemuCaps->hostCPUModelInfo->props[i].name,
-                              qemuCaps->hostCPUModelInfo->props[i].supported ?
-                              "yes" : "no");
-        }
-        virBufferAdjustIndent(&buf, -2);
-        virBufferAddLit(&buf, "</hostCPU>\n");
-    }
+    if (qemuCaps->hostCPUModelInfo)
+        virQEMUCapsFormatHostCPUModelInfo(qemuCaps, &buf);
 
     virQEMUCapsFormatCPUModels(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM);
     virQEMUCapsFormatCPUModels(qemuCaps, &buf, VIR_DOMAIN_VIRT_QEMU);
-- 
2.11.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]