From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3aPG-0003mm-13 for qemu-devel@nongnu.org; Mon, 20 Aug 2012 18:25:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T3aPE-0004un-9Z for qemu-devel@nongnu.org; Mon, 20 Aug 2012 18:25:09 -0400 Received: from mail.linux-iscsi.org ([67.23.28.174]:60648 helo=linux-iscsi.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3aPE-0004sA-1k for qemu-devel@nongnu.org; Mon, 20 Aug 2012 18:25:08 -0400 From: "Nicholas A. Bellinger" In-Reply-To: <20120819084426.GB26215@redhat.com> References: <1344846917-7411-1-git-send-email-nab@linux-iscsi.org> <1344846917-7411-4-git-send-email-nab@linux-iscsi.org> <20120813085325.GH14081@redhat.com> <1344976274.22433.93.camel@haakon2.linux-iscsi.org> <20120818191243.GB17770@redhat.com> <1345336586.25161.373.camel@haakon2.linux-iscsi.org> <20120819084426.GB26215@redhat.com> Content-Type: text/plain; charset="UTF-8" Date: Mon, 20 Aug 2012 15:24:58 -0700 Message-ID: <1345501498.23278.80.camel@haakon2.linux-iscsi.org> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Anthony Liguori , Stefan Hajnoczi , kvm-devel , Jan Kiszka , Zhi Yong Wu , qemu-devel , Zhi Yong Wu , Anthony Liguori , target-devel , Hannes Reinecke , Paolo Bonzini , lf-virt , Christoph Hellwig On Sun, 2012-08-19 at 11:44 +0300, Michael S. Tsirkin wrote: > 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 > > > > 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. > OK, so monitor_get_fd() will set this up for the case where the device is hot-plugged. That makes alot more sense now.. So renaming net_handle_fd_param -> qemu_handle_fd_param + moving into cutils.c, and will include as a leading patch for RFC-v3. Thanks MST! --nab