render / rpms / libvirt

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