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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548191147408330.2704299380139; Tue, 22 Jan 2019 13:05:47 -0800 (PST) Received: from localhost ([127.0.0.1]:49793 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm3Ek-0001EQ-5J for importer@patchew.org; Tue, 22 Jan 2019 16:05:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm1wQ-0008TX-0y for qemu-devel@nongnu.org; Tue, 22 Jan 2019 14:42:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gm1wN-0001UH-W7 for qemu-devel@nongnu.org; Tue, 22 Jan 2019 14:42:33 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:58080) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gm1wL-0001Q8-Uu; Tue, 22 Jan 2019 14:42:31 -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-0003Ul-9i; Tue, 22 Jan 2019 16:53:47 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1glyMl-0003ox-Kp; 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=OZ8n/qJLbfwe43gkjCASVFZNwa7d8OoxEwSMdDPefYw=; b=ps7fV2PxRydoxNNVnF4lhRDaKcfURKWRW9PNGSRoosbOMHLeU5riEGiwvB9Sgq4GSm4IoQnrkmwaoXqMoEjbZC/0eBVUYwEfqNL/vx+yUcUxGGtL7uYqZ1wBj0EXJuXpcWmvLt86+B/d2yrKW2ax+erJGkbFJg2OQdxQquHbw5NC28FjZ7RvOBu2JvWqk9pJVEHkqhJsQByN0Zn9WhuGgx41v98ulVlJ5TUk2QoP47npTZ73ipaLDmOibj8+lU1+8hRnViVqPxpZDOA8E3wBcPLHB7Hak0XtzO9B0Zu36tDDa1taxmoXMrpEV+x+MAOk8Tor7qP30IlsOnV0Gm4J0Q==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Tue, 22 Jan 2019 17:53:21 +0200 Message-Id: <98776952d40d436b2741f6c141ae618bdf6f83a5.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 1/3] virtio-scsi: Move BlockBackend back to the main AioContext on unplug 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 fixes a crash when attaching a disk to a SCSI device using iothreads, then detaching it and reattaching it again. Test case included. Signed-off-by: Alberto Garcia --- hw/scsi/virtio-scsi.c | 6 ++++ tests/qemu-iotests/240 | 89 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/240.out | 18 ++++++++++ tests/qemu-iotests/group | 1 + 4 files changed, 114 insertions(+) create mode 100755 tests/qemu-iotests/240 create mode 100644 tests/qemu-iotests/240.out diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 3aa99717e2..e1f7b208c7 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -824,6 +824,12 @@ static void virtio_scsi_hotunplug(HotplugHandler *hotp= lug_dev, DeviceState *dev, virtio_scsi_release(s); } =20 + if (s->ctx) { + virtio_scsi_acquire(s); + blk_set_aio_context(sd->conf.blk, qemu_get_aio_context()); + virtio_scsi_release(s); + } + qdev_simple_device_unplug_cb(hotplug_dev, dev, errp); } =20 diff --git a/tests/qemu-iotests/240 b/tests/qemu-iotests/240 new file mode 100755 index 0000000000..ead7ee08eb --- /dev/null +++ b/tests/qemu-iotests/240 @@ -0,0 +1,89 @@ +#!/bin/bash +# +# Test hot plugging and unplugging with iothreads +# +# Copyright (C) 2019 Igalia, S.L. +# Author: Alberto Garcia +# +# 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=3Dberto@igalia.com + +seq=3D`basename $0` +echo "QA output created by $seq" + +status=3D1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt generic +_supported_proto generic +_supported_os Linux + +do_run_qemu() +{ + echo Testing: "$@" + $QEMU -nographic -qmp stdio -serial none "$@" + echo +} + +# Remove QMP events from (pretty-printed) output. Doesn't handle +# nested dicts correctly, but we don't get any of those in this test. +_filter_qmp_events() +{ + tr '\n' '\t' | sed -e \ + 's/{\s*"timestamp":\s*{[^}]*},\s*"event":[^,}]*\(,\s*"data":\s*{[^}]*}\)\= ?\s*}\s*//g' \ + | tr '\t' '\n' +} + +run_qemu() +{ + do_run_qemu "$@" 2>&1 | _filter_qmp | _filter_qmp_events +} + +case "$QEMU_DEFAULT_MACHINE" in + s390-ccw-virtio) + virtio_scsi=3Dvirtio-scsi-ccw + ;; + *) + virtio_scsi=3Dvirtio-scsi-pci + ;; +esac + +echo +echo =3D=3D=3D Unplug a SCSI disk and then plug it again =3D=3D=3D +echo + +run_qemu <