]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: domain: Extract formatting of 'commit' blockjob data into a function
authorPeter Krempa <pkrempa@redhat.com>
Tue, 25 Feb 2020 06:14:13 +0000 (07:14 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 16 Mar 2020 16:33:08 +0000 (17:33 +0100)
I'll be adding more fields to care about so splitting the code out will
be better long-term.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
src/qemu/qemu_domain.c

index bdf62224cadab9be63907ebc8a4d47d1e284e56a..8f22f0e43285b699302241801ec2a45386a1f0d7 100644 (file)
@@ -2607,6 +2607,24 @@ qemuDomainObjPrivateXMLFormatBlockjobFormatSource(virBufferPtr buf,
 }
 
 
+static void
+qemuDomainPrivateBlockJobFormatCommit(qemuBlockJobDataPtr job,
+                                      virBufferPtr buf)
+{
+    if (job->data.commit.base)
+        virBufferAsprintf(buf, "<base node='%s'/>\n", job->data.commit.base->nodeformat);
+
+    if (job->data.commit.top)
+        virBufferAsprintf(buf, "<top node='%s'/>\n", job->data.commit.top->nodeformat);
+
+    if (job->data.commit.topparent)
+        virBufferAsprintf(buf, "<topparent node='%s'/>\n", job->data.commit.topparent->nodeformat);
+
+    if (job->data.commit.deleteCommittedImages)
+        virBufferAddLit(buf, "<deleteCommittedImages/>\n");
+}
+
+
 static int
 qemuDomainObjPrivateXMLFormatBlockjobIterator(void *payload,
                                               const void *name G_GNUC_UNUSED,
@@ -2666,14 +2684,7 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void *payload,
 
         case QEMU_BLOCKJOB_TYPE_COMMIT:
         case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
-            if (job->data.commit.base)
-                virBufferAsprintf(&childBuf, "<base node='%s'/>\n", job->data.commit.base->nodeformat);
-            if (job->data.commit.top)
-                virBufferAsprintf(&childBuf, "<top node='%s'/>\n", job->data.commit.top->nodeformat);
-            if (job->data.commit.topparent)
-                virBufferAsprintf(&childBuf, "<topparent node='%s'/>\n", job->data.commit.topparent->nodeformat);
-            if (job->data.commit.deleteCommittedImages)
-                virBufferAddLit(&childBuf, "<deleteCommittedImages/>\n");
+            qemuDomainPrivateBlockJobFormatCommit(job, &childBuf);
             break;
 
         case QEMU_BLOCKJOB_TYPE_CREATE: