Re: [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost

2012-08-20 Thread Paolo Bonzini
Il 13/08/2012 10:35, Nicholas A. Bellinger ha scritto:
 From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 
 This patch adds a new type of host device that drives the vhost_scsi
 device.  The syntax to add vhost-scsi is:
 
   qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123
 
 The virtio-scsi emulated device will make use of vhost-scsi to process
 virtio-scsi requests inside the kernel and hand them to the in-kernel
 SCSI target stack using the tcm_vhost fabric driver.
 
 The tcm_vhost driver was merged into the upstream linux kernel for 3.6-rc2,
 and the commit can be found here:
 
 http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=057cbf49a1f08297
 
 Changelog v1 - v2:
 
 - Expose ABI version via VHOST_SCSI_GET_ABI_VERSION + use Rev 0 as
   starting point for v3.6-rc code (Stefan + ALiguori + nab)
 - Fix upstream qemu conflict in hw/qdev-properties.c
 - Make GET_ABI_VERSION use int (nab + mst)
 - Fix vhost-scsi case lables in configure (reported by paolo)
 - Convert qdev_prop_vhost_scsi to use -get() + -set() following
   qdev_prop_netdev (reported by paolo)
 - Fix typo in qemu-options.hx definition of vhost-scsi (reported by paolo)
 
 Changelog v0 - v1:
 
 - Add VHOST_SCSI_SET_ENDPOINT call (stefan)
 - Enable vhost notifiers for multiple queues (Zhi)
 - clear vhost-scsi endpoint on stopped (Zhi)
 - Add CONFIG_VHOST_SCSI for QEMU build configure (nab)
 - Rename vhost_vring_target - vhost_scsi_target (mst + nab)
 - Add support for VHOST_SCSI_GET_ABI_VERSION ioctl (aliguori + nab)
 
 Cc: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 Cc: Zhi Yong Wu wu...@linux.vnet.ibm.com
 Cc: Anthony Liguori aligu...@us.ibm.com
 Cc: Paolo Bonzini pbonz...@redhat.com
 Cc: Michael S. Tsirkin m...@redhat.com
 Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
 ---
  configure|   10 +++
  hw/Makefile.objs |1 +
  hw/qdev-properties.c |   40 
  hw/qdev.h|3 +
  hw/vhost-scsi.c  |  170 
 ++
  hw/vhost-scsi.h  |   50 +++
  qemu-common.h|1 +
  qemu-config.c|   16 +
  qemu-options.hx  |4 +
  vl.c |   18 +
  10 files changed, 313 insertions(+), 0 deletions(-)
  create mode 100644 hw/vhost-scsi.c
  create mode 100644 hw/vhost-scsi.h
 
 diff --git a/configure b/configure
 index f0dbc03..1f03202 100755
 --- a/configure
 +++ b/configure
 @@ -168,6 +168,7 @@ libattr=
  xfs=
  
  vhost_net=no
 +vhost_scsi=no
  kvm=no
  gprof=no
  debug_tcg=no
 @@ -513,6 +514,7 @@ Haiku)
usb=linux
kvm=yes
vhost_net=yes
 +  vhost_scsi=yes
if [ $cpu = i386 -o $cpu = x86_64 ] ; then
  audio_possible_drivers=$audio_possible_drivers fmod
fi
 @@ -818,6 +820,10 @@ for opt do
;;
--enable-vhost-net) vhost_net=yes
;;
 +  --disable-vhost-scsi) vhost_scsi=no
 +  ;;
 +  --enable-vhost-scsi) vhost_scsi=yes
 +  ;;
--disable-opengl) opengl=no
;;
--enable-opengl) opengl=yes
 @@ -3116,6 +3122,7 @@ echo posix_madvise $posix_madvise
  echo uuid support  $uuid
  echo libcap-ng support $cap_ng
  echo vhost-net support $vhost_net
 +echo vhost-scsi support $vhost_scsi
  echo Trace backend $trace_backend
  echo Trace output file $trace_file-pid
  echo spice support $spice
 @@ -3828,6 +3835,9 @@ case $target_arch2 in
if test $vhost_net = yes ; then
  echo CONFIG_VHOST_NET=y  $config_target_mak
