render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
a41c76
From f306de1577b94e303cc6e6d50e48459751dfa02a Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <f306de1577b94e303cc6e6d50e48459751dfa02a@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Mon, 16 Mar 2020 22:12:20 +0100
a41c76
Subject: [PATCH] qemu: domain: Extract formatting of 'commit' blockjob data
a41c76
 into a function
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
I'll be adding more fields to care about so splitting the code out will
a41c76
be better long-term.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Pavel Mores <pmores@redhat.com>
a41c76
Reviewed-by: Eric Blake <eblake@redhat.com>
a41c76
(cherry picked from commit c72e9064ce2fd114aa5ac046f935d2a5661c8d20)
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1799013
a41c76
Message-Id: <98f3090755fcdb4b54deb37a004c9f0d0e40db31.1584391727.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_domain.c | 27 +++++++++++++++++++--------
a41c76
 1 file changed, 19 insertions(+), 8 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
a41c76
index cc47e7a2f0..a8ac68af92 100644
a41c76
--- a/src/qemu/qemu_domain.c
a41c76
+++ b/src/qemu/qemu_domain.c
a41c76
@@ -2599,6 +2599,24 @@ qemuDomainObjPrivateXMLFormatBlockjobFormatSource(virBufferPtr buf,
a41c76
 }
a41c76
 
a41c76
 
a41c76
+static void
a41c76
+qemuDomainPrivateBlockJobFormatCommit(qemuBlockJobDataPtr job,
a41c76
+                                      virBufferPtr buf)
a41c76
+{
a41c76
+    if (job->data.commit.base)
a41c76
+        virBufferAsprintf(buf, "<base node='%s'/>\n", job->data.commit.base->nodeformat);
a41c76
+
a41c76
+    if (job->data.commit.top)
a41c76
+        virBufferAsprintf(buf, "<top node='%s'/>\n", job->data.commit.top->nodeformat);
a41c76
+
a41c76
+    if (job->data.commit.topparent)
a41c76
+        virBufferAsprintf(buf, "<topparent node='%s'/>\n", job->data.commit.topparent->nodeformat);
a41c76
+
a41c76
+    if (job->data.commit.deleteCommittedImages)
a41c76
+        virBufferAddLit(buf, "<deleteCommittedImages/>\n");
a41c76
+}
a41c76
+
a41c76
+
a41c76
 static int
a41c76
 qemuDomainObjPrivateXMLFormatBlockjobIterator(void *payload,
a41c76
                                               const void *name G_GNUC_UNUSED,
a41c76
@@ -2658,14 +2676,7 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void *payload,
a41c76
 
a41c76
         case QEMU_BLOCKJOB_TYPE_COMMIT:
a41c76
         case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
a41c76
-            if (job->data.commit.base)
a41c76
-                virBufferAsprintf(&childBuf, "<base node='%s'/>\n", job->data.commit.base->nodeformat);
a41c76
-            if (job->data.commit.top)
a41c76
-                virBufferAsprintf(&childBuf, "<top node='%s'/>\n", job->data.commit.top->nodeformat);
a41c76
-            if (job->data.commit.topparent)
a41c76
-                virBufferAsprintf(&childBuf, "<topparent node='%s'/>\n", job->data.commit.topparent->nodeformat);
a41c76
-            if (job->data.commit.deleteCommittedImages)
a41c76
-                virBufferAddLit(&childBuf, "<deleteCommittedImages/>\n");
a41c76
+            qemuDomainPrivateBlockJobFormatCommit(job, &childBuf);
a41c76
             break;
a41c76
 
a41c76
         case QEMU_BLOCKJOB_TYPE_CREATE:
a41c76
-- 
a41c76
2.25.1
a41c76