From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4ZEn-0004bG-Hg for qemu-devel@nongnu.org; Wed, 09 Nov 2016 15:12:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4ZEk-0004QT-Az for qemu-devel@nongnu.org; Wed, 09 Nov 2016 15:12:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59656) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c4ZEk-0004Pm-5e for qemu-devel@nongnu.org; Wed, 09 Nov 2016 15:12:46 -0500 Date: Wed, 9 Nov 2016 22:12:43 +0200 From: "Michael S. Tsirkin" Message-ID: <20161109221207-mutt-send-email-mst@kernel.org> References: <1478704922-3400-1-git-send-email-yuri.benditovich@daynix.com> <1478704922-3400-3-git-send-email-yuri.benditovich@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: Paolo Bonzini Cc: yuri.benditovich@daynix.com, Jason Wang , qemu-devel@nongnu.org, dmitry@daynix.com, yan@daynix.com On Wed, Nov 09, 2016 at 06:07:29PM +0100, Paolo Bonzini wrote: > > > 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 I don't object but I think the bugfix is helpful in this QEMU version, and this change is minimally intrusive. > > > > /* In the cross-endian case, we need to reset the vring endianness to > > * native as legacy devices expect so by default. > >