fi
 +  if test $vhost_scsi = yes ; then
 +echo CONFIG_VHOST_SCSI=y  $config_target_mak
 +  fi
  fi
  esac
  case $target_arch2 in
 diff --git a/hw/Makefile.objs b/hw/Makefile.objs
 index 3ba5dd0..6ab75ec 100644
 --- a/hw/Makefile.objs
 +++ b/hw/Makefile.objs
 @@ -169,6 +169,7 @@ obj-$(CONFIG_VIRTIO) += virtio.o virtio-blk.o 
 virtio-balloon.o virtio-net.o
  obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o virtio-scsi.o
  obj-$(CONFIG_SOFTMMU) += vhost_net.o
  obj-$(CONFIG_VHOST_NET) += vhost.o
 +obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o
  obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/
  obj-$(CONFIG_NO_PCI) += pci-stub.o
  obj-$(CONFIG_VGA) += vga.o
 diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
 index 8aca0d4..0266266 100644
 --- a/hw/qdev-properties.c
 +++ b/hw/qdev-properties.c
 @@ -4,6 +4,7 @@
  #include blockdev.h
  #include hw/block-common.h
  #include net/hub.h
 +#include vhost-scsi.h
  
  void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
  {
 @@ -696,6 +697,45 @@ PropertyInfo qdev_prop_vlan = {
  .set   = set_vlan,
  };
  
 +/* --- vhost-scsi --- */
 +
 +static int parse_vhost_scsi_dev(DeviceState *dev, const char *str, void 
 **ptr)
 +{
 +   VHostSCSI *p;
 +
 +   p = find_vhost_scsi(str);
 +   if (p == NULL)
 +   return -ENOENT;
 +
 +   *ptr = p;
 +   return 0;
 +}
 +
 +static const char *print_vhost_scsi_dev(void *ptr)
 +{
 +VHostSCSI *p = ptr;
 +
 +return (p) ? vhost_scsi_get_id(p) : null;
 +}
 +
 +static void get_vhost_scsi_dev(Object *obj, Visitor *v, void 

Re: [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost

2012-08-20 Thread Nicholas A. Bellinger
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 +, Nicholas A. Bellinger wrote:
  From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com

SNIP

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

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost

2012-08-19 Thread Michael S. Tsirkin
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 +, Nicholas A. Bellinger wrote:
 From: Stefan Hajnoczi stefa...@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 */ }
  },
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost

2012-08-18 Thread Michael S. Tsirkin
On Tue, Aug 14, 2012 at 02:12:29PM -0700, Nicholas A. Bellinger wrote:
 On Mon, 2012-08-13 at 11:59 +0300, Michael S. Tsirkin wrote:
  On Mon, Aug 13, 2012 at 08:35:14AM +, Nicholas A. Bellinger wrote:
   From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
   
   This patch adds a new type of host device that drives the vhost_scsi
   device.  The syntax to add vhost-scsi is:
   
 qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123
   
   The virtio-scsi emulated device will make use of vhost-scsi to process
   virtio-scsi requests inside the kernel and hand them to the in-kernel
   SCSI target stack using the tcm_vhost fabric driver.
   
   The tcm_vhost driver was merged into the upstream linux kernel for 
   3.6-rc2,
   and the commit can be found here:
   
   http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=057cbf49a1f08297
   
   Changelog v1 - v2:
   
   - Expose ABI version via VHOST_SCSI_GET_ABI_VERSION + use Rev 0 as
 starting point for v3.6-rc code (Stefan + ALiguori + nab)
   - Fix upstream qemu conflict in hw/qdev-properties.c
   - Make GET_ABI_VERSION use int (nab + mst)
   - Fix vhost-scsi case lables in configure (reported by paolo)
   - Convert qdev_prop_vhost_scsi to use -get() + -set() following
 qdev_prop_netdev (reported by paolo)
   - Fix typo in qemu-options.hx definition of vhost-scsi (reported by paolo)
   
   Changelog v0 - v1:
   
   - Add VHOST_SCSI_SET_ENDPOINT call (stefan)
   - Enable vhost notifiers for multiple queues (Zhi)
   - clear vhost-scsi endpoint on stopped (Zhi)
   - Add CONFIG_VHOST_SCSI for QEMU build configure (nab)
   - Rename vhost_vring_target - vhost_scsi_target (mst + nab)
   - Add support for VHOST_SCSI_GET_ABI_VERSION ioctl (aliguori + nab)
   
   Cc: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
   Cc: Zhi Yong Wu wu...@linux.vnet.ibm.com
   Cc: Anthony Liguori aligu...@us.ibm.com
   Cc: Paolo Bonzini pbonz...@redhat.com
   Cc: Michael S. Tsirkin m...@redhat.com
   Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
  
  
  Sent mail too fast, sorry. More comments below.
  
   ---
configure|   10 +++
hw/Makefile.objs |1 +
hw/qdev-properties.c |   40 
hw/qdev.h|3 +
hw/vhost-scsi.c  |  170 
   ++
hw/vhost-scsi.h  |   50 +++
qemu-common.h|1 +
qemu-config.c|   16 +
qemu-options.hx  |4 +
vl.c |   18 +
10 files changed, 313 insertions(+), 0 deletions(-)
create mode 100644 hw/vhost-scsi.c
create mode 100644 hw/vhost-scsi.h
   
   diff --git a/configure b/configure
   index f0dbc03..1f03202 100755
   --- a/configure
   +++ b/configure
   @@ -168,6 +168,7 @@ libattr=
xfs=

vhost_net=no
   +vhost_scsi=no
kvm=no
gprof=no
debug_tcg=no
   @@ -513,6 +514,7 @@ Haiku)
  usb=linux
  kvm=yes
  vhost_net=yes
   +  vhost_scsi=yes
  if [ $cpu = i386 -o $cpu = x86_64 ] ; then
