From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4WLY-0004zQ-Kz for qemu-devel@nongnu.org; Wed, 09 Nov 2016 12:07:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4WLU-0006iO-GZ for qemu-devel@nongnu.org; Wed, 09 Nov 2016 12:07:36 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:33098) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c4WLU-0006hN-8n for qemu-devel@nongnu.org; Wed, 09 Nov 2016 12:07:32 -0500 Received: by mail-wm0-x244.google.com with SMTP id u144so30500904wmu.0 for ; Wed, 09 Nov 2016 09:07:32 -0800 (PST) Sender: Paolo Bonzini References: <1478704922-3400-1-git-send-email-yuri.benditovich@daynix.com> <1478704922-3400-3-git-send-email-yuri.benditovich@daynix.com> From: Paolo Bonzini Message-ID: Date: Wed, 9 Nov 2016 18:07:29 +0100 MIME-Version: 1.0 In-Reply-To: <1478704922-3400-3-git-send-email-yuri.benditovich@daynix.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v2 2/3] net: vhost stop updates virtio queue state List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: yuri.benditovich@daynix.com, "Michael S . Tsirkin" , Jason Wang , qemu-devel@nongnu.org Cc: dmitry@daynix.com, yan@daynix.com On 09/11/2016 16:22, yuri.benditovich@daynix.com wrote: > From: Yuri Benditovich > > Make virtio queue suitable for push operation from qemu > after vhost was stopped. > > Signed-off-by: Yuri Benditovich > --- > hw/virtio/vhost.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c > index bd051ab..2e990d0 100644 > --- a/hw/virtio/vhost.c > +++ b/hw/virtio/vhost.c > @@ -963,6 +963,7 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev, > virtio_queue_set_last_avail_idx(vdev, idx, state.num); > } > virtio_queue_invalidate_signalled_used(vdev, idx); > + virtio_queue_update_used_idx(vdev, idx); All three functions virtio_queue_set_last_avail_idx, virtio_queue_invalidate_signalled_used, virtio_queue_update_used_idx are only used here. Plus, virtio_queue_set_last_avail_idx is always called in practice, since the only failure modes for VHOST_GET_VRING_BASE are EFAULT and out-of-range virtqueue number. In both cases QEMU can ignore the other two steps. So perhaps we should have a single function virtio_queue_set_vring_base, taking a vhost_vring_state struct? It can do all three. Paolo > > /* In the cross-endian case, we need to reset the vring endianness to > * native as legacy devices expect so by default. >