thebeanogamer / rpms / qemu-kvm

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