audio_possible_drivers=$audio_possible_drivers fmod
  fi
   @@ -818,6 +820,10 @@ for opt do
  ;;
  --enable-vhost-net) vhost_net=yes
  ;;
   +  --disable-vhost-scsi) vhost_scsi=no
   +  ;;
   +  --enable-vhost-scsi) vhost_scsi=yes
   +  ;;
  --disable-opengl) opengl=no
  ;;
  --enable-opengl) opengl=yes
   @@ -3116,6 +3122,7 @@ echo posix_madvise $posix_madvise
echo uuid support  $uuid
echo libcap-ng support $cap_ng
echo vhost-net support $vhost_net
   +echo vhost-scsi support $vhost_scsi
echo Trace backend $trace_backend
echo Trace output file $trace_file-pid
echo spice support $spice
   @@ -3828,6 +3835,9 @@ case $target_arch2 in
  if test $vhost_net = yes ; then
echo CONFIG_VHOST_NET=y  $config_target_mak
  fi
   +  if test $vhost_scsi = yes ; then
   +echo CONFIG_VHOST_SCSI=y  $config_target_mak
   +  fi
fi
esac
case $target_arch2 in
   diff --git a/hw/Makefile.objs b/hw/Makefile.objs
   index 3ba5dd0..6ab75ec 100644
   --- a/hw/Makefile.objs
   +++ b/hw/Makefile.objs
   @@ -169,6 +169,7 @@ obj-$(CONFIG_VIRTIO) += virtio.o virtio-blk.o 
   virtio-balloon.o virtio-net.o
obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o virtio-scsi.o
obj-$(CONFIG_SOFTMMU) += vhost_net.o
obj-$(CONFIG_VHOST_NET) += vhost.o
   +obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o
obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/
obj-$(CONFIG_NO_PCI) += pci-stub.o
obj-$(CONFIG_VGA) += vga.o
   diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
   index 8aca0d4..0266266 100644
   --- a/hw/qdev-properties.c
   +++ b/hw/qdev-properties.c
   @@ -4,6 +4,7 @@
#include blockdev.h
#include hw/block-common.h
#include net/hub.h
   +#include vhost-scsi.h

