From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
kvm-devel <kvm@vger.kernel.org>,
Jan Kiszka <jan.kiszka@siemens.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>,
Paolo Bonzini <pbonzini@redhat.com>,
lf-virt <virtualization@lists.linux-foundation.org>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost
Date: Sun, 19 Aug 2012 11:44:26 +0300 [thread overview]
Message-ID: <20120819084426.GB26215@redhat.com> (raw)
In-Reply-To: <1345336586.25161.373.camel@haakon2.linux-iscsi.org>
On Sat, Aug 18, 2012 at 05:36:26PM -0700, Nicholas A. Bellinger wrote:
> On Sat, 2012-08-18 at 22:12 +0300, Michael S. Tsirkin wrote:
> > On Tue, Aug 14, 2012 at 01:31:14PM -0700, Nicholas A. Bellinger wrote:
> > > On Mon, 2012-08-13 at 11:53 +0300, Michael S. Tsirkin wrote:
> > > > On Mon, Aug 13, 2012 at 08:35:14AM +0000, Nicholas A. Bellinger wrote:
> > > > > From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
>
> <SNIP>
>
> > > > > +static VHostSCSI *vhost_scsi_add(const char *id, const char *wwpn,
> > > > > + uint16_t tpgt)
> > > > > +{
> > > > > + VHostSCSI *vs = g_malloc0(sizeof(*vs));
> > > > > + int ret;
> > > > > +
> > > > > + /* TODO set up vhost-scsi device and bind to tcm_vhost/$wwpm/tpgt_$tpgt */
> > > > > + fprintf(stderr, "wwpn = \"%s\" tpgt = \"%u\"\n", id, tpgt);
> > > > > +
> > > > > + ret = vhost_dev_init(&vs->dev, -1, "/dev/vhost-scsi", false);
> > > >
> > > > This -1 is a hack. You need to support passing in fd from
> > > > the monitor, and pass it here.
> > > >
> > >
> > > Mmm, looking at how vhost_net_init + tap.c does this, but am not quite
> > > what fd needs to be propagated up for virtio-scsi -> vhost-scsi..
> > >
> > > Can you please elaborate on this one a bit more..?
> > >
> >
> > The idea is to allow running as a user without access to
> > /dev/vhost-scsi.
> > For this, allow passing in the fd of /dev/vhost-scsi through unix domain sockets.
> >
>
> Ah, that is a pretty neat trick.. So for vhost-scsi code, this would
> mean something along the lines of the following, yes..?
Yes but with one correction. See below.
> Thanks MST!
> diff --git a/hw/vhost-scsi.c b/hw/vhost-scsi.c
> index 4206a75..8af8758 100644
> --- a/hw/vhost-scsi.c
> +++ b/hw/vhost-scsi.c
> @@ -21,6 +21,7 @@ struct VHostSCSI {
> const char *id;
> const char *wwpn;
> uint16_t tpgt;
> + int vhostfd;
> struct vhost_dev dev;
> struct vhost_virtqueue vqs[VHOST_SCSI_VQ_NUM];
> QLIST_ENTRY(VHostSCSI) list;
> @@ -114,13 +115,32 @@ void vhost_scsi_stop(VHostSCSI *vs, VirtIODevice *vdev)
> }
>
> static VHostSCSI *vhost_scsi_add(const char *id, const char *wwpn,
> - uint16_t tpgt)
> + uint16_t tpgt, const char *vhostfd_str)
> {
> - VHostSCSI *vs = g_malloc0(sizeof(*vs));
> + VHostSCSI *vs;
> int ret;
>
> + vs = g_malloc0(sizeof(*vs));
> + if (!vs) {
> + error_report("vhost-scsi: unable to allocate *vs\n");
> + return NULL;
> + }
> + vs->vhostfd = -1;
> +
> + if (vhostfd_str) {
> + if (!qemu_isdigit(vhostfd_str[0])) {
> + error_report("vhost-scsi: passed vhostfd value is not a digit\n");
> + return NULL;
This let you use an fd which was open at exec
but does not allow for fd to be open later in
case device is hot-plugged.
See net_handle_fd_param - I think you can just rename it
qemu_handle_fd_param to avoid code duplication.
> + }
> +
> + vs->vhostfd = qemu_parse_fd(vhostfd_str);
> + if (vs->vhostfd == -1) {
> + error_report("vhost-scsi: unable to parse vs->vhostfd\n");
> + return NULL;
> + }
> + }
> /* TODO set up vhost-scsi device and bind to tcm_vhost/$wwpm/tpgt_$tpgt */
> - ret = vhost_dev_init(&vs->dev, -1, "/dev/vhost-scsi", false);
> + ret = vhost_dev_init(&vs->dev, vs->vhostfd, "/dev/vhost-scsi", false);
> if (ret < 0) {
> error_report("vhost-scsi: vhost initialization failed: %s\n",
> strerror(-ret));
> @@ -140,7 +160,7 @@ static VHostSCSI *vhost_scsi_add(const char *id, const char *wwpn,
> VHostSCSI *vhost_scsi_add_opts(QemuOpts *opts)
> {
> const char *id;
> - const char *wwpn;
> + const char *wwpn, *vhostfd;
> uint64_t tpgt;
>
> id = qemu_opts_id(opts);
> @@ -164,6 +184,7 @@ VHostSCSI *vhost_scsi_add_opts(QemuOpts *opts)
> error_report("vhost-scsi: \"%s\" needs a 16-bit tpgt\n", id);
> return NULL;
> }
> + vhostfd = qemu_opt_get(opts, "vhostfd");
>
> - return vhost_scsi_add(id, wwpn, tpgt);
> + return vhost_scsi_add(id, wwpn, tpgt, vhostfd);
> }
> diff --git a/qemu-config.c b/qemu-config.c
> index 33399ea..2d4884c 100644
> --- a/qemu-config.c
> +++ b/qemu-config.c
> @@ -636,6 +636,9 @@ QemuOptsList qemu_vhost_scsi_opts = {
> }, {
> .name = "tpgt",
> .type = QEMU_OPT_NUMBER,
> + }, {
> + .name = "vhostfd",
> + .type = QEMU_OPT_STRING,
> },
> { /* end of list */ }
> },
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
kvm-devel <kvm@vger.kernel.org>,
Jan Kiszka <jan.kiszka@siemens.com>,
Zhi Yong Wu <wuzhy@linux.vnet.ibm.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>,
Paolo Bonzini <pbonzini@redhat.com>,
lf-virt <virtualization@lists.linux-foundation.org>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [Qemu-devel] [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost
Date: Sun, 19 Aug 2012 11:44:26 +0300 [thread overview]
Message-ID: <20120819084426.GB26215@redhat.com> (raw)
In-Reply-To: <1345336586.25161.373.camel@haakon2.linux-iscsi.org>
On Sat, Aug 18, 2012 at 05:36:26PM -0700, Nicholas A. Bellinger wrote:
> On Sat, 2012-08-18 at 22:12 +0300, Michael S. Tsirkin wrote:
> > On Tue, Aug 14, 2012 at 01:31:14PM -0700, Nicholas A. Bellinger wrote:
> > > On Mon, 2012-08-13 at 11:53 +0300, Michael S. Tsirkin wrote:
> > > > On Mon, Aug 13, 2012 at 08:35:14AM +0000, Nicholas A. Bellinger wrote:
> > > > > From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
>
> <SNIP>
>
> > > > > +static VHostSCSI *vhost_scsi_add(const char *id, const char *wwpn,
> > > > > + uint16_t tpgt)
> > > > > +{
> > > > > + VHostSCSI *vs = g_malloc0(sizeof(*vs));
> > > > > + int ret;
> > > > > +
> > > > > + /* TODO set up vhost-scsi device and bind to tcm_vhost/$wwpm/tpgt_$tpgt */
> > > > > + fprintf(stderr, "wwpn = \"%s\" tpgt = \"%u\"\n", id, tpgt);
> > > > > +
> > > > > + ret = vhost_dev_init(&vs->dev, -1, "/dev/vhost-scsi", false);
> > > >
> > > > This -1 is a hack. You need to support passing in fd from
> > > > the monitor, and pass it here.
> > > >
> > >
> > > Mmm, looking at how vhost_net_init + tap.c does this, but am not quite
> > > what fd needs to be propagated up for virtio-scsi -> vhost-scsi..
> > >
> > > Can you please elaborate on this one a bit more..?
> > >
> >
> > The idea is to allow running as a user without access to
> > /dev/vhost-scsi.
> > For this, allow passing in the fd of /dev/vhost-scsi through unix domain sockets.
> >
>
> Ah, that is a pretty neat trick.. So for vhost-scsi code, this would
> mean something along the lines of the following, yes..?
Yes but with one correction. See below.
> Thanks MST!
> diff --git a/hw/vhost-scsi.c b/hw/vhost-scsi.c
> index 4206a75..8af8758 100644
> --- a/hw/vhost-scsi.c
> +++ b/hw/vhost-scsi.c
> @@ -21,6 +21,7 @@ struct VHostSCSI {
> const char *id;
> const char *wwpn;
> uint16_t tpgt;
> + int vhostfd;
> struct vhost_dev dev;
> struct vhost_virtqueue vqs[VHOST_SCSI_VQ_NUM];
> QLIST_ENTRY(VHostSCSI) list;
> @@ -114,13 +115,32 @@ void vhost_scsi_stop(VHostSCSI *vs, VirtIODevice *vdev)
> }
>
> static VHostSCSI *vhost_scsi_add(const char *id, const char *wwpn,
> - uint16_t tpgt)
> + uint16_t tpgt, const char *vhostfd_str)
> {
> - VHostSCSI *vs = g_malloc0(sizeof(*vs));
> + VHostSCSI *vs;
> int ret;
>
> + vs = g_malloc0(sizeof(*vs));
> + if (!vs) {
> + error_report("vhost-scsi: unable to allocate *vs\n");
> + return NULL;
> + }
> + vs->vhostfd = -1;
> +
> + if (vhostfd_str) {
> + if (!qemu_isdigit(vhostfd_str[0])) {
> + error_report("vhost-scsi: passed vhostfd value is not a digit\n");
> + return NULL;
This let you use an fd which was open at exec
but does not allow for fd to be open later in
case device is hot-plugged.
See net_handle_fd_param - I think you can just rename it
qemu_handle_fd_param to avoid code duplication.
> + }
> +
> + vs->vhostfd = qemu_parse_fd(vhostfd_str);
> + if (vs->vhostfd == -1) {
> + error_report("vhost-scsi: unable to parse vs->vhostfd\n");
> + return NULL;
> + }
> + }
> /* TODO set up vhost-scsi device and bind to tcm_vhost/$wwpm/tpgt_$tpgt */
> - ret = vhost_dev_init(&vs->dev, -1, "/dev/vhost-scsi", false);
> + ret = vhost_dev_init(&vs->dev, vs->vhostfd, "/dev/vhost-scsi", false);
> if (ret < 0) {
> error_report("vhost-scsi: vhost initialization failed: %s\n",
> strerror(-ret));
> @@ -140,7 +160,7 @@ static VHostSCSI *vhost_scsi_add(const char *id, const char *wwpn,
> VHostSCSI *vhost_scsi_add_opts(QemuOpts *opts)
> {
> const char *id;
> - const char *wwpn;
> + const char *wwpn, *vhostfd;
> uint64_t tpgt;
>
> id = qemu_opts_id(opts);
> @@ -164,6 +184,7 @@ VHostSCSI *vhost_scsi_add_opts(QemuOpts *opts)
> error_report("vhost-scsi: \"%s\" needs a 16-bit tpgt\n", id);
> return NULL;
> }
> + vhostfd = qemu_opt_get(opts, "vhostfd");
>
> - return vhost_scsi_add(id, wwpn, tpgt);
> + return vhost_scsi_add(id, wwpn, tpgt, vhostfd);
> }
> diff --git a/qemu-config.c b/qemu-config.c
> index 33399ea..2d4884c 100644
> --- a/qemu-config.c
> +++ b/qemu-config.c
> @@ -636,6 +636,9 @@ QemuOptsList qemu_vhost_scsi_opts = {
> }, {
> .name = "tpgt",
> .type = QEMU_OPT_NUMBER,
> + }, {
> + .name = "vhostfd",
> + .type = QEMU_OPT_STRING,
> },
> { /* end of list */ }
> },
next prev parent reply other threads:[~2012-08-19 8:44 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-13 8:35 [RFC-v2 0/6] vhost-scsi: Add support for host virtualized target Nicholas A. Bellinger
2012-08-13 8:35 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-13 8:35 ` [RFC-v2 1/6] msix: Work-around for vhost-scsi with KVM in-kernel MSI injection Nicholas A. Bellinger
2012-08-13 8:35 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-13 8:51 ` Michael S. Tsirkin
2012-08-13 8:51 ` [Qemu-devel] " Michael S. Tsirkin
2012-08-13 12:06 ` Jan Kiszka
2012-08-13 12:06 ` [Qemu-devel] " Jan Kiszka
2012-08-13 18:03 ` Michael S. Tsirkin
2012-08-13 18:03 ` [Qemu-devel] " Michael S. Tsirkin
2012-08-13 18:06 ` Jan Kiszka
2012-08-13 18:06 ` [Qemu-devel] " Jan Kiszka
2012-08-13 18:17 ` Michael S. Tsirkin
2012-08-13 18:17 ` Michael S. Tsirkin
2012-08-13 18:17 ` [Qemu-devel] " Michael S. Tsirkin
2012-08-14 20:10 ` Nicholas A. Bellinger
2012-08-14 20:10 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-13 12:06 ` Jan Kiszka
2012-08-13 19:39 ` [Qemu-devel] " Blue Swirl
2012-08-13 19:39 ` Blue Swirl
2012-08-13 19:39 ` Blue Swirl
2012-08-13 8:35 ` [RFC-v2 2/6] vhost: Pass device path to vhost_dev_init() Nicholas A. Bellinger
2012-08-13 8:35 ` Nicholas A. Bellinger
2012-08-13 8:35 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-13 8:35 ` [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost Nicholas A. Bellinger
2012-08-13 8:35 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-13 8:53 ` Michael S. Tsirkin
2012-08-13 8:53 ` [Qemu-devel] " Michael S. Tsirkin
2012-08-14 20:31 ` Nicholas A. Bellinger
2012-08-14 20:31 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-18 19:12 ` Michael S. Tsirkin
2012-08-18 19:12 ` [Qemu-devel] " Michael S. Tsirkin
2012-08-19 0:36 ` Nicholas A. Bellinger
2012-08-19 0:36 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-19 8:44 ` Michael S. Tsirkin [this message]
2012-08-19 8:44 ` Michael S. Tsirkin
2012-08-20 22:24 ` Nicholas A. Bellinger
2012-08-20 22:24 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-13 8:59 ` Michael S. Tsirkin
2012-08-13 8:59 ` [Qemu-devel] " Michael S. Tsirkin
2012-08-14 21:12 ` Nicholas A. Bellinger
2012-08-14 21:12 ` Nicholas A. Bellinger
2012-08-14 21:12 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-18 19:10 ` Michael S. Tsirkin
2012-08-18 19:10 ` [Qemu-devel] " Michael S. Tsirkin
2012-08-18 23:38 ` Nicholas A. Bellinger
2012-08-18 23:38 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-18 23:38 ` Nicholas A. Bellinger
2012-08-13 19:47 ` [Qemu-devel] " Blue Swirl
2012-08-13 19:47 ` Blue Swirl
2012-08-13 19:47 ` Blue Swirl
2012-08-14 21:17 ` Nicholas A. Bellinger
2012-08-14 21:17 ` Nicholas A. Bellinger
2012-08-14 21:17 ` Nicholas A. Bellinger
2012-08-20 9:02 ` Paolo Bonzini
2012-08-20 9:02 ` [Qemu-devel] " Paolo Bonzini
2012-08-13 8:35 ` Nicholas A. Bellinger
2012-08-13 8:35 ` [RFC-v2 4/6] virtio-scsi: Add start/stop functionality for vhost-scsi Nicholas A. Bellinger
2012-08-13 8:35 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-20 9:04 ` Paolo Bonzini
2012-08-20 9:04 ` [Qemu-devel] " Paolo Bonzini
2012-08-20 11:31 ` Stefan Hajnoczi
2012-08-20 11:31 ` Stefan Hajnoczi
2012-08-20 11:31 ` [Qemu-devel] " Stefan Hajnoczi
2012-08-20 11:57 ` Michael S. Tsirkin
2012-08-20 11:57 ` [Qemu-devel] " Michael S. Tsirkin
2012-08-20 12:00 ` Paolo Bonzini
2012-08-20 12:00 ` [Qemu-devel] " Paolo Bonzini
2012-08-13 8:35 ` Nicholas A. Bellinger
2012-08-13 8:35 ` [RFC-v2 5/6] virtio-scsi: Set max_target=0 during vhost-scsi operation Nicholas A. Bellinger
2012-08-13 8:35 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-13 8:35 ` Nicholas A. Bellinger
2012-08-13 8:35 ` [RFC-v2 6/6] virtio-scsi: Fix incorrect VirtIOSCSI->cmd_vqs[0] definition Nicholas A. Bellinger
2012-08-13 8:35 ` Nicholas A. Bellinger
2012-08-13 8:35 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-13 9:02 ` Michael S. Tsirkin
2012-08-13 9:02 ` [Qemu-devel] " Michael S. Tsirkin
2012-08-14 20:20 ` Nicholas A. Bellinger
2012-08-14 20:20 ` Nicholas A. Bellinger
2012-08-14 20:20 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-18 18:52 ` Paolo Bonzini
2012-08-18 18:52 ` [Qemu-devel] " Paolo Bonzini
2012-08-18 21:47 ` Nicholas A. Bellinger
2012-08-18 21:47 ` [Qemu-devel] " Nicholas A. Bellinger
2012-08-18 21:47 ` Nicholas A. Bellinger
2012-08-13 9:04 ` [RFC-v2 0/6] vhost-scsi: Add support for host virtualized target Michael S. Tsirkin
2012-08-13 9:04 ` [Qemu-devel] " 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=20120819084426.GB26215@redhat.com \
--to=mst@redhat.com \
--cc=aliguori@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=hch@lst.de \
--cc=jan.kiszka@siemens.com \
--cc=kvm@vger.kernel.org \
--cc=nab@linux-iscsi.org \
--cc=pbonzini@redhat.com \
--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.