From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwoQK-000060-8k for qemu-devel@nongnu.org; Wed, 19 Oct 2016 06:48:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwoQH-0006Q9-5T for qemu-devel@nongnu.org; Wed, 19 Oct 2016 06:48:40 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:46507) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwoQG-0006Ow-TM for qemu-devel@nongnu.org; Wed, 19 Oct 2016 06:48:37 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9JAivH9002307 for ; Wed, 19 Oct 2016 06:48:35 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2662ghcycb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 19 Oct 2016 06:48:35 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 19 Oct 2016 11:48:33 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9E1582190061 for ; Wed, 19 Oct 2016 11:47:46 +0100 (BST) Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9JAmTH59437612 for ; Wed, 19 Oct 2016 10:48:29 GMT Received: from d06av11.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u9JAmTOM009056 for ; Wed, 19 Oct 2016 04:48:29 -0600 Date: Wed, 19 Oct 2016 12:48:27 +0200 From: Cornelia Huck In-Reply-To: <1476100421-28772-7-git-send-email-pbonzini@redhat.com> References: <1476100421-28772-1-git-send-email-pbonzini@redhat.com> <1476100421-28772-7-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <20161019124827.1d1305a1.cornelia.huck@de.ibm.com> Subject: Re: [Qemu-devel] [PATCH 06/13] virtio-blk: always use dataplane path if ioeventfd is active List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, stefanha@redhat.com, borntraeger@de.ibm.com, famz@redhat.com, mst@redhat.com On Mon, 10 Oct 2016 13:53:34 +0200 Paolo Bonzini wrote: > Override start_ioeventfd and stop_ioeventfd to start/stop the > whole dataplane logic. This has some positive side effects: > > - no need anymore for virtio_add_queue_aio (i.e. a revert of > commit 0ff841f6d138904d514efa1d885bcaf54583852d) > > - no need anymore to switch from generic ioeventfd handlers to > dataplane > > It detects some errors better: > > $ qemu-system-x86_64 -object iothread,id=io \ > -drive id=null,file=null-aio://,if=none,format=raw \ > -device virtio-blk-pci,ioeventfd=off,iothread=io,drive=null > qemu-system-x86_64: -device virtio-blk-pci,ioeventfd=off,iothread=io,drive=null: > ioeventfd is required for iothread > > while previously it would have started just fine. > > Signed-off-by: Paolo Bonzini > --- > v1->v2: improvement in error message consistency > loosen virtio_blk_set_status assertion [Christian] > > hw/block/dataplane/virtio-blk.c | 74 +++++++++++++++++++++++++---------------- > hw/block/dataplane/virtio-blk.h | 6 ++-- > hw/block/virtio-blk.c | 15 ++++----- > 3 files changed, 55 insertions(+), 40 deletions(-) > > diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c > index 9b268f4..d96f45c 100644 > --- a/hw/block/dataplane/virtio-blk.c > +++ b/hw/block/dataplane/virtio-blk.c > @@ -83,28 +83,33 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf, > Error **errp) > { > VirtIOBlockDataPlane *s; > - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); > + BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); Unrelated change? > VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); > > *dataplane = NULL; > > - if (!conf->iothread) { > - return; > - } > - > /* Don't try if transport does not support notifiers. */ I'd move this comment together with the next block, otherwise this is confusing. > - if (!k->set_guest_notifiers || !k->ioeventfd_assign) { > - error_setg(errp, > - "device is incompatible with dataplane " > - "(transport does not support notifiers)"); > - return; > - } > + if (conf->iothread) { > + if (!k->set_guest_notifiers || !k->ioeventfd_assign) { > + error_setg(errp, > + "device is incompatible with iothread " > + "(transport does not support notifiers)"); > + return; > + } > + if (!virtio_device_ioeventfd_enabled(vdev)) { > + error_setg(errp, "ioeventfd is required for iothread"); > + return; > + } > > - /* If dataplane is (re-)enabled while the guest is running there could be > - * block jobs that can conflict. > - */ > - if (blk_op_is_blocked(conf->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)) { > - error_prepend(errp, "cannot start dataplane thread: "); > + /* If dataplane is (re-)enabled while the guest is running there could > + * be block jobs that can conflict. > + */ > + if (blk_op_is_blocked(conf->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)) { > + error_prepend(errp, "cannot start virtio-blk dataplane: "); > + return; > + } > + } > + if (!virtio_device_ioeventfd_enabled(vdev)) { > return; > } > (...) > @@ -124,14 +133,18 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf, > /* Context: QEMU global mutex held */ > void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s) > { > + VirtIOBlock *vblk = VIRTIO_BLK(s->vdev); > + > if (!s) { You already dereferenced s above... > return; > } > > - virtio_blk_data_plane_stop(s); > + assert(!vblk->dataplane_started); > g_free(s->batch_notify_vqs); > qemu_bh_delete(s->bh); > - object_unref(OBJECT(s->iothread)); > + if (s->iothread) { > + object_unref(OBJECT(s->iothread)); > + } > g_free(s); > } > In general, I think this looks good, but I'll have a look at the end result as well.