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