|
|
902636 |
From 239f7bdeef48a3c0b07098617371b9955dc55348 Mon Sep 17 00:00:00 2001
|
|
|
902636 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
902636 |
Date: Fri, 13 Mar 2020 12:34:36 +0000
|
|
|
902636 |
Subject: [PATCH 16/20] iotests: Test mirror with temporarily disabled target
|
|
|
902636 |
backing file
|
|
|
902636 |
|
|
|
902636 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
902636 |
Message-id: <20200313123439.10548-11-kwolf@redhat.com>
|
|
|
902636 |
Patchwork-id: 94288
|
|
|
902636 |
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH v2 10/13] iotests: Test mirror with temporarily disabled target backing file
|
|
|
902636 |
Bugzilla: 1790482 1805143
|
|
|
902636 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
902636 |
RH-Acked-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
902636 |
RH-Acked-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
902636 |
|
|
|
902636 |
The newly tested scenario is a common live storage migration scenario:
|
|
|
902636 |
The target node is opened without a backing file so that the active
|
|
|
902636 |
layer is mirrored while its backing chain can be copied in the
|
|
|
902636 |
background.
|
|
|
902636 |
|
|
|
902636 |
The backing chain should be attached to the mirror target node when
|
|
|
902636 |
finalising the job, just before switching the users of the source node
|
|
|
902636 |
to the new copy (at which point the mirror job still has a reference to
|
|
|
902636 |
the node). drive-mirror did this automatically, but with blockdev-mirror
|
|
|
902636 |
this is the job of the QMP client.
|
|
|
902636 |
|
|
|
902636 |
This patch adds test cases for two ways to achieve the desired result,
|
|
|
902636 |
using either x-blockdev-reopen or blockdev-snapshot.
|
|
|
902636 |
|
|
|
902636 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
902636 |
Message-Id: <20200310113831.27293-5-kwolf@redhat.com>
|
|
|
902636 |
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
902636 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
902636 |
(cherry picked from commit 8bdee9f10eac2aefdcc5095feef756354c87bdec)
|
|
|
902636 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
902636 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
902636 |
---
|
|
|
902636 |
tests/qemu-iotests/155 | 56 +++++++++++++++++++++++++++++++++++++++++-----
|
|
|
902636 |
tests/qemu-iotests/155.out | 4 ++--
|
|
|
902636 |
2 files changed, 53 insertions(+), 7 deletions(-)
|
|
|
902636 |
|
|
|
902636 |
diff --git a/tests/qemu-iotests/155 b/tests/qemu-iotests/155
|
|
|
902636 |
index d7ef257..3053e50 100755
|
|
|
902636 |
--- a/tests/qemu-iotests/155
|
|
|
902636 |
+++ b/tests/qemu-iotests/155
|
|
|
902636 |
@@ -45,10 +45,15 @@ target_img = os.path.join(iotests.test_dir, 'target.' + iotests.imgfmt)
|
|
|
902636 |
# image during runtime, only makes sense if
|
|
|
902636 |
# target_blockdev_backing is not None
|
|
|
902636 |
# (None: same as target_backing)
|
|
|
902636 |
+# target_open_with_backing: If True, the target image is added with its backing
|
|
|
902636 |
+# chain opened right away. If False, blockdev-add
|
|
|
902636 |
+# opens it without a backing file and job completion
|
|
|
902636 |
+# is supposed to open the backing chain.
|
|
|
902636 |
|
|
|
902636 |
class BaseClass(iotests.QMPTestCase):
|
|
|
902636 |
target_blockdev_backing = None
|
|
|
902636 |
target_real_backing = None
|
|
|
902636 |
+ target_open_with_backing = True
|
|
|
902636 |
|
|
|
902636 |
def setUp(self):
|
|
|
902636 |
qemu_img('create', '-f', iotests.imgfmt, back0_img, '1440K')
|
|
|
902636 |
@@ -80,9 +85,13 @@ class BaseClass(iotests.QMPTestCase):
|
|
|
902636 |
options = { 'node-name': 'target',
|
|
|
902636 |
'driver': iotests.imgfmt,
|
|
|
902636 |
'file': { 'driver': 'file',
|
|
|
902636 |
+ 'node-name': 'target-file',
|
|
|
902636 |
'filename': target_img } }
|
|
|
902636 |
- if self.target_blockdev_backing:
|
|
|
902636 |
- options['backing'] = self.target_blockdev_backing
|
|
|
902636 |
+
|
|
|
902636 |
+ if not self.target_open_with_backing:
|
|
|
902636 |
+ options['backing'] = None
|
|
|
902636 |
+ elif self.target_blockdev_backing:
|
|
|
902636 |
+ options['backing'] = self.target_blockdev_backing
|
|
|
902636 |
|
|
|
902636 |
result = self.vm.qmp('blockdev-add', **options)
|
|
|
902636 |
self.assert_qmp(result, 'return', {})
|
|
|
902636 |
@@ -147,10 +156,14 @@ class BaseClass(iotests.QMPTestCase):
|
|
|
902636 |
# cmd: Mirroring command to execute, either drive-mirror or blockdev-mirror
|
|
|
902636 |
|
|
|
902636 |
class MirrorBaseClass(BaseClass):
|
|
|
902636 |
+ def openBacking(self):
|
|
|
902636 |
+ pass
|
|
|
902636 |
+
|
|
|
902636 |
def runMirror(self, sync):
|
|
|
902636 |
if self.cmd == 'blockdev-mirror':
|
|
|
902636 |
result = self.vm.qmp(self.cmd, job_id='mirror-job', device='source',
|
|
|
902636 |
- sync=sync, target='target')
|
|
|
902636 |
+ sync=sync, target='target',
|
|
|
902636 |
+ auto_finalize=False)
|
|
|
902636 |
else:
|
|
|
902636 |
if self.existing:
|
|
|
902636 |
mode = 'existing'
|
|
|
902636 |
@@ -159,11 +172,12 @@ class MirrorBaseClass(BaseClass):
|
|
|
902636 |
result = self.vm.qmp(self.cmd, job_id='mirror-job', device='source',
|
|
|
902636 |
sync=sync, target=target_img,
|
|
|
902636 |
format=iotests.imgfmt, mode=mode,
|
|
|
902636 |
- node_name='target')
|
|
|
902636 |
+ node_name='target', auto_finalize=False)
|
|
|
902636 |
|
|
|
902636 |
self.assert_qmp(result, 'return', {})
|
|
|
902636 |
|
|
|
902636 |
- self.complete_and_wait('mirror-job')
|
|
|
902636 |
+ self.vm.run_job('mirror-job', use_log=False, auto_finalize=False,
|
|
|
902636 |
+ pre_finalize=self.openBacking, auto_dismiss=True)
|
|
|
902636 |
|
|
|
902636 |
def testFull(self):
|
|
|
902636 |
self.runMirror('full')
|
|
|
902636 |
@@ -221,6 +235,38 @@ class TestBlockdevMirrorForcedBacking(MirrorBaseClass):
|
|
|
902636 |
target_blockdev_backing = { 'driver': 'null-co' }
|
|
|
902636 |
target_real_backing = 'null-co://'
|
|
|
902636 |
|
|
|
902636 |
+# Attach the backing chain only during completion, with blockdev-reopen
|
|
|
902636 |
+class TestBlockdevMirrorReopen(MirrorBaseClass):
|
|
|
902636 |
+ cmd = 'blockdev-mirror'
|
|
|
902636 |
+ existing = True
|
|
|
902636 |
+ target_backing = 'null-co://'
|
|
|
902636 |
+ target_open_with_backing = False
|
|
|
902636 |
+
|
|
|
902636 |
+ def openBacking(self):
|
|
|
902636 |
+ if not self.target_open_with_backing:
|
|
|
902636 |
+ result = self.vm.qmp('blockdev-add', node_name="backing",
|
|
|
902636 |
+ driver="null-co")
|
|
|
902636 |
+ self.assert_qmp(result, 'return', {})
|
|
|
902636 |
+ result = self.vm.qmp('x-blockdev-reopen', node_name="target",
|
|
|
902636 |
+ driver=iotests.imgfmt, file="target-file",
|
|
|
902636 |
+ backing="backing")
|
|
|
902636 |
+ self.assert_qmp(result, 'return', {})
|
|
|
902636 |
+
|
|
|
902636 |
+# Attach the backing chain only during completion, with blockdev-snapshot
|
|
|
902636 |
+class TestBlockdevMirrorSnapshot(MirrorBaseClass):
|
|
|
902636 |
+ cmd = 'blockdev-mirror'
|
|
|
902636 |
+ existing = True
|
|
|
902636 |
+ target_backing = 'null-co://'
|
|
|
902636 |
+ target_open_with_backing = False
|
|
|
902636 |
+
|
|
|
902636 |
+ def openBacking(self):
|
|
|
902636 |
+ if not self.target_open_with_backing:
|
|
|
902636 |
+ result = self.vm.qmp('blockdev-add', node_name="backing",
|
|
|
902636 |
+ driver="null-co")
|
|
|
902636 |
+ self.assert_qmp(result, 'return', {})
|
|
|
902636 |
+ result = self.vm.qmp('blockdev-snapshot', node="backing",
|
|
|
902636 |
+ overlay="target")
|
|
|
902636 |
+ self.assert_qmp(result, 'return', {})
|
|
|
902636 |
|
|
|
902636 |
class TestCommit(BaseClass):
|
|
|
902636 |
existing = False
|
|
|
902636 |
diff --git a/tests/qemu-iotests/155.out b/tests/qemu-iotests/155.out
|
|
|
902636 |
index 4176bb9..4fd1c2d 100644
|
|
|
902636 |
--- a/tests/qemu-iotests/155.out
|
|
|
902636 |
+++ b/tests/qemu-iotests/155.out
|
|
|
902636 |
@@ -1,5 +1,5 @@
|
|
|
902636 |
-...................
|
|
|
902636 |
+.........................
|
|
|
902636 |
----------------------------------------------------------------------
|
|
|
902636 |
-Ran 19 tests
|
|
|
902636 |
+Ran 25 tests
|
|
|
902636 |
|
|
|
902636 |
OK
|
|
|
902636 |
--
|
|
|
902636 |
1.8.3.1
|
|
|
902636 |
|