void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
{
   @@ -696,6 +697,45 @@ PropertyInfo qdev_prop_vlan = {
.set   

Re: [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost

2012-08-18 Thread Michael S. Tsirkin
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 +, Nicholas A. Bellinger wrote:
   From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
   
   This patch adds a new type of host device that drives the vhost_scsi
   device.  The syntax to add vhost-scsi is:
   
 qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123
   
   The virtio-scsi emulated device will make use of vhost-scsi to process
   virtio-scsi requests inside the kernel and hand them to the in-kernel
   SCSI target stack using the tcm_vhost fabric driver.
 
 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..?
 
 --nab
 


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.

-- 
MST
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost

2012-08-18 Thread Nicholas A. Bellinger
On Sat, 2012-08-18 at 22:10 +0300, Michael S. Tsirkin wrote:
 On Tue, Aug 14, 2012 at 02:12:29PM -0700, Nicholas A. Bellinger wrote:
  On Mon, 2012-08-13 at 11:59 +0300, Michael S. Tsirkin wrote:
   On Mon, Aug 13, 2012 at 08:35:14AM +, Nicholas A. Bellinger wrote:

SNIP

  
+if (ret  0) {
+fprintf(stderr, vhost-scsi: vhost initialization failed: 
%s\n,
+strerror(-ret));
   
   errors should go to monitor, here and elsewhere.
   
  
  I think this means using monitor_printf() right..?
  
  Looking at that now..
 
 
 error_report is handier.
 

Converted all fprintf(stderr, ...) - error_report() usage for RFC-v3.

Thanks MST!

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost

2012-08-18 Thread Nicholas A. Bellinger
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 +, Nicholas A. Bellinger wrote:
From: Stefan Hajnoczi stefa...@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..?

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;
+}
+
+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 */ }
 },

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost

2012-08-14 Thread Nicholas A. Bellinger
On Mon, 2012-08-13 at 11:53 +0300, Michael S. Tsirkin wrote:
 On Mon, Aug 13, 2012 at 08:35:14AM +, Nicholas A. Bellinger wrote:
  From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
  
  This patch adds a new type of host device that drives the vhost_scsi
  device.  The syntax to add vhost-scsi is:
  
qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123
  
  The virtio-scsi emulated device will make use of vhost-scsi to process
  virtio-scsi requests inside the kernel and hand them to the in-kernel
  SCSI target stack using the tcm_vhost fabric driver.

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..?

--nab


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost

2012-08-14 Thread Nicholas A. Bellinger
On Mon, 2012-08-13 at 11:59 +0300, Michael S. Tsirkin wrote:
 On Mon, Aug 13, 2012 at 08:35:14AM +, Nicholas A. Bellinger wrote:
  From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
  
  This patch adds a new type of host device that drives the vhost_scsi
  device.  The syntax to add vhost-scsi is:
  
qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123
  
  The virtio-scsi emulated device will make use of vhost-scsi to process
  virtio-scsi requests inside the kernel and hand them to the in-kernel
  SCSI target stack using the tcm_vhost fabric driver.
  
  The tcm_vhost driver was merged into the upstream linux kernel for 3.6-rc2,
  and the commit can be found here:
  
  http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=057cbf49a1f08297
  
  Changelog v1 - v2:
  
  - Expose ABI version via VHOST_SCSI_GET_ABI_VERSION + use Rev 0 as
starting point for v3.6-rc code (Stefan + ALiguori + nab)
  - Fix upstream qemu conflict in hw/qdev-properties.c
  - Make GET_ABI_VERSION use int (nab + mst)
  - Fix vhost-scsi case lables in configure (reported by paolo)
  - Convert qdev_prop_vhost_scsi to use -get() + -set() following
qdev_prop_netdev (reported by paolo)
  - Fix typo in qemu-options.hx definition of vhost-scsi (reported by paolo)
  
  Changelog v0 - v1:
  
  - Add VHOST_SCSI_SET_ENDPOINT call (stefan)
  - Enable vhost notifiers for multiple queues (Zhi)
  - clear vhost-scsi endpoint on stopped (Zhi)
  - Add CONFIG_VHOST_SCSI for QEMU build configure (nab)
  - Rename vhost_vring_target - vhost_scsi_target (mst + nab)
  - Add support for VHOST_SCSI_GET_ABI_VERSION ioctl (aliguori + nab)
  
  Cc: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
  Cc: Zhi Yong Wu wu...@linux.vnet.ibm.com
  Cc: Anthony Liguori aligu...@us.ibm.com
  Cc: Paolo Bonzini pbonz...@redhat.com
  Cc: Michael S. Tsirkin m...@redhat.com
  Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
 
 
 Sent mail too fast, sorry. More comments below.
 
  ---
   configure|   10 +++
   hw/Makefile.objs |1 +
   hw/qdev-properties.c |   40 
   hw/qdev.h|3 +
   hw/vhost-scsi.c  |  170 
  ++
   hw/vhost-scsi.h  |   50 +++
   qemu-common.h|1 +
   qemu-config.c|   16 +
   qemu-options.hx  |4 +
   vl.c |   18 +
   10 files changed, 313 insertions(+), 0 deletions(-)
   create mode 100644 hw/vhost-scsi.c
   create mode 100644 hw/vhost-scsi.h
  
  diff --git a/configure b/configure
  index f0dbc03..1f03202 100755
  --- a/configure
  +++ b/configure
  @@ -168,6 +168,7 @@ libattr=
   xfs=
   
   vhost_net=no
  +vhost_scsi=no
   kvm=no
   gprof=no
   debug_tcg=no
  @@ -513,6 +514,7 @@ Haiku)
 usb=linux
 kvm=yes
 vhost_net=yes
  +  vhost_scsi=yes
 if [ $cpu = i386 -o $cpu = x86_64 ] ; then
   audio_possible_drivers=$audio_possible_drivers fmod
 fi
  @@ -818,6 +820,10 @@ for opt do
 ;;
 --enable-vhost-net) vhost_net=yes
 ;;
  +  --disable-vhost-scsi) vhost_scsi=no
  +  ;;
  +  --enable-vhost-scsi) vhost_scsi=yes
  +  ;;
 --disable-opengl) opengl=no
 ;;
 --enable-opengl) opengl=yes
  @@ -3116,6 +3122,7 @@ echo posix_madvise $posix_madvise
   echo uuid support  $uuid
   echo libcap-ng support $cap_ng
   echo vhost-net support $vhost_net
  +echo vhost-scsi support $vhost_scsi
   echo Trace backend $trace_backend
   echo Trace output file $trace_file-pid
   echo spice support $spice
  @@ -3828,6 +3835,9 @@ case $target_arch2 in
 if test $vhost_net = yes ; then
   echo CONFIG_VHOST_NET=y  $config_target_mak
 fi
  +  if test $vhost_scsi = yes ; then
  +echo CONFIG_VHOST_SCSI=y  $config_target_mak
  +  fi
   fi
   esac
   case $target_arch2 in
  diff --git a/hw/Makefile.objs b/hw/Makefile.objs
  index 3ba5dd0..6ab75ec 100644
  --- a/hw/Makefile.objs
  +++ b/hw/Makefile.objs
  @@ -169,6 +169,7 @@ obj-$(CONFIG_VIRTIO) += virtio.o virtio-blk.o 
  virtio-balloon.o virtio-net.o
   obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o virtio-scsi.o
   obj-$(CONFIG_SOFTMMU) += vhost_net.o
   obj-$(CONFIG_VHOST_NET) += vhost.o
  +obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o
   obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/
   obj-$(CONFIG_NO_PCI) += pci-stub.o
   obj-$(CONFIG_VGA) += vga.o
  diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
  index 8aca0d4..0266266 100644
  --- a/hw/qdev-properties.c
  +++ b/hw/qdev-properties.c
  @@ -4,6 +4,7 @@
   #include blockdev.h
   #include hw/block-common.h
   #include net/hub.h
  +#include vhost-scsi.h
   
   void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
   {
  @@ -696,6 +697,45 @@ PropertyInfo qdev_prop_vlan = {
   .set   = set_vlan,
   };
   
  +/* --- vhost-scsi --- */
  +
  +static int parse_vhost_scsi_dev(DeviceState *dev, const char *str, void 
  **ptr)
  +{
  +   VHostSCSI *p;
  +
  +   p = find_vhost_scsi(str);
  +   if (p == 

Re: [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost

2012-08-13 Thread Michael S. Tsirkin
On Mon, Aug 13, 2012 at 08:35:14AM +, Nicholas A. Bellinger wrote:
 From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 
 This patch adds a new type of host device that drives the vhost_scsi
 device.  The syntax to add vhost-scsi is:
 
   qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123
 
 The virtio-scsi emulated device will make use of vhost-scsi to process
 virtio-scsi requests inside the kernel and hand them to the in-kernel
 SCSI target stack using the tcm_vhost fabric driver.
 
 The tcm_vhost driver was merged into the upstream linux kernel for 3.6-rc2,
 and the commit can be found here:
 
 http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=057cbf49a1f08297
 
 Changelog v1 - v2:
 
 - Expose ABI version via VHOST_SCSI_GET_ABI_VERSION + use Rev 0 as
   starting point for v3.6-rc code (Stefan + ALiguori + nab)
 - Fix upstream qemu conflict in hw/qdev-properties.c
 - Make GET_ABI_VERSION use int (nab + mst)
 - Fix vhost-scsi case lables in configure (reported by paolo)
 - Convert qdev_prop_vhost_scsi to use -get() + -set() following
   qdev_prop_netdev (reported by paolo)
 - Fix typo in qemu-options.hx definition of vhost-scsi (reported by paolo)
 
 Changelog v0 - v1:
 
 - Add VHOST_SCSI_SET_ENDPOINT call (stefan)
 - Enable vhost notifiers for multiple queues (Zhi)
 - clear vhost-scsi endpoint on stopped (Zhi)
 - Add CONFIG_VHOST_SCSI for QEMU build configure (nab)
 - Rename vhost_vring_target - vhost_scsi_target (mst + nab)
 - Add support for VHOST_SCSI_GET_ABI_VERSION ioctl (aliguori + nab)
 
 Cc: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 Cc: Zhi Yong Wu wu...@linux.vnet.ibm.com
 Cc: Anthony Liguori aligu...@us.ibm.com
 Cc: Paolo Bonzini pbonz...@redhat.com
 Cc: Michael S. Tsirkin m...@redhat.com
 Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org
 ---
  configure|   10 +++
  hw/Makefile.objs |1 +
  hw/qdev-properties.c |   40 
  hw/qdev.h|3 +
  hw/vhost-scsi.c  |  170 
 ++
  hw/vhost-scsi.h  |   50 +++
  qemu-common.h|1 +
  qemu-config.c|   16 +
  qemu-options.hx  |4 +
  vl.c |   18 +
  10 files changed, 313 insertions(+), 0 deletions(-)
  create mode 100644 hw/vhost-scsi.c
  create mode 100644 hw/vhost-scsi.h
 
 diff --git a/configure b/configure
 index f0dbc03..1f03202 100755
 --- a/configure
 +++ b/configure
 @@ -168,6 +168,7 @@ libattr=
  xfs=
  
  vhost_net=no
 +vhost_scsi=no
  kvm=no
  gprof=no
  debug_tcg=no
 @@ -513,6 +514,7 @@ Haiku)
usb=linux
kvm=yes
vhost_net=yes
 +  vhost_scsi=yes
if [ $cpu = i386 -o $cpu = x86_64 ] ; then
  audio_possible_drivers=$audio_possible_drivers fmod
fi
 @@ -818,6 +820,10 @@ for opt do
;;
--enable-vhost-net) vhost_net=yes
;;
 +  --disable-vhost-scsi) vhost_scsi=no
 +  ;;
 +  --enable-vhost-scsi) vhost_scsi=yes
 +  ;;
