[PATCH 2/7] domain_cof: Switch to virXMLFormatElement() in virDomainMemoryDefFormat()

Michal Privoznik via Devel posted 7 patches 1 month, 2 weeks ago
[PATCH 2/7] domain_cof: Switch to virXMLFormatElement() in virDomainMemoryDefFormat()
Posted by Michal Privoznik via Devel 1 month, 2 weeks ago
From: Michal Privoznik <mprivozn@redhat.com>

SSIA

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/conf/domain_conf.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0a647a1b44..0d32bcad47 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -26604,33 +26604,32 @@ virDomainMemoryDefFormat(virBuffer *buf,
                          unsigned int flags)
 {
     const char *model = virDomainMemoryModelTypeToString(def->model);
+    g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
+    g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
 
-    virBufferAsprintf(buf, "<memory model='%s'", model);
+    virBufferAsprintf(&attrBuf, " model='%s'", model);
     if (def->access)
-        virBufferAsprintf(buf, " access='%s'",
+        virBufferAsprintf(&attrBuf, " access='%s'",
                           virDomainMemoryAccessTypeToString(def->access));
     if (def->discard)
-        virBufferAsprintf(buf, " discard='%s'",
+        virBufferAsprintf(&attrBuf, " discard='%s'",
                           virTristateBoolTypeToString(def->discard));
-    virBufferAddLit(buf, ">\n");
-    virBufferAdjustIndent(buf, 2);
 
     if (def->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
         def->target.nvdimm.uuid) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
 
         virUUIDFormat(def->target.nvdimm.uuid, uuidstr);
-        virBufferAsprintf(buf, "<uuid>%s</uuid>\n", uuidstr);
+        virBufferAsprintf(&childBuf, "<uuid>%s</uuid>\n", uuidstr);
     }
 
-    virDomainMemorySourceDefFormat(buf, def);
+    virDomainMemorySourceDefFormat(&childBuf, def);
 
-    virDomainMemoryTargetDefFormat(buf, def, flags);
+    virDomainMemoryTargetDefFormat(&childBuf, def, flags);
 
-    virDomainDeviceInfoFormat(buf, &def->info, flags);
+    virDomainDeviceInfoFormat(&childBuf, &def->info, flags);
 
-    virBufferAdjustIndent(buf, -2);
-    virBufferAddLit(buf, "</memory>\n");
+    virXMLFormatElement(buf, "memory", &attrBuf, &childBuf);
 }
 
 static void
-- 
2.51.0
Re: [PATCH 2/7] domain_cof: Switch to virXMLFormatElement() in virDomainMemoryDefFormat()
Posted by Ján Tomko via Devel 1 month, 2 weeks ago
On a Wednesday in 2025, Michal Privoznik via Devel wrote:
>From: Michal Privoznik <mprivozn@redhat.com>
>
>SSIA

Instead of obscure acronyms, just leave the commit message blank

Also, s/cof/conf/ in the summary

Or s/domain_cof/conf/

Jano

>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> src/conf/domain_conf.c | 21 ++++++++++-----------
> 1 file changed, 10 insertions(+), 11 deletions(-)
>
Re: [PATCH 2/7] domain_cof: Switch to virXMLFormatElement() in virDomainMemoryDefFormat()
Posted by Jiri Denemark via Devel 1 month, 2 weeks ago
On Wed, Oct 29, 2025 at 08:53:02 +0100, Michal Privoznik wrote:
> From: Michal Privoznik <mprivozn@redhat.com>
> 
> SSIA
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/conf/domain_conf.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>