From nobody Fri Nov 7 14:35:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548190859139342.5806110504865; Tue, 22 Jan 2019 13:00:59 -0800 (PST) Received: from localhost ([127.0.0.1]:49703 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm3AH-00064X-Sr for importer@patchew.org; Tue, 22 Jan 2019 16:00:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm1wR-0008VH-PA for qemu-devel@nongnu.org; Tue, 22 Jan 2019 14:42:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gm1wQ-0001XS-Gm for qemu-devel@nongnu.org; Tue, 22 Jan 2019 14:42:35 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:58083) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gm1wQ-0001Ue-28; Tue, 22 Jan 2019 14:42:34 -0500 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1glyN1-0003Uk-8h; Tue, 22 Jan 2019 16:53:47 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1glyMl-0003p1-Mp; Tue, 22 Jan 2019 17:53:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=PmiB8gJjNwvCcThPwk3UusXlZAJqIGnqvhbtrhpklDA=; b=d/ztQ/L25q/ITrG7MVFU98Va0xbCYfRNaxpb7ybzCMzJcErHN7tXScXeLrEtfHMTb1rcZfWXFYwUhNTZsLD9jQ7YCcTa2D7LMNVlFxNt1ycaQrdQvilvoC8KyOv88Mfk4JY3JE8TKK3bRzgoEE5qFF2wu9fRT2wAwpp3q/0QhxuZ9hfkGvLmTyJtwRXgWwyYuSuA+RbwmvhtD7Z1D42XJmjMGxAG/yL3piTsqX0A986ogAZUdcqT6z3Bywf4DMI/wjTS1QNio0jxHhLoGd8Nwkyaa+y1iJdXpsqQ6VNm6GBRbm9yO9mvIpI6L0U8ulr1pq3Rgg+G/6vulvzMTziS1g==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Tue, 22 Jan 2019 17:53:23 +0200 Message-Id: <6ad371df66eecffccce29a0bd14695f40edd6120.1548171741.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH 3/3] virtio-scsi: Forbid devices with different iothreads sharing a blockdev X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch forbids attaching a disk to a SCSI device if its using a different AioContext. Test case included. Signed-off-by: Alberto Garcia --- hw/scsi/virtio-scsi.c | 7 +++++++ tests/qemu-iotests/240 | 22 ++++++++++++++++++++++ tests/qemu-iotests/240.out | 20 ++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index e1f7b208c7..eb90288f47 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -791,9 +791,16 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplu= g_dev, DeviceState *dev, SCSIDevice *sd =3D SCSI_DEVICE(dev); =20 if (s->ctx && !s->dataplane_fenced) { + AioContext *ctx; if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)= ) { return; } + ctx =3D blk_get_aio_context(sd->conf.blk); + if (ctx !=3D s->ctx && ctx !=3D qemu_get_aio_context()) { + error_setg(errp, "Cannot attach a blockdev that is using " + "a different iothread"); + return; + } virtio_scsi_acquire(s); blk_set_aio_context(sd->conf.blk, s->ctx); virtio_scsi_release(s); diff --git a/tests/qemu-iotests/240 b/tests/qemu-iotests/240 index 5d499c9a00..65cc3b39b1 100755 --- a/tests/qemu-iotests/240 +++ b/tests/qemu-iotests/240 @@ -101,6 +101,28 @@ run_qemu <