--disable-opengl) opengl=no
;;
--enable-opengl) opengl=yes
 @@ -3116,6 +3122,7 @@ echo posix_madvise $posix_madvise
  echo uuid support  $uuid
  echo libcap-ng support $cap_ng
  echo vhost-net support $vhost_net
 +echo vhost-scsi support $vhost_scsi
  echo Trace backend $trace_backend
  echo Trace output file $trace_file-pid
  echo spice support $spice
 @@ -3828,6 +3835,9 @@ case $target_arch2 in
if test $vhost_net = yes ; then
  echo CONFIG_VHOST_NET=y  $config_target_mak
fi
 +  if test $vhost_scsi = yes ; then
 +echo CONFIG_VHOST_SCSI=y  $config_target_mak
 +  fi
  fi
  esac
  case $target_arch2 in
 diff --git a/hw/Makefile.objs b/hw/Makefile.objs
 index 3ba5dd0..6ab75ec 100644
 --- a/hw/Makefile.objs
 +++ b/hw/Makefile.objs
 @@ -169,6 +169,7 @@ obj-$(CONFIG_VIRTIO) += virtio.o virtio-blk.o 
 virtio-balloon.o virtio-net.o
  obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o virtio-scsi.o
  obj-$(CONFIG_SOFTMMU) += vhost_net.o
  obj-$(CONFIG_VHOST_NET) += vhost.o
 +obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o
  obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/
  obj-$(CONFIG_NO_PCI) += pci-stub.o
  obj-$(CONFIG_VGA) += vga.o
 diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
 index 8aca0d4..0266266 100644
 --- a/hw/qdev-properties.c
 +++ b/hw/qdev-properties.c
 @@ -4,6 +4,7 @@
  #include blockdev.h
  #include hw/block-common.h
  #include net/hub.h
 +#include vhost-scsi.h
  
  void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
  {
 @@ -696,6 +697,45 @@ PropertyInfo qdev_prop_vlan = {
  .set   = set_vlan,
  };
  
 +/* --- vhost-scsi --- */
 +
 +static int parse_vhost_scsi_dev(DeviceState *dev, const char *str, void 
 **ptr)
 +{
 +   VHostSCSI *p;
 +
 +   p = find_vhost_scsi(str);
 +   if (p == NULL)
 +   return -ENOENT;
 +
 +   *ptr = p;
 +   return 0;
 +}
 +
 +static const char *print_vhost_scsi_dev(void *ptr)
 +{
 +VHostSCSI *p = ptr;
 +
 +return (p) ? vhost_scsi_get_id(p) : null;
 +}
 +
 +static void get_vhost_scsi_dev(Object *obj, 

Re: [RFC-v2 3/6] vhost-scsi: add -vhost-scsi host device for use with tcm-vhost

2012-08-13 Thread Michael S. Tsirkin
On Mon, Aug 13, 2012 at 08:35:14AM +, Nicholas A. Bellinger wrote:
 From: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 
 This patch adds a new type of host device that drives the vhost_scsi
 device.  The syntax to add vhost-scsi is:
 
   qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123
 
 The virtio-scsi emulated device will make use of vhost-scsi to process
 virtio-scsi requests inside the kernel and hand them to the in-kernel
 SCSI target stack using the tcm_vhost fabric driver.
 
 The tcm_vhost driver was merged into the upstream linux kernel for 3.6-rc2,
 and the commit can be found here:
 
 http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=057cbf49a1f08297
 
 Changelog v1 - v2:
 
 - Expose ABI version via VHOST_SCSI_GET_ABI_VERSION + use Rev 0 as
   starting point for v3.6-rc code (Stefan + ALiguori + nab)
 - Fix upstream qemu conflict in hw/qdev-properties.c
 - Make GET_ABI_VERSION use int (nab + mst)
 - Fix vhost-scsi case lables in configure (reported by paolo)
 - Convert qdev_prop_vhost_scsi to use -get() + -set() following
   qdev_prop_netdev (reported by paolo)
 - Fix typo in qemu-options.hx definition of vhost-scsi (reported by paolo)
 
 Changelog v0 - v1:
 
 - Add VHOST_SCSI_SET_ENDPOINT call (stefan)
 - Enable vhost notifiers for multiple queues (Zhi)
 - clear vhost-scsi endpoint on stopped (Zhi)
 - Add CONFIG_VHOST_SCSI for QEMU build configure (nab)
 - Rename vhost_vring_target - vhost_scsi_target (mst + nab)
 - Add support for VHOST_SCSI_GET_ABI_VERSION ioctl (aliguori + nab)
 
 Cc: Stefan Hajnoczi stefa...@linux.vnet.ibm.com
 Cc: Zhi Yong Wu wu...@linux.vnet.ibm.com
 Cc: Anthony Liguori aligu...@us.ibm.com
 Cc: Paolo Bonzini pbonz...@redhat.com
 Cc: Michael S. Tsirkin m...@redhat.com
 Signed-off-by: Nicholas Bellinger n...@linux-iscsi.org


Sent mail too fast, sorry. More comments below.

 ---
  configure|   10 +++
  hw/Makefile.objs |1 +
  hw/qdev-properties.c |   40 
  hw/qdev.h|3 +
  hw/vhost-scsi.c  |  170 
 ++
  hw/vhost-scsi.h  |   50 +++
  qemu-common.h|1 +
  qemu-config.c|   16 +
  qemu-options.hx  |4 +
  vl.c |   18 +
  10 files changed, 313 insertions(+), 0 deletions(-)
  create mode 100644 hw/vhost-scsi.c
  create mode 100644 hw/vhost-scsi.h
 
 diff --git a/configure b/configure
 index f0dbc03..1f03202 100755
 --- a/configure
 +++ b/configure
 @@ -168,6 +168,7 @@ libattr=
  xfs=
  
  vhost_net=no
 +vhost_scsi=no
  kvm=no
  gprof=no
  debug_tcg=no
 @@ -513,6 +514,7 @@ Haiku)
usb=linux
kvm=yes
vhost_net=yes
 +  vhost_scsi=yes
if [ $cpu = i386 -o $cpu = x86_64 ] ; then
  audio_possible_drivers=$audio_possible_drivers fmod
fi
 @@ -818,6 +820,10 @@ for opt do
;;
--enable-vhost-net) vhost_net=yes
;;
 +  --disable-vhost-scsi) vhost_scsi=no
 +  ;;
 +  --enable-vhost-scsi) vhost_scsi=yes
 +  ;;
