From: Jason Wang Subject: [PATCH V2 15/20] virtio: introduce virtio_del_queue() Date: Fri, 25 Jan 2013 18:35:38 +0800 Message-ID: <1359110143-42984-16-git-send-email-jasowang@redhat.com> References: <1359110143-42984-1-git-send-email-jasowang@redhat.com> Cc: krkumar2@in.ibm.com, kvm@vger.kernel.org, mprivozn@redhat.com, rusty@rustcorp.com.au, jwhan@filewood.snu.ac.kr, shiyer@redhat.com, gaowanlong@cn.fujitsu.com, Jason Wang To: mst@redhat.com, qemu-devel@nongnu.org, aliguori@us.ibm.com, shajnocz@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:13968 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756672Ab3AYKpz (ORCPT ); Fri, 25 Jan 2013 05:45:55 -0500 In-Reply-To: <1359110143-42984-1-git-send-email-jasowang@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Some device (such as virtio-net) needs the ability to destroy or re-order the virtqueues, this patch adds a helper to do this. Signed-off-by: Jason Wang --- hw/virtio.c | 9 +++++++++ hw/virtio.h | 2 ++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/hw/virtio.c b/hw/virtio.c index ca170c3..d8c77b0 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -701,6 +701,15 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size, return &vdev->vq[i]; } +void virtio_del_queue(VirtIODevice *vdev, int n) +{ + if (n < 0 || n >= VIRTIO_PCI_QUEUE_MAX) { + abort(); + } + + vdev->vq[n].vring.num = 0; +} + void virtio_irq(VirtQueue *vq) { trace_virtio_irq(vq); diff --git a/hw/virtio.h b/hw/virtio.h index 9cc7b85..d3da1d2 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -181,6 +181,8 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size, void (*handle_output)(VirtIODevice *, VirtQueue *)); +void virtio_del_queue(VirtIODevice *vdev, int n); + void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len); void virtqueue_flush(VirtQueue *vq, unsigned int count); -- 1.7.1