|
|
357786 |
From 561418d66933d9262f1678fda614dc0bde2a8f45 Mon Sep 17 00:00:00 2001
|
|
|
357786 |
From: John Snow <jsnow@redhat.com>
|
|
|
357786 |
Date: Tue, 24 Jul 2018 12:25:31 +0200
|
|
|
357786 |
Subject: [PATCH 62/89] iotests: add 222 to test basic fleecing
|
|
|
357786 |
|
|
|
357786 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
357786 |
Message-id: <20180718225511.14878-12-jsnow@redhat.com>
|
|
|
357786 |
Patchwork-id: 81407
|
|
|
357786 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 11/35] iotests: add 222 to test basic fleecing
|
|
|
357786 |
Bugzilla: 1207657
|
|
|
357786 |
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
|
357786 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
357786 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
357786 |
Message-Id: <20180702194630.9360-3-jsnow@redhat.com>
|
|
|
357786 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
357786 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
357786 |
(cherry picked from commit bacebdedbf921a2c641a34486ff543089d338f32)
|
|
|
357786 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
357786 |
---
|
|
|
357786 |
tests/qemu-iotests/222 | 155 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
357786 |
tests/qemu-iotests/222.out | 67 ++++++++++++++++++++
|
|
|
357786 |
tests/qemu-iotests/group | 1 +
|
|
|
357786 |
3 files changed, 223 insertions(+)
|
|
|
357786 |
create mode 100644 tests/qemu-iotests/222
|
|
|
357786 |
create mode 100644 tests/qemu-iotests/222.out
|
|
|
357786 |
|
|
|
357786 |
diff --git a/tests/qemu-iotests/222 b/tests/qemu-iotests/222
|
|
|
357786 |
new file mode 100644
|
|
|
357786 |
index 0000000..ff3bfc1
|
|
|
357786 |
--- /dev/null
|
|
|
357786 |
+++ b/tests/qemu-iotests/222
|
|
|
357786 |
@@ -0,0 +1,155 @@
|
|
|
357786 |
+#!/usr/bin/env python
|
|
|
357786 |
+#
|
|
|
357786 |
+# This test covers the basic fleecing workflow, which provides a
|
|
|
357786 |
+# point-in-time snapshot of a node that can be queried over NBD.
|
|
|
357786 |
+#
|
|
|
357786 |
+# Copyright (C) 2018 Red Hat, Inc.
|
|
|
357786 |
+# John helped, too.
|
|
|
357786 |
+#
|
|
|
357786 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
357786 |
+# it under the terms of the GNU General Public License as published by
|
|
|
357786 |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
357786 |
+# (at your option) any later version.
|
|
|
357786 |
+#
|
|
|
357786 |
+# This program is distributed in the hope that it will be useful,
|
|
|
357786 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
357786 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
357786 |
+# GNU General Public License for more details.
|
|
|
357786 |
+#
|
|
|
357786 |
+# You should have received a copy of the GNU General Public License
|
|
|
357786 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
357786 |
+#
|
|
|
357786 |
+# Creator/Owner: John Snow <jsnow@redhat.com>
|
|
|
357786 |
+
|
|
|
357786 |
+import iotests
|
|
|
357786 |
+from iotests import log, qemu_img, qemu_io, qemu_io_silent
|
|
|
357786 |
+
|
|
|
357786 |
+iotests.verify_platform(['linux'])
|
|
|
357786 |
+
|
|
|
357786 |
+patterns = [("0x5d", "0", "64k"),
|
|
|
357786 |
+ ("0xd5", "1M", "64k"),
|
|
|
357786 |
+ ("0xdc", "32M", "64k"),
|
|
|
357786 |
+ ("0xcd", "0x3ff0000", "64k")] # 64M - 64K
|
|
|
357786 |
+
|
|
|
357786 |
+overwrite = [("0xab", "0", "64k"), # Full overwrite
|
|
|
357786 |
+ ("0xad", "0x00f8000", "64k"), # Partial-left (1M-32K)
|
|
|
357786 |
+ ("0x1d", "0x2008000", "64k"), # Partial-right (32M+32K)
|
|
|
357786 |
+ ("0xea", "0x3fe0000", "64k")] # Adjacent-left (64M - 128K)
|
|
|
357786 |
+
|
|
|
357786 |
+zeroes = [("0", "0x00f8000", "32k"), # Left-end of partial-left (1M-32K)
|
|
|
357786 |
+ ("0", "0x2010000", "32k"), # Right-end of partial-right (32M+64K)
|
|
|
357786 |
+ ("0", "0x3fe0000", "64k")] # overwrite[3]
|
|
|
357786 |
+
|
|
|
357786 |
+remainder = [("0xd5", "0x108000", "32k"), # Right-end of partial-left [1]
|
|
|
357786 |
+ ("0xdc", "32M", "32k"), # Left-end of partial-right [2]
|
|
|
357786 |
+ ("0xcd", "0x3ff0000", "64k")] # patterns[3]
|
|
|
357786 |
+
|
|
|
357786 |
+with iotests.FilePath('base.img') as base_img_path, \
|
|
|
357786 |
+ iotests.FilePath('fleece.img') as fleece_img_path, \
|
|
|
357786 |
+ iotests.FilePath('nbd.sock') as nbd_sock_path, \
|
|
|
357786 |
+ iotests.VM() as vm:
|
|
|
357786 |
+
|
|
|
357786 |
+ log('--- Setting up images ---')
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+
|
|
|
357786 |
+ assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0
|
|
|
357786 |
+ assert qemu_img('create', '-f', "qcow2", fleece_img_path, '64M') == 0
|
|
|
357786 |
+
|
|
|
357786 |
+ for p in patterns:
|
|
|
357786 |
+ qemu_io('-f', iotests.imgfmt,
|
|
|
357786 |
+ '-c', 'write -P%s %s %s' % p, base_img_path)
|
|
|
357786 |
+
|
|
|
357786 |
+ log('Done')
|
|
|
357786 |
+
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+ log('--- Launching VM ---')
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+
|
|
|
357786 |
+ vm.add_drive(base_img_path)
|
|
|
357786 |
+ vm.launch()
|
|
|
357786 |
+ log('Done')
|
|
|
357786 |
+
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+ log('--- Setting up Fleecing Graph ---')
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+
|
|
|
357786 |
+ src_node = "drive0"
|
|
|
357786 |
+ tgt_node = "fleeceNode"
|
|
|
357786 |
+
|
|
|
357786 |
+ # create tgt_node backed by src_node
|
|
|
357786 |
+ log(vm.qmp("blockdev-add", **{
|
|
|
357786 |
+ "driver": "qcow2",
|
|
|
357786 |
+ "node-name": tgt_node,
|
|
|
357786 |
+ "file": {
|
|
|
357786 |
+ "driver": "file",
|
|
|
357786 |
+ "filename": fleece_img_path,
|
|
|
357786 |
+ },
|
|
|
357786 |
+ "backing": src_node,
|
|
|
357786 |
+ }))
|
|
|
357786 |
+
|
|
|
357786 |
+ # Establish COW from source to fleecing node
|
|
|
357786 |
+ log(vm.qmp("blockdev-backup",
|
|
|
357786 |
+ device=src_node,
|
|
|
357786 |
+ target=tgt_node,
|
|
|
357786 |
+ sync="none"))
|
|
|
357786 |
+
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+ log('--- Setting up NBD Export ---')
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+
|
|
|
357786 |
+ nbd_uri = 'nbd+unix:///%s?socket=%s' % (tgt_node, nbd_sock_path)
|
|
|
357786 |
+ log(vm.qmp("nbd-server-start",
|
|
|
357786 |
+ **{"addr": { "type": "unix",
|
|
|
357786 |
+ "data": { "path": nbd_sock_path } } }))
|
|
|
357786 |
+
|
|
|
357786 |
+ log(vm.qmp("nbd-server-add", device=tgt_node))
|
|
|
357786 |
+
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+ log('--- Sanity Check ---')
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+
|
|
|
357786 |
+ for p in (patterns + zeroes):
|
|
|
357786 |
+ cmd = "read -P%s %s %s" % p
|
|
|
357786 |
+ log(cmd)
|
|
|
357786 |
+ assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) == 0
|
|
|
357786 |
+
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+ log('--- Testing COW ---')
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+
|
|
|
357786 |
+ for p in overwrite:
|
|
|
357786 |
+ cmd = "write -P%s %s %s" % p
|
|
|
357786 |
+ log(cmd)
|
|
|
357786 |
+ log(vm.hmp_qemu_io(src_node, cmd))
|
|
|
357786 |
+
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+ log('--- Verifying Data ---')
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+
|
|
|
357786 |
+ for p in (patterns + zeroes):
|
|
|
357786 |
+ cmd = "read -P%s %s %s" % p
|
|
|
357786 |
+ log(cmd)
|
|
|
357786 |
+ assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) == 0
|
|
|
357786 |
+
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+ log('--- Cleanup ---')
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+
|
|
|
357786 |
+ log(vm.qmp('block-job-cancel', device=src_node))
|
|
|
357786 |
+ log(vm.event_wait('BLOCK_JOB_CANCELLED'),
|
|
|
357786 |
+ filters=[iotests.filter_qmp_event])
|
|
|
357786 |
+ log(vm.qmp('nbd-server-stop'))
|
|
|
357786 |
+ log(vm.qmp('blockdev-del', node_name=tgt_node))
|
|
|
357786 |
+ vm.shutdown()
|
|
|
357786 |
+
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+ log('--- Confirming writes ---')
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+
|
|
|
357786 |
+ for p in (overwrite + remainder):
|
|
|
357786 |
+ cmd = "read -P%s %s %s" % p
|
|
|
357786 |
+ log(cmd)
|
|
|
357786 |
+ assert qemu_io_silent(base_img_path, '-c', cmd) == 0
|
|
|
357786 |
+
|
|
|
357786 |
+ log('')
|
|
|
357786 |
+ log('Done')
|
|
|
357786 |
diff --git a/tests/qemu-iotests/222.out b/tests/qemu-iotests/222.out
|
|
|
357786 |
new file mode 100644
|
|
|
357786 |
index 0000000..48f336a
|
|
|
357786 |
--- /dev/null
|
|
|
357786 |
+++ b/tests/qemu-iotests/222.out
|
|
|
357786 |
@@ -0,0 +1,67 @@
|
|
|
357786 |
+--- Setting up images ---
|
|
|
357786 |
+
|
|
|
357786 |
+Done
|
|
|
357786 |
+
|
|
|
357786 |
+--- Launching VM ---
|
|
|
357786 |
+
|
|
|
357786 |
+Done
|
|
|
357786 |
+
|
|
|
357786 |
+--- Setting up Fleecing Graph ---
|
|
|
357786 |
+
|
|
|
357786 |
+{u'return': {}}
|
|
|
357786 |
+{u'return': {}}
|
|
|
357786 |
+
|
|
|
357786 |
+--- Setting up NBD Export ---
|
|
|
357786 |
+
|
|
|
357786 |
+{u'return': {}}
|
|
|
357786 |
+{u'return': {}}
|
|
|
357786 |
+
|
|
|
357786 |
+--- Sanity Check ---
|
|
|
357786 |
+
|
|
|
357786 |
+read -P0x5d 0 64k
|
|
|
357786 |
+read -P0xd5 1M 64k
|
|
|
357786 |
+read -P0xdc 32M 64k
|
|
|
357786 |
+read -P0xcd 0x3ff0000 64k
|
|
|
357786 |
+read -P0 0x00f8000 32k
|
|
|
357786 |
+read -P0 0x2010000 32k
|
|
|
357786 |
+read -P0 0x3fe0000 64k
|
|
|
357786 |
+
|
|
|
357786 |
+--- Testing COW ---
|
|
|
357786 |
+
|
|
|
357786 |
+write -P0xab 0 64k
|
|
|
357786 |
+{u'return': u''}
|
|
|
357786 |
+write -P0xad 0x00f8000 64k
|
|
|
357786 |
+{u'return': u''}
|
|
|
357786 |
+write -P0x1d 0x2008000 64k
|
|
|
357786 |
+{u'return': u''}
|
|
|
357786 |
+write -P0xea 0x3fe0000 64k
|
|
|
357786 |
+{u'return': u''}
|
|
|
357786 |
+
|
|
|
357786 |
+--- Verifying Data ---
|
|
|
357786 |
+
|
|
|
357786 |
+read -P0x5d 0 64k
|
|
|
357786 |
+read -P0xd5 1M 64k
|
|
|
357786 |
+read -P0xdc 32M 64k
|
|
|
357786 |
+read -P0xcd 0x3ff0000 64k
|
|
|
357786 |
+read -P0 0x00f8000 32k
|
|
|
357786 |
+read -P0 0x2010000 32k
|
|
|
357786 |
+read -P0 0x3fe0000 64k
|
|
|
357786 |
+
|
|
|
357786 |
+--- Cleanup ---
|
|
|
357786 |
+
|
|
|
357786 |
+{u'return': {}}
|
|
|
357786 |
+{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'drive0', u'type': u'backup', u'speed': 0, u'len': 67108864, u'offset': 393216}, u'event': u'BLOCK_JOB_CANCELLED'}
|
|
|
357786 |
+{u'return': {}}
|
|
|
357786 |
+{u'return': {}}
|
|
|
357786 |
+
|
|
|
357786 |
+--- Confirming writes ---
|
|
|
357786 |
+
|
|
|
357786 |
+read -P0xab 0 64k
|
|
|
357786 |
+read -P0xad 0x00f8000 64k
|
|
|
357786 |
+read -P0x1d 0x2008000 64k
|
|
|
357786 |
+read -P0xea 0x3fe0000 64k
|
|
|
357786 |
+read -P0xd5 0x108000 32k
|
|
|
357786 |
+read -P0xdc 32M 32k
|
|
|
357786 |
+read -P0xcd 0x3ff0000 64k
|
|
|
357786 |
+
|
|
|
357786 |
+Done
|
|
|
357786 |
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
|
|
|
357786 |
index 11498fd..be55905 100644
|
|
|
357786 |
--- a/tests/qemu-iotests/group
|
|
|
357786 |
+++ b/tests/qemu-iotests/group
|
|
|
357786 |
@@ -218,4 +218,5 @@
|
|
|
357786 |
217 rw auto quick
|
|
|
357786 |
218 rw auto quick
|
|
|
357786 |
219 rw auto
|
|
|
357786 |
+222 rw auto quick
|
|
|
357786 |
226 auto quick
|
|
|
357786 |
--
|
|
|
357786 |
1.8.3.1
|
|
|
357786 |
|