From patchwork Wed Apr 6 10:16:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8760521 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B0BFDC0553 for ; Wed, 6 Apr 2016 10:16:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0809A201E4 for ; Wed, 6 Apr 2016 10:16:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 57540201D3 for ; Wed, 6 Apr 2016 10:16:50 +0000 (UTC) Received: from localhost ([::1]:42155 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ankW1-0003fH-Jq for patchwork-qemu-devel@patchwork.kernel.org; Wed, 06 Apr 2016 06:16:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ankVp-0003eD-MA for qemu-devel@nongnu.org; Wed, 06 Apr 2016 06:16:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ankVn-0001oN-Qm for qemu-devel@nongnu.org; Wed, 06 Apr 2016 06:16:37 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:35988) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ankVn-0001oH-JZ for qemu-devel@nongnu.org; Wed, 06 Apr 2016 06:16:35 -0400 Received: by mail-wm0-x241.google.com with SMTP id o129so2311261wmo.3 for ; Wed, 06 Apr 2016 03:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Mbg0fTQ4BB63EkpiG3B84P6af1NKwDjn6dGN6jn7izc=; b=wSb6a9T2XYpkJnrpXvXhALC9ltYS8ti7VcYotoeOMkL3Q48R/7v3BFq/RkBYYWJQ0R oNgA+gK3dIcWrGDL213EV8X0Fo/ceU7pYaMsC5VYD3hSAnbx4BYjpRLJ59/waY+Ucb3N fBbd6sy9PP85ChV+iAE/pycuCo2y2BbJQTlbry3/BPXfwb+jGCi2SgSeLAHIiObtzgKF RgjjTZEEB+uAm5YxCTvB/i+Z8GdfmRhVIsjBWLVto4Vt+tZvwJvv39ENh5qEEO6seVJ5 gzM5HrsVAKDJnDWzjvG9HVmrbG5Y/sBY1HhmW+kwB/0u+U9CPt/31XNowaIdnKizvNro Q1Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Mbg0fTQ4BB63EkpiG3B84P6af1NKwDjn6dGN6jn7izc=; b=JbNKkZ6XbAD8hycIYx9dmGP6JRoSkMnWb5DCOm+9wKEzoxccO/4mF3hzAZHOpif/lI napUO6JnMD1a4jmi2Y6lBeG/ZDevdM2kmWe78V7y0Pr72G/1s6zny2BFsoJD9wYQ7U9P 22AvDFmhG8Jinr/TV3wI4nlqYs6fG9Aapf1YwKDUSxBp/OcWj+MuLa4tliTEp4KsLXfI rYtpaJIbxpju2QBW/ud+M1m9+YPCxBY08CzUo6oYAB3VUJYXO4sgKUHYSZjFm+1YeQxM 5oDO4omfk8JP81CfAl8cCHHevFgIDjBZTZ8y0cXANIcy4cRmjjKhkKd1NpAbhXwbX68k Xm0g== X-Gm-Message-State: AD7BkJKFKUMGjOlF+Aw4cS0t4ubzjxZxN66+sfDGAEsYYnfK4KCDYe+ds/Wm990k1cFBOA== X-Received: by 10.28.189.10 with SMTP id n10mr18353983wmf.101.1459937795046; Wed, 06 Apr 2016 03:16:35 -0700 (PDT) Received: from 640k.lan (94-39-141-76.adsl-ull.clienti.tiscali.it. [94.39.141.76]) by smtp.gmail.com with ESMTPSA id u3sm24048429wmg.15.2016.04.06.03.16.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Apr 2016 03:16:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 6 Apr 2016 12:16:23 +0200 Message-Id: <1459937788-31904-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1459937788-31904-1-git-send-email-pbonzini@redhat.com> References: <1459937788-31904-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Cc: famz@redhat.com, tubo@linux.vnet.ibm.com, mst@redhat.com, borntraeger@de.ibm.com, stefanha@redhat.com, cornelia.huck@de.ibm.com Subject: [Qemu-devel] [PATCH 2/7] virtio-blk: fix disabled mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We must not call virtio_blk_data_plane_notify if dataplane is disabled: we would hit a segmentation fault in notify_guest_bh as s->guest_notifier has not been setup and is NULL. Reviewed-by: Cornelia Huck Signed-off-by: Paolo Bonzini --- hw/block/dataplane/virtio-blk.c | 7 +++---- hw/block/virtio-blk.c | 2 +- include/hw/virtio/virtio-blk.h | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c index e666dd4..2870d21 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -29,7 +29,6 @@ struct VirtIOBlockDataPlane { bool starting; bool stopping; - bool disabled; VirtIOBlkConf *conf; @@ -234,7 +233,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) fail_host_notifier: k->set_guest_notifiers(qbus->parent, 1, false); fail_guest_notifiers: - s->disabled = true; + vblk->dataplane_disabled = true; s->starting = false; vblk->dataplane_started = true; } @@ -251,8 +250,8 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s) } /* Better luck next time. */ - if (s->disabled) { - s->disabled = false; + if (vblk->dataplane_disabled) { + vblk->dataplane_disabled = false; vblk->dataplane_started = false; return; } diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 870d345..151fe78 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -54,7 +54,7 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status) stb_p(&req->in->status, status); virtqueue_push(s->vq, &req->elem, req->in_len); - if (s->dataplane) { + if (s->dataplane_started && !s->dataplane_disabled) { virtio_blk_data_plane_notify(s->dataplane); } else { virtio_notify(vdev, s->vq); diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index ae84d92..59ae1e4 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -53,6 +53,7 @@ typedef struct VirtIOBlock { unsigned short sector_mask; bool original_wce; VMChangeStateEntry *change; + bool dataplane_disabled; bool dataplane_started; struct VirtIOBlockDataPlane *dataplane; } VirtIOBlock;