From nobody Mon Nov 25 05:19:31 2024 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=1717178885; cv=none; d=zohomail.com; s=zohoarc; b=nPq2r+XHy/kAS9owQFsKxoekGZHRV2Xhri5bOMx4To8Syq9OrDnN6inzBfRDGHvt55cyOfRPhJ69L0Ac9OGgwvG0VjkhayTczMUF7SNITLCc8ltx8hR0ELWlIk5lsXadiSDLsnkaZAi3Zrn2vPHpiD8bnKl24B1KpgHzbVYnwpM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717178885; h=Content-Type: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=YnruYBBBdA9Oe8gL91INL662nm0pO2g3Q1Z56AOjdoI=; b=ieFZy1k25SteHPDmQPF/WT7QIL6W3bIfC+Aakl3lUykK6aQwLdQwYfOWnFwzmGHaBHsbgZlnmol7r+eJTBOCDoGwxDaahOHeUWPoKduFBJ+R68hQh7rTCpGIUgf0xdoeRwMuVuBgXclHw07LXq2rk/xCccSbK98UUexj6tvnbBQ= 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 17171788853151000.6059847133238; Fri, 31 May 2024 11:08:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sD6eT-0002Ay-In; Fri, 31 May 2024 14:06:53 -0400 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 1sD6eR-00029q-TB for qemu-devel@nongnu.org; Fri, 31 May 2024 14:06:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sD6eO-0002kN-RW for qemu-devel@nongnu.org; Fri, 31 May 2024 14:06:51 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-618-O5e7EgMmOAaAB5maDYC4HA-1; Fri, 31 May 2024 14:06:43 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id C1617800169; Fri, 31 May 2024 18:06:42 +0000 (UTC) Received: from green.redhat.com (unknown [10.2.16.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 142C5492BC6; Fri, 31 May 2024 18:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717178806; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YnruYBBBdA9Oe8gL91INL662nm0pO2g3Q1Z56AOjdoI=; b=MC/M9ds3xoxpwos90ReyZpJUy7y/AhPXqGYfQyXf7+/kaKp4LFOHPAWYsbohv/CaIwo6Ip tu0QSj0ZPp1YUKu9/XYVWbgZ6UeS+w3BXK8RLeKHjUlWqqEimdEK6QYa8iVUlbSVfTdXC1 4sYhTeXA+RdiqAqRTm87bebC0ELBkjM= X-MC-Unique: O5e7EgMmOAaAB5maDYC4HA-1 From: Eric Blake To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Stefan Hajnoczi , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , qemu-stable@nongnu.org Subject: [PATCH v3 1/2] qio: Inherit follow_coroutine_ctx across TLS Date: Fri, 31 May 2024 13:04:58 -0500 Message-ID: <20240531180639.1392905-5-eblake@redhat.com> In-Reply-To: <20240531180639.1392905-4-eblake@redhat.com> References: <20240531180639.1392905-4-eblake@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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.133.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.085, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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: 1717178886176100001 Since qemu 8.2, the combination of NBD + TLS + iothread crashes on an assertion failure: qemu-kvm: ../io/channel.c:534: void qio_channel_restart_read(void *): Asser= tion `qemu_get_current_aio_context() =3D=3D qemu_coroutine_get_aio_context(= co)' failed. It turns out that when we removed AioContext locking, we did so by having NBD tell its qio channels that it wanted to opt in to qio_channel_set_follow_coroutine_ctx(); but while we opted in on the main channel, we did not opt in on the TLS wrapper channel. qemu-iotests has coverage of NBD+iothread and NBD+TLS, but apparently no coverage of NBD+TLS+iothread, or we would have noticed this regression sooner. (I'll add that in the next patch) But while we could manually opt in to the TLS channel in nbd/server.c (a one-line change), it is more generic if all qio channels that wrap other channels inherit the follow status, in the same way that they inherit feature bits. CC: Stefan Hajnoczi CC: Daniel P. Berrang=C3=A9 CC: qemu-stable@nongnu.org Fixes: https://issues.redhat.com/browse/RHEL-34786 Fixes: 06e0f098 ("io: follow coroutine AioContext in qio_channel_yield()", = v8.2.0) Signed-off-by: Eric Blake Reviewed-by: Stefan Hajnoczi Reviewed-by: Daniel P. Berrang=C3=A9 Message-ID: <20240518025246.791593-5-eblake@redhat.com> --- io/channel-tls.c | 26 +++++++++++++++----------- io/channel-websock.c | 1 + 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/io/channel-tls.c b/io/channel-tls.c index 1d9c9c72bfb..67b97000060 100644 --- a/io/channel-tls.c +++ b/io/channel-tls.c @@ -69,37 +69,40 @@ qio_channel_tls_new_server(QIOChannel *master, const char *aclname, Error **errp) { - QIOChannelTLS *ioc; + QIOChannelTLS *tioc; + QIOChannel *ioc; - ioc =3D QIO_CHANNEL_TLS(object_new(TYPE_QIO_CHANNEL_TLS)); + tioc =3D QIO_CHANNEL_TLS(object_new(TYPE_QIO_CHANNEL_TLS)); + ioc =3D QIO_CHANNEL(tioc); - ioc->master =3D master; + tioc->master =3D master; + ioc->follow_coroutine_ctx =3D master->follow_coroutine_ctx; if (qio_channel_has_feature(master, QIO_CHANNEL_FEATURE_SHUTDOWN)) { - qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_SHUT= DOWN); + qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN); } object_ref(OBJECT(master)); - ioc->session =3D qcrypto_tls_session_new( + tioc->session =3D qcrypto_tls_session_new( creds, NULL, aclname, QCRYPTO_TLS_CREDS_ENDPOINT_SERVER, errp); - if (!ioc->session) { + if (!tioc->session) { goto error; } qcrypto_tls_session_set_callbacks( - ioc->session, + tioc->session, qio_channel_tls_write_handler, qio_channel_tls_read_handler, - ioc); + tioc); - trace_qio_channel_tls_new_server(ioc, master, creds, aclname); - return ioc; + trace_qio_channel_tls_new_server(tioc, master, creds, aclname); + return tioc; error: - object_unref(OBJECT(ioc)); + object_unref(OBJECT(tioc)); return NULL; } @@ -116,6 +119,7 @@ qio_channel_tls_new_client(QIOChannel *master, ioc =3D QIO_CHANNEL(tioc); tioc->master =3D master; + ioc->follow_coroutine_ctx =3D master->follow_coroutine_ctx; if (qio_channel_has_feature(master, QIO_CHANNEL_FEATURE_SHUTDOWN)) { qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN); } diff --git a/io/channel-websock.c b/io/channel-websock.c index a12acc27cf2..de39f0d182d 100644 --- a/io/channel-websock.c +++ b/io/channel-websock.c @@ -883,6 +883,7 @@ qio_channel_websock_new_server(QIOChannel *master) ioc =3D QIO_CHANNEL(wioc); wioc->master =3D master; + ioc->follow_coroutine_ctx =3D master->follow_coroutine_ctx; if (qio_channel_has_feature(master, QIO_CHANNEL_FEATURE_SHUTDOWN)) { qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN); } --=20 2.45.1 From nobody Mon Nov 25 05:19:31 2024 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=1717178885; cv=none; d=zohomail.com; s=zohoarc; b=K6LZo4SM7pLYQDUV+GWzaNGnyg0P8whb4DK4clkgZXrNkNTzJtoJxOKG2U4xBRqd96H4eWYoo10ayzDHIllmJ8NJ4G3YkQObxj0yjraNS/arOVl5GWwPGK2s/Q/zJUvmK9RpgzAzS0crXuqKqeIkzoGfMIo1knJ674v3751RXXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717178885; h=Content-Type: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=BHEGoFPBRRM7n5Ye/e/Yv0LXuJQl1PwDp4h3b7lDHYY=; b=l46VBaNCop9l0zdOKbOR6Y+W2OYSQ7K2hjI3XhPJdrGRAIKuyWNDMwn6WOB98mcfZC4Exo8U59P1GU5/kg010LQO+OZPHpNb5idjGE+4Ros2xNmmJvWT2Cn1lztelr5YLoU/z+F681EqLh2JURgDf19j+wKK2Y8qFaLgGAZkRPQ= 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 1717178885312815.6754127838938; Fri, 31 May 2024 11:08:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sD6eS-0002AW-B8; Fri, 31 May 2024 14:06:52 -0400 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 1sD6eQ-00029e-Tv for qemu-devel@nongnu.org; Fri, 31 May 2024 14:06:50 -0400 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 1sD6eO-0002ka-ON for qemu-devel@nongnu.org; Fri, 31 May 2024 14:06:50 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-159-CTurRoVBNaG6OJsJRk-8xQ-1; Fri, 31 May 2024 14:06:45 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A262185A780; Fri, 31 May 2024 18:06:44 +0000 (UTC) Received: from green.redhat.com (unknown [10.2.16.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF86F400057; Fri, 31 May 2024 18:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717178808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BHEGoFPBRRM7n5Ye/e/Yv0LXuJQl1PwDp4h3b7lDHYY=; b=Tp4s1ye08UZ7L6m00CugbK8vH29Sk0F9HCjIxhmFI6V47lUFLdas9ewDd41pGtYnerEDcx AVtvRkKavYzh5x04S+rFyQEaf2/a/AmWb3N9KQHNCvvXCwzxMU7dYGwCTV34NDrJPYWPP4 fb5QahExXWdwmXS6AsXvTzywBmOJRzU= X-MC-Unique: CTurRoVBNaG6OJsJRk-8xQ-1 From: Eric Blake To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, qemu-stable@nongnu.org, "Richard W.M. Jones" , Vladimir Sementsov-Ogievskiy , Kevin Wolf , Hanna Reitz Subject: [PATCH v3 2/2] iotests: test NBD+TLS+iothread Date: Fri, 31 May 2024 13:04:59 -0500 Message-ID: <20240531180639.1392905-6-eblake@redhat.com> In-Reply-To: <20240531180639.1392905-4-eblake@redhat.com> References: <20240531180639.1392905-4-eblake@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.085, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1717178886239100003 Content-Type: text/plain; charset="utf-8" Prevent regressions when using NBD with TLS in the presence of iothreads, adding coverage the fix to qio channels made in the previous patch. The shell function pick_unused_port() was copied from nbdkit.git/tests/functions.sh.in, where it had all authors from Red Hat, agreeing to the resulting relicensing from 2-clause BSD to GPLv2. CC: qemu-stable@nongnu.org CC: "Richard W.M. Jones" Signed-off-by: Eric Blake --- tests/qemu-iotests/tests/nbd-tls-iothread | 168 ++++++++++++++++++ tests/qemu-iotests/tests/nbd-tls-iothread.out | 54 ++++++ 2 files changed, 222 insertions(+) create mode 100755 tests/qemu-iotests/tests/nbd-tls-iothread create mode 100644 tests/qemu-iotests/tests/nbd-tls-iothread.out diff --git a/tests/qemu-iotests/tests/nbd-tls-iothread b/tests/qemu-iotests= /tests/nbd-tls-iothread new file mode 100755 index 00000000000..a2fb07206e5 --- /dev/null +++ b/tests/qemu-iotests/tests/nbd-tls-iothread @@ -0,0 +1,168 @@ +#!/usr/bin/env bash +# group: rw quick +# +# Test of NBD+TLS+iothread +# +# Copyright (C) 2024 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=3Deblake@redhat.com + +seq=3D`basename $0` +echo "QA output created by $seq" + +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_qemu + _cleanup_test_img + rm -f "$dst_image" + tls_x509_cleanup +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +cd .. +. ./common.rc +. ./common.filter +. ./common.qemu +. ./common.tls +. ./common.nbd + +_supported_fmt qcow2 # Hardcoded to qcow2 command line and QMP below +_supported_proto file + +# pick_unused_port +# +# Picks and returns an "unused" port, setting the global variable +# $port. +# +# This is inherently racy, but we need it because qemu does not currently +# permit NBD+TLS over a Unix domain socket +pick_unused_port () +{ + if ! (ss --version) >/dev/null 2>&1; then + _notrun "ss utility required, skipped this test" + fi + + # Start at a random port to make it less likely that two parallel + # tests will conflict. + port=3D$(( 50000 + (RANDOM%15000) )) + while ss -ltn | grep -sqE ":$port\b"; do + ((port++)) + if [ $port -eq 65000 ]; then port=3D50000; fi + done + echo picked unused port +} + +tls_x509_init + +size=3D1G +DST_IMG=3D"$TEST_DIR/dst.qcow2" + +echo +echo "=3D=3D preparing TLS creds and spare port =3D=3D" + +pick_unused_port +tls_x509_create_root_ca "ca1" +tls_x509_create_server "ca1" "server1" +tls_x509_create_client "ca1" "client1" +tls_obj_base=3Dtls-creds-x509,id=3Dtls0,verify-peer=3Dtrue,dir=3D"${tls_di= r}" + +echo +echo "=3D=3D preparing image =3D=3D" + +_make_test_img $size +$QEMU_IMG create -f qcow2 "$DST_IMG" $size | _filter_img_create + +echo +echo =3D=3D=3D Starting Src QEMU =3D=3D=3D +echo + +_launch_qemu -machine q35 \ + -object iothread,id=3Diothread0 \ + -object "${tls_obj_base}"/client1,endpoint=3Dclient \ + -device '{"driver":"pcie-root-port", "id":"root0", "multifunction":tru= e, + "bus":"pcie.0"}' \ + -device '{"driver":"virtio-scsi-pci", "id":"virtio_scsi_pci0", + "bus":"root0", "iothread":"iothread0"}' \ + -device '{"driver":"scsi-hd", "id":"image1", "drive":"drive_image1", + "bus":"virtio_scsi_pci0.0"}' \ + -blockdev '{"driver":"file", "cache":{"direct":true, "no-flush":false}, + "filename":"'"$TEST_IMG"'", "node-name":"drive_sys1"}' \ + -blockdev '{"driver":"qcow2", "node-name":"drive_image1", + "file":"drive_sys1"}' +h1=3D$QEMU_HANDLE +_send_qemu_cmd $h1 '{"execute": "qmp_capabilities"}' 'return' + +echo +echo =3D=3D=3D Starting Dst VM2 =3D=3D=3D +echo + +_launch_qemu -machine q35 \ + -object iothread,id=3Diothread0 \ + -object "${tls_obj_base}"/server1,endpoint=3Dserver \ + -device '{"driver":"pcie-root-port", "id":"root0", "multifunction":tru= e, + "bus":"pcie.0"}' \ + -device '{"driver":"virtio-scsi-pci", "id":"virtio_scsi_pci0", + "bus":"root0", "iothread":"iothread0"}' \ + -device '{"driver":"scsi-hd", "id":"image1", "drive":"drive_image1", + "bus":"virtio_scsi_pci0.0"}' \ + -blockdev '{"driver":"file", "cache":{"direct":true, "no-flush":false}, + "filename":"'"$DST_IMG"'", "node-name":"drive_sys1"}' \ + -blockdev '{"driver":"qcow2", "node-name":"drive_image1", + "file":"drive_sys1"}' \ + -incoming defer +h2=3D$QEMU_HANDLE +_send_qemu_cmd $h2 '{"execute": "qmp_capabilities"}' 'return' + +echo +echo =3D=3D=3D Dst VM: Enable NBD server for incoming storage migration = =3D=3D=3D +echo + +_send_qemu_cmd $h2 '{"execute": "nbd-server-start", "arguments": + {"addr": {"type": "inet", "data": {"host": "127.0.0.1", "port": "'$por= t'"}}, + "tls-creds": "tls0"}}' '{"return": {}}' | sed "s/\"$port\"/P= ORT/g" +_send_qemu_cmd $h2 '{"execute": "block-export-add", "arguments": + {"node-name": "drive_image1", "type": "nbd", "writable": true, + "id": "drive_image1"}}' '{"return": {}}' + +echo +echo =3D=3D=3D Src VM: Mirror to dst NBD for outgoing storage migration = =3D=3D=3D +echo + +_send_qemu_cmd $h1 '{"execute": "blockdev-add", "arguments": + {"node-name": "mirror", "driver": "nbd", + "server": {"type": "inet", "host": "127.0.0.1", "port": "'$port'"}, + "export": "drive_image1", "tls-creds": "tls0", + "tls-hostname": "127.0.0.1"}}' '{"return": {}}' | sed "s/\"$port\"/PO= RT/g" +_send_qemu_cmd $h1 '{"execute": "blockdev-mirror", "arguments": + {"sync": "full", "device": "drive_image1", "target": "mirror", + "job-id": "drive_image1_53"}}' '{"return": {}}' +_timed_wait_for $h1 '"ready"' + +echo +echo =3D=3D=3D Cleaning up =3D=3D=3D +echo + +_send_qemu_cmd $h1 '{"execute":"quit"}' '' +_send_qemu_cmd $h2 '{"execute":"quit"}' '' + +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/tests/nbd-tls-iothread.out b/tests/qemu-iot= ests/tests/nbd-tls-iothread.out new file mode 100644 index 00000000000..1d83d4f903b --- /dev/null +++ b/tests/qemu-iotests/tests/nbd-tls-iothread.out @@ -0,0 +1,54 @@ +QA output created by nbd-tls-iothread + +=3D=3D preparing TLS creds and spare port =3D=3D +picked unused port +Generating a self signed certificate... +Generating a signed certificate... +Generating a signed certificate... + +=3D=3D preparing image =3D=3D +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 +Formatting 'TEST_DIR/dst.IMGFMT', fmt=3DIMGFMT size=3D1073741824 + +=3D=3D=3D Starting Src QEMU =3D=3D=3D + +{"execute": "qmp_capabilities"} +{"return": {}} + +=3D=3D=3D Starting Dst VM2 =3D=3D=3D + +{"execute": "qmp_capabilities"} +{"return": {}} + +=3D=3D=3D Dst VM: Enable NBD server for incoming storage migration =3D=3D= =3D + +{"execute": "nbd-server-start", "arguments": + {"addr": {"type": "inet", "data": {"host": "127.0.0.1", "port": PORT}}, + "tls-creds": "tls0"}} +{"return": {}} +{"execute": "block-export-add", "arguments": + {"node-name": "drive_image1", "type": "nbd", "writable": true, + "id": "drive_image1"}} +{"return": {}} + +=3D=3D=3D Src VM: Mirror to dst NBD for outgoing storage migration =3D=3D= =3D + +{"execute": "blockdev-add", "arguments": + {"node-name": "mirror", "driver": "nbd", + "server": {"type": "inet", "host": "127.0.0.1", "port": PORT}, + "export": "drive_image1", "tls-creds": "tls0", + "tls-hostname": "127.0.0.1"}} +{"return": {}} +{"execute": "blockdev-mirror", "arguments": + {"sync": "full", "device": "drive_image1", "target": "mirror", + "job-id": "drive_image1_53"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "drive_image1_53= "}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "drive_image1_53= "}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "drive_image1_53"}} + +=3D=3D=3D Cleaning up =3D=3D=3D + +{"execute":"quit"} +{"execute":"quit"} +*** done --=20 2.45.1