On Wed, Mar 04, 2020 at 06:26:30PM +0100, Peter Krempa wrote:
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(a)redhat.com>
---
src/qemu/qemu_domain.c | 57 ++++++++++++++++++++++++++----------------
1 file changed, 36 insertions(+), 21 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 71d0a400cc..0a478d2080 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3153,6 +3153,40 @@ qemuDomainObjPrivateXMLParseBlockjobNodename(qemuBlockJobDataPtr
job,
}
+static int
+qemuDomainObjPrivateXMLParseBlockjobDataCommit(qemuBlockJobDataPtr job,
+ xmlXPathContextPtr ctxt)
+{
+ if (job->type == QEMU_BLOCKJOB_TYPE_COMMIT) {
+ qemuDomainObjPrivateXMLParseBlockjobNodename(job,
+
"string(./topparent/@node)",
+
&job->data.commit.topparent,
+ ctxt);
+
+ if (!job->data.commit.topparent)
+ return -1;
+ }
+
+ qemuDomainObjPrivateXMLParseBlockjobNodename(job,
+ "string(./top/@node)",
+ &job->data.commit.top,
+ ctxt);
+ qemuDomainObjPrivateXMLParseBlockjobNodename(job,
+ "string(./base/@node)",
+ &job->data.commit.base,
+ ctxt);
+
+ if (virXPathNode("./deleteCommittedImages", ctxt))
+ job->data.commit.deleteCommittedImages = true;
+
+ if (!job->data.commit.top ||
+ !job->data.commit.base)
+ return -1;
+
+ return 0;
+}
+
+
static void
qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qemuBlockJobDataPtr job,
xmlXPathContextPtr ctxt,
@@ -3172,29 +3206,10 @@
qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qemuBlockJobDataPtr job,
break;
case QEMU_BLOCKJOB_TYPE_COMMIT:
- qemuDomainObjPrivateXMLParseBlockjobNodename(job,
-
"string(./topparent/@node)",
-
&job->data.commit.topparent,
- ctxt);
-
- if (!job->data.commit.topparent)
- goto broken;
-
- G_GNUC_FALLTHROUGH;
case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
- qemuDomainObjPrivateXMLParseBlockjobNodename(job,
-
"string(./top/@node)",
- &job->data.commit.top,
- ctxt);
- qemuDomainObjPrivateXMLParseBlockjobNodename(job,
-
"string(./base/@node)",
- &job->data.commit.base,
- ctxt);
- if (virXPathNode("./deleteCommittedImages", ctxt))
- job->data.commit.deleteCommittedImages = true;
- if (!job->data.commit.top ||
- !job->data.commit.base)
+ if (qemuDomainObjPrivateXMLParseBlockjobDataCommit(job, ctxt) < 0)
goto broken;
+
break;
case QEMU_BLOCKJOB_TYPE_CREATE:
--
2.24.1
Reviewed-by: Pavel Mores <pmores(a)redhat.com>