--disable-opengl) opengl=no
;;
--enable-opengl) opengl=yes
 @@ -3116,6 +3122,7 @@ echo posix_madvise $posix_madvise
  echo uuid support  $uuid
  echo libcap-ng support $cap_ng
  echo vhost-net support $vhost_net
 +echo vhost-scsi support $vhost_scsi
  echo Trace backend $trace_backend
  echo Trace output file $trace_file-pid
  echo spice support $spice
 @@ -3828,6 +3835,9 @@ case $target_arch2 in
if test $vhost_net = yes ; then
  echo CONFIG_VHOST_NET=y  $config_target_mak
fi
 +  if test $vhost_scsi = yes ; then
 +echo CONFIG_VHOST_SCSI=y  $config_target_mak
 +  fi
  fi
  esac
  case $target_arch2 in
 diff --git a/hw/Makefile.objs b/hw/Makefile.objs
 index 3ba5dd0..6ab75ec 100644
 --- a/hw/Makefile.objs
 +++ b/hw/Makefile.objs
 @@ -169,6 +169,7 @@ obj-$(CONFIG_VIRTIO) += virtio.o virtio-blk.o 
 virtio-balloon.o virtio-net.o
  obj-$(CONFIG_VIRTIO) += virtio-serial-bus.o virtio-scsi.o
  obj-$(CONFIG_SOFTMMU) += vhost_net.o
  obj-$(CONFIG_VHOST_NET) += vhost.o
 +obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o
  obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/
  obj-$(CONFIG_NO_PCI) += pci-stub.o
  obj-$(CONFIG_VGA) += vga.o
 diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
 index 8aca0d4..0266266 100644
 --- a/hw/qdev-properties.c
 +++ b/hw/qdev-properties.c
 @@ -4,6 +4,7 @@
  #include blockdev.h
  #include hw/block-common.h
  #include net/hub.h
 +#include vhost-scsi.h
  
  void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
  {
 @@ -696,6 +697,45 @@ PropertyInfo qdev_prop_vlan = {
  .set   = set_vlan,
  };
  
 +/* --- vhost-scsi --- */
 +
 +static int parse_vhost_scsi_dev(DeviceState *dev, const char *str, void 
 **ptr)
 +{
 +   VHostSCSI *p;
 +
 +   p = find_vhost_scsi(str);
 +   if (p == NULL)
 +   return -ENOENT;
 +
 +   *ptr = p;
 +   return 0;
 +}
 +
 +static const char *print_vhost_scsi_dev(void *ptr)
 +{
 +VHostSCSI *p = ptr;
 +
 +return (p) ? vhost_scsi_get_id(p) : null;
 +}
 +