|
|
7711c0 |
From 15ebf0b3bcbca92d0d63a67be3deee35572f1f00 Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
Date: Thu, 6 Dec 2018 10:03:56 +0100
|
|
|
7711c0 |
Subject: [PATCH 16/34] iotests: Test migration with -blockdev
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Message-id: <20181128092947.24543-3-kwolf@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 83181
|
|
|
7711c0 |
O-Subject: [RHEL-7.7/7.6.z qemu-kvm-rhev PATCH 2/2] iotests: Test migration with -blockdev
|
|
|
7711c0 |
Bugzilla: 1633536
|
|
|
7711c0 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Check that block node activation and inactivation works with a block
|
|
|
7711c0 |
graph that is built with individually created nodes.
|
|
|
7711c0 |
|
|
|
7711c0 |
RHEL: Disabled query-migrate call on the destination; this returns only
|
|
|
7711c0 |
an empty object in 2.12. Changed reference output for Python 2 (we lack
|
|
|
7711c0 |
the compatibility patches from upstream that make the output independent
|
|
|
7711c0 |
from the Python version).
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit 330ca111ea0979d8c6fc9b3958f72d6dce164d5a)
|
|
|
7711c0 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
tests/qemu-iotests/234 | 123 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
7711c0 |
tests/qemu-iotests/234.out | 28 +++++++++++
|
|
|
7711c0 |
tests/qemu-iotests/group | 1 +
|
|
|
7711c0 |
3 files changed, 152 insertions(+)
|
|
|
7711c0 |
create mode 100755 tests/qemu-iotests/234
|
|
|
7711c0 |
create mode 100644 tests/qemu-iotests/234.out
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/tests/qemu-iotests/234 b/tests/qemu-iotests/234
|
|
|
7711c0 |
new file mode 100755
|
|
|
7711c0 |
index 0000000..2b0f869
|
|
|
7711c0 |
--- /dev/null
|
|
|
7711c0 |
+++ b/tests/qemu-iotests/234
|
|
|
7711c0 |
@@ -0,0 +1,123 @@
|
|
|
7711c0 |
+#!/usr/bin/env python
|
|
|
7711c0 |
+#
|
|
|
7711c0 |
+# Copyright (C) 2018 Red Hat, Inc.
|
|
|
7711c0 |
+#
|
|
|
7711c0 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
7711c0 |
+# it under the terms of the GNU General Public License as published by
|
|
|
7711c0 |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
7711c0 |
+# (at your option) any later version.
|
|
|
7711c0 |
+#
|
|
|
7711c0 |
+# This program is distributed in the hope that it will be useful,
|
|
|
7711c0 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
7711c0 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
7711c0 |
+# GNU General Public License for more details.
|
|
|
7711c0 |
+#
|
|
|
7711c0 |
+# You should have received a copy of the GNU General Public License
|
|
|
7711c0 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
7711c0 |
+#
|
|
|
7711c0 |
+# Creator/Owner: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
+#
|
|
|
7711c0 |
+# Check that block node activation and inactivation works with a block graph
|
|
|
7711c0 |
+# that is built with individually created nodes
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+import iotests
|
|
|
7711c0 |
+import os
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+iotests.verify_image_format(supported_fmts=['qcow2'])
|
|
|
7711c0 |
+iotests.verify_platform(['linux'])
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+with iotests.FilePath('img') as img_path, \
|
|
|
7711c0 |
+ iotests.FilePath('backing') as backing_path, \
|
|
|
7711c0 |
+ iotests.FilePath('mig_fifo_a') as fifo_a, \
|
|
|
7711c0 |
+ iotests.FilePath('mig_fifo_b') as fifo_b, \
|
|
|
7711c0 |
+ iotests.VM(path_suffix='a') as vm_a, \
|
|
|
7711c0 |
+ iotests.VM(path_suffix='b') as vm_b:
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, backing_path, '64M')
|
|
|
7711c0 |
+ iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, img_path, '64M')
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ os.mkfifo(fifo_a)
|
|
|
7711c0 |
+ os.mkfifo(fifo_b)
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ iotests.log('Launching source VM...')
|
|
|
7711c0 |
+ (vm_a.add_blockdev('file,filename=%s,node-name=drive0-file' % (img_path))
|
|
|
7711c0 |
+ .add_blockdev('%s,file=drive0-file,node-name=drive0' % (iotests.imgfmt))
|
|
|
7711c0 |
+ .add_blockdev('file,filename=%s,node-name=drive0-backing-file' % (backing_path))
|
|
|
7711c0 |
+ .add_blockdev('%s,file=drive0-backing-file,node-name=drive0-backing' % (iotests.imgfmt))
|
|
|
7711c0 |
+ .launch())
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ iotests.log('Launching destination VM...')
|
|
|
7711c0 |
+ (vm_b.add_blockdev('file,filename=%s,node-name=drive0-file' % (img_path))
|
|
|
7711c0 |
+ .add_blockdev('%s,file=drive0-file,node-name=drive0' % (iotests.imgfmt))
|
|
|
7711c0 |
+ .add_blockdev('file,filename=%s,node-name=drive0-backing-file' % (backing_path))
|
|
|
7711c0 |
+ .add_blockdev('%s,file=drive0-backing-file,node-name=drive0-backing' % (iotests.imgfmt))
|
|
|
7711c0 |
+ .add_incoming("exec: cat '%s'" % (fifo_a))
|
|
|
7711c0 |
+ .launch())
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ # Add a child node that was created after the parent node. The reverse case
|
|
|
7711c0 |
+ # is covered by the -blockdev options above.
|
|
|
7711c0 |
+ iotests.log(vm_a.qmp('blockdev-snapshot', node='drive0-backing',
|
|
|
7711c0 |
+ overlay='drive0'))
|
|
|
7711c0 |
+ iotests.log(vm_b.qmp('blockdev-snapshot', node='drive0-backing',
|
|
|
7711c0 |
+ overlay='drive0'))
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ iotests.log('Enabling migration QMP events on A...')
|
|
|
7711c0 |
+ iotests.log(vm_a.qmp('migrate-set-capabilities', capabilities=[
|
|
|
7711c0 |
+ {
|
|
|
7711c0 |
+ 'capability': 'events',
|
|
|
7711c0 |
+ 'state': True
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
+ ]))
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ iotests.log('Starting migration to B...')
|
|
|
7711c0 |
+ iotests.log(vm_a.qmp('migrate', uri='exec:cat >%s' % (fifo_a)))
|
|
|
7711c0 |
+ with iotests.Timeout(3, 'Migration does not complete'):
|
|
|
7711c0 |
+ while True:
|
|
|
7711c0 |
+ event = vm_a.event_wait('MIGRATION')
|
|
|
7711c0 |
+ iotests.log(event, filters=[iotests.filter_qmp_event])
|
|
|
7711c0 |
+ if event['data']['status'] == 'completed':
|
|
|
7711c0 |
+ break
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ iotests.log(vm_a.qmp('query-migrate')['return']['status'])
|
|
|
7711c0 |
+ # Returns only {} on this QEMU version (no status)
|
|
|
7711c0 |
+ # iotests.log(vm_b.qmp('query-migrate')['return']['status'])
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ iotests.log(vm_a.qmp('query-status'))
|
|
|
7711c0 |
+ iotests.log(vm_b.qmp('query-status'))
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ iotests.log('Add a second parent to drive0-file...')
|
|
|
7711c0 |
+ iotests.log(vm_b.qmp('blockdev-add', driver='raw', file='drive0-file',
|
|
|
7711c0 |
+ node_name='drive0-raw'))
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ iotests.log('Restart A with -incoming and second parent...')
|
|
|
7711c0 |
+ vm_a.shutdown()
|
|
|
7711c0 |
+ (vm_a.add_blockdev('raw,file=drive0-file,node-name=drive0-raw')
|
|
|
7711c0 |
+ .add_incoming("exec: cat '%s'" % (fifo_b))
|
|
|
7711c0 |
+ .launch())
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ iotests.log(vm_a.qmp('blockdev-snapshot', node='drive0-backing',
|
|
|
7711c0 |
+ overlay='drive0'))
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ iotests.log('Enabling migration QMP events on B...')
|
|
|
7711c0 |
+ iotests.log(vm_b.qmp('migrate-set-capabilities', capabilities=[
|
|
|
7711c0 |
+ {
|
|
|
7711c0 |
+ 'capability': 'events',
|
|
|
7711c0 |
+ 'state': True
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
+ ]))
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ iotests.log('Starting migration back to A...')
|
|
|
7711c0 |
+ iotests.log(vm_b.qmp('migrate', uri='exec:cat >%s' % (fifo_b)))
|
|
|
7711c0 |
+ with iotests.Timeout(3, 'Migration does not complete'):
|
|
|
7711c0 |
+ while True:
|
|
|
7711c0 |
+ event = vm_b.event_wait('MIGRATION')
|
|
|
7711c0 |
+ iotests.log(event, filters=[iotests.filter_qmp_event])
|
|
|
7711c0 |
+ if event['data']['status'] == 'completed':
|
|
|
7711c0 |
+ break
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ # Returns only {} on this QEMU version (no status)
|
|
|
7711c0 |
+ # iotests.log(vm_a.qmp('query-migrate')['return']['status'])
|
|
|
7711c0 |
+ iotests.log(vm_b.qmp('query-migrate')['return']['status'])
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ iotests.log(vm_a.qmp('query-status'))
|
|
|
7711c0 |
+ iotests.log(vm_b.qmp('query-status'))
|
|
|
7711c0 |
diff --git a/tests/qemu-iotests/234.out b/tests/qemu-iotests/234.out
|
|
|
7711c0 |
new file mode 100644
|
|
|
7711c0 |
index 0000000..c7cd95f
|
|
|
7711c0 |
--- /dev/null
|
|
|
7711c0 |
+++ b/tests/qemu-iotests/234.out
|
|
|
7711c0 |
@@ -0,0 +1,28 @@
|
|
|
7711c0 |
+Launching source VM...
|
|
|
7711c0 |
+Launching destination VM...
|
|
|
7711c0 |
+{u'return': {}}
|
|
|
7711c0 |
+{u'return': {}}
|
|
|
7711c0 |
+Enabling migration QMP events on A...
|
|
|
7711c0 |
+{u'return': {}}
|
|
|
7711c0 |
+Starting migration to B...
|
|
|
7711c0 |
+{u'return': {}}
|
|
|
7711c0 |
+{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'setup'}, u'event': u'MIGRATION'}
|
|
|
7711c0 |
+{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'active'}, u'event': u'MIGRATION'}
|
|
|
7711c0 |
+{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'completed'}, u'event': u'MIGRATION'}
|
|
|
7711c0 |
+completed
|
|
|
7711c0 |
+{u'return': {u'status': u'postmigrate', u'singlestep': False, u'running': False}}
|
|
|
7711c0 |
+{u'return': {u'status': u'running', u'singlestep': False, u'running': True}}
|
|
|
7711c0 |
+Add a second parent to drive0-file...
|
|
|
7711c0 |
+{u'return': {}}
|
|
|
7711c0 |
+Restart A with -incoming and second parent...
|
|
|
7711c0 |
+{u'return': {}}
|
|
|
7711c0 |
+Enabling migration QMP events on B...
|
|
|
7711c0 |
+{u'return': {}}
|
|
|
7711c0 |
+Starting migration back to A...
|
|
|
7711c0 |
+{u'return': {}}
|
|
|
7711c0 |
+{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'setup'}, u'event': u'MIGRATION'}
|
|
|
7711c0 |
+{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'active'}, u'event': u'MIGRATION'}
|
|
|
7711c0 |
+{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'completed'}, u'event': u'MIGRATION'}
|
|
|
7711c0 |
+completed
|
|
|
7711c0 |
+{u'return': {u'status': u'running', u'singlestep': False, u'running': True}}
|
|
|
7711c0 |
+{u'return': {u'status': u'postmigrate', u'singlestep': False, u'running': False}}
|
|
|
7711c0 |
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
|
|
|
7711c0 |
index fcbf3f3..0998dcd 100644
|
|
|
7711c0 |
--- a/tests/qemu-iotests/group
|
|
|
7711c0 |
+++ b/tests/qemu-iotests/group
|
|
|
7711c0 |
@@ -226,3 +226,4 @@
|
|
|
7711c0 |
229 auto quick
|
|
|
7711c0 |
231 auto quick
|
|
|
7711c0 |
232 auto quick
|
|
|
7711c0 |
+234 auto quick migration
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|