render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
a41c76
From 4cbdc7ecefe8351e9e354c1906aba46869f220fd Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <4cbdc7ecefe8351e9e354c1906aba46869f220fd@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Mon, 16 Mar 2020 22:12:21 +0100
a41c76
Subject: [PATCH] qemu: domain: Extract parsing of 'commit' blockjob data into
a41c76
 a function
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
I'll be adding more fields to care about so splitting the code out will
a41c76
be better long-term.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Pavel Mores <pmores@redhat.com>
a41c76
Reviewed-by: Eric Blake <eblake@redhat.com>
a41c76
(cherry picked from commit 38d0dd08d61446455ff54e0a7b97b1a48054b7c5)
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1799013
a41c76
Message-Id: <9689f027815d6fc799bae46ce9c12c3d55d9c728.1584391727.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_domain.c | 57 ++++++++++++++++++++++++++----------------
a41c76
 1 file changed, 36 insertions(+), 21 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
a41c76
index a8ac68af92..0faf042145 100644
a41c76
--- a/src/qemu/qemu_domain.c
a41c76
+++ b/src/qemu/qemu_domain.c
a41c76
@@ -3236,6 +3236,40 @@ qemuDomainObjPrivateXMLParseBlockjobNodename(qemuBlockJobDataPtr job,
a41c76
 }
a41c76
 
a41c76
 
a41c76
+static int
a41c76
+qemuDomainObjPrivateXMLParseBlockjobDataCommit(qemuBlockJobDataPtr job,
a41c76
+                                               xmlXPathContextPtr ctxt)
a41c76
+{
a41c76
+    if (job->type == QEMU_BLOCKJOB_TYPE_COMMIT) {
a41c76
+        qemuDomainObjPrivateXMLParseBlockjobNodename(job,
a41c76
+                                                     "string(./topparent/@node)",
a41c76
+                                                     &job->data.commit.topparent,
a41c76
+                                                     ctxt);
a41c76
+
a41c76
+        if (!job->data.commit.topparent)
a41c76
+            return -1;
a41c76
+    }
a41c76
+
a41c76
+    qemuDomainObjPrivateXMLParseBlockjobNodename(job,
a41c76
+                                                 "string(./top/@node)",
a41c76
+                                                 &job->data.commit.top,
a41c76
+                                                 ctxt);
a41c76
+    qemuDomainObjPrivateXMLParseBlockjobNodename(job,
a41c76
+                                                 "string(./base/@node)",
a41c76
+                                                 &job->data.commit.base,
a41c76
+                                                 ctxt);
a41c76
+
a41c76
+    if (virXPathNode("./deleteCommittedImages", ctxt))
a41c76
+        job->data.commit.deleteCommittedImages = true;
a41c76
+
a41c76
+    if (!job->data.commit.top ||
a41c76
+        !job->data.commit.base)
a41c76
+        return -1;
a41c76
+
a41c76
+    return 0;
a41c76
+}
a41c76
+
a41c76
+
a41c76
 static void
a41c76
 qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qemuBlockJobDataPtr job,
a41c76
                                                  xmlXPathContextPtr ctxt,
a41c76
@@ -3255,29 +3289,10 @@ qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qemuBlockJobDataPtr job,
a41c76
             break;
a41c76
 
a41c76
         case QEMU_BLOCKJOB_TYPE_COMMIT:
a41c76
-            qemuDomainObjPrivateXMLParseBlockjobNodename(job,
a41c76
-                                                         "string(./topparent/@node)",
a41c76
-                                                         &job->data.commit.topparent,
a41c76
-                                                         ctxt);
a41c76
-
a41c76
-            if (!job->data.commit.topparent)
a41c76
-                goto broken;
a41c76
-
a41c76
-            G_GNUC_FALLTHROUGH;
a41c76
         case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
a41c76
-            qemuDomainObjPrivateXMLParseBlockjobNodename(job,
a41c76
-                                                         "string(./top/@node)",
a41c76
-                                                         &job->data.commit.top,
a41c76
-                                                         ctxt);
a41c76
-            qemuDomainObjPrivateXMLParseBlockjobNodename(job,
a41c76
-                                                         "string(./base/@node)",
a41c76
-                                                         &job->data.commit.base,
a41c76
-                                                         ctxt);
a41c76
-            if (virXPathNode("./deleteCommittedImages", ctxt))
a41c76
-                job->data.commit.deleteCommittedImages = true;
a41c76
-            if (!job->data.commit.top ||
a41c76
-                !job->data.commit.base)
a41c76
+            if (qemuDomainObjPrivateXMLParseBlockjobDataCommit(job, ctxt) < 0)
a41c76
                 goto broken;
a41c76
+
a41c76
             break;
a41c76
 
a41c76
         case QEMU_BLOCKJOB_TYPE_CREATE:
a41c76
-- 
a41c76
2.25.1
a41c76