All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: Jens Axboe <axboe@kernel.dk>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
	kvm-devel <kvm@vger.kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	Zhi Yong Wu <wuzhy@cn.ibm.com>,
	Anthony Liguori <aliguori@linux.vnet.ibm.com>,
	target-devel <target-devel@vger.kernel.org>,
	Hannes Reinecke <hare@suse.de>,
	lf-virt <virtualization@lists.linux-foundation.org>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [RFC 2/9] virtio-pci: support host notifiers in TCG mode
Date: Wed, 25 Jul 2012 08:50:51 +0200	[thread overview]
Message-ID: <500F974B.4050905@redhat.com> (raw)
In-Reply-To: <1343169246-17636-3-git-send-email-nab@linux-iscsi.org>

Il 25/07/2012 00:33, Nicholas A. Bellinger ha scritto:
> From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> 
> Normally host notifiers are only used together with vhost-net in KVM
> mode.  It is occassionally useful to use vhost with TCG mode, mainly for
> testing and development.  This isn't hard to achieve, simply fall back
> to notifying the host notifier manually from qemu if KVM mode is
> disabled.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> Cc: Anthony Liguori <aliguori@us.ibm.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> ---
>  hw/virtio-pci.c |   23 ++++++++++++++++++++---
>  hw/virtio.c     |    7 +++++++
>  2 files changed, 27 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index 4e03f0b..538eef4 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -249,6 +249,25 @@ void virtio_pci_reset(DeviceState *d)
>      proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG;
>  }
>  
> +static void virtio_pci_queue_notify(VirtIOPCIProxy *proxy, uint32_t n)
> +{
> +    VirtQueue *vq;
> +    EventNotifier *notifier;
> +
> +    if (n >= VIRTIO_PCI_QUEUE_MAX) {
> +        return;
> +    }
> +
> +    vq = virtio_get_queue(proxy->vdev, n);
> +    notifier = virtio_queue_get_host_notifier(vq);
> +    if (event_notifier_valid(notifier)) {
> +        printf("notifying vq %u host notifier from userspace\n", n);

Debug printf.

> +        event_notifier_notify(notifier);
> +    } else {
> +        virtio_queue_notify_vq(vq);
> +    }

This can be done directly in virtio_queue_notify, there is nothing
specific to virtio-pci.

> +}
> +
>  static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
>  {
>      VirtIOPCIProxy *proxy = opaque;
> @@ -278,9 +297,7 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
>              vdev->queue_sel = val;
>          break;
>      case VIRTIO_PCI_QUEUE_NOTIFY:
> -        if (val < VIRTIO_PCI_QUEUE_MAX) {
> -            virtio_queue_notify(vdev, val);
> -        }
> +        virtio_pci_queue_notify(proxy, val);
>          break;
>      case VIRTIO_PCI_STATUS:
>          if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) {
> diff --git a/hw/virtio.c b/hw/virtio.c
> index d146f86..36a18b5 100644
> --- a/hw/virtio.c
> +++ b/hw/virtio.c
> @@ -536,6 +536,11 @@ void virtio_reset(void *opaque)
>          vdev->vq[i].signalled_used = 0;
>          vdev->vq[i].signalled_used_valid = false;
>          vdev->vq[i].notification = true;
> +
> +        assert(!event_notifier_valid(&vdev->vq[i].guest_notifier));
> +        assert(!event_notifier_valid(&vdev->vq[i].host_notifier));
> +        vdev->vq[i].guest_notifier = EVENT_NOTIFIER_INITIALIZER;
> +        vdev->vq[i].host_notifier = EVENT_NOTIFIER_INITIALIZER;

Given the assertions, the assignments should be no-ops.

>      }
>  }
>  
> @@ -905,6 +910,8 @@ VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
>      for(i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
>          vdev->vq[i].vector = VIRTIO_NO_VECTOR;
>          vdev->vq[i].vdev = vdev;
> +        vdev->vq[i].guest_notifier = EVENT_NOTIFIER_INITIALIZER;
> +        vdev->vq[i].host_notifier = EVENT_NOTIFIER_INITIALIZER;
>      }
>  
>      vdev->name = name;
> 

