render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From 5e36101be25d8e80eb14635d9e3eccccaba43550 Mon Sep 17 00:00:00 2001
Message-Id: <5e36101be25d8e80eb14635d9e3eccccaba43550@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 16 Mar 2020 22:11:36 +0100
Subject: [PATCH] qemuDomainBlockPivot: Move check prior to executing the pivot
 steps
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Move the check whether the job is already synchronised to the beginning
of the function so that we don't try to do some of the steps necessary
for pivoting prior to actually wanting to pivot.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit a89ba6524c01473f3e5272dc787f01f806df32bb)

https://bugzilla.redhat.com/show_bug.cgi?id=1803092
Message-Id: <17682fad2c82b2f48505b3f8776bb75201eb2d89.1584391726.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/qemu_driver.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0bdb2851ec..bedd69ea2b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17561,6 +17561,13 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
     bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
     g_autoptr(virJSONValue) actions = NULL;
 
+    if (job->state != QEMU_BLOCKJOB_STATE_READY) {
+        virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
+                       _("block job '%s' not ready for pivot yet"),
+                       job->name);
+        return -1;
+    }
+
     switch ((qemuBlockJobType) job->type) {
     case QEMU_BLOCKJOB_TYPE_NONE:
     case QEMU_BLOCKJOB_TYPE_LAST:
@@ -17598,13 +17605,6 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
         break;
     }
 
-    if (job->state != QEMU_BLOCKJOB_STATE_READY) {
-        virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
-                       _("block job '%s' not ready for pivot yet"),
-                       job->name);
-        return -1;
-    }
-
     qemuDomainObjEnterMonitor(driver, vm);
     if (blockdev) {
         int rc = 0;
-- 
2.25.1