From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baWKY-0001rM-Eo for qemu-devel@nongnu.org; Thu, 18 Aug 2016 19:02:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1baWKS-0005UM-Fv for qemu-devel@nongnu.org; Thu, 18 Aug 2016 19:02:33 -0400 Received: from mail-ve1eur01on0107.outbound.protection.outlook.com ([104.47.1.107]:11640 helo=EUR01-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baWKS-0005UI-56 for qemu-devel@nongnu.org; Thu, 18 Aug 2016 19:02:28 -0400 From: Roman Kagan Date: Thu, 18 Aug 2016 21:27:52 +0300 Message-ID: <1471544874-26996-3-git-send-email-rkagan@virtuozzo.com> In-Reply-To: <1471544874-26996-1-git-send-email-rkagan@virtuozzo.com> References: <1471544874-26996-1-git-send-email-rkagan@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH 2/4] virtio-balloon: make stats virtqueue length 1 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Denis V. Lunev" , Roman Kagan , "Michael S. Tsirkin" , Ladi Prosek The protocol for virtio-balloon stats virtqueue doesn't allow more than one element in the virtqueue. So, instead of trying to compensate for guest misbehavior if it sends new data before the slot has been released by the host, just define the stats virtqueue length to 1 initially and rely on the generic virtio code to handle overflows. Signed-off-by: Roman Kagan Cc: "Michael S. Tsirkin" Cc: Ladi Prosek --- hw/virtio/virtio-balloon.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 5af429a..0baf4b3 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -262,13 +262,6 @@ static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq) goto out; } - if (s->stats_vq_elem != NULL) { - /* This should never happen if the driver follows the spec. */ - virtqueue_push(vq, s->stats_vq_elem, 0); - virtio_notify(vdev, vq); - g_free(s->stats_vq_elem); - } - s->stats_vq_elem = elem; /* Initialize the stats to get rid of any stale values. This is only @@ -443,7 +436,7 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp) s->ivq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output); s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output); - s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats); + s->svq = virtio_add_queue(vdev, 1, virtio_balloon_receive_stats); reset_stats(s); } -- 2.7.4