render / rpms / libvirt

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