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