WARNING: multiple messages have this Message-ID (diff)
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: Jens Axboe <axboe@kernel.dk>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
	kvm-devel <kvm@vger.kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	Zhi Yong Wu <wuzhy@cn.ibm.com>,
	Anthony Liguori <aliguori@linux.vnet.ibm.com>,
	target-devel <target-devel@vger.kernel.org>,
	Hannes Reinecke <hare@suse.de>,
	lf-virt <virtualization@lists.linux-foundation.org>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [Qemu-devel] [RFC 2/9] virtio-pci: support host notifiers in TCG mode
Date: Wed, 25 Jul 2012 08:50:51 +0200	[thread overview]
Message-ID: <500F974B.4050905@redhat.com> (raw)
In-Reply-To: <1343169246-17636-3-git-send-email-nab@linux-iscsi.org>

Il 25/07/2012 00:33, Nicholas A. Bellinger ha scritto:
> From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> 
> Normally host notifiers are only used together with vhost-net in KVM
> mode.  It is occassionally useful to use vhost with TCG mode, mainly for
> testing and development.  This isn't hard to achieve, simply fall back
> to notifying the host notifier manually from qemu if KVM mode is
> disabled.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> Cc: Anthony Liguori <aliguori@us.ibm.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> ---
>  hw/virtio-pci.c |   23 ++++++++++++++++++++---
>  hw/virtio.c     |    7 +++++++
>  2 files changed, 27 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index 4e03f0b..538eef4 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -249,6 +249,25 @@ void virtio_pci_reset(DeviceState *d)
>      proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG;
>  }
>  
> +static void virtio_pci_queue_notify(VirtIOPCIProxy *proxy, uint32_t n)
> +{
> +    VirtQueue *vq;
> +    EventNotifier *notifier;
> +
> +    if (n >= VIRTIO_PCI_QUEUE_MAX) {
> +        return;
> +    }
> +
> +    vq = virtio_get_queue(proxy->vdev, n);
> +    notifier = virtio_queue_get_host_notifier(vq);
> +    if (event_notifier_valid(notifier)) {
> +        printf("notifying vq %u host notifier from userspace\n", n);

Debug printf.

> +        event_notifier_notify(notifier);
> +    } else {
> +        virtio_queue_notify_vq(vq);
> +    }

This can be done directly in virtio_queue_notify, there is nothing
specific to virtio-pci.

> +}
> +
>  static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
>  {
>      VirtIOPCIProxy *proxy = opaque;
> @@ -278,9 +297,7 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
>              vdev->queue_sel = val;
>          break;
>      case VIRTIO_PCI_QUEUE_NOTIFY:
> -        if (val < VIRTIO_PCI_QUEUE_MAX) {
> -            virtio_queue_notify(vdev, val);
> -        }
> +        virtio_pci_queue_notify(proxy, val);
>          break;
>      case VIRTIO_PCI_STATUS:
>          if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) {
> diff --git a/hw/virtio.c b/hw/virtio.c
> index d146f86..36a18b5 100644
> --- a/hw/virtio.c
> +++ b/hw/virtio.c
> @@ -536,6 +536,11 @@ void virtio_reset(void *opaque)
>          vdev->vq[i].signalled_used = 0;
>          vdev->vq[i].signalled_used_valid = false;
>          vdev->vq[i].notification = true;
> +
> +        assert(!event_notifier_valid(&vdev->vq[i].guest_notifier));
> +        assert(!event_notifier_valid(&vdev->vq[i].host_notifier));
> +        vdev->vq[i].guest_notifier = EVENT_NOTIFIER_INITIALIZER;
> +        vdev->vq[i].host_notifier = EVENT_NOTIFIER_INITIALIZER;

Given the assertions, the assignments should be no-ops.

>      }
>  }
>  
> @@ -905,6 +910,8 @@ VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
>      for(i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
>          vdev->vq[i].vector = VIRTIO_NO_VECTOR;
>          vdev->vq[i].vdev = vdev;
> +        vdev->vq[i].guest_notifier = EVENT_NOTIFIER_INITIALIZER;
> +        vdev->vq[i].host_notifier = EVENT_NOTIFIER_INITIALIZER;
>      }
>  
>      vdev->name = name;
> 

  reply	other threads:[~2012-07-25  6:50 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-24 22:33 [RFC 0/9] vhost-scsi: Add support for host virtualized target Nicholas A. Bellinger
2012-07-24 22:33 ` [Qemu-devel] " Nicholas A. Bellinger
2012-07-24 22:33 ` [RFC 1/9] notifier: add validity check and notify function Nicholas A. Bellinger
2012-07-24 22:33 ` Nicholas A. Bellinger
2012-07-24 22:33   ` [Qemu-devel] " Nicholas A. Bellinger
2012-07-25  6:53   ` Paolo Bonzini
2012-07-25  6:53   ` Paolo Bonzini
2012-07-25  6:53     ` [Qemu-devel] " Paolo Bonzini
2012-07-24 22:33 ` [RFC 2/9] virtio-pci: support host notifiers in TCG mode Nicholas A. Bellinger
2012-07-24 22:33 ` Nicholas A. Bellinger
2012-07-24 22:33   ` [Qemu-devel] " Nicholas A. Bellinger
2012-07-25  6:50   ` Paolo Bonzini [this message]
2012-07-25  6:50     ` Paolo Bonzini
2012-07-24 22:34 ` [RFC 3/9] virtio-pci: check that event notification worked Nicholas A. Bellinger
2012-07-24 22:34 ` Nicholas A. Bellinger
2012-07-24 22:34   ` [Qemu-devel] " Nicholas A. Bellinger
2012-07-24 22:34 ` [RFC 4/9] vhost: Pass device path to vhost_dev_init() Nicholas A. Bellinger
2012-07-24 22:34   ` [Qemu-devel] " Nicholas A. Bellinger
2012-07-24 22:34 ` Nicholas A. Bellinger
2012-07-24 22:34 ` [RFC 5/9] virtio-scsi: Add wwpn and tgpt properties Nicholas A. Bellinger
2012-07-24 22:34   ` [Qemu-devel] " Nicholas A. Bellinger
2012-07-24 22:34 ` Nicholas A. Bellinger
2012-07-24 22:34 ` [RFC 6/9] virtio-scsi: Open and initialize /dev/vhost-scsi Nicholas A. Bellinger
2012-07-24 22:34   ` [Qemu-devel] " Nicholas A. Bellinger
2012-07-25  7:05   ` Paolo Bonzini
2012-07-25  7:05     ` [Qemu-devel] " Paolo Bonzini
2012-07-24 22:34 ` Nicholas A. Bellinger
2012-07-24 22:34 ` [RFC 7/9] virtio-scsi: Start/stop vhost Nicholas A. Bellinger
2012-07-24 22:34   ` [Qemu-devel] " Nicholas A. Bellinger
2012-07-25  7:01   ` Paolo Bonzini
2012-07-25  7:01   ` Paolo Bonzini
2012-07-25  7:01     ` [Qemu-devel] " Paolo Bonzini
2012-07-25  7:03     ` Paolo Bonzini
2012-07-25  7:03     ` Paolo Bonzini
2012-07-25  7:03       ` [Qemu-devel] " Paolo Bonzini
2012-07-24 22:34 ` Nicholas A. Bellinger
2012-07-24 22:34 ` [RFC 8/9] virtio-scsi: Set max_target=0 during vhost-scsi operation Nicholas A. Bellinger
2012-07-24 22:34   ` [Qemu-devel] " Nicholas A. Bellinger
2012-07-24 22:34 ` Nicholas A. Bellinger
2012-07-24 22:34 ` [RFC 9/9] vhost-scsi: add -vhost-scsi host device Nicholas A. Bellinger
2012-07-24 22:34 ` Nicholas A. Bellinger
2012-07-24 22:34   ` [Qemu-devel] " Nicholas A. Bellinger
2012-07-25  6:58   ` Paolo Bonzini
2012-07-25  6:58     ` [Qemu-devel] " Paolo Bonzini
2012-07-25  2:53 ` [RFC 0/9] vhost-scsi: Add support for host virtualized target Zhi Yong Wu
2012-07-25  2:53   ` [Qemu-devel] " Zhi Yong Wu
2012-07-25  2:53 ` Zhi Yong Wu

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=500F974B.4050905@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=aliguori@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=axboe@kernel.dk \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=nab@linux-iscsi.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    --cc=target-devel@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=wuzhy@cn.ibm.com \
    /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.