All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
To: target-devel <target-devel@vger.kernel.org>
Cc: lf-virt <virtualization@lists.linux-foundation.org>,
	kvm-devel <kvm@vger.kernel.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>, Asias He <asias@redhat.com>,
	Anthony Liguori <aliguori@linux.vnet.ibm.com>
Subject: [PATCH 1/3] virtio: add API to check that ring is setup
Date: Fri, 29 Mar 2013 04:33:10 +0000	[thread overview]
Message-ID: <1364531592-8368-2-git-send-email-nab@linux-iscsi.org> (raw)
In-Reply-To: <1364531592-8368-1-git-send-email-nab@linux-iscsi.org>

From: Michael S. Tsirkin <mst@redhat.com>

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 <mst@redhat.com>
Cc: Asias He <asias@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
---
 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);
-- 
1.7.2.5


WARNING: multiple messages have this Message-ID (diff)
From: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
To: target-devel <target-devel@vger.kernel.org>
Cc: kvm-devel <kvm@vger.kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	lf-virt <virtualization@lists.linux-foundation.org>,
	Anthony Liguori <aliguori@linux.vnet.ibm.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>, Asias He <asias@redhat.com>
Subject: [Qemu-devel] [PATCH 1/3] virtio: add API to check that ring is setup
Date: Fri, 29 Mar 2013 04:33:10 +0000	[thread overview]
Message-ID: <1364531592-8368-2-git-send-email-nab@linux-iscsi.org> (raw)
In-Reply-To: <1364531592-8368-1-git-send-email-nab@linux-iscsi.org>

From: Michael S. Tsirkin <mst@redhat.com>

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 <mst@redhat.com>
Cc: Asias He <asias@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
---
 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);
-- 
1.7.2.5

  parent reply	other threads:[~2013-03-29  4:44 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-29  4:33 [PATCH 0/3] virtio/vhost: Add checks for uninitialized VQs Nicholas A. Bellinger
2013-03-29  4:33 ` [Qemu-devel] " Nicholas A. Bellinger
2013-03-29  4:33 ` [PATCH 1/3] virtio: add API to check that ring is setup Nicholas A. Bellinger
2013-03-29  4:33 ` Nicholas A. Bellinger [this message]
2013-03-29  4:33   ` [Qemu-devel] " Nicholas A. Bellinger
2013-03-29  4:33 ` [PATCH 2/3] virtio-pci: Add virtio_queue_valid checks ahead of virtio_queue_get_num Nicholas A. Bellinger
2013-03-29  4:33   ` [Qemu-devel] " Nicholas A. Bellinger
2013-03-31  7:37   ` Michael S. Tsirkin
2013-03-31  7:37     ` [Qemu-devel] " Michael S. Tsirkin
2013-04-01 23:16     ` Nicholas A. Bellinger
2013-04-01 23:16     ` Nicholas A. Bellinger
2013-04-01 23:16       ` [Qemu-devel] " Nicholas A. Bellinger
2013-03-31  7:37   ` Michael S. Tsirkin
2013-03-29  4:33 ` [PATCH 3/3] vhost: Check+skip uninitialized VQs in vhost_verify_ring_mappings Nicholas A. Bellinger
2013-03-29  4:33 ` Nicholas A. Bellinger
2013-03-29  4:33   ` [Qemu-devel] " Nicholas A. Bellinger
2013-03-31  7:45   ` Michael S. Tsirkin
2013-03-31  7:45     ` [Qemu-devel] " Michael S. Tsirkin
2013-04-01 23:49     ` Nicholas A. Bellinger
2013-04-01 23:49       ` [Qemu-devel] " Nicholas A. Bellinger
2013-04-01 23:49     ` Nicholas A. Bellinger
2013-03-31  7:46 ` [PATCH 0/3] virtio/vhost: Add checks for uninitialized VQs Michael S. Tsirkin
2013-03-31  7:46   ` [Qemu-devel] " Michael S. Tsirkin
2013-04-01 23:51   ` Nicholas A. Bellinger
2013-04-01 23:51     ` [Qemu-devel] " Nicholas A. Bellinger
2013-04-01 23:51   ` Nicholas A. Bellinger
2013-03-31  7:46 ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1364531592-8368-2-git-send-email-nab@linux-iscsi.org \
    --to=nab@linux-iscsi.org \
    --cc=aliguori@linux.vnet.ibm.com \
    --cc=asias@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=target-devel@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.