render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
d76c62
From 4cbdc7ecefe8351e9e354c1906aba46869f220fd Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <4cbdc7ecefe8351e9e354c1906aba46869f220fd@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Mon, 16 Mar 2020 22:12:21 +0100
d76c62
Subject: [PATCH] qemu: domain: Extract parsing of 'commit' blockjob data into
d76c62
 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 38d0dd08d61446455ff54e0a7b97b1a48054b7c5)
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1799013
d76c62
Message-Id: <9689f027815d6fc799bae46ce9c12c3d55d9c728.1584391727.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/qemu/qemu_domain.c | 57 ++++++++++++++++++++++++++----------------
d76c62
 1 file changed, 36 insertions(+), 21 deletions(-)
d76c62
d76c62
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
d76c62
index a8ac68af92..0faf042145 100644
d76c62
--- a/src/qemu/qemu_domain.c
d76c62
+++ b/src/qemu/qemu_domain.c
d76c62
@@ -3236,6 +3236,40 @@ qemuDomainObjPrivateXMLParseBlockjobNodename(qemuBlockJobDataPtr job,
d76c62
 }
d76c62
 
d76c62
 
d76c62
+static int
d76c62
+qemuDomainObjPrivateXMLParseBlockjobDataCommit(qemuBlockJobDataPtr job,
d76c62
+                                               xmlXPathContextPtr ctxt)
d76c62
+{
d76c62
+    if (job->type == QEMU_BLOCKJOB_TYPE_COMMIT) {
d76c62
+        qemuDomainObjPrivateXMLParseBlockjobNodename(job,
d76c62
+                                                     "string(./topparent/@node)",
d76c62
+                                                     &job->data.commit.topparent,
d76c62
+                                                     ctxt);
d76c62
+
d76c62
+        if (!job->data.commit.topparent)
d76c62
+            return -1;
d76c62
+    }
d76c62
+
d76c62
+    qemuDomainObjPrivateXMLParseBlockjobNodename(job,
d76c62
+                                                 "string(./top/@node)",
d76c62
+                                                 &job->data.commit.top,
d76c62
+                                                 ctxt);
d76c62
+    qemuDomainObjPrivateXMLParseBlockjobNodename(job,
d76c62
+                                                 "string(./base/@node)",
d76c62
+                                                 &job->data.commit.base,
d76c62
+                                                 ctxt);
d76c62
+
d76c62
+    if (virXPathNode("./deleteCommittedImages", ctxt))
d76c62
+        job->data.commit.deleteCommittedImages = true;
d76c62
+
d76c62
+    if (!job->data.commit.top ||
d76c62
+        !job->data.commit.base)
d76c62
+        return -1;
d76c62
+
d76c62
+    return 0;
d76c62
+}
d76c62
+
d76c62
+
d76c62
 static void
d76c62
 qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qemuBlockJobDataPtr job,
d76c62
                                                  xmlXPathContextPtr ctxt,
d76c62
@@ -3255,29 +3289,10 @@ qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qemuBlockJobDataPtr job,
d76c62
             break;
d76c62
 
d76c62
         case QEMU_BLOCKJOB_TYPE_COMMIT:
d76c62
-            qemuDomainObjPrivateXMLParseBlockjobNodename(job,
d76c62
-                                                         "string(./topparent/@node)",
d76c62
-                                                         &job->data.commit.topparent,
d76c62
-                                                         ctxt);
d76c62
-
d76c62
-            if (!job->data.commit.topparent)
d76c62
-                goto broken;
d76c62
-
d76c62
-            G_GNUC_FALLTHROUGH;
d76c62
         case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
d76c62
-            qemuDomainObjPrivateXMLParseBlockjobNodename(job,
d76c62
-                                                         "string(./top/@node)",
d76c62
-                                                         &job->data.commit.top,
d76c62
-                                                         ctxt);
d76c62
-            qemuDomainObjPrivateXMLParseBlockjobNodename(job,
d76c62
-                                                         "string(./base/@node)",
d76c62
-                                                         &job->data.commit.base,
d76c62
-                                                         ctxt);
d76c62
-            if (virXPathNode("./deleteCommittedImages", ctxt))
d76c62
-                job->data.commit.deleteCommittedImages = true;
d76c62
-            if (!job->data.commit.top ||
d76c62
-                !job->data.commit.base)
d76c62
+            if (qemuDomainObjPrivateXMLParseBlockjobDataCommit(job, ctxt) < 0)
d76c62
                 goto broken;
d76c62
+
d76c62
             break;
d76c62
 
d76c62
         case QEMU_BLOCKJOB_TYPE_CREATE:
d76c62
-- 
d76c62
2.25.1
d76c62