render / rpms / libvirt

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