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

Jiri Denemark posted 33 patches 8 years, 11 months ago
There is a newer version of this series
[libvirt] [PATCH v2 09/33] qemu: Introduce virQEMUCapsFormatHostCPUModelInfo
Posted by Jiri Denemark 8 years, 11 months ago
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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 09/33] qemu: Introduce virQEMUCapsFormatHostCPUModelInfo
Posted by John Ferlan 8 years, 11 months ago

On 02/15/2017 11:44 AM, Jiri Denemark wrote:
> 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(-)
> 

ACK

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 09/33] qemu: Introduce virQEMUCapsFormatHostCPUModelInfo
Posted by Jiri Denemark 8 years, 11 months ago
On Tue, Feb 21, 2017 at 09:25:38 -0500, John Ferlan wrote:
> 
> 
> On 02/15/2017 11:44 AM, Jiri Denemark wrote:
> > 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(-)
> > 

Thanks. I pushed it since it didn't have any dependencies on the other
patches in this series.

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list