[PATCH 1/5] domain_capabilities: Move indentation adjustment out of virDomainCapsCPUCustomFormat()

Michal Privoznik via Devel posted 5 patches 1 week, 4 days ago
[PATCH 1/5] domain_capabilities: Move indentation adjustment out of virDomainCapsCPUCustomFormat()
Posted by Michal Privoznik via Devel 1 week, 4 days ago
From: Michal Privoznik <mprivozn@redhat.com>

The aim of virDomainCapsCPUCustomFormat() is to format CPU models
into given buffer. But it starts by adjusting indentation. Move
this one level up into the caller so that another buffer can be
used. This also makes the pattern match in the caller
(virDomainCapsCPUFormat()) with the rest of CPU related domcaps
formatting.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/conf/domain_capabilities.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 422b68c085..5a94edf9bc 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -446,8 +446,6 @@ virDomainCapsCPUCustomFormat(virBuffer *buf,
 {
     size_t i;
 
-    virBufferAdjustIndent(buf, 2);
-
     for (i = 0; i < custom->nmodels; i++) {
         virDomainCapsCPUModel *model = custom->models + i;
 
@@ -480,8 +478,6 @@ virDomainCapsCPUCustomFormat(virBuffer *buf,
             virBufferAddLit(buf, "</blockers>\n");
         }
     }
-
-    virBufferAdjustIndent(buf, -2);
 }
 
 static void
@@ -539,7 +535,9 @@ virDomainCapsCPUFormat(virBuffer *buf,
                       virCPUModeTypeToString(VIR_CPU_MODE_CUSTOM));
     if (cpu->custom && cpu->custom->nmodels) {
         virBufferAddLit(buf, "supported='yes'>\n");
+        virBufferAdjustIndent(buf, 2);
         virDomainCapsCPUCustomFormat(buf, cpu->custom);
+        virBufferAdjustIndent(buf, -2);
         virBufferAddLit(buf, "</mode>\n");
     } else {
         virBufferAddLit(buf, "supported='no'/>\n");
-- 
2.51.0
Re: [PATCH 1/5] domain_capabilities: Move indentation adjustment out of virDomainCapsCPUCustomFormat()
Posted by Peter Krempa via Devel 1 week, 4 days ago
On Mon, Nov 10, 2025 at 09:39:46 +0100, Michal Privoznik via Devel wrote:
> From: Michal Privoznik <mprivozn@redhat.com>
> 
> The aim of virDomainCapsCPUCustomFormat() is to format CPU models
> into given buffer. But it starts by adjusting indentation. Move
> this one level up into the caller so that another buffer can be
> used. This also makes the pattern match in the caller
> (virDomainCapsCPUFormat()) with the rest of CPU related domcaps
> formatting.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/conf/domain_capabilities.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>