From nobody Sat Apr 5 00:09:28 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1739204023; cv=none; d=zohomail.com; s=zohoarc; b=l37mS+71Lv2EypfrOc8NmCx/atqguNX4f1x2p78lI5m/rLUq+/Qcd8KdO2N63zfN+xQDqEqwexA3EFbEy61cNUIBTrW8aDP01/lvFk4YQbVuo57GwV24spE1YApPny521xDyY75k0xH6I57d5z98g+jJJiID4Q74LkeOJanOfwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739204023; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yzw6kPQK4fjsn/KDPQEjLySTEtEaxHvhHdbz5V3w+cw=; b=JCmICft0zCnVBXMxUpwPpgIAw+NGoGZbPewMce1uqFl1X5PiVAQj611S9pfdoUrjsXXP7RGsVuPqfgK87pomh4J0ndpznd384YH7Eekaws1/qLgCxYlLm0ssAhoOg3dgr/+JXaMCZJmSxGQ3u7DEkaUU7yPIzZxIPdiWzmhEDzA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1739204022982488.2066900037555; Mon, 10 Feb 2025 08:13:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWO7-0006pE-RA; Mon, 10 Feb 2025 11:11:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1thWNs-0006h8-TI for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:11:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1thWNp-00017z-TS for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:11:44 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-vfnsuIUrMNW6wM7MpzG0jA-1; Mon, 10 Feb 2025 11:11:39 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2D43319560AA; Mon, 10 Feb 2025 16:11:33 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.45.225.156]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D817C195608D; Mon, 10 Feb 2025 16:11:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739203901; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yzw6kPQK4fjsn/KDPQEjLySTEtEaxHvhHdbz5V3w+cw=; b=J7qYivGwVgw1ObYdvxOnf3If0/TG/Wc63jJH98TS6DClu6W/ASPb4DTQVlbSzNwFhsoGX0 zxNvr/qnmQQ4/eRmRJI8T1pVwcLr3tPnPwFFmf/63gvtUzM/s47QK/kvhIkpP1hLtospoF XDTBtQXbw5rfc0DrIp4V/UbYJVn+498= X-MC-Unique: vfnsuIUrMNW6wM7MpzG0jA-1 X-Mimecast-MFC-AGG-ID: vfnsuIUrMNW6wM7MpzG0jA From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 23/25] iotests: Add qsd-migrate case Date: Mon, 10 Feb 2025 17:10:32 +0100 Message-ID: <20250210161034.76494-24-kwolf@redhat.com> In-Reply-To: <20250210161034.76494-1-kwolf@redhat.com> References: <20250210161034.76494-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.388, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1739204024901019100 Content-Type: text/plain; charset="utf-8" Test that it's possible to migrate a VM that uses an image on shared storage through qemu-storage-daemon. Signed-off-by: Kevin Wolf Acked-by: Fabiano Rosas Reviewed-by: Eric Blake Message-ID: <20250204211407.381505-16-kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- tests/qemu-iotests/tests/qsd-migrate | 140 +++++++++++++++++++++++ tests/qemu-iotests/tests/qsd-migrate.out | 59 ++++++++++ 2 files changed, 199 insertions(+) create mode 100755 tests/qemu-iotests/tests/qsd-migrate create mode 100644 tests/qemu-iotests/tests/qsd-migrate.out diff --git a/tests/qemu-iotests/tests/qsd-migrate b/tests/qemu-iotests/test= s/qsd-migrate new file mode 100755 index 0000000000..de17562cb0 --- /dev/null +++ b/tests/qemu-iotests/tests/qsd-migrate @@ -0,0 +1,140 @@ +#!/usr/bin/env python3 +# group: rw quick +# +# Copyright (C) Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Creator/Owner: Kevin Wolf + +import iotests + +from iotests import filter_qemu_io, filter_qtest + +iotests.script_initialize(supported_fmts=3D['generic'], + supported_protocols=3D['file'], + supported_platforms=3D['linux']) + +with iotests.FilePath('disk.img') as path, \ + iotests.FilePath('nbd-src.sock', base_dir=3Diotests.sock_dir) as nbd_= src, \ + iotests.FilePath('nbd-dst.sock', base_dir=3Diotests.sock_dir) as nbd_= dst, \ + iotests.FilePath('migrate.sock', base_dir=3Diotests.sock_dir) as mig_= sock, \ + iotests.VM(path_suffix=3D"-src") as vm_src, \ + iotests.VM(path_suffix=3D"-dst") as vm_dst: + + img_size =3D '10M' + + iotests.log('Preparing disk...') + iotests.qemu_img_create('-f', iotests.imgfmt, path, img_size) + + iotests.log('Launching source QSD...') + qsd_src =3D iotests.QemuStorageDaemon( + '--blockdev', f'file,node-name=3Ddisk-file,filename=3D{path}', + '--blockdev', f'{iotests.imgfmt},file=3Ddisk-file,node-name=3Ddisk= -fmt', + '--nbd-server', f'addr.type=3Dunix,addr.path=3D{nbd_src}', + '--export', 'nbd,id=3Dexp0,node-name=3Ddisk-fmt,writable=3Dtrue,' + 'allow-inactive=3Dtrue', + qmp=3DTrue, + ) + + iotests.log('Launching source VM...') + vm_src.add_args('-blockdev', f'nbd,node-name=3Ddisk,server.type=3Dunix= ,' + f'server.path=3D{nbd_src},export=3Ddisk-f= mt') + vm_src.add_args('-device', 'virtio-blk,drive=3Ddisk,id=3Dvirtio0') + vm_src.launch() + + iotests.log('Launching destination QSD...') + qsd_dst =3D iotests.QemuStorageDaemon( + '--blockdev', f'file,node-name=3Ddisk-file,filename=3D{path},activ= e=3Doff', + '--blockdev', f'{iotests.imgfmt},file=3Ddisk-file,node-name=3Ddisk= -fmt,' + f'active=3Doff', + '--nbd-server', f'addr.type=3Dunix,addr.path=3D{nbd_dst}', + '--export', 'nbd,id=3Dexp0,node-name=3Ddisk-fmt,writable=3Dtrue,' + 'allow-inactive=3Dtrue', + qmp=3DTrue, + instance_id=3D'b', + ) + + iotests.log('Launching destination VM...') + vm_dst.add_args('-blockdev', f'nbd,node-name=3Ddisk,server.type=3Dunix= ,' + f'server.path=3D{nbd_dst},export=3Ddisk-f= mt') + vm_dst.add_args('-device', 'virtio-blk,drive=3Ddisk,id=3Dvirtio0') + vm_dst.add_args('-incoming', f'unix:{mig_sock}') + vm_dst.launch() + + iotests.log('\nTest I/O on the source') + vm_src.hmp_qemu_io('virtio0/virtio-backend', 'write -P 0x11 0 4k', + use_log=3DTrue, qdev=3DTrue) + vm_src.hmp_qemu_io('virtio0/virtio-backend', 'read -P 0x11 0 4k', + use_log=3DTrue, qdev=3DTrue) + + iotests.log('\nStarting migration...') + + mig_caps =3D [ + {'capability': 'events', 'state': True}, + {'capability': 'pause-before-switchover', 'state': True}, + ] + vm_src.qmp_log('migrate-set-capabilities', capabilities=3Dmig_caps) + vm_dst.qmp_log('migrate-set-capabilities', capabilities=3Dmig_caps) + vm_src.qmp_log('migrate', uri=3Df'unix:{mig_sock}', + filters=3D[iotests.filter_qmp_testfiles]) + + vm_src.event_wait('MIGRATION', + match=3D{'data': {'status': 'pre-switchover'}}) + + iotests.log('\nPre-switchover: Reconfigure QSD instances') + + iotests.log(qsd_src.qmp('blockdev-set-active', {'active': False})) + + # Reading is okay from both sides while the image is inactive. Note th= at + # the destination may have stale data until it activates the image, th= ough. + vm_src.hmp_qemu_io('virtio0/virtio-backend', 'read -P 0x11 0 4k', + use_log=3DTrue, qdev=3DTrue) + vm_dst.hmp_qemu_io('virtio0/virtio-backend', 'read 0 4k', + use_log=3DTrue, qdev=3DTrue) + + iotests.log(qsd_dst.qmp('blockdev-set-active', {'active': True})) + + iotests.log('\nCompleting migration...') + + vm_src.qmp_log('migrate-continue', state=3D'pre-switchover') + vm_dst.event_wait('MIGRATION', match=3D{'data': {'status': 'completed'= }}) + + iotests.log('\nTest I/O on the destination') + + # Now the destination must see what the source wrote + vm_dst.hmp_qemu_io('virtio0/virtio-backend', 'read -P 0x11 0 4k', + use_log=3DTrue, qdev=3DTrue) + + # And be able to overwrite it + vm_dst.hmp_qemu_io('virtio0/virtio-backend', 'write -P 0x22 0 4k', + use_log=3DTrue, qdev=3DTrue) + vm_dst.hmp_qemu_io('virtio0/virtio-backend', 'read -P 0x22 0 4k', + use_log=3DTrue, qdev=3DTrue) + + iotests.log('\nDone') + + vm_src.shutdown() + iotests.log('\n--- vm_src log ---') + log =3D vm_src.get_log() + if log: + iotests.log(log, [filter_qtest, filter_qemu_io]) + qsd_src.stop() + + vm_dst.shutdown() + iotests.log('\n--- vm_dst log ---') + log =3D vm_dst.get_log() + if log: + iotests.log(log, [filter_qtest, filter_qemu_io]) + qsd_dst.stop() diff --git a/tests/qemu-iotests/tests/qsd-migrate.out b/tests/qemu-iotests/= tests/qsd-migrate.out new file mode 100644 index 0000000000..4a5241e5d4 --- /dev/null +++ b/tests/qemu-iotests/tests/qsd-migrate.out @@ -0,0 +1,59 @@ +Preparing disk... +Launching source QSD... +Launching source VM... +Launching destination QSD... +Launching destination VM... + +Test I/O on the source +{"execute": "human-monitor-command", "arguments": {"command-line": "qemu-i= o -d virtio0/virtio-backend \"write -P 0x11 0 4k\""}} +{"return": ""} +{"execute": "human-monitor-command", "arguments": {"command-line": "qemu-i= o -d virtio0/virtio-backend \"read -P 0x11 0 4k\""}} +{"return": ""} + +Starting migration... +{"execute": "migrate-set-capabilities", "arguments": {"capabilities": [{"c= apability": "events", "state": true}, {"capability": "pause-before-switchov= er", "state": true}]}} +{"return": {}} +{"execute": "migrate-set-capabilities", "arguments": {"capabilities": [{"c= apability": "events", "state": true}, {"capability": "pause-before-switchov= er", "state": true}]}} +{"return": {}} +{"execute": "migrate", "arguments": {"uri": "unix:SOCK_DIR/PID-migrate.soc= k"}} +{"return": {}} + +Pre-switchover: Reconfigure QSD instances +{"return": {}} +{"execute": "human-monitor-command", "arguments": {"command-line": "qemu-i= o -d virtio0/virtio-backend \"read -P 0x11 0 4k\""}} +{"return": ""} +{"execute": "human-monitor-command", "arguments": {"command-line": "qemu-i= o -d virtio0/virtio-backend \"read 0 4k\""}} +{"return": ""} +{"return": {}} + +Completing migration... +{"execute": "migrate-continue", "arguments": {"state": "pre-switchover"}} +{"return": {}} + +Test I/O on the destination +{"execute": "human-monitor-command", "arguments": {"command-line": "qemu-i= o -d virtio0/virtio-backend \"read -P 0x11 0 4k\""}} +{"return": ""} +{"execute": "human-monitor-command", "arguments": {"command-line": "qemu-i= o -d virtio0/virtio-backend \"write -P 0x22 0 4k\""}} +{"return": ""} +{"execute": "human-monitor-command", "arguments": {"command-line": "qemu-i= o -d virtio0/virtio-backend \"read -P 0x22 0 4k\""}} +{"return": ""} + +Done + +--- vm_src log --- +wrote 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +--- vm_dst log --- +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) --=20 2.48.1