From patchwork Wed Jan 30 11:12:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 216896 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7AC012C0097 for ; Wed, 30 Jan 2013 23:40:32 +1100 (EST) Received: from localhost ([::1]:55240 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0Wxq-0000iu-CX for incoming@patchwork.ozlabs.org; Wed, 30 Jan 2013 07:40:30 -0500 Received: from eggs.gnu.org ([208.118.235.92]:46569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0Wxe-0000hi-RT for qemu-devel@nongnu.org; Wed, 30 Jan 2013 07:40:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U0Wxa-0002lR-69 for qemu-devel@nongnu.org; Wed, 30 Jan 2013 07:40:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11440) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0Vlj-0005bc-Ey for qemu-devel@nongnu.org; Wed, 30 Jan 2013 06:23:55 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0UBNkgA023782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 30 Jan 2013 06:23:46 -0500 Received: from amd-6168-8-1.englab.nay.redhat.com (amd-6168-8-1.englab.nay.redhat.com [10.66.104.52]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0UBLHRh018213; Wed, 30 Jan 2013 06:23:37 -0500 From: Jason Wang To: aliguori@us.ibm.com, mst@redhat.com, qemu-devel@nongnu.org, blauwirbel@gmail.com, shajnocz@redhat.com Date: Wed, 30 Jan 2013 19:12:36 +0800 Message-Id: <1359544361-5089-18-git-send-email-jasowang@redhat.com> In-Reply-To: <1359544361-5089-1-git-send-email-jasowang@redhat.com> References: <1359544361-5089-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: krkumar2@in.ibm.com, kvm@vger.kernel.org, mprivozn@redhat.com, Jason Wang , rusty@rustcorp.com.au, shiyer@redhat.com, jwhan@filewood.snu.ac.kr, gaowanlong@cn.fujitsu.com Subject: [Qemu-devel] [PATCH V4 17/22] virtio: introduce virtio_del_queue() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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);