From patchwork Mon Apr 1 23:58:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 232845 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 24ABC2C013C for ; Tue, 2 Apr 2013 11:10:10 +1100 (EST) Received: from localhost ([::1]:43181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMong-0003ew-8G for incoming@patchwork.ozlabs.org; Mon, 01 Apr 2013 20:10:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMonG-0003ef-E1 for qemu-devel@nongnu.org; Mon, 01 Apr 2013 20:09:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UMonE-0004zk-E5 for qemu-devel@nongnu.org; Mon, 01 Apr 2013 20:09:42 -0400 Received: from mail.linux-iscsi.org ([67.23.28.174]:39645 helo=linux-iscsi.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMonE-0004zf-9T for qemu-devel@nongnu.org; Mon, 01 Apr 2013 20:09:40 -0400 Received: from linux-iscsi.org (localhost [127.0.0.1]) by linux-iscsi.org (Postfix) with ESMTP id 3E2F322D9D4; Mon, 1 Apr 2013 23:58:28 +0000 (UTC) From: "Nicholas A. Bellinger" To: target-devel Date: Mon, 1 Apr 2013 23:58:22 +0000 Message-Id: <1364860704-11896-2-git-send-email-nab@linux-iscsi.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1364860704-11896-1-git-send-email-nab@linux-iscsi.org> References: <1364860704-11896-1-git-send-email-nab@linux-iscsi.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 67.23.28.174 Cc: kvm-devel , "Michael S. Tsirkin" , qemu-devel , lf-virt , Anthony Liguori , Stefan Hajnoczi , Paolo Bonzini , Asias He Subject: [Qemu-devel] [PATCH-v2 1/3] virtio: add API to check that ring is setup 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 From: Michael S. Tsirkin virtio scsi makes it legal to only setup a subset of rings. The only way to detect the ring is setup seems to be to check whether PA was written to. Add API to do this, and teach code to use it instead of checking hardware queue size. (nab: use .vring.desc instead of .vring.pa) Signed-off-by: Michael S. Tsirkin Cc: Asias He Cc: Paolo Bonzini Signed-off-by: Nicholas Bellinger --- hw/virtio.c | 5 +++++ hw/virtio.h | 1 + 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/hw/virtio.c b/hw/virtio.c index 26fbc79..65ba253 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -651,6 +651,11 @@ int virtio_queue_get_num(VirtIODevice *vdev, int n) return vdev->vq[n].vring.num; } +bool virtio_queue_valid(VirtIODevice *vdev, int n) +{ + return vdev->vq[n].vring.num && vdev->vq[n].vring.desc; +} + int virtio_queue_get_id(VirtQueue *vq) { VirtIODevice *vdev = vq->vdev; diff --git a/hw/virtio.h b/hw/virtio.h index fdbe931..3086798 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -227,6 +227,7 @@ void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data); void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr); hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n); int virtio_queue_get_num(VirtIODevice *vdev, int n); +bool virtio_queue_valid(VirtIODevice *vdev, int n); void virtio_queue_notify(VirtIODevice *vdev, int n); uint16_t virtio_queue_vector(VirtIODevice *vdev, int n); void virtio_queue_set_vector(VirtIODevice *vdev, int n, uint16_t vector);