From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToXNg-0000iz-RP for qemu-devel@nongnu.org; Fri, 28 Dec 2012 05:41:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ToXNf-0003LO-9J for qemu-devel@nongnu.org; Fri, 28 Dec 2012 05:41:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22985) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToXNf-0003LK-1J for qemu-devel@nongnu.org; Fri, 28 Dec 2012 05:41:35 -0500 From: Jason Wang Date: Fri, 28 Dec 2012 18:31:59 +0800 Message-Id: <1356690724-37891-8-git-send-email-jasowang@redhat.com> In-Reply-To: <1356690724-37891-1-git-send-email-jasowang@redhat.com> References: <1356690724-37891-1-git-send-email-jasowang@redhat.com> Subject: [Qemu-devel] [PATCH 07/12] virtio: introduce virtio_queue_del() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mst@redhat.com, aliguori@us.ibm.com, stefanha@redhat.com, qemu-devel@nongnu.org Cc: krkumar2@in.ibm.com, kvm@vger.kernel.org, mprivozn@redhat.com, Jason Wang , rusty@rustcorp.com.au, jwhan@filewood.snu.ac.kr, shiyer@redhat.com 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 f40a8c5..bc3c9c3 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -700,6 +700,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 7c17f7b..f6cb0f9 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -138,6 +138,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