diff mbox

[6/9] vhost-scsi: new device supporting the tcm_vhost Linux kernel module

Message ID 1366381460-6041-7-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini April 19, 2013, 2:24 p.m. UTC
From: Nicholas Bellinger <nab@linux-iscsi.org>

The WWPN specified in configfs is passed to "-device vhost-scsi-pci".
The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not
available from the QEMU command-line.  Instead, I hardcode it to zero.

Changes in Patch-v2:
   - Add vhost_scsi_get_features() in order to determine feature bits
     supports by host kernel (mst + nab)
   - Re-enable usage of DEFINE_VIRTIO_COMMON_FEATURES, and allow
     EVENT_IDX to be disabled by host in vhost_scsi_get_features()
   - Drop unused hotplug bit in DEFINE_VHOST_SCSI_PROPERTIES

Changes in Patch-v1:
   - Set event_idx=off by default (nab, thanks asias)
   - Disable hotplug feature bit for v3.9 tcm_vhost kernel code, need to
     re-enable in v3.10 (nab)
   - Update to latest qemu.git/master HEAD

Changes in WIP-V3:
   - Drop ioeventfd vhost_scsi_properties (asias, thanks stefanha)
   - Add CONFIG_VHOST_SCSI (asias, thanks stefanha)
   - Add hotplug feature bit

Changes in WIP-V2:
   - Add backend guest masking support (nab)
   - Bump ABI_VERSION to 1 (nab)
   - Set up set_guest_notifiers (asias)
   - Set up vs->dev.vq_index (asias)
   - Drop vs->vs.vdev.{set,clear}_vhost_endpoint (asias)
   - Drop VIRTIO_CONFIG_S_DRIVER check in vhost_scsi_set_status (asias)

Howto:
   Use the latest seabios, at least commit b44a7be17b
   git clone git://git.seabios.org/seabios.git
   make
   cp out/bios.bin /usr/share/qemu/bios.bin
   qemu -device vhost-scsi-pci,wwpn=naa.6001405bd4e8476d
...

Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Asias He <asias@redhat.com>
[ Rebase on top of VirtIOSCSICommon patch, fix bugs in feature
  negotiation and irqfd masking - Paolo ]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure                       |  10 ++
 hw/scsi/Makefile.objs           |   6 +-
 hw/scsi/vhost-scsi.c            | 288 ++++++++++++++++++++++++++++++++++++++++
 include/hw/virtio/vhost-scsi.h  |  73 ++++++++++
 include/hw/virtio/virtio-scsi.h |   2 +
 5 files changed, 378 insertions(+), 1 deletion(-)
 create mode 100644 hw/scsi/vhost-scsi.c
 create mode 100644 include/hw/virtio/vhost-scsi.h

Comments

Wayne Xia May 28, 2013, 7:13 a.m. UTC | #1
于 2013-4-19 22:24, Paolo Bonzini 写道:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
> 
> The WWPN specified in configfs is passed to "-device vhost-scsi-pci".
> The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not
> available from the QEMU command-line.  Instead, I hardcode it to zero.
> 
Hi, Paolo
  Any document about how to config it correctly in configfs, before
invoking qemu with the WWPN number?


> Changes in Patch-v2:
>     - Add vhost_scsi_get_features() in order to determine feature bits
>       supports by host kernel (mst + nab)
>     - Re-enable usage of DEFINE_VIRTIO_COMMON_FEATURES, and allow
>       EVENT_IDX to be disabled by host in vhost_scsi_get_features()
>     - Drop unused hotplug bit in DEFINE_VHOST_SCSI_PROPERTIES
> 
> Changes in Patch-v1:
>     - Set event_idx=off by default (nab, thanks asias)
>     - Disable hotplug feature bit for v3.9 tcm_vhost kernel code, need to
>       re-enable in v3.10 (nab)
>     - Update to latest qemu.git/master HEAD
> 
> Changes in WIP-V3:
>     - Drop ioeventfd vhost_scsi_properties (asias, thanks stefanha)
>     - Add CONFIG_VHOST_SCSI (asias, thanks stefanha)
>     - Add hotplug feature bit
> 
> Changes in WIP-V2:
>     - Add backend guest masking support (nab)
>     - Bump ABI_VERSION to 1 (nab)
>     - Set up set_guest_notifiers (asias)
>     - Set up vs->dev.vq_index (asias)
>     - Drop vs->vs.vdev.{set,clear}_vhost_endpoint (asias)
>     - Drop VIRTIO_CONFIG_S_DRIVER check in vhost_scsi_set_status (asias)
> 
> Howto:
>     Use the latest seabios, at least commit b44a7be17b
>     git clone git://git.seabios.org/seabios.git
>     make
>     cp out/bios.bin /usr/share/qemu/bios.bin
>     qemu -device vhost-scsi-pci,wwpn=naa.6001405bd4e8476d
> ...
> 
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> Signed-off-by: Asias He <asias@redhat.com>
> [ Rebase on top of VirtIOSCSICommon patch, fix bugs in feature
>    negotiation and irqfd masking - Paolo ]
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   configure                       |  10 ++
>   hw/scsi/Makefile.objs           |   6 +-
>   hw/scsi/vhost-scsi.c            | 288 ++++++++++++++++++++++++++++++++++++++++
>   include/hw/virtio/vhost-scsi.h  |  73 ++++++++++
>   include/hw/virtio/virtio-scsi.h |   2 +
>   5 files changed, 378 insertions(+), 1 deletion(-)
>   create mode 100644 hw/scsi/vhost-scsi.c
>   create mode 100644 include/hw/virtio/vhost-scsi.h
> 
> diff --git a/configure b/configure
> index ed49f91..51a6c56 100755
> --- a/configure
> +++ b/configure
> @@ -179,6 +179,7 @@ libattr=""
>   xfs=""
> 
>   vhost_net="no"
> +vhost_scsi="no"
>   kvm="no"
>   gprof="no"
>   debug_tcg="no"
> @@ -543,6 +544,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
> @@ -870,6 +872,10 @@ for opt do
>     ;;
>     --enable-vhost-net) vhost_net="yes"
>     ;;
> +  --disable-vhost-scsi) vhost_scsi="no"
> +  ;;
> +  --enable-vhost-scsi) vhost_scsi="yes"
> +  ;;
>     --disable-glx) glx="no"
>     ;;
>     --enable-glx) glx="yes"
> @@ -3553,6 +3559,7 @@ echo "sigev_thread_id   $sigev_thread_id"
>   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 ($spice_protocol_version/$spice_server_version)"
> @@ -3836,6 +3843,9 @@ fi
>   if test "$virtfs" = "yes" ; then
>     echo "CONFIG_VIRTFS=y" >> $config_host_mak
>   fi
> +if test "$vhost_scsi" = "yes" ; then
> +  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
> +fi
>   if test "$blobs" = "yes" ; then
>     echo "INSTALL_BLOBS=yes" >> $config_host_mak
>   fi
> diff --git a/hw/scsi/Makefile.objs b/hw/scsi/Makefile.objs
> index eaec6c8..121ddc5 100644
> --- a/hw/scsi/Makefile.objs
> +++ b/hw/scsi/Makefile.objs
> @@ -6,4 +6,8 @@ common-obj-$(CONFIG_VMW_PVSCSI_SCSI_PCI) += vmw_pvscsi.o
>   common-obj-$(CONFIG_ESP) += esp.o
>   common-obj-$(CONFIG_ESP_PCI) += esp-pci.o
>   obj-$(CONFIG_PSERIES) += spapr_vscsi.o
> -obj-$(CONFIG_VIRTIO) += virtio-scsi.o
> +
> +ifeq ($(CONFIG_VIRTIO),y)
> +obj-y += virtio-scsi.o
> +obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o
> +endif
> diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
> new file mode 100644
> index 0000000..3dd1a0f
> --- /dev/null
> +++ b/hw/scsi/vhost-scsi.c
> @@ -0,0 +1,288 @@
> +/*
> + * vhost_scsi host device
> + *
> + * Copyright IBM, Corp. 2011
> + *
> + * Authors:
> + *  Stefan Hajnoczi   <stefanha@linux.vnet.ibm.com>
> + *
> + * Changes for QEMU mainline + tcm_vhost kernel upstream:
> + *  Nicholas Bellinger <nab@risingtidesystems.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2 or later.
> + * See the COPYING.LIB file in the top-level directory.
> + *
> + */
> +
> +#include <sys/ioctl.h>
> +#include "config.h"
> +#include "qemu/queue.h"
> +#include "monitor/monitor.h"
> +#include "migration/migration.h"
> +#include "hw/virtio/vhost-scsi.h"
> +#include "hw/virtio/vhost.h"
> +#include "hw/virtio/virtio-scsi.h"
> +
> +static int vhost_scsi_set_endpoint(VHostSCSI *s)
> +{
> +    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
> +    struct vhost_scsi_target backend;
> +    int ret;
> +
> +    memset(&backend, 0, sizeof(backend));
> +    pstrcpy(backend.vhost_wwpn, sizeof(backend.vhost_wwpn), vs->conf.wwpn);
> +    ret = ioctl(s->dev.control, VHOST_SCSI_SET_ENDPOINT, &backend);
> +    if (ret < 0) {
> +        return -errno;
> +    }
> +    return 0;
> +}
> +
> +static void vhost_scsi_clear_endpoint(VHostSCSI *s)
> +{
> +    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
> +    struct vhost_scsi_target backend;
> +
> +    memset(&backend, 0, sizeof(backend));
> +    pstrcpy(backend.vhost_wwpn, sizeof(backend.vhost_wwpn), vs->conf.wwpn);
> +    ioctl(s->dev.control, VHOST_SCSI_CLEAR_ENDPOINT, &backend);
> +}
> +
> +static int vhost_scsi_start(VHostSCSI *s)
> +{
> +    int ret, abi_version, i;
> +    VirtIODevice *vdev = VIRTIO_DEVICE(s);
> +
> +    if (!vdev->binding->set_guest_notifiers) {
> +        error_report("binding does not support guest notifiers");
> +        return -ENOSYS;
> +    }
> +
> +    ret = ioctl(s->dev.control, VHOST_SCSI_GET_ABI_VERSION, &abi_version);
> +    if (ret < 0) {
> +        return -errno;
> +    }
> +    if (abi_version > VHOST_SCSI_ABI_VERSION) {
> +        error_report("vhost-scsi: The running tcm_vhost kernel abi_version:"
> +                     " %d is greater than vhost_scsi userspace supports: %d, please"
> +                     " upgrade your version of QEMU\n", abi_version,
> +                     VHOST_SCSI_ABI_VERSION);
> +        return -ENOSYS;
> +    }
> +
> +    ret = vhost_dev_enable_notifiers(&s->dev, vdev);
> +    if (ret < 0) {
> +        return ret;
> +    }
> +
> +    s->dev.acked_features = vdev->guest_features;
> +    ret = vhost_dev_start(&s->dev, vdev);
> +    if (ret < 0) {
> +        error_report("Error start vhost dev");
> +        goto err_notifiers;
> +    }
> +
> +    ret = vhost_scsi_set_endpoint(s);
> +    if (ret < 0) {
> +        error_report("Error set vhost-scsi endpoint");
> +        goto err_vhost_stop;
> +    }
> +
> +    ret = vdev->binding->set_guest_notifiers(vdev->binding_opaque, s->dev.nvqs, true);
> +    if (ret < 0) {
> +        error_report("Error binding guest notifier");
> +        goto err_endpoint;
> +    }
> +
> +    /* guest_notifier_mask/pending not used yet, so just unmask
> +     * everything here.  virtio-pci will do the right thing by
> +     * enabling/disabling irqfd.
> +     */
> +    for (i = 0; i < s->dev.nvqs; i++) {
> +        vhost_virtqueue_mask(&s->dev, vdev, i, false);
> +    }
> +
> +    return ret;
> +
> +err_endpoint:
> +    vhost_scsi_clear_endpoint(s);
> +err_vhost_stop:
> +    vhost_dev_stop(&s->dev, vdev);
> +err_notifiers:
> +    vhost_dev_disable_notifiers(&s->dev, vdev);
> +    return ret;
> +}
> +
> +static void vhost_scsi_stop(VHostSCSI *s)
> +{
> +    VirtIODevice *vdev = VIRTIO_DEVICE(s);
> +    int ret = 0;
> +
> +    if (!vdev->binding->set_guest_notifiers) {
> +        ret = vdev->binding->set_guest_notifiers(vdev->binding_opaque,
> +                                                 s->dev.nvqs, false);
> +        if (ret < 0) {
> +                error_report("vhost guest notifier cleanup failed: %d\n", ret);
> +        }
> +    }
> +    assert(ret >= 0);
> +
> +    vhost_scsi_clear_endpoint(s);
> +    vhost_dev_stop(&s->dev, vdev);
> +    vhost_dev_disable_notifiers(&s->dev, vdev);
> +}
> +
> +static uint32_t vhost_scsi_get_features(VirtIODevice *vdev,
> +                                        uint32_t features)
> +{
> +    VHostSCSI *s = VHOST_SCSI(vdev);
> +
> +    /* Clear features not supported by host kernel. */
> +    if (!(s->dev.features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY))) {
> +        features &= ~(1 << VIRTIO_F_NOTIFY_ON_EMPTY);
> +    }
> +    if (!(s->dev.features & (1 << VIRTIO_RING_F_INDIRECT_DESC))) {
> +        features &= ~(1 << VIRTIO_RING_F_INDIRECT_DESC);
> +    }
> +    if (!(s->dev.features & (1 << VIRTIO_RING_F_EVENT_IDX))) {
> +        features &= ~(1 << VIRTIO_RING_F_EVENT_IDX);
> +    }
> +    if (!(s->dev.features & (1 << VIRTIO_SCSI_F_HOTPLUG))) {
> +        features &= ~(1 << VIRTIO_SCSI_F_HOTPLUG);
> +    }
> +
> +    return features;
> +}
> +
> +static void vhost_scsi_set_config(VirtIODevice *vdev,
> +                                  const uint8_t *config)
> +{
> +    VirtIOSCSIConfig *scsiconf = (VirtIOSCSIConfig *)config;
> +    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
> +
> +    if ((uint32_t) ldl_raw(&scsiconf->sense_size) != vs->sense_size ||
> +        (uint32_t) ldl_raw(&scsiconf->cdb_size) != vs->cdb_size) {
> +        error_report("vhost-scsi does not support changing the sense data and CDB sizes");
> +        exit(1);
> +    }
> +}
> +
> +static void vhost_scsi_set_status(VirtIODevice *vdev, uint8_t val)
> +{
> +    VHostSCSI *s = (VHostSCSI *)vdev;
> +    bool start = (val & VIRTIO_CONFIG_S_DRIVER_OK);
> +
> +    if (s->dev.started == start) {
> +        return;
> +    }
> +
> +    if (start) {
> +        int ret;
> +
> +        ret = vhost_scsi_start(s);
> +        if (ret < 0) {
> +            error_report("virtio-scsi: unable to start vhost: %s\n",
> +                         strerror(-ret));
> +
> +            /* There is no userspace virtio-scsi fallback so exit */
> +            exit(1);
> +        }
> +    } else {
> +        vhost_scsi_stop(s);
> +    }
> +}
> +
> +static int vhost_scsi_init(VirtIODevice *vdev)
> +{
> +    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
> +    VHostSCSI *s = VHOST_SCSI(vdev);
> +    int vhostfd = -1;
> +    int ret;
> +
> +    if (!vs->conf.wwpn) {
> +        error_report("vhost-scsi: missing wwpn\n");
> +        return -EINVAL;
> +    }
> +
> +    if (vs->conf.vhostfd) {
> +        vhostfd = monitor_handle_fd_param(cur_mon, vs->conf.vhostfd);
> +        if (vhostfd == -1) {
> +            error_report("vhost-scsi: unable to parse vhostfd\n");
> +            return -EINVAL;
> +        }
> +    }
> +
> +    ret = virtio_scsi_common_init(vs);
> +    if (ret < 0) {
> +        return ret;
> +    }
> +
> +    vdev->get_features = vhost_scsi_get_features;
> +    vdev->set_config = vhost_scsi_set_config;
> +    vdev->set_status = vhost_scsi_set_status;
> +
> +    s->dev.nvqs = VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues;
> +    s->dev.vqs = g_new(struct vhost_virtqueue, s->dev.nvqs);
> +    s->dev.vq_index = 0;
> +
> +    ret = vhost_dev_init(&s->dev, vhostfd, "/dev/vhost-scsi", true);
> +    if (ret < 0) {
> +        error_report("vhost-scsi: vhost initialization failed: %s\n",
> +                strerror(-ret));
> +        return ret;
> +    }
> +    s->dev.backend_features = 0;
> +
> +    error_setg(&s->migration_blocker,
> +            "vhost-scsi does not support migration");
> +    migrate_add_blocker(s->migration_blocker);
> +
> +    return 0;
> +}
> +
> +static int vhost_scsi_exit(DeviceState *qdev)
> +{
> +    VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
> +    VHostSCSI *s = VHOST_SCSI(qdev);
> +    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(qdev);
> +
> +    migrate_del_blocker(s->migration_blocker);
> +    error_free(s->migration_blocker);
> +
> +    /* This will stop vhost backend. */
> +    vhost_scsi_set_status(vdev, 0);
> +
> +    g_free(s->dev.vqs);
> +    return virtio_scsi_common_exit(vs);
> +}
> +
> +static Property vhost_scsi_properties[] = {
> +    DEFINE_VHOST_SCSI_PROPERTIES(VHostSCSI, parent_obj.conf),
> +    DEFINE_PROP_END_OF_LIST(),
> +};
> +
> +static void vhost_scsi_class_init(ObjectClass *klass, void *data)
> +{
> +    DeviceClass *dc = DEVICE_CLASS(klass);
> +    VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
> +    dc->exit = vhost_scsi_exit;
> +    dc->props = vhost_scsi_properties;
> +    vdc->init = vhost_scsi_init;
> +    vdc->get_features = vhost_scsi_get_features;
> +    vdc->set_config = vhost_scsi_set_config;
> +    vdc->set_status = vhost_scsi_set_status;
> +}
> +
> +static const TypeInfo vhost_scsi_info = {
> +    .name = TYPE_VHOST_SCSI,
> +    .parent = TYPE_VIRTIO_SCSI_COMMON,
> +    .instance_size = sizeof(VHostSCSI),
> +    .class_init = vhost_scsi_class_init,
> +};
> +
> +static void virtio_register_types(void)
> +{
> +    type_register_static(&vhost_scsi_info);
> +}
> +
> +type_init(virtio_register_types)
> diff --git a/include/hw/virtio/vhost-scsi.h b/include/hw/virtio/vhost-scsi.h
> new file mode 100644
> index 0000000..85cc031
> --- /dev/null
> +++ b/include/hw/virtio/vhost-scsi.h
> @@ -0,0 +1,73 @@
> +/*
> + * vhost_scsi host device
> + *
> + * Copyright IBM, Corp. 2011
> + *
> + * Authors:
> + *  Stefan Hajnoczi   <stefanha@linux.vnet.ibm.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2 or later.
> + * See the COPYING.LIB file in the top-level directory.
> + *
> + */
> +
> +#ifndef VHOST_SCSI_H
> +#define VHOST_SCSI_H
> +
> +#include "qemu-common.h"
> +#include "hw/qdev.h"
> +#include "hw/virtio/virtio-scsi.h"
> +#include "hw/virtio/vhost.h"
> +
> +/*
> + * Used by QEMU userspace to ensure a consistent vhost-scsi ABI.
> + *
> + * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate +
> + *            RFC-v2 vhost-scsi userspace.  Add GET_ABI_VERSION ioctl usage
> + * ABI Rev 1: January 2013. Ignore vhost_tpgt filed in struct vhost_scsi_target.
> + * 	      All the targets under vhost_wwpn can be seen and used by guest.
> + */
> +
> +#define VHOST_SCSI_ABI_VERSION 1
> +
> +/* TODO #include <linux/vhost.h> properly */
> +/* For VHOST_SCSI_SET_ENDPOINT/VHOST_SCSI_CLEAR_ENDPOINT ioctl */
> +struct vhost_scsi_target {
> +    int abi_version;
> +    char vhost_wwpn[224];
> +    unsigned short vhost_tpgt;
> +    unsigned short reserved;
> +};
> +
> +enum vhost_scsi_vq_list {
> +    VHOST_SCSI_VQ_CONTROL = 0,
> +    VHOST_SCSI_VQ_EVENT = 1,
> +    VHOST_SCSI_VQ_NUM_FIXED = 2,
> +};
> +
> +#define VHOST_VIRTIO 0xAF
> +#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target)
> +#define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
> +#define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int)
> +
> +#define TYPE_VHOST_SCSI "vhost-scsi"
> +#define VHOST_SCSI(obj) \
> +        OBJECT_CHECK(VHostSCSI, (obj), TYPE_VHOST_SCSI)
> +
> +typedef struct VHostSCSI {
> +    VirtIOSCSICommon parent_obj;
> +
> +    Error *migration_blocker;
> +
> +    struct vhost_dev dev;
> +} VHostSCSI;
> +
> +#define DEFINE_VHOST_SCSI_PROPERTIES(_state, _conf_field) \
> +    DEFINE_PROP_STRING("vhostfd", _state, _conf_field.vhostfd), \
> +    DEFINE_PROP_STRING("wwpn", _state, _conf_field.wwpn), \
> +    DEFINE_PROP_UINT32("num_queues", _state, _conf_field.num_queues, 1), \
> +    DEFINE_PROP_UINT32("max_sectors", _state, _conf_field.max_sectors, 0xFFFF), \
> +    DEFINE_PROP_UINT32("cmd_per_lun", _state, _conf_field.cmd_per_lun, 128)
> +
> +
> +#endif
> diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
> index 4a961b9..4db346b 100644
> --- a/include/hw/virtio/virtio-scsi.h
> +++ b/include/hw/virtio/virtio-scsi.h
> @@ -151,6 +151,8 @@ struct VirtIOSCSIConf {
>       uint32_t num_queues;
>       uint32_t max_sectors;
>       uint32_t cmd_per_lun;
> +    char *vhostfd;
> +    char *wwpn;
>   };
> 
>   typedef struct VirtIOSCSICommon {
>
Paolo Bonzini May 28, 2013, 8:01 a.m. UTC | #2
Il 28/05/2013 09:13, Wenchao Xia ha scritto:
>> > From: Nicholas Bellinger <nab@linux-iscsi.org>
>> > 
>> > The WWPN specified in configfs is passed to "-device vhost-scsi-pci".
>> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not
>> > available from the QEMU command-line.  Instead, I hardcode it to zero.
>> > 
> Hi, Paolo
>   Any document about how to config it correctly in configfs, before
> invoking qemu with the WWPN number?

Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
iSCSI for example) so it's quite simple.  Here is an example:

cd /sys/kernel/config/target
mkdir -p core/fileio_0/fileio
echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' > core/fileio_0/fileio/control
echo 1 > core/fileio_0/fileio/enable
mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
cd vhost/naa.600140554cf3a18e/tpgt_0
ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
echo naa.60014053226f0388 > nexus

The "nexus" value is the initiator WWN.  naa.600140554cf3a18e is the
target WWN that you have to pass to "-device vhost-scsi-pci".

Paolo
Asias He May 28, 2013, 8:33 a.m. UTC | #3
On Tue, May 28, 2013 at 10:01:14AM +0200, Paolo Bonzini wrote:
> Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> >> > 
> >> > The WWPN specified in configfs is passed to "-device vhost-scsi-pci".
> >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not
> >> > available from the QEMU command-line.  Instead, I hardcode it to zero.
> >> > 
> > Hi, Paolo
> >   Any document about how to config it correctly in configfs, before
> > invoking qemu with the WWPN number?
> 
> Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
> iSCSI for example) so it's quite simple.  Here is an example:
> 
> cd /sys/kernel/config/target
> mkdir -p core/fileio_0/fileio
> echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' > core/fileio_0/fileio/control
> echo 1 > core/fileio_0/fileio/enable
> mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> cd vhost/naa.600140554cf3a18e/tpgt_0
> ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
> echo naa.60014053226f0388 > nexus
> 
> The "nexus" value is the initiator WWN.  naa.600140554cf3a18e is the
> target WWN that you have to pass to "-device vhost-scsi-pci".
> 
> Paolo

For me, I always use targetcli utils instead of the sysfs interface.
targetcli in F18 has vhost support now.
Wayne Xia May 28, 2013, 9 a.m. UTC | #4
于 2013-5-28 16:33, Asias He 写道:
> On Tue, May 28, 2013 at 10:01:14AM +0200, Paolo Bonzini wrote:
>> Il 28/05/2013 09:13, Wenchao Xia ha scritto:
>>>>> From: Nicholas Bellinger <nab@linux-iscsi.org>
>>>>>
>>>>> The WWPN specified in configfs is passed to "-device vhost-scsi-pci".
>>>>> The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not
>>>>> available from the QEMU command-line.  Instead, I hardcode it to zero.
>>>>>
>>> Hi, Paolo
>>>    Any document about how to config it correctly in configfs, before
>>> invoking qemu with the WWPN number?
>>
>> Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
>> iSCSI for example) so it's quite simple.  Here is an example:
>>
>> cd /sys/kernel/config/target
>> mkdir -p core/fileio_0/fileio
>> echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' > core/fileio_0/fileio/control
>> echo 1 > core/fileio_0/fileio/enable
>> mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
>> cd vhost/naa.600140554cf3a18e/tpgt_0
>> ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
>> echo naa.60014053226f0388 > nexus
>>
>> The "nexus" value is the initiator WWN.  naa.600140554cf3a18e is the
>> target WWN that you have to pass to "-device vhost-scsi-pci".
>>
>> Paolo
>
> For me, I always use targetcli utils instead of the sysfs interface.
> targetcli in F18 has vhost support now.
>
   Thanks very much for above information, I'll try it for test.
Wayne Xia May 29, 2013, 9:05 a.m. UTC | #5
于 2013-5-28 17:00, Wenchao Xia 写道:
> 于 2013-5-28 16:33, Asias He 写道:
>> On Tue, May 28, 2013 at 10:01:14AM +0200, Paolo Bonzini wrote:
>>> Il 28/05/2013 09:13, Wenchao Xia ha scritto:
>>>>>> From: Nicholas Bellinger <nab@linux-iscsi.org>
>>>>>>
>>>>>> The WWPN specified in configfs is passed to "-device vhost-scsi-pci".
>>>>>> The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is
>>>>>> not
>>>>>> available from the QEMU command-line.  Instead, I hardcode it to
>>>>>> zero.
>>>>>>
>>>> Hi, Paolo
>>>>    Any document about how to config it correctly in configfs, before
>>>> invoking qemu with the WWPN number?
>>>
>>> Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
>>> iSCSI for example) so it's quite simple.  Here is an example:
>>>
>>> cd /sys/kernel/config/target
>>> mkdir -p core/fileio_0/fileio
>>> echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
>>> core/fileio_0/fileio/control
>>> echo 1 > core/fileio_0/fileio/enable
>>> mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
>>> cd vhost/naa.600140554cf3a18e/tpgt_0
>>> ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
>>> echo naa.60014053226f0388 > nexus
>>>
>>> The "nexus" value is the initiator WWN.  naa.600140554cf3a18e is the
>>> target WWN that you have to pass to "-device vhost-scsi-pci".
>>>
>>> Paolo
>>
>> For me, I always use targetcli utils instead of the sysfs interface.
>> targetcli in F18 has vhost support now.
>>
>    Thanks very much for above information, I'll try it for test.
>
   I have done a basic test of vhost-scsi, following is the result I'd
like to post, generally it seems fine:

Result:
   fdisk/mkfs: fdisk can find it, mke2fs works fine.
   mount: can mount it.
   file I/O: dd 90M zero to a file in that disk succeed.

Issues:
   1) in fdisk -l, sometime timeout with dmesg "end_request: I/O error,
dev  fd0, sector 0", I guess it is caused by nested KVM that failed
to kick host kernel?
   2) in fdisk -l, it shows 512 bytes larger than the parameter I
specified in fd_dev_size parameter in configfs on host.(shows
104858112 bytes, see the invocation script below)

ENV:
  nested KVM:

                        RH6.4
(Qemu Virtual CPU 1.5.50, Linux 3.10.0.rc3)
                           |  (100M vhost-scsi hooked with file backend)
                        RH6.4
(Common KVM processer, Linux 3.10.0.rc3,
qemu-system-x86_64 1.5.50+, 6a4e17711442849bf2cc731ccddef5a2a2d92d29,
seabios 1.7.2.2, e9725dd76d5d7212cb4a97fd18ff2599538955cf)
                           |
                       Fefora 18
(Intel Xeon X5650, Linux version 3.8.11-200.fc18.x86_64,
  QEMU emulator version 1.2.2)

Invocation details:
   On RH6.4 host:
   1  with root, execute following script to prepare configfs system:

FILEIO=fileio_1
IMAGE=/home/xiawenc/Work/qemu/test/test1.raw
SIZE=104857600
QEMU_WWPN=naa.600140554cf3a1fe
NEXUS=naa.60014053226f03f8

mkdir -p /sys/kernel/config/target/core/$FILEIO/fileio
echo "fd_dev_name=$IMAGE,fd_dev_size=$SIZE" > 
/sys/kernel/config/target/core/$FILEIO/fileio/control
echo 1 > /sys/kernel/config/target/core/$FILEIO/fileio/enable

mkdir -p /sys/kernel/config/target/vhost/$QEMU_WWPN/tpgt_0/lun/lun_0
ln -sf /sys/kernel/config/target/core/$FILEIO/fileio/ 
/sys/kernel/config/target/vhost/$QEMU_WWPN/tpgt_0/lun/lun_0/virtual_scsi_port
echo $NEXUS > /sys/kernel/config/target/vhost/$QEMU_WWPN/tpgt_0/nexus

   2 invoke qemu, test_guest_RH64.qcow2 is a pre-made disk containing
RH6.4 system:

x86_64-softmmu/qemu-system-x86_64     --enablem 1024 -drive 
file=/mnt/nfs/test_guest_RH64.qcow2,if=ide,cache=writethrough -vnc 
0.0.0.0:10 -L mybios/ -device 
vhost-scsi-pci,wwpn=naa.600140554cf3a1fe,event_idx=off
Asias He May 29, 2013, 9:27 a.m. UTC | #6
On Wed, May 29, 2013 at 05:05:31PM +0800, Wenchao Xia wrote:
> 于 2013-5-28 17:00, Wenchao Xia 写道:
> >于 2013-5-28 16:33, Asias He 写道:
> >>On Tue, May 28, 2013 at 10:01:14AM +0200, Paolo Bonzini wrote:
> >>>Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> >>>>>>From: Nicholas Bellinger <nab@linux-iscsi.org>
> >>>>>>
> >>>>>>The WWPN specified in configfs is passed to "-device vhost-scsi-pci".
> >>>>>>The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is
> >>>>>>not
> >>>>>>available from the QEMU command-line.  Instead, I hardcode it to
> >>>>>>zero.
> >>>>>>
> >>>>Hi, Paolo
> >>>>   Any document about how to config it correctly in configfs, before
> >>>>invoking qemu with the WWPN number?
> >>>
> >>>Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
> >>>iSCSI for example) so it's quite simple.  Here is an example:
> >>>
> >>>cd /sys/kernel/config/target
> >>>mkdir -p core/fileio_0/fileio
> >>>echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> >>>core/fileio_0/fileio/control
> >>>echo 1 > core/fileio_0/fileio/enable
> >>>mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> >>>cd vhost/naa.600140554cf3a18e/tpgt_0
> >>>ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
> >>>echo naa.60014053226f0388 > nexus
> >>>
> >>>The "nexus" value is the initiator WWN.  naa.600140554cf3a18e is the
> >>>target WWN that you have to pass to "-device vhost-scsi-pci".
> >>>
> >>>Paolo
> >>
> >>For me, I always use targetcli utils instead of the sysfs interface.
> >>targetcli in F18 has vhost support now.
> >>
> >   Thanks very much for above information, I'll try it for test.
> >
>   I have done a basic test of vhost-scsi, following is the result I'd
> like to post, generally it seems fine:
> 
> Result:
>   fdisk/mkfs: fdisk can find it, mke2fs works fine.
>   mount: can mount it.
>   file I/O: dd 90M zero to a file in that disk succeed.
> 
> Issues:
>   1) in fdisk -l, sometime timeout with dmesg "end_request: I/O error,
> dev  fd0, sector 0", I guess it is caused by nested KVM that failed
> to kick host kernel?

Did you run without nested KVM?

>   2) in fdisk -l, it shows 512 bytes larger than the parameter I
> specified in fd_dev_size parameter in configfs on host.(shows
> 104858112 bytes, see the invocation script below)

Does targetcli give you the correct size? Also, to narrow the issue down,
you can try other backstores, e.g block or ramdisk.

> ENV:
>  nested KVM:
> 
>                        RH6.4
> (Qemu Virtual CPU 1.5.50, Linux 3.10.0.rc3)
>                           |  (100M vhost-scsi hooked with file backend)
>                        RH6.4
> (Common KVM processer, Linux 3.10.0.rc3,
> qemu-system-x86_64 1.5.50+, 6a4e17711442849bf2cc731ccddef5a2a2d92d29,
> seabios 1.7.2.2, e9725dd76d5d7212cb4a97fd18ff2599538955cf)
>                           |
>                       Fefora 18
> (Intel Xeon X5650, Linux version 3.8.11-200.fc18.x86_64,
>  QEMU emulator version 1.2.2)
> 
> Invocation details:
>   On RH6.4 host:
>   1  with root, execute following script to prepare configfs system:
> 
> FILEIO=fileio_1
> IMAGE=/home/xiawenc/Work/qemu/test/test1.raw
> SIZE=104857600
> QEMU_WWPN=naa.600140554cf3a1fe
> NEXUS=naa.60014053226f03f8
> 
> mkdir -p /sys/kernel/config/target/core/$FILEIO/fileio
> echo "fd_dev_name=$IMAGE,fd_dev_size=$SIZE" >
> /sys/kernel/config/target/core/$FILEIO/fileio/control
> echo 1 > /sys/kernel/config/target/core/$FILEIO/fileio/enable
> 
> mkdir -p /sys/kernel/config/target/vhost/$QEMU_WWPN/tpgt_0/lun/lun_0
> ln -sf /sys/kernel/config/target/core/$FILEIO/fileio/ /sys/kernel/config/target/vhost/$QEMU_WWPN/tpgt_0/lun/lun_0/virtual_scsi_port
> echo $NEXUS > /sys/kernel/config/target/vhost/$QEMU_WWPN/tpgt_0/nexus
> 
>   2 invoke qemu, test_guest_RH64.qcow2 is a pre-made disk containing
> RH6.4 system:
> 
> x86_64-softmmu/qemu-system-x86_64     --enablem 1024 -drive
> file=/mnt/nfs/test_guest_RH64.qcow2,if=ide,cache=writethrough -vnc
> 0.0.0.0:10 -L mybios/ -device
> vhost-scsi-pci,wwpn=naa.600140554cf3a1fe,event_idx=off
> 
> 
> -- 
> Best Regards
> 
> Wenchao Xia
>
Badari Pulavarty May 29, 2013, 3:10 p.m. UTC | #7
On 05/29/2013 02:05 AM, Wenchao Xia wrote:
> 于 2013-5-28 17:00, Wenchao Xia 写道:
>> 于 2013-5-28 16:33, Asias He 写道:
>>> On Tue, May 28, 2013 at 10:01:14AM +0200, Paolo Bonzini wrote:
>>>> Il 28/05/2013 09:13, Wenchao Xia ha scritto:
>>>>>>> From: Nicholas Bellinger <nab@linux-iscsi.org>
>>>>>>>
>>>>>>> The WWPN specified in configfs is passed to "-device 
>>>>>>> vhost-scsi-pci".
>>>>>>> The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is
>>>>>>> not
>>>>>>> available from the QEMU command-line.  Instead, I hardcode it to
>>>>>>> zero.
>>>>>>>
>>>>> Hi, Paolo
>>>>>    Any document about how to config it correctly in configfs, before
>>>>> invoking qemu with the WWPN number?
>>>>
>>>> Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
>>>> iSCSI for example) so it's quite simple.  Here is an example:
>>>>
>>>> cd /sys/kernel/config/target
>>>> mkdir -p core/fileio_0/fileio
>>>> echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
>>>> core/fileio_0/fileio/control
>>>> echo 1 > core/fileio_0/fileio/enable
>>>> mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
>>>> cd vhost/naa.600140554cf3a18e/tpgt_0
>>>> ln -sf ../../../../../core/fileio_0/fileio/ 
>>>> lun/lun_0/virtual_scsi_port
>>>> echo naa.60014053226f0388 > nexus
>>>>
>>>> The "nexus" value is the initiator WWN. naa.600140554cf3a18e is the
>>>> target WWN that you have to pass to "-device vhost-scsi-pci".
>>>>
>>>> Paolo
>>>
>>> For me, I always use targetcli utils instead of the sysfs interface.
>>> targetcli in F18 has vhost support now.
>>>
>>    Thanks very much for above information, I'll try it for test.
>>
>   I have done a basic test of vhost-scsi, following is the result I'd
> like to post, generally it seems fine:
>
> Result:
>   fdisk/mkfs: fdisk can find it, mke2fs works fine.
>   mount: can mount it.
>   file I/O: dd 90M zero to a file in that disk succeed.



I tried without nested kvm.

>
> Issues:
>   1) in fdisk -l, sometime timeout with dmesg "end_request: I/O error,
> dev  fd0, sector 0", I guess it is caused by nested KVM that failed
> to kick host kernel?


I don't see this issue. Are you sure "fd0" is actually the scsi device ?
what is "fd0" ?

>   2) in fdisk -l, it shows 512 bytes larger than the parameter I
> specified in fd_dev_size parameter in configfs on host.(shows
> 104858112 bytes, see the invocation script below)
>

I see the same. For some reason "fdisk -l" in the VM shows
512-bytes more than the actual size for the file (on the host).

Thanks,
Badari
Asias He May 29, 2013, 10:17 p.m. UTC | #8
On Wed, May 29, 2013 at 08:10:44AM -0700, Badari Pulavarty wrote:
> On 05/29/2013 02:05 AM, Wenchao Xia wrote:
> >于 2013-5-28 17:00, Wenchao Xia 写道:
> >>于 2013-5-28 16:33, Asias He 写道:
> >>>On Tue, May 28, 2013 at 10:01:14AM +0200, Paolo Bonzini wrote:
> >>>>Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> >>>>>>>From: Nicholas Bellinger <nab@linux-iscsi.org>
> >>>>>>>
> >>>>>>>The WWPN specified in configfs is passed to "-device
> >>>>>>>vhost-scsi-pci".
> >>>>>>>The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is
> >>>>>>>not
> >>>>>>>available from the QEMU command-line.  Instead, I hardcode it to
> >>>>>>>zero.
> >>>>>>>
> >>>>>Hi, Paolo
> >>>>>   Any document about how to config it correctly in configfs, before
> >>>>>invoking qemu with the WWPN number?
> >>>>
> >>>>Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
> >>>>iSCSI for example) so it's quite simple.  Here is an example:
> >>>>
> >>>>cd /sys/kernel/config/target
> >>>>mkdir -p core/fileio_0/fileio
> >>>>echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> >>>>core/fileio_0/fileio/control
> >>>>echo 1 > core/fileio_0/fileio/enable
> >>>>mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> >>>>cd vhost/naa.600140554cf3a18e/tpgt_0
> >>>>ln -sf ../../../../../core/fileio_0/fileio/
> >>>>lun/lun_0/virtual_scsi_port
> >>>>echo naa.60014053226f0388 > nexus
> >>>>
> >>>>The "nexus" value is the initiator WWN. naa.600140554cf3a18e is the
> >>>>target WWN that you have to pass to "-device vhost-scsi-pci".
> >>>>
> >>>>Paolo
> >>>
> >>>For me, I always use targetcli utils instead of the sysfs interface.
> >>>targetcli in F18 has vhost support now.
> >>>
> >>   Thanks very much for above information, I'll try it for test.
> >>
> >  I have done a basic test of vhost-scsi, following is the result I'd
> >like to post, generally it seems fine:
> >
> >Result:
> >  fdisk/mkfs: fdisk can find it, mke2fs works fine.
> >  mount: can mount it.
> >  file I/O: dd 90M zero to a file in that disk succeed.
> 
> 
> 
> I tried without nested kvm.
> 
> >
> >Issues:
> >  1) in fdisk -l, sometime timeout with dmesg "end_request: I/O error,
> >dev  fd0, sector 0", I guess it is caused by nested KVM that failed
> >to kick host kernel?
> 
> 
> I don't see this issue. Are you sure "fd0" is actually the scsi device ?
> what is "fd0" ?
> 
> >  2) in fdisk -l, it shows 512 bytes larger than the parameter I
> >specified in fd_dev_size parameter in configfs on host.(shows
> >104858112 bytes, see the invocation script below)
> >
> 
> I see the same. For some reason "fdisk -l" in the VM shows
> 512-bytes more than the actual size for the file (on the host).

Hmm, interesting. Will look into it.

Nick, Any ideas here?

> Thanks,
> Badari
>
Wayne Xia May 30, 2013, 2:09 a.m. UTC | #9
于 2013-5-29 23:10, Badari Pulavarty 写道:
> On 05/29/2013 02:05 AM, Wenchao Xia wrote:
>> 于 2013-5-28 17:00, Wenchao Xia 写道:
>>> 于 2013-5-28 16:33, Asias He 写道:
>>>> On Tue, May 28, 2013 at 10:01:14AM +0200, Paolo Bonzini wrote:
>>>>> Il 28/05/2013 09:13, Wenchao Xia ha scritto:
>>>>>>>> From: Nicholas Bellinger <nab@linux-iscsi.org>
>>>>>>>>
>>>>>>>> The WWPN specified in configfs is passed to "-device 
>>>>>>>> vhost-scsi-pci".
>>>>>>>> The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is
>>>>>>>> not
>>>>>>>> available from the QEMU command-line.  Instead, I hardcode it to
>>>>>>>> zero.
>>>>>>>>
>>>>>> Hi, Paolo
>>>>>>    Any document about how to config it correctly in configfs, before
>>>>>> invoking qemu with the WWPN number?
>>>>>
>>>>> Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
>>>>> iSCSI for example) so it's quite simple.  Here is an example:
>>>>>
>>>>> cd /sys/kernel/config/target
>>>>> mkdir -p core/fileio_0/fileio
>>>>> echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
>>>>> core/fileio_0/fileio/control
>>>>> echo 1 > core/fileio_0/fileio/enable
>>>>> mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
>>>>> cd vhost/naa.600140554cf3a18e/tpgt_0
>>>>> ln -sf ../../../../../core/fileio_0/fileio/ 
>>>>> lun/lun_0/virtual_scsi_port
>>>>> echo naa.60014053226f0388 > nexus
>>>>>
>>>>> The "nexus" value is the initiator WWN. naa.600140554cf3a18e is the
>>>>> target WWN that you have to pass to "-device vhost-scsi-pci".
>>>>>
>>>>> Paolo
>>>>
>>>> For me, I always use targetcli utils instead of the sysfs interface.
>>>> targetcli in F18 has vhost support now.
>>>>
>>>    Thanks very much for above information, I'll try it for test.
>>>
>>   I have done a basic test of vhost-scsi, following is the result I'd
>> like to post, generally it seems fine:
>>
>> Result:
>>   fdisk/mkfs: fdisk can find it, mke2fs works fine.
>>   mount: can mount it.
>>   file I/O: dd 90M zero to a file in that disk succeed.
> 
> 
> 
> I tried without nested kvm.
> 
>>
>> Issues:
>>   1) in fdisk -l, sometime timeout with dmesg "end_request: I/O error,
>> dev  fd0, sector 0", I guess it is caused by nested KVM that failed
>> to kick host kernel?
> 
> 
> I don't see this issue. Are you sure "fd0" is actually the scsi device ?
> what is "fd0" ?
> 
  I am not sure, it just come out from dmesg when fdisk -l hung, and
following line is "sdb" which is the vhost-scsi device, and fdisk
printing stopped before "sdb" for a few seconds, so I think it's it.
it happened once after my partition operation.
  My instinct opinion is it happens only in nested KVM when host
missed a kick, since following I/O can succeed. Sadly I have no
bare-metal at hand to test as a comparation.

>>   2) in fdisk -l, it shows 512 bytes larger than the parameter I
>> specified in fd_dev_size parameter in configfs on host.(shows
>> 104858112 bytes, see the invocation script below)
>>
> 
> I see the same. For some reason "fdisk -l" in the VM shows
> 512-bytes more than the actual size for the file (on the host).
> 
> Thanks,
> Badari
>
Libaiqing June 19, 2013, 12:55 p.m. UTC | #10
Hi paolo,
  The vhost-scsi device can be used as boot device?
  I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
  Could you give me some advise to debug this problem ? I can provide more information if need.

Regards,
baiqing

> -----Original Message-----
> From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
> [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org] On
> Behalf Of Paolo Bonzini
> Sent: Tuesday, May 28, 2013 4:01 PM
> To: Wenchao Xia
> Cc: asias@redhat.com; qemu-devel@nongnu.org; nab@linux-iscsi.org;
> Michael S. Tsirkin
> Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> tcm_vhost Linux kernel module
> 
> Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> >> >
> >> > The WWPN specified in configfs is passed to "-device vhost-scsi-pci".
> >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not
> >> > available from the QEMU command-line.  Instead, I hardcode it to
> zero.
> >> >
> > Hi, Paolo
> >   Any document about how to config it correctly in configfs, before
> > invoking qemu with the WWPN number?
> 
> Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
> iSCSI for example) so it's quite simple.  Here is an example:
> 
> cd /sys/kernel/config/target
> mkdir -p core/fileio_0/fileio
> echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> core/fileio_0/fileio/control
> echo 1 > core/fileio_0/fileio/enable
> mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> cd vhost/naa.600140554cf3a18e/tpgt_0
> ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
> echo naa.60014053226f0388 > nexus
> 
> The "nexus" value is the initiator WWN.  naa.600140554cf3a18e is the
> target WWN that you have to pass to "-device vhost-scsi-pci".
> 
> Paolo
Asias He June 20, 2013, 1:33 a.m. UTC | #11
On Wed, Jun 19, 2013 at 12:55:10PM +0000, Libaiqing wrote:
> Hi paolo,
>   The vhost-scsi device can be used as boot device?
>   I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
>   Could you give me some advise to debug this problem ? I can provide more information if need.

Boot from vhost-scsi is supposed to work. The seabios you used should be
fine which contains the fixes for vhost-scsi.

Instead of playing with the /sys/kernel/config/target directly, I really
recommend using targetcli utils.

Nab, I think we really should write some docs for people to use
vhost-scsi.

This is how I install and use targetcli in RHEL6. Note you need upstream
kernel and qemu bits for vhost-scsi.

# yum groupinstall  'Development tools'
# yum install python-devel epydoc python-simpleparse

# git clone git://github.com/agrover/rtslib-fb.git
# git clone git://github.com/agrover/targetcli-fb.git
# git clone git://github.com/agrover/configshell-fb.git
# for i in rtslib-fb configshell-fb targetcli-fb; do
  	make -C $i rpm
  	yum localinstall $i/dist/*.noarch.rpm
  done

In targetcli, create a backstore and vhost wwpn, e.g.
# targetcli
/> /backstores/ramdisk create r0 1g
/> /vhost create
/> cd /vhost/naa.500140527cb6616b/tpg1/luns
/> create /backstores/ramdisk/r0

# qemu -device vhost-scsi-pci,wwpn=naa.500140527cb6616b ...

Hope this helps.

> Regards,
> baiqing
> 
> > -----Original Message-----
> > From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
> > [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org] On
> > Behalf Of Paolo Bonzini
> > Sent: Tuesday, May 28, 2013 4:01 PM
> > To: Wenchao Xia
> > Cc: asias@redhat.com; qemu-devel@nongnu.org; nab@linux-iscsi.org;
> > Michael S. Tsirkin
> > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> > tcm_vhost Linux kernel module
> > 
> > Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> > >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > >> >
> > >> > The WWPN specified in configfs is passed to "-device vhost-scsi-pci".
> > >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not
> > >> > available from the QEMU command-line.  Instead, I hardcode it to
> > zero.
> > >> >
> > > Hi, Paolo
> > >   Any document about how to config it correctly in configfs, before
> > > invoking qemu with the WWPN number?
> > 
> > Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
> > iSCSI for example) so it's quite simple.  Here is an example:
> > 
> > cd /sys/kernel/config/target
> > mkdir -p core/fileio_0/fileio
> > echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> > core/fileio_0/fileio/control
> > echo 1 > core/fileio_0/fileio/enable
> > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> > cd vhost/naa.600140554cf3a18e/tpgt_0
> > ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
> > echo naa.60014053226f0388 > nexus
> > 
> > The "nexus" value is the initiator WWN.  naa.600140554cf3a18e is the
> > target WWN that you have to pass to "-device vhost-scsi-pci".
> > 
> > Paolo
>
Wayne Xia June 20, 2013, 3:22 a.m. UTC | #12
于 2013-6-20 9:33, Asias He 写道:
> On Wed, Jun 19, 2013 at 12:55:10PM +0000, Libaiqing wrote:
>> Hi paolo,
>>    The vhost-scsi device can be used as boot device?
>>    I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
>>    Could you give me some advise to debug this problem ? I can provide more information if need.
>
> Boot from vhost-scsi is supposed to work. The seabios you used should be
> fine which contains the fixes for vhost-scsi.
>
> Instead of playing with the /sys/kernel/config/target directly, I really
> recommend using targetcli utils.
>
> Nab, I think we really should write some docs for people to use
> vhost-scsi.

   A section in qemu-options.hx would be great, currently an example is
good enough to me.

>
> This is how I install and use targetcli in RHEL6. Note you need upstream
> kernel and qemu bits for vhost-scsi.
>
> # yum groupinstall  'Development tools'
> # yum install python-devel epydoc python-simpleparse
>
> # git clone git://github.com/agrover/rtslib-fb.git
> # git clone git://github.com/agrover/targetcli-fb.git
> # git clone git://github.com/agrover/configshell-fb.git
> # for i in rtslib-fb configshell-fb targetcli-fb; do
>    	make -C $i rpm
>    	yum localinstall $i/dist/*.noarch.rpm
>    done
>
> In targetcli, create a backstore and vhost wwpn, e.g.
> # targetcli
> /> /backstores/ramdisk create r0 1g
> /> /vhost create
> /> cd /vhost/naa.500140527cb6616b/tpg1/luns
> /> create /backstores/ramdisk/r0
>
> # qemu -device vhost-scsi-pci,wwpn=naa.500140527cb6616b ...
>
> Hope this helps.
>
>> Regards,
>> baiqing
>>
>>> -----Original Message-----
>>> From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
>>> [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org] On
>>> Behalf Of Paolo Bonzini
>>> Sent: Tuesday, May 28, 2013 4:01 PM
>>> To: Wenchao Xia
>>> Cc: asias@redhat.com; qemu-devel@nongnu.org; nab@linux-iscsi.org;
>>> Michael S. Tsirkin
>>> Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
>>> tcm_vhost Linux kernel module
>>>
>>> Il 28/05/2013 09:13, Wenchao Xia ha scritto:
>>>>>> From: Nicholas Bellinger <nab@linux-iscsi.org>
>>>>>>
>>>>>> The WWPN specified in configfs is passed to "-device vhost-scsi-pci".
>>>>>> The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not
>>>>>> available from the QEMU command-line.  Instead, I hardcode it to
>>> zero.
>>>>>>
>>>> Hi, Paolo
>>>>    Any document about how to config it correctly in configfs, before
>>>> invoking qemu with the WWPN number?
>>>
>>> Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
>>> iSCSI for example) so it's quite simple.  Here is an example:
>>>
>>> cd /sys/kernel/config/target
>>> mkdir -p core/fileio_0/fileio
>>> echo 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
>>> core/fileio_0/fileio/control
>>> echo 1 > core/fileio_0/fileio/enable
>>> mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
>>> cd vhost/naa.600140554cf3a18e/tpgt_0
>>> ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
>>> echo naa.60014053226f0388 > nexus
>>>
>>> The "nexus" value is the initiator WWN.  naa.600140554cf3a18e is the
>>> target WWN that you have to pass to "-device vhost-scsi-pci".
>>>
>>> Paolo
>>
>
Libaiqing June 20, 2013, 8:49 a.m. UTC | #13
Hi Asias,
    Thanks for your config.
    According to you config,I test booting from vhost device with upstream kernel and qemu,but failed.
    
    1 installing guest from cdrom,ok.
    2 booting vhost-scsi,guest fs error occurs. 
    3 using fileio backstores,the error is same..
    4 rebooting guest,a log printed:
     (qemu) hw/scsi/virtio-scsi.c:533:virtio_scsi_handle_event: Object 0x7fccae7f2c88 is not an instance of type virtio-scsi-device
    5 using upstream seabios,core dumped.
 
    Could you give me some advise to debug this problem ? I can provide more information if need.

The qemu cmd:
[root@fedora121 x86_64-softmmu]# ./qemu-system-x86_64 -enable-kvm -name fedora   -M pc -m 1024 -smp 2   -drive file=/home/fedora18.iso,if=ide,media=cdrom -device vhost-scsi-pci,wwpn=naa.50014057133e25dc  -monitor stdio   -vga qxl  -vnc :1

The vnc output:
Dracut-initqueue[189]:/dev/mapper/fedora-root:UNEXPECTED INCONSISTENCY;RUN FSCK MANUALLY.
Dracut-initqueue[189]: Warning: e2fsck returned with 4
Dracut-initqueue[189]: Warning: ***An error occurred during the file system check.

The guest kernel log:
Kernel: virtio-pci 0000:00:04.0: irq 40 for MSI/MSI-X
Kernel: virtio-pci 0000:00:04.0: irq 41 for MSI/MSI-X
Kernel: virtio-pci 0000:00:04.0: irq 42 for MSI/MSI-X
Kernel: virtio-pci 0000:00:04.0: irq 43 for MSI/MSI-X
Kernel: scsi2 : Virtio SCSI HBA
Kernel: scsi 2:0:1:0: Direct-Access LIO-ORG r0
Kernel: sd 2:0:1:0: Attached scsi generic sg1 type 0
Kernel: sd 2:0:1:0: [sda]1258912 512-byte logical .....
Kernel: sd 2:0:1:0: [sda]write protect is off
Kernel: sd 2:0:1:0: [sda]Mode sense :43 00 00 08
Kernel: sd 2:0:1:0: [sda]write cache: disabled, read .....
Kernel: sda sda1 sda2
Kernel: sd 2:0:1:0: [sda] Attached SCSI disk
Dracut-initqueue[189]: Scanning devices sda2 for LVM
Dracut-initqueue[189]: inactive '/dev/fedora/swap'...
Dracut-initqueue[189]: inactive '/dev/fedora/root'...

The info of host:
[root@fedora121 x86_64-softmmu]# uname -a
Linux fedora121 3.10.0-rc6 #1 SMP Wed Jun 19 19:34:24 CST 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@fedora121 x86_64-softmmu]# lsmod |grep vhost_scsi
vhost_scsi             49456  5
target_core_mod       282163  14 target_core_iblock,target_core_pscsi,iscsi_target_mod,target_core_file,vhost_scsi
[root@fedora121 x86_64-softmmu]# targetcli
targetcli shell version v2.1.fb26
Copyright 2011 by RisingTide Systems LLC and others.
For help on commands, type 'help'.

/> ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................. [Storage Objects: 0]
  | o- fileio ................................................................................................. [Storage Objects: 0]
  | o- pscsi .................................................................................................. [Storage Objects: 0]
  | o- ramdisk ................................................................................................ [Storage Objects: 1]
  |   o- r0 ................................................................................................... [(6.0GiB) activated]
  o- iscsi ............................................................................................................ [Targets: 0]
  o- loopback ......................................................................................................... [Targets: 0]
  o- vhost ............................................................................................................ [Targets: 1]
    o- naa.50014057133e25dc .............................................................................................. [TPGs: 1]
      o- tpg1 ............................................................................................... [naa.5001405a70ac3421]
        o- acls .......................................................................................................... [ACLs: 0]
        o- luns .......................................................................................................... [LUNs: 1]
          o- lun0 ..................................................................................................... [ramdisk/r0]

Regards,
baiqing
> -----Original Message-----
> From: Asias He [mailto:asias@redhat.com]
> Sent: Thursday, June 20, 2013 9:34 AM
> To: Libaiqing
> Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> tcm_vhost Linux kernel module
> 
> On Wed, Jun 19, 2013 at 12:55:10PM +0000, Libaiqing wrote:
> > Hi paolo,
> >   The vhost-scsi device can be used as boot device?
> >   I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
> >   Could you give me some advise to debug this problem ? I can provide
> more information if need.
> 
> Boot from vhost-scsi is supposed to work. The seabios you used should be
> fine which contains the fixes for vhost-scsi.
> 
> Instead of playing with the /sys/kernel/config/target directly, I really
> recommend using targetcli utils.
> 
> Nab, I think we really should write some docs for people to use
> vhost-scsi.
> 
> This is how I install and use targetcli in RHEL6. Note you need upstream
> kernel and qemu bits for vhost-scsi.
> 
> # yum groupinstall  'Development tools'
> # yum install python-devel epydoc python-simpleparse
> 
> # git clone git://github.com/agrover/rtslib-fb.git
> # git clone git://github.com/agrover/targetcli-fb.git
> # git clone git://github.com/agrover/configshell-fb.git
> # for i in rtslib-fb configshell-fb targetcli-fb; do
>   	make -C $i rpm
>   	yum localinstall $i/dist/*.noarch.rpm
>   done
> 
> In targetcli, create a backstore and vhost wwpn, e.g.
> # targetcli
> /> /backstores/ramdisk create r0 1g
> /> /vhost create
> /> cd /vhost/naa.500140527cb6616b/tpg1/luns
> /> create /backstores/ramdisk/r0
> 
> # qemu -device vhost-scsi-pci,wwpn=naa.500140527cb6616b ...
> 
> Hope this helps.
> 
> > Regards,
> > baiqing
> >
> > > -----Original Message-----
> > > From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
> > > [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org] On
> > > Behalf Of Paolo Bonzini
> > > Sent: Tuesday, May 28, 2013 4:01 PM
> > > To: Wenchao Xia
> > > Cc: asias@redhat.com; qemu-devel@nongnu.org; nab@linux-iscsi.org;
> > > Michael S. Tsirkin
> > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting
> the
> > > tcm_vhost Linux kernel module
> > >
> > > Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> > > >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > > >> >
> > > >> > The WWPN specified in configfs is passed to "-device
> vhost-scsi-pci".
> > > >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not
> > > >> > available from the QEMU command-line.  Instead, I hardcode it to
> > > zero.
> > > >> >
> > > > Hi, Paolo
> > > >   Any document about how to config it correctly in configfs, before
> > > > invoking qemu with the WWPN number?
> > >
> > > Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
> > > iSCSI for example) so it's quite simple.  Here is an example:
> > >
> > > cd /sys/kernel/config/target
> > > mkdir -p core/fileio_0/fileio
> > > echo
> 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> > > core/fileio_0/fileio/control
> > > echo 1 > core/fileio_0/fileio/enable
> > > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> > > cd vhost/naa.600140554cf3a18e/tpgt_0
> > > ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
> > > echo naa.60014053226f0388 > nexus
> > >
> > > The "nexus" value is the initiator WWN.  naa.600140554cf3a18e is the
> > > target WWN that you have to pass to "-device vhost-scsi-pci".
> > >
> > > Paolo
> >
> 
> --
> Asias
Asias He June 20, 2013, 9:38 a.m. UTC | #14
On Thu, Jun 20, 2013 at 08:49:50AM +0000, Libaiqing wrote:
> Hi Asias,
>     Thanks for your config.
>     According to you config,I test booting from vhost device with upstream kernel and qemu,but failed.
>     
>     1 installing guest from cdrom,ok.
>     2 booting vhost-scsi,guest fs error occurs. 
>     3 using fileio backstores,the error is same..
>     4 rebooting guest,a log printed:
>      (qemu) hw/scsi/virtio-scsi.c:533:virtio_scsi_handle_event: Object 0x7fccae7f2c88 is not an instance of type virtio-scsi-device

Paolo, I remember you fixed a similar issue?

>     5 using upstream seabios,core dumped.
>  
>     Could you give me some advise to debug this problem ? I can provide more information if need.

Can you show me qemu commit id you used? Can you verity that if using the
host kernel for guest helps? Does booting directly (without the install
and reboot process) work?

> The qemu cmd:
> [root@fedora121 x86_64-softmmu]# ./qemu-system-x86_64 -enable-kvm -name fedora   -M pc -m 1024 -smp 2   -drive file=/home/fedora18.iso,if=ide,media=cdrom -device vhost-scsi-pci,wwpn=naa.50014057133e25dc  -monitor stdio   -vga qxl  -vnc :1
> 
> The vnc output:
> Dracut-initqueue[189]:/dev/mapper/fedora-root:UNEXPECTED INCONSISTENCY;RUN FSCK MANUALLY.
> Dracut-initqueue[189]: Warning: e2fsck returned with 4
> Dracut-initqueue[189]: Warning: ***An error occurred during the file system check.
> 
> The guest kernel log:
> Kernel: virtio-pci 0000:00:04.0: irq 40 for MSI/MSI-X
> Kernel: virtio-pci 0000:00:04.0: irq 41 for MSI/MSI-X
> Kernel: virtio-pci 0000:00:04.0: irq 42 for MSI/MSI-X
> Kernel: virtio-pci 0000:00:04.0: irq 43 for MSI/MSI-X
> Kernel: scsi2 : Virtio SCSI HBA
> Kernel: scsi 2:0:1:0: Direct-Access LIO-ORG r0
> Kernel: sd 2:0:1:0: Attached scsi generic sg1 type 0
> Kernel: sd 2:0:1:0: [sda]1258912 512-byte logical .....
> Kernel: sd 2:0:1:0: [sda]write protect is off
> Kernel: sd 2:0:1:0: [sda]Mode sense :43 00 00 08
> Kernel: sd 2:0:1:0: [sda]write cache: disabled, read .....
> Kernel: sda sda1 sda2
> Kernel: sd 2:0:1:0: [sda] Attached SCSI disk
> Dracut-initqueue[189]: Scanning devices sda2 for LVM
> Dracut-initqueue[189]: inactive '/dev/fedora/swap'...
> Dracut-initqueue[189]: inactive '/dev/fedora/root'...
> 
> The info of host:
> [root@fedora121 x86_64-softmmu]# uname -a
> Linux fedora121 3.10.0-rc6 #1 SMP Wed Jun 19 19:34:24 CST 2013 x86_64 x86_64 x86_64 GNU/Linux
> [root@fedora121 x86_64-softmmu]# lsmod |grep vhost_scsi
> vhost_scsi             49456  5
> target_core_mod       282163  14 target_core_iblock,target_core_pscsi,iscsi_target_mod,target_core_file,vhost_scsi
> [root@fedora121 x86_64-softmmu]# targetcli
> targetcli shell version v2.1.fb26
> Copyright 2011 by RisingTide Systems LLC and others.
> For help on commands, type 'help'.
> 
> /> ls
> o- / ......................................................................................................................... [...]
>   o- backstores .............................................................................................................. [...]
>   | o- block .................................................................................................. [Storage Objects: 0]
>   | o- fileio ................................................................................................. [Storage Objects: 0]
>   | o- pscsi .................................................................................................. [Storage Objects: 0]
>   | o- ramdisk ................................................................................................ [Storage Objects: 1]
>   |   o- r0 ................................................................................................... [(6.0GiB) activated]
>   o- iscsi ............................................................................................................ [Targets: 0]
>   o- loopback ......................................................................................................... [Targets: 0]
>   o- vhost ............................................................................................................ [Targets: 1]
>     o- naa.50014057133e25dc .............................................................................................. [TPGs: 1]
>       o- tpg1 ............................................................................................... [naa.5001405a70ac3421]
>         o- acls .......................................................................................................... [ACLs: 0]
>         o- luns .......................................................................................................... [LUNs: 1]
>           o- lun0 ..................................................................................................... [ramdisk/r0]
> 
> Regards,
> baiqing
> > -----Original Message-----
> > From: Asias He [mailto:asias@redhat.com]
> > Sent: Thursday, June 20, 2013 9:34 AM
> > To: Libaiqing
> > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> > tcm_vhost Linux kernel module
> > 
> > On Wed, Jun 19, 2013 at 12:55:10PM +0000, Libaiqing wrote:
> > > Hi paolo,
> > >   The vhost-scsi device can be used as boot device?
> > >   I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
> > >   Could you give me some advise to debug this problem ? I can provide
> > more information if need.
> > 
> > Boot from vhost-scsi is supposed to work. The seabios you used should be
> > fine which contains the fixes for vhost-scsi.
> > 
> > Instead of playing with the /sys/kernel/config/target directly, I really
> > recommend using targetcli utils.
> > 
> > Nab, I think we really should write some docs for people to use
> > vhost-scsi.
> > 
> > This is how I install and use targetcli in RHEL6. Note you need upstream
> > kernel and qemu bits for vhost-scsi.
> > 
> > # yum groupinstall  'Development tools'
> > # yum install python-devel epydoc python-simpleparse
> > 
> > # git clone git://github.com/agrover/rtslib-fb.git
> > # git clone git://github.com/agrover/targetcli-fb.git
> > # git clone git://github.com/agrover/configshell-fb.git
> > # for i in rtslib-fb configshell-fb targetcli-fb; do
> >   	make -C $i rpm
> >   	yum localinstall $i/dist/*.noarch.rpm
> >   done
> > 
> > In targetcli, create a backstore and vhost wwpn, e.g.
> > # targetcli
> > /> /backstores/ramdisk create r0 1g
> > /> /vhost create
> > /> cd /vhost/naa.500140527cb6616b/tpg1/luns
> > /> create /backstores/ramdisk/r0
> > 
> > # qemu -device vhost-scsi-pci,wwpn=naa.500140527cb6616b ...
> > 
> > Hope this helps.
> > 
> > > Regards,
> > > baiqing
> > >
> > > > -----Original Message-----
> > > > From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
> > > > [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org] On
> > > > Behalf Of Paolo Bonzini
> > > > Sent: Tuesday, May 28, 2013 4:01 PM
> > > > To: Wenchao Xia
> > > > Cc: asias@redhat.com; qemu-devel@nongnu.org; nab@linux-iscsi.org;
> > > > Michael S. Tsirkin
> > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting
> > the
> > > > tcm_vhost Linux kernel module
> > > >
> > > > Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> > > > >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > > > >> >
> > > > >> > The WWPN specified in configfs is passed to "-device
> > vhost-scsi-pci".
> > > > >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is not
> > > > >> > available from the QEMU command-line.  Instead, I hardcode it to
> > > > zero.
> > > > >> >
> > > > > Hi, Paolo
> > > > >   Any document about how to config it correctly in configfs, before
> > > > > invoking qemu with the WWPN number?
> > > >
> > > > Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
> > > > iSCSI for example) so it's quite simple.  Here is an example:
> > > >
> > > > cd /sys/kernel/config/target
> > > > mkdir -p core/fileio_0/fileio
> > > > echo
> > 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> > > > core/fileio_0/fileio/control
> > > > echo 1 > core/fileio_0/fileio/enable
> > > > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> > > > cd vhost/naa.600140554cf3a18e/tpgt_0
> > > > ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
> > > > echo naa.60014053226f0388 > nexus
> > > >
> > > > The "nexus" value is the initiator WWN.  naa.600140554cf3a18e is the
> > > > target WWN that you have to pass to "-device vhost-scsi-pci".
> > > >
> > > > Paolo
> > >
> > 
> > --
> > Asias
Libaiqing June 21, 2013, 10:16 a.m. UTC | #15
Hi Asias,

> -----Original Message-----
> From: Asias He [mailto:asias@redhat.com]
> Sent: Thursday, June 20, 2013 5:39 PM
> To: Libaiqing
> Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> tcm_vhost Linux kernel module
> 
> On Thu, Jun 20, 2013 at 08:49:50AM +0000, Libaiqing wrote:
> > Hi Asias,
> >     Thanks for your config.
> >     According to you config,I test booting from vhost device with
> upstream kernel and qemu,but failed.
> >
> >     1 installing guest from cdrom,ok.
> >     2 booting vhost-scsi,guest fs error occurs.
> >     3 using fileio backstores,the error is same..
> >     4 rebooting guest,a log printed:
> >      (qemu) hw/scsi/virtio-scsi.c:533:virtio_scsi_handle_event: Object
> 0x7fccae7f2c88 is not an instance of type virtio-scsi-device
> 
> Paolo, I remember you fixed a similar issue?
> 
> >     5 using upstream seabios,core dumped.
> >
> >     Could you give me some advise to debug this problem ? I can provide
> more information if need.
> 
> Can you show me qemu commit id you used? Can you verity that if using the
> host kernel for guest helps? Does booting directly (without the install
> and reboot process) work?
Qemu commit id is "commit 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427".

Guest kernel updateing is useless.

Booting directly doesn't work too.


> > The qemu cmd:
> > [root@fedora121 x86_64-softmmu]# ./qemu-system-x86_64 -enable-kvm
> -name fedora   -M pc -m 1024 -smp 2   -drive
> file=/home/fedora18.iso,if=ide,media=cdrom -device
> vhost-scsi-pci,wwpn=naa.50014057133e25dc  -monitor stdio   -vga qxl
> -vnc :1
> >
> > The vnc output:
> > Dracut-initqueue[189]:/dev/mapper/fedora-root:UNEXPECTED
> INCONSISTENCY;RUN FSCK MANUALLY.
> > Dracut-initqueue[189]: Warning: e2fsck returned with 4
> > Dracut-initqueue[189]: Warning: ***An error occurred during the file
> system check.
> >
> > The guest kernel log:
> > Kernel: virtio-pci 0000:00:04.0: irq 40 for MSI/MSI-X
> > Kernel: virtio-pci 0000:00:04.0: irq 41 for MSI/MSI-X
> > Kernel: virtio-pci 0000:00:04.0: irq 42 for MSI/MSI-X
> > Kernel: virtio-pci 0000:00:04.0: irq 43 for MSI/MSI-X
> > Kernel: scsi2 : Virtio SCSI HBA
> > Kernel: scsi 2:0:1:0: Direct-Access LIO-ORG r0
> > Kernel: sd 2:0:1:0: Attached scsi generic sg1 type 0
> > Kernel: sd 2:0:1:0: [sda]1258912 512-byte logical .....
> > Kernel: sd 2:0:1:0: [sda]write protect is off
> > Kernel: sd 2:0:1:0: [sda]Mode sense :43 00 00 08
> > Kernel: sd 2:0:1:0: [sda]write cache: disabled, read .....
> > Kernel: sda sda1 sda2
> > Kernel: sd 2:0:1:0: [sda] Attached SCSI disk
> > Dracut-initqueue[189]: Scanning devices sda2 for LVM
> > Dracut-initqueue[189]: inactive '/dev/fedora/swap'...
> > Dracut-initqueue[189]: inactive '/dev/fedora/root'...
> >
> > The info of host:
> > [root@fedora121 x86_64-softmmu]# uname -a
> > Linux fedora121 3.10.0-rc6 #1 SMP Wed Jun 19 19:34:24 CST 2013 x86_64
> x86_64 x86_64 GNU/Linux
> > [root@fedora121 x86_64-softmmu]# lsmod |grep vhost_scsi
> > vhost_scsi             49456  5
> > target_core_mod       282163  14
> target_core_iblock,target_core_pscsi,iscsi_target_mod,target_core_file,vh
> ost_scsi
> > [root@fedora121 x86_64-softmmu]# targetcli
> > targetcli shell version v2.1.fb26
> > Copyright 2011 by RisingTide Systems LLC and others.
> > For help on commands, type 'help'.
> >
> > /> ls
> > o-
> / ..............................................................................................................
> ........... [...]
> >   o-
> backstores ...............................................................................................
> ............... [...]
> >   | o-
> block ..................................................................................................
> [Storage Objects: 0]
> >   | o-
> fileio .................................................................................................
> [Storage Objects: 0]
> >   | o-
> pscsi ..................................................................................................
> [Storage Objects: 0]
> >   | o-
> ramdisk ................................................................................................
> [Storage Objects: 1]
> >   |   o-
> r0 ...................................................................................................
> [(6.0GiB) activated]
> >   o-
> iscsi .........................................................................................................
> ... [Targets: 0]
> >   o-
> loopback ..................................................................................................
> ....... [Targets: 0]
> >   o-
> vhost .......................................................................................................
> ..... [Targets: 1]
> >     o-
> naa.50014057133e25dc ............................................................................
> .................. [TPGs: 1]
> >       o-
> tpg1 ...............................................................................................
> [naa.5001405a70ac3421]
> >         o-
> acls ..........................................................................................................
> [ACLs: 0]
> >         o-
> luns ..........................................................................................................
> [LUNs: 1]
> >           o-
> lun0 .....................................................................................................
> [ramdisk/r0]
> >
> > Regards,
> > baiqing
> > > -----Original Message-----
> > > From: Asias He [mailto:asias@redhat.com]
> > > Sent: Thursday, June 20, 2013 9:34 AM
> > > To: Libaiqing
> > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting
> the
> > > tcm_vhost Linux kernel module
> > >
> > > On Wed, Jun 19, 2013 at 12:55:10PM +0000, Libaiqing wrote:
> > > > Hi paolo,
> > > >   The vhost-scsi device can be used as boot device?
> > > >   I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
> > > >   Could you give me some advise to debug this problem ? I can
> provide
> > > more information if need.
> > >
> > > Boot from vhost-scsi is supposed to work. The seabios you used should
> be
> > > fine which contains the fixes for vhost-scsi.
> > >
> > > Instead of playing with the /sys/kernel/config/target directly, I really
> > > recommend using targetcli utils.
> > >
> > > Nab, I think we really should write some docs for people to use
> > > vhost-scsi.
> > >
> > > This is how I install and use targetcli in RHEL6. Note you need upstream
> > > kernel and qemu bits for vhost-scsi.
> > >
> > > # yum groupinstall  'Development tools'
> > > # yum install python-devel epydoc python-simpleparse
> > >
> > > # git clone git://github.com/agrover/rtslib-fb.git
> > > # git clone git://github.com/agrover/targetcli-fb.git
> > > # git clone git://github.com/agrover/configshell-fb.git
> > > # for i in rtslib-fb configshell-fb targetcli-fb; do
> > >   	make -C $i rpm
> > >   	yum localinstall $i/dist/*.noarch.rpm
> > >   done
> > >
> > > In targetcli, create a backstore and vhost wwpn, e.g.
> > > # targetcli
> > > /> /backstores/ramdisk create r0 1g
> > > /> /vhost create
> > > /> cd /vhost/naa.500140527cb6616b/tpg1/luns
> > > /> create /backstores/ramdisk/r0
> > >
> > > # qemu -device vhost-scsi-pci,wwpn=naa.500140527cb6616b ...
> > >
> > > Hope this helps.
> > >
> > > > Regards,
> > > > baiqing
> > > >
> > > > > -----Original Message-----
> > > > > From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
> > > > > [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org]
> On
> > > > > Behalf Of Paolo Bonzini
> > > > > Sent: Tuesday, May 28, 2013 4:01 PM
> > > > > To: Wenchao Xia
> > > > > Cc: asias@redhat.com; qemu-devel@nongnu.org;
> nab@linux-iscsi.org;
> > > > > Michael S. Tsirkin
> > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> supporting
> > > the
> > > > > tcm_vhost Linux kernel module
> > > > >
> > > > > Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> > > > > >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > > > > >> >
> > > > > >> > The WWPN specified in configfs is passed to "-device
> > > vhost-scsi-pci".
> > > > > >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is
> not
> > > > > >> > available from the QEMU command-line.  Instead, I hardcode it
> to
> > > > > zero.
> > > > > >> >
> > > > > > Hi, Paolo
> > > > > >   Any document about how to config it correctly in configfs,
> before
> > > > > > invoking qemu with the WWPN number?
> > > > >
> > > > > Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
> > > > > iSCSI for example) so it's quite simple.  Here is an example:
> > > > >
> > > > > cd /sys/kernel/config/target
> > > > > mkdir -p core/fileio_0/fileio
> > > > > echo
> > > 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> > > > > core/fileio_0/fileio/control
> > > > > echo 1 > core/fileio_0/fileio/enable
> > > > > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> > > > > cd vhost/naa.600140554cf3a18e/tpgt_0
> > > > > ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
> > > > > echo naa.60014053226f0388 > nexus
> > > > >
> > > > > The "nexus" value is the initiator WWN.  naa.600140554cf3a18e is
> the
> > > > > target WWN that you have to pass to "-device vhost-scsi-pci".
> > > > >
> > > > > Paolo
> > > >
> > >
> > > --
> > > Asias
> 
> --
> Asias
Libaiqing July 3, 2013, 3:08 a.m. UTC | #16
Hi asias,
   I'm testing vhost-blk,for comparimg the performance with virtio-blk.
   I got the kernel patch from this mail: https://lkml.org/lkml/2012/12/1/174
   And I got the userspace code for qemu from this git: https://github.com/asias/qemu/tree/blk.vhost-blk;
   Used vhost-blk device as non-bootable device,the configuration is :   
        Qemu-kvm -enable-kvm -name win7 -M pc-0.15 -m 1024 -smp 2 -boot c -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/home/fedora188.img,if=virtio,index=0,format=raw  -drive file=/home/fedora18.img,if=virtio,index=1,format=raw,id=hd,vhost=on   -monitor stdio   -vga qxl  -vnc :1  -device usb-tablet,id=input0

   On fedora17 host,I used kernel 3.6.3 for building vhos_blk module,but the vm will hang when vm starting.

   1 Is there any new patch for kernel 3.8 3.10?
   2 which version of the kernel is suitable for the current kernel patch?

   Could you give me some advise to debug this problem ? I can provide more information if need.
   Or could you give me some advise to run vhost-blk,such as RHEL version,kernel version and so on?

Thanks
Baiqing.
Asias He July 3, 2013, 3:18 a.m. UTC | #17
On Wed, Jul 03, 2013 at 03:08:34AM +0000, Libaiqing wrote:
> Hi asias,
>    I'm testing vhost-blk,for comparimg the performance with virtio-blk.
>    I got the kernel patch from this mail: https://lkml.org/lkml/2012/12/1/174

You can find the latest vhost-blk kernel bits here:

  git://github.com/asias/linux.git blk.vhost-blk

>    And I got the userspace code for qemu from this git: https://github.com/asias/qemu/tree/blk.vhost-blk;
>    Used vhost-blk device as non-bootable device,the configuration is :   
>         Qemu-kvm -enable-kvm -name win7 -M pc-0.15 -m 1024 -smp 2 -boot c -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/home/fedora188.img,if=virtio,index=0,format=raw  -drive file=/home/fedora18.img,if=virtio,index=1,format=raw,id=hd,vhost=on   -monitor stdio   -vga qxl  -vnc :1  -device usb-tablet,id=input0

Please use raw block device for vhost-blk.

>    On fedora17 host,I used kernel 3.6.3 for building vhos_blk module,but the vm will hang when vm starting.
> 
>    1 Is there any new patch for kernel 3.8 3.10?
>    2 which version of the kernel is suitable for the current kernel patch?
> 
>    Could you give me some advise to debug this problem ? I can provide more information if need.
>    Or could you give me some advise to run vhost-blk,such as RHEL version,kernel version and so on?

I recommend you to use the kernel I provided above for both guest and
host.

> Thanks
> Baiqing.
Asias He July 3, 2013, 3:23 a.m. UTC | #18
On Fri, Jun 21, 2013 at 10:16:48AM +0000, Libaiqing wrote:
> Hi Asias,
> 
> > -----Original Message-----
> > From: Asias He [mailto:asias@redhat.com]
> > Sent: Thursday, June 20, 2013 5:39 PM
> > To: Libaiqing
> > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> > tcm_vhost Linux kernel module
> > 
> > On Thu, Jun 20, 2013 at 08:49:50AM +0000, Libaiqing wrote:
> > > Hi Asias,
> > >     Thanks for your config.
> > >     According to you config,I test booting from vhost device with
> > upstream kernel and qemu,but failed.
> > >
> > >     1 installing guest from cdrom,ok.
> > >     2 booting vhost-scsi,guest fs error occurs.
> > >     3 using fileio backstores,the error is same..
> > >     4 rebooting guest,a log printed:
> > >      (qemu) hw/scsi/virtio-scsi.c:533:virtio_scsi_handle_event: Object
> > 0x7fccae7f2c88 is not an instance of type virtio-scsi-device
> > 
> > Paolo, I remember you fixed a similar issue?
> > 
> > >     5 using upstream seabios,core dumped.
> > >
> > >     Could you give me some advise to debug this problem ? I can provide
> > more information if need.
> > 
> > Can you show me qemu commit id you used? Can you verity that if using the
> > host kernel for guest helps? Does booting directly (without the install
> > and reboot process) work?
> Qemu commit id is "commit 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427".
> 
> Guest kernel updateing is useless.
> 
> Booting directly doesn't work too.


Hello Libaiqing,

Sorry for the delay. I will try to reproduce it myself.

> 
> > > The qemu cmd:
> > > [root@fedora121 x86_64-softmmu]# ./qemu-system-x86_64 -enable-kvm
> > -name fedora   -M pc -m 1024 -smp 2   -drive
> > file=/home/fedora18.iso,if=ide,media=cdrom -device
> > vhost-scsi-pci,wwpn=naa.50014057133e25dc  -monitor stdio   -vga qxl
> > -vnc :1
> > >
> > > The vnc output:
> > > Dracut-initqueue[189]:/dev/mapper/fedora-root:UNEXPECTED
> > INCONSISTENCY;RUN FSCK MANUALLY.
> > > Dracut-initqueue[189]: Warning: e2fsck returned with 4
> > > Dracut-initqueue[189]: Warning: ***An error occurred during the file
> > system check.
> > >
> > > The guest kernel log:
> > > Kernel: virtio-pci 0000:00:04.0: irq 40 for MSI/MSI-X
> > > Kernel: virtio-pci 0000:00:04.0: irq 41 for MSI/MSI-X
> > > Kernel: virtio-pci 0000:00:04.0: irq 42 for MSI/MSI-X
> > > Kernel: virtio-pci 0000:00:04.0: irq 43 for MSI/MSI-X
> > > Kernel: scsi2 : Virtio SCSI HBA
> > > Kernel: scsi 2:0:1:0: Direct-Access LIO-ORG r0
> > > Kernel: sd 2:0:1:0: Attached scsi generic sg1 type 0
> > > Kernel: sd 2:0:1:0: [sda]1258912 512-byte logical .....
> > > Kernel: sd 2:0:1:0: [sda]write protect is off
> > > Kernel: sd 2:0:1:0: [sda]Mode sense :43 00 00 08
> > > Kernel: sd 2:0:1:0: [sda]write cache: disabled, read .....
> > > Kernel: sda sda1 sda2
> > > Kernel: sd 2:0:1:0: [sda] Attached SCSI disk
> > > Dracut-initqueue[189]: Scanning devices sda2 for LVM
> > > Dracut-initqueue[189]: inactive '/dev/fedora/swap'...
> > > Dracut-initqueue[189]: inactive '/dev/fedora/root'...
> > >
> > > The info of host:
> > > [root@fedora121 x86_64-softmmu]# uname -a
> > > Linux fedora121 3.10.0-rc6 #1 SMP Wed Jun 19 19:34:24 CST 2013 x86_64
> > x86_64 x86_64 GNU/Linux
> > > [root@fedora121 x86_64-softmmu]# lsmod |grep vhost_scsi
> > > vhost_scsi             49456  5
> > > target_core_mod       282163  14
> > target_core_iblock,target_core_pscsi,iscsi_target_mod,target_core_file,vh
> > ost_scsi
> > > [root@fedora121 x86_64-softmmu]# targetcli
> > > targetcli shell version v2.1.fb26
> > > Copyright 2011 by RisingTide Systems LLC and others.
> > > For help on commands, type 'help'.
> > >
> > > /> ls
> > > o-
> > / ..............................................................................................................
> > ........... [...]
> > >   o-
> > backstores ...............................................................................................
> > ............... [...]
> > >   | o-
> > block ..................................................................................................
> > [Storage Objects: 0]
> > >   | o-
> > fileio .................................................................................................
> > [Storage Objects: 0]
> > >   | o-
> > pscsi ..................................................................................................
> > [Storage Objects: 0]
> > >   | o-
> > ramdisk ................................................................................................
> > [Storage Objects: 1]
> > >   |   o-
> > r0 ...................................................................................................
> > [(6.0GiB) activated]
> > >   o-
> > iscsi .........................................................................................................
> > ... [Targets: 0]
> > >   o-
> > loopback ..................................................................................................
> > ....... [Targets: 0]
> > >   o-
> > vhost .......................................................................................................
> > ..... [Targets: 1]
> > >     o-
> > naa.50014057133e25dc ............................................................................
> > .................. [TPGs: 1]
> > >       o-
> > tpg1 ...............................................................................................
> > [naa.5001405a70ac3421]
> > >         o-
> > acls ..........................................................................................................
> > [ACLs: 0]
> > >         o-
> > luns ..........................................................................................................
> > [LUNs: 1]
> > >           o-
> > lun0 .....................................................................................................
> > [ramdisk/r0]
> > >
> > > Regards,
> > > baiqing
> > > > -----Original Message-----
> > > > From: Asias He [mailto:asias@redhat.com]
> > > > Sent: Thursday, June 20, 2013 9:34 AM
> > > > To: Libaiqing
> > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting
> > the
> > > > tcm_vhost Linux kernel module
> > > >
> > > > On Wed, Jun 19, 2013 at 12:55:10PM +0000, Libaiqing wrote:
> > > > > Hi paolo,
> > > > >   The vhost-scsi device can be used as boot device?
> > > > >   I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
> > > > >   Could you give me some advise to debug this problem ? I can
> > provide
> > > > more information if need.
> > > >
> > > > Boot from vhost-scsi is supposed to work. The seabios you used should
> > be
> > > > fine which contains the fixes for vhost-scsi.
> > > >
> > > > Instead of playing with the /sys/kernel/config/target directly, I really
> > > > recommend using targetcli utils.
> > > >
> > > > Nab, I think we really should write some docs for people to use
> > > > vhost-scsi.
> > > >
> > > > This is how I install and use targetcli in RHEL6. Note you need upstream
> > > > kernel and qemu bits for vhost-scsi.
> > > >
> > > > # yum groupinstall  'Development tools'
> > > > # yum install python-devel epydoc python-simpleparse
> > > >
> > > > # git clone git://github.com/agrover/rtslib-fb.git
> > > > # git clone git://github.com/agrover/targetcli-fb.git
> > > > # git clone git://github.com/agrover/configshell-fb.git
> > > > # for i in rtslib-fb configshell-fb targetcli-fb; do
> > > >   	make -C $i rpm
> > > >   	yum localinstall $i/dist/*.noarch.rpm
> > > >   done
> > > >
> > > > In targetcli, create a backstore and vhost wwpn, e.g.
> > > > # targetcli
> > > > /> /backstores/ramdisk create r0 1g
> > > > /> /vhost create
> > > > /> cd /vhost/naa.500140527cb6616b/tpg1/luns
> > > > /> create /backstores/ramdisk/r0
> > > >
> > > > # qemu -device vhost-scsi-pci,wwpn=naa.500140527cb6616b ...
> > > >
> > > > Hope this helps.
> > > >
> > > > > Regards,
> > > > > baiqing
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
> > > > > > [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org]
> > On
> > > > > > Behalf Of Paolo Bonzini
> > > > > > Sent: Tuesday, May 28, 2013 4:01 PM
> > > > > > To: Wenchao Xia
> > > > > > Cc: asias@redhat.com; qemu-devel@nongnu.org;
> > nab@linux-iscsi.org;
> > > > > > Michael S. Tsirkin
> > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > supporting
> > > > the
> > > > > > tcm_vhost Linux kernel module
> > > > > >
> > > > > > Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> > > > > > >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > > > > > >> >
> > > > > > >> > The WWPN specified in configfs is passed to "-device
> > > > vhost-scsi-pci".
> > > > > > >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is
> > not
> > > > > > >> > available from the QEMU command-line.  Instead, I hardcode it
> > to
> > > > > > zero.
> > > > > > >> >
> > > > > > > Hi, Paolo
> > > > > > >   Any document about how to config it correctly in configfs,
> > before
> > > > > > > invoking qemu with the WWPN number?
> > > > > >
> > > > > > Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
> > > > > > iSCSI for example) so it's quite simple.  Here is an example:
> > > > > >
> > > > > > cd /sys/kernel/config/target
> > > > > > mkdir -p core/fileio_0/fileio
> > > > > > echo
> > > > 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> > > > > > core/fileio_0/fileio/control
> > > > > > echo 1 > core/fileio_0/fileio/enable
> > > > > > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> > > > > > cd vhost/naa.600140554cf3a18e/tpgt_0
> > > > > > ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
> > > > > > echo naa.60014053226f0388 > nexus
> > > > > >
> > > > > > The "nexus" value is the initiator WWN.  naa.600140554cf3a18e is
> > the
> > > > > > target WWN that you have to pass to "-device vhost-scsi-pci".
> > > > > >
> > > > > > Paolo
> > > > >
> > > >
> > > > --
> > > > Asias
> > 
> > --
> > Asias
Asias He July 3, 2013, 8:08 a.m. UTC | #19
On Wed, Jul 03, 2013 at 11:23:26AM +0800, Asias He wrote:
> On Fri, Jun 21, 2013 at 10:16:48AM +0000, Libaiqing wrote:
> > Hi Asias,
> > 
> > > -----Original Message-----
> > > From: Asias He [mailto:asias@redhat.com]
> > > Sent: Thursday, June 20, 2013 5:39 PM
> > > To: Libaiqing
> > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> > > tcm_vhost Linux kernel module
> > > 
> > > On Thu, Jun 20, 2013 at 08:49:50AM +0000, Libaiqing wrote:
> > > > Hi Asias,
> > > >     Thanks for your config.
> > > >     According to you config,I test booting from vhost device with
> > > upstream kernel and qemu,but failed.
> > > >
> > > >     1 installing guest from cdrom,ok.
> > > >     2 booting vhost-scsi,guest fs error occurs.
> > > >     3 using fileio backstores,the error is same..
> > > >     4 rebooting guest,a log printed:
> > > >      (qemu) hw/scsi/virtio-scsi.c:533:virtio_scsi_handle_event: Object
> > > 0x7fccae7f2c88 is not an instance of type virtio-scsi-device
> > > 
> > > Paolo, I remember you fixed a similar issue?
> > > 
> > > >     5 using upstream seabios,core dumped.
> > > >
> > > >     Could you give me some advise to debug this problem ? I can provide
> > > more information if need.
> > > 
> > > Can you show me qemu commit id you used? Can you verity that if using the
> > > host kernel for guest helps? Does booting directly (without the install
> > > and reboot process) work?
> > Qemu commit id is "commit 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427".
> > 
> > Guest kernel updateing is useless.
> > 
> > Booting directly doesn't work too.
> 
> 
> Hello Libaiqing,
> 
> Sorry for the delay. I will try to reproduce it myself.

I tried 1.5.1 and qemu.git/master and your particular commit
4eda32f588086b6cd0ec2be6a7a6c131f8c2b427.

All work well for me. I used 3.10.0-rc6 as both and guest kernel.

> 
> > 
> > > > The qemu cmd:
> > > > [root@fedora121 x86_64-softmmu]# ./qemu-system-x86_64 -enable-kvm
> > > -name fedora   -M pc -m 1024 -smp 2   -drive
> > > file=/home/fedora18.iso,if=ide,media=cdrom -device
> > > vhost-scsi-pci,wwpn=naa.50014057133e25dc  -monitor stdio   -vga qxl
> > > -vnc :1
> > > >
> > > > The vnc output:
> > > > Dracut-initqueue[189]:/dev/mapper/fedora-root:UNEXPECTED
> > > INCONSISTENCY;RUN FSCK MANUALLY.
> > > > Dracut-initqueue[189]: Warning: e2fsck returned with 4
> > > > Dracut-initqueue[189]: Warning: ***An error occurred during the file
> > > system check.
> > > >
> > > > The guest kernel log:
> > > > Kernel: virtio-pci 0000:00:04.0: irq 40 for MSI/MSI-X
> > > > Kernel: virtio-pci 0000:00:04.0: irq 41 for MSI/MSI-X
> > > > Kernel: virtio-pci 0000:00:04.0: irq 42 for MSI/MSI-X
> > > > Kernel: virtio-pci 0000:00:04.0: irq 43 for MSI/MSI-X
> > > > Kernel: scsi2 : Virtio SCSI HBA
> > > > Kernel: scsi 2:0:1:0: Direct-Access LIO-ORG r0
> > > > Kernel: sd 2:0:1:0: Attached scsi generic sg1 type 0
> > > > Kernel: sd 2:0:1:0: [sda]1258912 512-byte logical .....
> > > > Kernel: sd 2:0:1:0: [sda]write protect is off
> > > > Kernel: sd 2:0:1:0: [sda]Mode sense :43 00 00 08
> > > > Kernel: sd 2:0:1:0: [sda]write cache: disabled, read .....
> > > > Kernel: sda sda1 sda2
> > > > Kernel: sd 2:0:1:0: [sda] Attached SCSI disk
> > > > Dracut-initqueue[189]: Scanning devices sda2 for LVM
> > > > Dracut-initqueue[189]: inactive '/dev/fedora/swap'...
> > > > Dracut-initqueue[189]: inactive '/dev/fedora/root'...
> > > >
> > > > The info of host:
> > > > [root@fedora121 x86_64-softmmu]# uname -a
> > > > Linux fedora121 3.10.0-rc6 #1 SMP Wed Jun 19 19:34:24 CST 2013 x86_64
> > > x86_64 x86_64 GNU/Linux
> > > > [root@fedora121 x86_64-softmmu]# lsmod |grep vhost_scsi
> > > > vhost_scsi             49456  5
> > > > target_core_mod       282163  14
> > > target_core_iblock,target_core_pscsi,iscsi_target_mod,target_core_file,vh
> > > ost_scsi
> > > > [root@fedora121 x86_64-softmmu]# targetcli
> > > > targetcli shell version v2.1.fb26
> > > > Copyright 2011 by RisingTide Systems LLC and others.
> > > > For help on commands, type 'help'.
> > > >
> > > > /> ls
> > > > o-
> > > / ..............................................................................................................
> > > ........... [...]
> > > >   o-
> > > backstores ...............................................................................................
> > > ............... [...]
> > > >   | o-
> > > block ..................................................................................................
> > > [Storage Objects: 0]
> > > >   | o-
> > > fileio .................................................................................................
> > > [Storage Objects: 0]
> > > >   | o-
> > > pscsi ..................................................................................................
> > > [Storage Objects: 0]
> > > >   | o-
> > > ramdisk ................................................................................................
> > > [Storage Objects: 1]
> > > >   |   o-
> > > r0 ...................................................................................................
> > > [(6.0GiB) activated]
> > > >   o-
> > > iscsi .........................................................................................................
> > > ... [Targets: 0]
> > > >   o-
> > > loopback ..................................................................................................
> > > ....... [Targets: 0]
> > > >   o-
> > > vhost .......................................................................................................
> > > ..... [Targets: 1]
> > > >     o-
> > > naa.50014057133e25dc ............................................................................
> > > .................. [TPGs: 1]
> > > >       o-
> > > tpg1 ...............................................................................................
> > > [naa.5001405a70ac3421]
> > > >         o-
> > > acls ..........................................................................................................
> > > [ACLs: 0]
> > > >         o-
> > > luns ..........................................................................................................
> > > [LUNs: 1]
> > > >           o-
> > > lun0 .....................................................................................................
> > > [ramdisk/r0]
> > > >
> > > > Regards,
> > > > baiqing
> > > > > -----Original Message-----
> > > > > From: Asias He [mailto:asias@redhat.com]
> > > > > Sent: Thursday, June 20, 2013 9:34 AM
> > > > > To: Libaiqing
> > > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting
> > > the
> > > > > tcm_vhost Linux kernel module
> > > > >
> > > > > On Wed, Jun 19, 2013 at 12:55:10PM +0000, Libaiqing wrote:
> > > > > > Hi paolo,
> > > > > >   The vhost-scsi device can be used as boot device?
> > > > > >   I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
> > > > > >   Could you give me some advise to debug this problem ? I can
> > > provide
> > > > > more information if need.
> > > > >
> > > > > Boot from vhost-scsi is supposed to work. The seabios you used should
> > > be
> > > > > fine which contains the fixes for vhost-scsi.
> > > > >
> > > > > Instead of playing with the /sys/kernel/config/target directly, I really
> > > > > recommend using targetcli utils.
> > > > >
> > > > > Nab, I think we really should write some docs for people to use
> > > > > vhost-scsi.
> > > > >
> > > > > This is how I install and use targetcli in RHEL6. Note you need upstream
> > > > > kernel and qemu bits for vhost-scsi.
> > > > >
> > > > > # yum groupinstall  'Development tools'
> > > > > # yum install python-devel epydoc python-simpleparse
> > > > >
> > > > > # git clone git://github.com/agrover/rtslib-fb.git
> > > > > # git clone git://github.com/agrover/targetcli-fb.git
> > > > > # git clone git://github.com/agrover/configshell-fb.git
> > > > > # for i in rtslib-fb configshell-fb targetcli-fb; do
> > > > >   	make -C $i rpm
> > > > >   	yum localinstall $i/dist/*.noarch.rpm
> > > > >   done
> > > > >
> > > > > In targetcli, create a backstore and vhost wwpn, e.g.
> > > > > # targetcli
> > > > > /> /backstores/ramdisk create r0 1g
> > > > > /> /vhost create
> > > > > /> cd /vhost/naa.500140527cb6616b/tpg1/luns
> > > > > /> create /backstores/ramdisk/r0
> > > > >
> > > > > # qemu -device vhost-scsi-pci,wwpn=naa.500140527cb6616b ...
> > > > >
> > > > > Hope this helps.
> > > > >
> > > > > > Regards,
> > > > > > baiqing
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
> > > > > > > [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org]
> > > On
> > > > > > > Behalf Of Paolo Bonzini
> > > > > > > Sent: Tuesday, May 28, 2013 4:01 PM
> > > > > > > To: Wenchao Xia
> > > > > > > Cc: asias@redhat.com; qemu-devel@nongnu.org;
> > > nab@linux-iscsi.org;
> > > > > > > Michael S. Tsirkin
> > > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > > supporting
> > > > > the
> > > > > > > tcm_vhost Linux kernel module
> > > > > > >
> > > > > > > Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> > > > > > > >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > > > > > > >> >
> > > > > > > >> > The WWPN specified in configfs is passed to "-device
> > > > > vhost-scsi-pci".
> > > > > > > >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now, so it is
> > > not
> > > > > > > >> > available from the QEMU command-line.  Instead, I hardcode it
> > > to
> > > > > > > zero.
> > > > > > > >> >
> > > > > > > > Hi, Paolo
> > > > > > > >   Any document about how to config it correctly in configfs,
> > > before
> > > > > > > > invoking qemu with the WWPN number?
> > > > > > >
> > > > > > > Unfortunately no, but vhost-scsi doesn't have many knobs (unlike
> > > > > > > iSCSI for example) so it's quite simple.  Here is an example:
> > > > > > >
> > > > > > > cd /sys/kernel/config/target
> > > > > > > mkdir -p core/fileio_0/fileio
> > > > > > > echo
> > > > > 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> > > > > > > core/fileio_0/fileio/control
> > > > > > > echo 1 > core/fileio_0/fileio/enable
> > > > > > > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> > > > > > > cd vhost/naa.600140554cf3a18e/tpgt_0
> > > > > > > ln -sf ../../../../../core/fileio_0/fileio/ lun/lun_0/virtual_scsi_port
> > > > > > > echo naa.60014053226f0388 > nexus
> > > > > > >
> > > > > > > The "nexus" value is the initiator WWN.  naa.600140554cf3a18e is
> > > the
> > > > > > > target WWN that you have to pass to "-device vhost-scsi-pci".
> > > > > > >
> > > > > > > Paolo
> > > > > >
> > > > >
> > > > > --
> > > > > Asias
> > > 
> > > --
> > > Asias
> 
> -- 
> Asias
Libaiqing July 3, 2013, 12:33 p.m. UTC | #20
Hi asias,
    I got the rootcause:guest was installed on raw img with lvm partition,which vhost does not support.
    
    Now vhost-scsi can be used as bootable device.
Thanks
baiqing
> -----Original Message-----
> From: Asias He [mailto:asias@redhat.com]
> Sent: Wednesday, July 03, 2013 4:09 PM
> To: Libaiqing
> Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> tcm_vhost Linux kernel module
> 
> On Wed, Jul 03, 2013 at 11:23:26AM +0800, Asias He wrote:
> > On Fri, Jun 21, 2013 at 10:16:48AM +0000, Libaiqing wrote:
> > > Hi Asias,
> > >
> > > > -----Original Message-----
> > > > From: Asias He [mailto:asias@redhat.com]
> > > > Sent: Thursday, June 20, 2013 5:39 PM
> > > > To: Libaiqing
> > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> supporting the
> > > > tcm_vhost Linux kernel module
> > > >
> > > > On Thu, Jun 20, 2013 at 08:49:50AM +0000, Libaiqing wrote:
> > > > > Hi Asias,
> > > > >     Thanks for your config.
> > > > >     According to you config,I test booting from vhost device with
> > > > upstream kernel and qemu,but failed.
> > > > >
> > > > >     1 installing guest from cdrom,ok.
> > > > >     2 booting vhost-scsi,guest fs error occurs.
> > > > >     3 using fileio backstores,the error is same..
> > > > >     4 rebooting guest,a log printed:
> > > > >      (qemu) hw/scsi/virtio-scsi.c:533:virtio_scsi_handle_event:
> Object
> > > > 0x7fccae7f2c88 is not an instance of type virtio-scsi-device
> > > >
> > > > Paolo, I remember you fixed a similar issue?
> > > >
> > > > >     5 using upstream seabios,core dumped.
> > > > >
> > > > >     Could you give me some advise to debug this problem ? I can
> provide
> > > > more information if need.
> > > >
> > > > Can you show me qemu commit id you used? Can you verity that if
> using the
> > > > host kernel for guest helps? Does booting directly (without the install
> > > > and reboot process) work?
> > > Qemu commit id is "commit
> 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427".
> > >
> > > Guest kernel updateing is useless.
> > >
> > > Booting directly doesn't work too.
> >
> >
> > Hello Libaiqing,
> >
> > Sorry for the delay. I will try to reproduce it myself.
> 
> I tried 1.5.1 and qemu.git/master and your particular commit
> 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427.
> 
> All work well for me. I used 3.10.0-rc6 as both and guest kernel.
> 
> >
> > >
> > > > > The qemu cmd:
> > > > > [root@fedora121 x86_64-softmmu]# ./qemu-system-x86_64
> -enable-kvm
> > > > -name fedora   -M pc -m 1024 -smp 2   -drive
> > > > file=/home/fedora18.iso,if=ide,media=cdrom -device
> > > > vhost-scsi-pci,wwpn=naa.50014057133e25dc  -monitor stdio   -vga
> qxl
> > > > -vnc :1
> > > > >
> > > > > The vnc output:
> > > > > Dracut-initqueue[189]:/dev/mapper/fedora-root:UNEXPECTED
> > > > INCONSISTENCY;RUN FSCK MANUALLY.
> > > > > Dracut-initqueue[189]: Warning: e2fsck returned with 4
> > > > > Dracut-initqueue[189]: Warning: ***An error occurred during the file
> > > > system check.
> > > > >
> > > > > The guest kernel log:
> > > > > Kernel: virtio-pci 0000:00:04.0: irq 40 for MSI/MSI-X
> > > > > Kernel: virtio-pci 0000:00:04.0: irq 41 for MSI/MSI-X
> > > > > Kernel: virtio-pci 0000:00:04.0: irq 42 for MSI/MSI-X
> > > > > Kernel: virtio-pci 0000:00:04.0: irq 43 for MSI/MSI-X
> > > > > Kernel: scsi2 : Virtio SCSI HBA
> > > > > Kernel: scsi 2:0:1:0: Direct-Access LIO-ORG r0
> > > > > Kernel: sd 2:0:1:0: Attached scsi generic sg1 type 0
> > > > > Kernel: sd 2:0:1:0: [sda]1258912 512-byte logical .....
> > > > > Kernel: sd 2:0:1:0: [sda]write protect is off
> > > > > Kernel: sd 2:0:1:0: [sda]Mode sense :43 00 00 08
> > > > > Kernel: sd 2:0:1:0: [sda]write cache: disabled, read .....
> > > > > Kernel: sda sda1 sda2
> > > > > Kernel: sd 2:0:1:0: [sda] Attached SCSI disk
> > > > > Dracut-initqueue[189]: Scanning devices sda2 for LVM
> > > > > Dracut-initqueue[189]: inactive '/dev/fedora/swap'...
> > > > > Dracut-initqueue[189]: inactive '/dev/fedora/root'...
> > > > >
> > > > > The info of host:
> > > > > [root@fedora121 x86_64-softmmu]# uname -a
> > > > > Linux fedora121 3.10.0-rc6 #1 SMP Wed Jun 19 19:34:24 CST 2013
> x86_64
> > > > x86_64 x86_64 GNU/Linux
> > > > > [root@fedora121 x86_64-softmmu]# lsmod |grep vhost_scsi
> > > > > vhost_scsi             49456  5
> > > > > target_core_mod       282163  14
> > > >
> target_core_iblock,target_core_pscsi,iscsi_target_mod,target_core_file,vh
> > > > ost_scsi
> > > > > [root@fedora121 x86_64-softmmu]# targetcli
> > > > > targetcli shell version v2.1.fb26
> > > > > Copyright 2011 by RisingTide Systems LLC and others.
> > > > > For help on commands, type 'help'.
> > > > >
> > > > > /> ls
> > > > > o-
> > > >
> / ..............................................................................................................
> > > > ........... [...]
> > > > >   o-
> > > >
> backstores ...............................................................................................
> > > > ............... [...]
> > > > >   | o-
> > > >
> block ..................................................................................................
> > > > [Storage Objects: 0]
> > > > >   | o-
> > > >
> fileio .................................................................................................
> > > > [Storage Objects: 0]
> > > > >   | o-
> > > >
> pscsi ..................................................................................................
> > > > [Storage Objects: 0]
> > > > >   | o-
> > > >
> ramdisk ................................................................................................
> > > > [Storage Objects: 1]
> > > > >   |   o-
> > > > r0 ...................................................................................................
> > > > [(6.0GiB) activated]
> > > > >   o-
> > > >
> iscsi .........................................................................................................
> > > > ... [Targets: 0]
> > > > >   o-
> > > >
> loopback ..................................................................................................
> > > > ....... [Targets: 0]
> > > > >   o-
> > > >
> vhost .......................................................................................................
> > > > ..... [Targets: 1]
> > > > >     o-
> > > >
> naa.50014057133e25dc ............................................................................
> > > > .................. [TPGs: 1]
> > > > >       o-
> > > > tpg1 ...............................................................................................
> > > > [naa.5001405a70ac3421]
> > > > >         o-
> > > >
> acls .........................................................................................................
> .
> > > > [ACLs: 0]
> > > > >         o-
> > > >
> luns .........................................................................................................
> .
> > > > [LUNs: 1]
> > > > >           o-
> > > >
> lun0 .....................................................................................................
> > > > [ramdisk/r0]
> > > > >
> > > > > Regards,
> > > > > baiqing
> > > > > > -----Original Message-----
> > > > > > From: Asias He [mailto:asias@redhat.com]
> > > > > > Sent: Thursday, June 20, 2013 9:34 AM
> > > > > > To: Libaiqing
> > > > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> supporting
> > > > the
> > > > > > tcm_vhost Linux kernel module
> > > > > >
> > > > > > On Wed, Jun 19, 2013 at 12:55:10PM +0000, Libaiqing wrote:
> > > > > > > Hi paolo,
> > > > > > >   The vhost-scsi device can be used as boot device?
> > > > > > >   I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
> > > > > > >   Could you give me some advise to debug this problem ? I can
> > > > provide
> > > > > > more information if need.
> > > > > >
> > > > > > Boot from vhost-scsi is supposed to work. The seabios you used
> should
> > > > be
> > > > > > fine which contains the fixes for vhost-scsi.
> > > > > >
> > > > > > Instead of playing with the /sys/kernel/config/target directly, I
> really
> > > > > > recommend using targetcli utils.
> > > > > >
> > > > > > Nab, I think we really should write some docs for people to use
> > > > > > vhost-scsi.
> > > > > >
> > > > > > This is how I install and use targetcli in RHEL6. Note you need
> upstream
> > > > > > kernel and qemu bits for vhost-scsi.
> > > > > >
> > > > > > # yum groupinstall  'Development tools'
> > > > > > # yum install python-devel epydoc python-simpleparse
> > > > > >
> > > > > > # git clone git://github.com/agrover/rtslib-fb.git
> > > > > > # git clone git://github.com/agrover/targetcli-fb.git
> > > > > > # git clone git://github.com/agrover/configshell-fb.git
> > > > > > # for i in rtslib-fb configshell-fb targetcli-fb; do
> > > > > >   	make -C $i rpm
> > > > > >   	yum localinstall $i/dist/*.noarch.rpm
> > > > > >   done
> > > > > >
> > > > > > In targetcli, create a backstore and vhost wwpn, e.g.
> > > > > > # targetcli
> > > > > > /> /backstores/ramdisk create r0 1g
> > > > > > /> /vhost create
> > > > > > /> cd /vhost/naa.500140527cb6616b/tpg1/luns
> > > > > > /> create /backstores/ramdisk/r0
> > > > > >
> > > > > > # qemu -device vhost-scsi-pci,wwpn=naa.500140527cb6616b ...
> > > > > >
> > > > > > Hope this helps.
> > > > > >
> > > > > > > Regards,
> > > > > > > baiqing
> > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
> > > > > > > >
> [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org]
> > > > On
> > > > > > > > Behalf Of Paolo Bonzini
> > > > > > > > Sent: Tuesday, May 28, 2013 4:01 PM
> > > > > > > > To: Wenchao Xia
> > > > > > > > Cc: asias@redhat.com; qemu-devel@nongnu.org;
> > > > nab@linux-iscsi.org;
> > > > > > > > Michael S. Tsirkin
> > > > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > > > supporting
> > > > > > the
> > > > > > > > tcm_vhost Linux kernel module
> > > > > > > >
> > > > > > > > Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> > > > > > > > >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > > > > > > > >> >
> > > > > > > > >> > The WWPN specified in configfs is passed to "-device
> > > > > > vhost-scsi-pci".
> > > > > > > > >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now,
> so it is
> > > > not
> > > > > > > > >> > available from the QEMU command-line.  Instead, I
> hardcode it
> > > > to
> > > > > > > > zero.
> > > > > > > > >> >
> > > > > > > > > Hi, Paolo
> > > > > > > > >   Any document about how to config it correctly in configfs,
> > > > before
> > > > > > > > > invoking qemu with the WWPN number?
> > > > > > > >
> > > > > > > > Unfortunately no, but vhost-scsi doesn't have many knobs
> (unlike
> > > > > > > > iSCSI for example) so it's quite simple.  Here is an example:
> > > > > > > >
> > > > > > > > cd /sys/kernel/config/target
> > > > > > > > mkdir -p core/fileio_0/fileio
> > > > > > > > echo
> > > > > >
> 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> > > > > > > > core/fileio_0/fileio/control
> > > > > > > > echo 1 > core/fileio_0/fileio/enable
> > > > > > > > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> > > > > > > > cd vhost/naa.600140554cf3a18e/tpgt_0
> > > > > > > > ln -sf ../../../../../core/fileio_0/fileio/
> lun/lun_0/virtual_scsi_port
> > > > > > > > echo naa.60014053226f0388 > nexus
> > > > > > > >
> > > > > > > > The "nexus" value is the initiator WWN.
> naa.600140554cf3a18e is
> > > > the
> > > > > > > > target WWN that you have to pass to "-device vhost-scsi-pci".
> > > > > > > >
> > > > > > > > Paolo
> > > > > > >
> > > > > >
> > > > > > --
> > > > > > Asias
> > > >
> > > > --
> > > > Asias
> >
> > --
> > Asias
> 
> --
> Asias
Libaiqing July 4, 2013, 7 a.m. UTC | #21
Hi asias,
    1 Window can not boot from vhost-scsi device;
    2 A non-bootable vhost-scsi device can not be driven by windows guest.(I used the driver virtio-win-0.1-59 version.)
    
    Do you have any plan about these?

Thanks,
Baiqing.
> -----Original Message-----
> From: Asias He [mailto:asias@redhat.com]
> Sent: Wednesday, July 03, 2013 4:09 PM
> To: Libaiqing
> Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> tcm_vhost Linux kernel module
> 
> On Wed, Jul 03, 2013 at 11:23:26AM +0800, Asias He wrote:
> > On Fri, Jun 21, 2013 at 10:16:48AM +0000, Libaiqing wrote:
> > > Hi Asias,
> > >
> > > > -----Original Message-----
> > > > From: Asias He [mailto:asias@redhat.com]
> > > > Sent: Thursday, June 20, 2013 5:39 PM
> > > > To: Libaiqing
> > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> supporting the
> > > > tcm_vhost Linux kernel module
> > > >
> > > > On Thu, Jun 20, 2013 at 08:49:50AM +0000, Libaiqing wrote:
> > > > > Hi Asias,
> > > > >     Thanks for your config.
> > > > >     According to you config,I test booting from vhost device with
> > > > upstream kernel and qemu,but failed.
> > > > >
> > > > >     1 installing guest from cdrom,ok.
> > > > >     2 booting vhost-scsi,guest fs error occurs.
> > > > >     3 using fileio backstores,the error is same..
> > > > >     4 rebooting guest,a log printed:
> > > > >      (qemu) hw/scsi/virtio-scsi.c:533:virtio_scsi_handle_event:
> Object
> > > > 0x7fccae7f2c88 is not an instance of type virtio-scsi-device
> > > >
> > > > Paolo, I remember you fixed a similar issue?
> > > >
> > > > >     5 using upstream seabios,core dumped.
> > > > >
> > > > >     Could you give me some advise to debug this problem ? I can
> provide
> > > > more information if need.
> > > >
> > > > Can you show me qemu commit id you used? Can you verity that if
> using the
> > > > host kernel for guest helps? Does booting directly (without the install
> > > > and reboot process) work?
> > > Qemu commit id is "commit
> 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427".
> > >
> > > Guest kernel updateing is useless.
> > >
> > > Booting directly doesn't work too.
> >
> >
> > Hello Libaiqing,
> >
> > Sorry for the delay. I will try to reproduce it myself.
> 
> I tried 1.5.1 and qemu.git/master and your particular commit
> 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427.
> 
> All work well for me. I used 3.10.0-rc6 as both and guest kernel.
> 
> >
> > >
> > > > > The qemu cmd:
> > > > > [root@fedora121 x86_64-softmmu]# ./qemu-system-x86_64
> -enable-kvm
> > > > -name fedora   -M pc -m 1024 -smp 2   -drive
> > > > file=/home/fedora18.iso,if=ide,media=cdrom -device
> > > > vhost-scsi-pci,wwpn=naa.50014057133e25dc  -monitor stdio   -vga
> qxl
> > > > -vnc :1
> > > > >
> > > > > The vnc output:
> > > > > Dracut-initqueue[189]:/dev/mapper/fedora-root:UNEXPECTED
> > > > INCONSISTENCY;RUN FSCK MANUALLY.
> > > > > Dracut-initqueue[189]: Warning: e2fsck returned with 4
> > > > > Dracut-initqueue[189]: Warning: ***An error occurred during the file
> > > > system check.
> > > > >
> > > > > The guest kernel log:
> > > > > Kernel: virtio-pci 0000:00:04.0: irq 40 for MSI/MSI-X
> > > > > Kernel: virtio-pci 0000:00:04.0: irq 41 for MSI/MSI-X
> > > > > Kernel: virtio-pci 0000:00:04.0: irq 42 for MSI/MSI-X
> > > > > Kernel: virtio-pci 0000:00:04.0: irq 43 for MSI/MSI-X
> > > > > Kernel: scsi2 : Virtio SCSI HBA
> > > > > Kernel: scsi 2:0:1:0: Direct-Access LIO-ORG r0
> > > > > Kernel: sd 2:0:1:0: Attached scsi generic sg1 type 0
> > > > > Kernel: sd 2:0:1:0: [sda]1258912 512-byte logical .....
> > > > > Kernel: sd 2:0:1:0: [sda]write protect is off
> > > > > Kernel: sd 2:0:1:0: [sda]Mode sense :43 00 00 08
> > > > > Kernel: sd 2:0:1:0: [sda]write cache: disabled, read .....
> > > > > Kernel: sda sda1 sda2
> > > > > Kernel: sd 2:0:1:0: [sda] Attached SCSI disk
> > > > > Dracut-initqueue[189]: Scanning devices sda2 for LVM
> > > > > Dracut-initqueue[189]: inactive '/dev/fedora/swap'...
> > > > > Dracut-initqueue[189]: inactive '/dev/fedora/root'...
> > > > >
> > > > > The info of host:
> > > > > [root@fedora121 x86_64-softmmu]# uname -a
> > > > > Linux fedora121 3.10.0-rc6 #1 SMP Wed Jun 19 19:34:24 CST 2013
> x86_64
> > > > x86_64 x86_64 GNU/Linux
> > > > > [root@fedora121 x86_64-softmmu]# lsmod |grep vhost_scsi
> > > > > vhost_scsi             49456  5
> > > > > target_core_mod       282163  14
> > > >
> target_core_iblock,target_core_pscsi,iscsi_target_mod,target_core_file,vh
> > > > ost_scsi
> > > > > [root@fedora121 x86_64-softmmu]# targetcli
> > > > > targetcli shell version v2.1.fb26
> > > > > Copyright 2011 by RisingTide Systems LLC and others.
> > > > > For help on commands, type 'help'.
> > > > >
> > > > > /> ls
> > > > > o-
> > > >
> / ..............................................................................................................
> > > > ........... [...]
> > > > >   o-
> > > >
> backstores ...............................................................................................
> > > > ............... [...]
> > > > >   | o-
> > > >
> block ..................................................................................................
> > > > [Storage Objects: 0]
> > > > >   | o-
> > > >
> fileio .................................................................................................
> > > > [Storage Objects: 0]
> > > > >   | o-
> > > >
> pscsi ..................................................................................................
> > > > [Storage Objects: 0]
> > > > >   | o-
> > > >
> ramdisk ................................................................................................
> > > > [Storage Objects: 1]
> > > > >   |   o-
> > > > r0 ...................................................................................................
> > > > [(6.0GiB) activated]
> > > > >   o-
> > > >
> iscsi .........................................................................................................
> > > > ... [Targets: 0]
> > > > >   o-
> > > >
> loopback ..................................................................................................
> > > > ....... [Targets: 0]
> > > > >   o-
> > > >
> vhost .......................................................................................................
> > > > ..... [Targets: 1]
> > > > >     o-
> > > >
> naa.50014057133e25dc ............................................................................
> > > > .................. [TPGs: 1]
> > > > >       o-
> > > > tpg1 ...............................................................................................
> > > > [naa.5001405a70ac3421]
> > > > >         o-
> > > >
> acls .........................................................................................................
> .
> > > > [ACLs: 0]
> > > > >         o-
> > > >
> luns .........................................................................................................
> .
> > > > [LUNs: 1]
> > > > >           o-
> > > >
> lun0 .....................................................................................................
> > > > [ramdisk/r0]
> > > > >
> > > > > Regards,
> > > > > baiqing
> > > > > > -----Original Message-----
> > > > > > From: Asias He [mailto:asias@redhat.com]
> > > > > > Sent: Thursday, June 20, 2013 9:34 AM
> > > > > > To: Libaiqing
> > > > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> supporting
> > > > the
> > > > > > tcm_vhost Linux kernel module
> > > > > >
> > > > > > On Wed, Jun 19, 2013 at 12:55:10PM +0000, Libaiqing wrote:
> > > > > > > Hi paolo,
> > > > > > >   The vhost-scsi device can be used as boot device?
> > > > > > >   I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
> > > > > > >   Could you give me some advise to debug this problem ? I can
> > > > provide
> > > > > > more information if need.
> > > > > >
> > > > > > Boot from vhost-scsi is supposed to work. The seabios you used
> should
> > > > be
> > > > > > fine which contains the fixes for vhost-scsi.
> > > > > >
> > > > > > Instead of playing with the /sys/kernel/config/target directly, I
> really
> > > > > > recommend using targetcli utils.
> > > > > >
> > > > > > Nab, I think we really should write some docs for people to use
> > > > > > vhost-scsi.
> > > > > >
> > > > > > This is how I install and use targetcli in RHEL6. Note you need
> upstream
> > > > > > kernel and qemu bits for vhost-scsi.
> > > > > >
> > > > > > # yum groupinstall  'Development tools'
> > > > > > # yum install python-devel epydoc python-simpleparse
> > > > > >
> > > > > > # git clone git://github.com/agrover/rtslib-fb.git
> > > > > > # git clone git://github.com/agrover/targetcli-fb.git
> > > > > > # git clone git://github.com/agrover/configshell-fb.git
> > > > > > # for i in rtslib-fb configshell-fb targetcli-fb; do
> > > > > >   	make -C $i rpm
> > > > > >   	yum localinstall $i/dist/*.noarch.rpm
> > > > > >   done
> > > > > >
> > > > > > In targetcli, create a backstore and vhost wwpn, e.g.
> > > > > > # targetcli
> > > > > > /> /backstores/ramdisk create r0 1g
> > > > > > /> /vhost create
> > > > > > /> cd /vhost/naa.500140527cb6616b/tpg1/luns
> > > > > > /> create /backstores/ramdisk/r0
> > > > > >
> > > > > > # qemu -device vhost-scsi-pci,wwpn=naa.500140527cb6616b ...
> > > > > >
> > > > > > Hope this helps.
> > > > > >
> > > > > > > Regards,
> > > > > > > baiqing
> > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
> > > > > > > >
> [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org]
> > > > On
> > > > > > > > Behalf Of Paolo Bonzini
> > > > > > > > Sent: Tuesday, May 28, 2013 4:01 PM
> > > > > > > > To: Wenchao Xia
> > > > > > > > Cc: asias@redhat.com; qemu-devel@nongnu.org;
> > > > nab@linux-iscsi.org;
> > > > > > > > Michael S. Tsirkin
> > > > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > > > supporting
> > > > > > the
> > > > > > > > tcm_vhost Linux kernel module
> > > > > > > >
> > > > > > > > Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> > > > > > > > >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > > > > > > > >> >
> > > > > > > > >> > The WWPN specified in configfs is passed to "-device
> > > > > > vhost-scsi-pci".
> > > > > > > > >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now,
> so it is
> > > > not
> > > > > > > > >> > available from the QEMU command-line.  Instead, I
> hardcode it
> > > > to
> > > > > > > > zero.
> > > > > > > > >> >
> > > > > > > > > Hi, Paolo
> > > > > > > > >   Any document about how to config it correctly in configfs,
> > > > before
> > > > > > > > > invoking qemu with the WWPN number?
> > > > > > > >
> > > > > > > > Unfortunately no, but vhost-scsi doesn't have many knobs
> (unlike
> > > > > > > > iSCSI for example) so it's quite simple.  Here is an example:
> > > > > > > >
> > > > > > > > cd /sys/kernel/config/target
> > > > > > > > mkdir -p core/fileio_0/fileio
> > > > > > > > echo
> > > > > >
> 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> > > > > > > > core/fileio_0/fileio/control
> > > > > > > > echo 1 > core/fileio_0/fileio/enable
> > > > > > > > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> > > > > > > > cd vhost/naa.600140554cf3a18e/tpgt_0
> > > > > > > > ln -sf ../../../../../core/fileio_0/fileio/
> lun/lun_0/virtual_scsi_port
> > > > > > > > echo naa.60014053226f0388 > nexus
> > > > > > > >
> > > > > > > > The "nexus" value is the initiator WWN.
> naa.600140554cf3a18e is
> > > > the
> > > > > > > > target WWN that you have to pass to "-device vhost-scsi-pci".
> > > > > > > >
> > > > > > > > Paolo
> > > > > > >
> > > > > >
> > > > > > --
> > > > > > Asias
> > > >
> > > > --
> > > > Asias
> >
> > --
> > Asias
> 
> --
> Asias
Paolo Bonzini July 4, 2013, 11:23 a.m. UTC | #22
Il 03/07/2013 14:33, Libaiqing ha scritto:
> Hi asias,
>     I got the rootcause:guest was installed on raw img with lvm partition,which vhost does not support.

You mean LVM in the host or the guest?  I guess in the host, but I'd
rather make sure because otherwise you've found a bug.

Paolo

>     Now vhost-scsi can be used as bootable device.
Asias He July 5, 2013, midnight UTC | #23
On Thu, Jul 04, 2013 at 07:00:49AM +0000, Libaiqing wrote:
> Hi asias,
>     1 Window can not boot from vhost-scsi device;
>     2 A non-bootable vhost-scsi device can not be driven by windows guest.(I used the driver virtio-win-0.1-59 version.)
>     
>     Do you have any plan about these?

Thanks for testing. I will take a look.

> 
> Thanks,
> Baiqing.
> > -----Original Message-----
> > From: Asias He [mailto:asias@redhat.com]
> > Sent: Wednesday, July 03, 2013 4:09 PM
> > To: Libaiqing
> > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> > tcm_vhost Linux kernel module
> > 
> > On Wed, Jul 03, 2013 at 11:23:26AM +0800, Asias He wrote:
> > > On Fri, Jun 21, 2013 at 10:16:48AM +0000, Libaiqing wrote:
> > > > Hi Asias,
> > > >
> > > > > -----Original Message-----
> > > > > From: Asias He [mailto:asias@redhat.com]
> > > > > Sent: Thursday, June 20, 2013 5:39 PM
> > > > > To: Libaiqing
> > > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > supporting the
> > > > > tcm_vhost Linux kernel module
> > > > >
> > > > > On Thu, Jun 20, 2013 at 08:49:50AM +0000, Libaiqing wrote:
> > > > > > Hi Asias,
> > > > > >     Thanks for your config.
> > > > > >     According to you config,I test booting from vhost device with
> > > > > upstream kernel and qemu,but failed.
> > > > > >
> > > > > >     1 installing guest from cdrom,ok.
> > > > > >     2 booting vhost-scsi,guest fs error occurs.
> > > > > >     3 using fileio backstores,the error is same..
> > > > > >     4 rebooting guest,a log printed:
> > > > > >      (qemu) hw/scsi/virtio-scsi.c:533:virtio_scsi_handle_event:
> > Object
> > > > > 0x7fccae7f2c88 is not an instance of type virtio-scsi-device
> > > > >
> > > > > Paolo, I remember you fixed a similar issue?
> > > > >
> > > > > >     5 using upstream seabios,core dumped.
> > > > > >
> > > > > >     Could you give me some advise to debug this problem ? I can
> > provide
> > > > > more information if need.
> > > > >
> > > > > Can you show me qemu commit id you used? Can you verity that if
> > using the
> > > > > host kernel for guest helps? Does booting directly (without the install
> > > > > and reboot process) work?
> > > > Qemu commit id is "commit
> > 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427".
> > > >
> > > > Guest kernel updateing is useless.
> > > >
> > > > Booting directly doesn't work too.
> > >
> > >
> > > Hello Libaiqing,
> > >
> > > Sorry for the delay. I will try to reproduce it myself.
> > 
> > I tried 1.5.1 and qemu.git/master and your particular commit
> > 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427.
> > 
> > All work well for me. I used 3.10.0-rc6 as both and guest kernel.
> > 
> > >
> > > >
> > > > > > The qemu cmd:
> > > > > > [root@fedora121 x86_64-softmmu]# ./qemu-system-x86_64
> > -enable-kvm
> > > > > -name fedora   -M pc -m 1024 -smp 2   -drive
> > > > > file=/home/fedora18.iso,if=ide,media=cdrom -device
> > > > > vhost-scsi-pci,wwpn=naa.50014057133e25dc  -monitor stdio   -vga
> > qxl
> > > > > -vnc :1
> > > > > >
> > > > > > The vnc output:
> > > > > > Dracut-initqueue[189]:/dev/mapper/fedora-root:UNEXPECTED
> > > > > INCONSISTENCY;RUN FSCK MANUALLY.
> > > > > > Dracut-initqueue[189]: Warning: e2fsck returned with 4
> > > > > > Dracut-initqueue[189]: Warning: ***An error occurred during the file
> > > > > system check.
> > > > > >
> > > > > > The guest kernel log:
> > > > > > Kernel: virtio-pci 0000:00:04.0: irq 40 for MSI/MSI-X
> > > > > > Kernel: virtio-pci 0000:00:04.0: irq 41 for MSI/MSI-X
> > > > > > Kernel: virtio-pci 0000:00:04.0: irq 42 for MSI/MSI-X
> > > > > > Kernel: virtio-pci 0000:00:04.0: irq 43 for MSI/MSI-X
> > > > > > Kernel: scsi2 : Virtio SCSI HBA
> > > > > > Kernel: scsi 2:0:1:0: Direct-Access LIO-ORG r0
> > > > > > Kernel: sd 2:0:1:0: Attached scsi generic sg1 type 0
> > > > > > Kernel: sd 2:0:1:0: [sda]1258912 512-byte logical .....
> > > > > > Kernel: sd 2:0:1:0: [sda]write protect is off
> > > > > > Kernel: sd 2:0:1:0: [sda]Mode sense :43 00 00 08
> > > > > > Kernel: sd 2:0:1:0: [sda]write cache: disabled, read .....
> > > > > > Kernel: sda sda1 sda2
> > > > > > Kernel: sd 2:0:1:0: [sda] Attached SCSI disk
> > > > > > Dracut-initqueue[189]: Scanning devices sda2 for LVM
> > > > > > Dracut-initqueue[189]: inactive '/dev/fedora/swap'...
> > > > > > Dracut-initqueue[189]: inactive '/dev/fedora/root'...
> > > > > >
> > > > > > The info of host:
> > > > > > [root@fedora121 x86_64-softmmu]# uname -a
> > > > > > Linux fedora121 3.10.0-rc6 #1 SMP Wed Jun 19 19:34:24 CST 2013
> > x86_64
> > > > > x86_64 x86_64 GNU/Linux
> > > > > > [root@fedora121 x86_64-softmmu]# lsmod |grep vhost_scsi
> > > > > > vhost_scsi             49456  5
> > > > > > target_core_mod       282163  14
> > > > >
> > target_core_iblock,target_core_pscsi,iscsi_target_mod,target_core_file,vh
> > > > > ost_scsi
> > > > > > [root@fedora121 x86_64-softmmu]# targetcli
> > > > > > targetcli shell version v2.1.fb26
> > > > > > Copyright 2011 by RisingTide Systems LLC and others.
> > > > > > For help on commands, type 'help'.
> > > > > >
> > > > > > /> ls
> > > > > > o-
> > > > >
> > / ..............................................................................................................
> > > > > ........... [...]
> > > > > >   o-
> > > > >
> > backstores ...............................................................................................
> > > > > ............... [...]
> > > > > >   | o-
> > > > >
> > block ..................................................................................................
> > > > > [Storage Objects: 0]
> > > > > >   | o-
> > > > >
> > fileio .................................................................................................
> > > > > [Storage Objects: 0]
> > > > > >   | o-
> > > > >
> > pscsi ..................................................................................................
> > > > > [Storage Objects: 0]
> > > > > >   | o-
> > > > >
> > ramdisk ................................................................................................
> > > > > [Storage Objects: 1]
> > > > > >   |   o-
> > > > > r0 ...................................................................................................
> > > > > [(6.0GiB) activated]
> > > > > >   o-
> > > > >
> > iscsi .........................................................................................................
> > > > > ... [Targets: 0]
> > > > > >   o-
> > > > >
> > loopback ..................................................................................................
> > > > > ....... [Targets: 0]
> > > > > >   o-
> > > > >
> > vhost .......................................................................................................
> > > > > ..... [Targets: 1]
> > > > > >     o-
> > > > >
> > naa.50014057133e25dc ............................................................................
> > > > > .................. [TPGs: 1]
> > > > > >       o-
> > > > > tpg1 ...............................................................................................
> > > > > [naa.5001405a70ac3421]
> > > > > >         o-
> > > > >
> > acls .........................................................................................................
> > .
> > > > > [ACLs: 0]
> > > > > >         o-
> > > > >
> > luns .........................................................................................................
> > .
> > > > > [LUNs: 1]
> > > > > >           o-
> > > > >
> > lun0 .....................................................................................................
> > > > > [ramdisk/r0]
> > > > > >
> > > > > > Regards,
> > > > > > baiqing
> > > > > > > -----Original Message-----
> > > > > > > From: Asias He [mailto:asias@redhat.com]
> > > > > > > Sent: Thursday, June 20, 2013 9:34 AM
> > > > > > > To: Libaiqing
> > > > > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > supporting
> > > > > the
> > > > > > > tcm_vhost Linux kernel module
> > > > > > >
> > > > > > > On Wed, Jun 19, 2013 at 12:55:10PM +0000, Libaiqing wrote:
> > > > > > > > Hi paolo,
> > > > > > > >   The vhost-scsi device can be used as boot device?
> > > > > > > >   I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
> > > > > > > >   Could you give me some advise to debug this problem ? I can
> > > > > provide
> > > > > > > more information if need.
> > > > > > >
> > > > > > > Boot from vhost-scsi is supposed to work. The seabios you used
> > should
> > > > > be
> > > > > > > fine which contains the fixes for vhost-scsi.
> > > > > > >
> > > > > > > Instead of playing with the /sys/kernel/config/target directly, I
> > really
> > > > > > > recommend using targetcli utils.
> > > > > > >
> > > > > > > Nab, I think we really should write some docs for people to use
> > > > > > > vhost-scsi.
> > > > > > >
> > > > > > > This is how I install and use targetcli in RHEL6. Note you need
> > upstream
> > > > > > > kernel and qemu bits for vhost-scsi.
> > > > > > >
> > > > > > > # yum groupinstall  'Development tools'
> > > > > > > # yum install python-devel epydoc python-simpleparse
> > > > > > >
> > > > > > > # git clone git://github.com/agrover/rtslib-fb.git
> > > > > > > # git clone git://github.com/agrover/targetcli-fb.git
> > > > > > > # git clone git://github.com/agrover/configshell-fb.git
> > > > > > > # for i in rtslib-fb configshell-fb targetcli-fb; do
> > > > > > >   	make -C $i rpm
> > > > > > >   	yum localinstall $i/dist/*.noarch.rpm
> > > > > > >   done
> > > > > > >
> > > > > > > In targetcli, create a backstore and vhost wwpn, e.g.
> > > > > > > # targetcli
> > > > > > > /> /backstores/ramdisk create r0 1g
> > > > > > > /> /vhost create
> > > > > > > /> cd /vhost/naa.500140527cb6616b/tpg1/luns
> > > > > > > /> create /backstores/ramdisk/r0
> > > > > > >
> > > > > > > # qemu -device vhost-scsi-pci,wwpn=naa.500140527cb6616b ...
> > > > > > >
> > > > > > > Hope this helps.
> > > > > > >
> > > > > > > > Regards,
> > > > > > > > baiqing
> > > > > > > >
> > > > > > > > > -----Original Message-----
> > > > > > > > > From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
> > > > > > > > >
> > [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org]
> > > > > On
> > > > > > > > > Behalf Of Paolo Bonzini
> > > > > > > > > Sent: Tuesday, May 28, 2013 4:01 PM
> > > > > > > > > To: Wenchao Xia
> > > > > > > > > Cc: asias@redhat.com; qemu-devel@nongnu.org;
> > > > > nab@linux-iscsi.org;
> > > > > > > > > Michael S. Tsirkin
> > > > > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > > > > supporting
> > > > > > > the
> > > > > > > > > tcm_vhost Linux kernel module
> > > > > > > > >
> > > > > > > > > Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> > > > > > > > > >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > > > > > > > > >> >
> > > > > > > > > >> > The WWPN specified in configfs is passed to "-device
> > > > > > > vhost-scsi-pci".
> > > > > > > > > >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now,
> > so it is
> > > > > not
> > > > > > > > > >> > available from the QEMU command-line.  Instead, I
> > hardcode it
> > > > > to
> > > > > > > > > zero.
> > > > > > > > > >> >
> > > > > > > > > > Hi, Paolo
> > > > > > > > > >   Any document about how to config it correctly in configfs,
> > > > > before
> > > > > > > > > > invoking qemu with the WWPN number?
> > > > > > > > >
> > > > > > > > > Unfortunately no, but vhost-scsi doesn't have many knobs
> > (unlike
> > > > > > > > > iSCSI for example) so it's quite simple.  Here is an example:
> > > > > > > > >
> > > > > > > > > cd /sys/kernel/config/target
> > > > > > > > > mkdir -p core/fileio_0/fileio
> > > > > > > > > echo
> > > > > > >
> > 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> > > > > > > > > core/fileio_0/fileio/control
> > > > > > > > > echo 1 > core/fileio_0/fileio/enable
> > > > > > > > > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> > > > > > > > > cd vhost/naa.600140554cf3a18e/tpgt_0
> > > > > > > > > ln -sf ../../../../../core/fileio_0/fileio/
> > lun/lun_0/virtual_scsi_port
> > > > > > > > > echo naa.60014053226f0388 > nexus
> > > > > > > > >
> > > > > > > > > The "nexus" value is the initiator WWN.
> > naa.600140554cf3a18e is
> > > > > the
> > > > > > > > > target WWN that you have to pass to "-device vhost-scsi-pci".
> > > > > > > > >
> > > > > > > > > Paolo
> > > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Asias
> > > > >
> > > > > --
> > > > > Asias
> > >
> > > --
> > > Asias
> > 
> > --
> > Asias
Asias He July 5, 2013, 6:52 a.m. UTC | #24
[CCing Vadim and Yan]

On Thu, Jul 04, 2013 at 07:00:49AM +0000, Libaiqing wrote:
> Hi asias,
>     1 Window can not boot from vhost-scsi device;
>     2 A non-bootable vhost-scsi device can not be driven by windows guest.(I used the driver virtio-win-0.1-59 version.)
>     
>     Do you have any plan about these?

I can reproduce this issue on win2003 (Linux guest works fine). The guest
hangs in the boot process. OS is on virito-blk disk, vhost-scsi is
attached as the second disk.

Guest probes from target 0 to 255. Only target 1 is available.
vhost-scsi sends VIRTIO_SCSI_S_BAD_TARGET back to target 0 and 255 except
tareget 1. Howerver, from the log we can see, guest is sending to target
0 again and hangs afterwards.

Vadim and Yan, any ideas?

[ 3109.954237] br0: port 2(tap0) entered disabled state
[ 3109.954387] device tap0 left promiscuous mode
[ 3109.954389] br0: port 2(tap0) entered disabled state
[ 3119.534136] device tap0 entered promiscuous mode
[ 3119.534169] br0: port 2(tap0) entered forwarding state
[ 3119.534180] br0: port 2(tap0) entered forwarding state
[ 3120.138334] vhost_scsi_ctl_handle_kick: The handling func for control queue.
[ 3120.138666] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.138669] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
[ 3120.138671] target=0, tpg=          (null)
[ 3120.138672] send bad target head=0, out=1
[ 3120.138673] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.139219] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.139221] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
[ 3120.139223] target=1, tpg=ffff88021f8fc800
[ 3120.139225] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 36, data_direction: 2
[ 3120.139226] vhost_scsi got command opcode: 0x12, lun: 0
[ 3120.139228] vhost_scsi_map_iov_to_sgl sg ffff8802242bde60 sgl_count 1 is_err 0
[ 3120.139229] Mapping 1 iovecs for 1 pages
[ 3120.139233] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.139261] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
[ 3120.139470] vhost_get_vq_desc: head: 0, out: 1 in: 1
[ 3120.139472] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006bd9, len: 51
[ 3120.139474] target=1, tpg=ffff88021f8fc800
[ 3120.139475] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 0, data_direction: 3
[ 3120.139476] vhost_scsi got command opcode: 0x0, lun: 0
[ 3120.139480] vhost_get_vq_desc: head: 128, out: 1 in: 1
[ 3120.139487] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
[ 3120.139554] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.139557] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
[ 3120.139558] target=1, tpg=ffff88021f8fc800
[ 3120.139560] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 8, data_direction: 2
[ 3120.139561] vhost_scsi got command opcode: 0x25, lun: 0
[ 3120.139563] vhost_scsi_map_iov_to_sgl sg ffff8802242bde60 sgl_count 1 is_err 0
[ 3120.139564] Mapping 1 iovecs for 1 pages
[ 3120.139568] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.139575] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
[ 3120.139783] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.139785] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
[ 3120.139787] target=2, tpg=          (null)
[ 3120.139788] send bad target head=0, out=1
[ 3120.139789] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.139938] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.139940] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51

...

[ 3120.170209] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.170304] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.170305] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
[ 3120.170306] target=255, tpg=          (null)
[ 3120.170306] send bad target head=0, out=1
[ 3120.170307] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.474648] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.474652] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f280efe85, len: 51
[ 3120.474654] target=1, tpg=ffff88021f8fc800
[ 3120.474656] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 512, data_direction: 2
[ 3120.474658] vhost_scsi got command opcode: 0x28, lun: 0
[ 3120.474660] vhost_scsi_map_iov_to_sgl sg ffff880208f70d40 sgl_count 2 is_err 0
[ 3120.474662] Mapping 1 iovecs for 2 pages
[ 3120.474666] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.474680] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
[ 3120.532843] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.532845] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f280efe85, len: 51
[ 3120.532847] target=1, tpg=ffff88021f8fc800
[ 3120.532848] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 512, data_direction: 2
[ 3120.532850] vhost_scsi got command opcode: 0x28, lun: 0
[ 3120.532852] vhost_scsi_map_iov_to_sgl sg ffff8802242bde60 sgl_count 1 is_err 0
[ 3120.532853] Mapping 1 iovecs for 1 pages
[ 3120.532857] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.532863] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
[ 3120.532889] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.532891] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f280efe85, len: 51
[ 3120.532892] target=1, tpg=ffff88021f8fc800
[ 3120.532894] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 512, data_direction: 2
[ 3120.532895] vhost_scsi got command opcode: 0x28, lun: 0
[ 3120.532897] vhost_scsi_map_iov_to_sgl sg ffff8802242bde60 sgl_count 1 is_err 0
[ 3120.532898] Mapping 1 iovecs for 1 pages
[ 3120.532901] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.532906] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
[ 3123.852940] vhost_scsi_ctl_handle_kick: The handling func for control queue.
[ 3123.853694] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3123.853696] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f2e6c53ac, len: 51
[ 3123.853697] target=0, tpg=          (null)
[ 3123.853698] send bad target head=0, out=1
[ 3123.853700] vhost_get_vq_desc: head: 128, out: 1 in: 2

> Thanks,
> Baiqing.
> > -----Original Message-----
> > From: Asias He [mailto:asias@redhat.com]
> > Sent: Wednesday, July 03, 2013 4:09 PM
> > To: Libaiqing
> > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> > tcm_vhost Linux kernel module
> > 
> > On Wed, Jul 03, 2013 at 11:23:26AM +0800, Asias He wrote:
> > > On Fri, Jun 21, 2013 at 10:16:48AM +0000, Libaiqing wrote:
> > > > Hi Asias,
> > > >
> > > > > -----Original Message-----
> > > > > From: Asias He [mailto:asias@redhat.com]
> > > > > Sent: Thursday, June 20, 2013 5:39 PM
> > > > > To: Libaiqing
> > > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > supporting the
> > > > > tcm_vhost Linux kernel module
> > > > >
> > > > > On Thu, Jun 20, 2013 at 08:49:50AM +0000, Libaiqing wrote:
> > > > > > Hi Asias,
> > > > > >     Thanks for your config.
> > > > > >     According to you config,I test booting from vhost device with
> > > > > upstream kernel and qemu,but failed.
> > > > > >
> > > > > >     1 installing guest from cdrom,ok.
> > > > > >     2 booting vhost-scsi,guest fs error occurs.
> > > > > >     3 using fileio backstores,the error is same..
> > > > > >     4 rebooting guest,a log printed:
> > > > > >      (qemu) hw/scsi/virtio-scsi.c:533:virtio_scsi_handle_event:
> > Object
> > > > > 0x7fccae7f2c88 is not an instance of type virtio-scsi-device
> > > > >
> > > > > Paolo, I remember you fixed a similar issue?
> > > > >
> > > > > >     5 using upstream seabios,core dumped.
> > > > > >
> > > > > >     Could you give me some advise to debug this problem ? I can
> > provide
> > > > > more information if need.
> > > > >
> > > > > Can you show me qemu commit id you used? Can you verity that if
> > using the
> > > > > host kernel for guest helps? Does booting directly (without the install
> > > > > and reboot process) work?
> > > > Qemu commit id is "commit
> > 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427".
> > > >
> > > > Guest kernel updateing is useless.
> > > >
> > > > Booting directly doesn't work too.
> > >
> > >
> > > Hello Libaiqing,
> > >
> > > Sorry for the delay. I will try to reproduce it myself.
> > 
> > I tried 1.5.1 and qemu.git/master and your particular commit
> > 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427.
> > 
> > All work well for me. I used 3.10.0-rc6 as both and guest kernel.
> > 
> > >
> > > >
> > > > > > The qemu cmd:
> > > > > > [root@fedora121 x86_64-softmmu]# ./qemu-system-x86_64
> > -enable-kvm
> > > > > -name fedora   -M pc -m 1024 -smp 2   -drive
> > > > > file=/home/fedora18.iso,if=ide,media=cdrom -device
> > > > > vhost-scsi-pci,wwpn=naa.50014057133e25dc  -monitor stdio   -vga
> > qxl
> > > > > -vnc :1
> > > > > >
> > > > > > The vnc output:
> > > > > > Dracut-initqueue[189]:/dev/mapper/fedora-root:UNEXPECTED
> > > > > INCONSISTENCY;RUN FSCK MANUALLY.
> > > > > > Dracut-initqueue[189]: Warning: e2fsck returned with 4
> > > > > > Dracut-initqueue[189]: Warning: ***An error occurred during the file
> > > > > system check.
> > > > > >
> > > > > > The guest kernel log:
> > > > > > Kernel: virtio-pci 0000:00:04.0: irq 40 for MSI/MSI-X
> > > > > > Kernel: virtio-pci 0000:00:04.0: irq 41 for MSI/MSI-X
> > > > > > Kernel: virtio-pci 0000:00:04.0: irq 42 for MSI/MSI-X
> > > > > > Kernel: virtio-pci 0000:00:04.0: irq 43 for MSI/MSI-X
> > > > > > Kernel: scsi2 : Virtio SCSI HBA
> > > > > > Kernel: scsi 2:0:1:0: Direct-Access LIO-ORG r0
> > > > > > Kernel: sd 2:0:1:0: Attached scsi generic sg1 type 0
> > > > > > Kernel: sd 2:0:1:0: [sda]1258912 512-byte logical .....
> > > > > > Kernel: sd 2:0:1:0: [sda]write protect is off
> > > > > > Kernel: sd 2:0:1:0: [sda]Mode sense :43 00 00 08
> > > > > > Kernel: sd 2:0:1:0: [sda]write cache: disabled, read .....
> > > > > > Kernel: sda sda1 sda2
> > > > > > Kernel: sd 2:0:1:0: [sda] Attached SCSI disk
> > > > > > Dracut-initqueue[189]: Scanning devices sda2 for LVM
> > > > > > Dracut-initqueue[189]: inactive '/dev/fedora/swap'...
> > > > > > Dracut-initqueue[189]: inactive '/dev/fedora/root'...
> > > > > >
> > > > > > The info of host:
> > > > > > [root@fedora121 x86_64-softmmu]# uname -a
> > > > > > Linux fedora121 3.10.0-rc6 #1 SMP Wed Jun 19 19:34:24 CST 2013
> > x86_64
> > > > > x86_64 x86_64 GNU/Linux
> > > > > > [root@fedora121 x86_64-softmmu]# lsmod |grep vhost_scsi
> > > > > > vhost_scsi             49456  5
> > > > > > target_core_mod       282163  14
> > > > >
> > target_core_iblock,target_core_pscsi,iscsi_target_mod,target_core_file,vh
> > > > > ost_scsi
> > > > > > [root@fedora121 x86_64-softmmu]# targetcli
> > > > > > targetcli shell version v2.1.fb26
> > > > > > Copyright 2011 by RisingTide Systems LLC and others.
> > > > > > For help on commands, type 'help'.
> > > > > >
> > > > > > /> ls
> > > > > > o-
> > > > >
> > / ..............................................................................................................
> > > > > ........... [...]
> > > > > >   o-
> > > > >
> > backstores ...............................................................................................
> > > > > ............... [...]
> > > > > >   | o-
> > > > >
> > block ..................................................................................................
> > > > > [Storage Objects: 0]
> > > > > >   | o-
> > > > >
> > fileio .................................................................................................
> > > > > [Storage Objects: 0]
> > > > > >   | o-
> > > > >
> > pscsi ..................................................................................................
> > > > > [Storage Objects: 0]
> > > > > >   | o-
> > > > >
> > ramdisk ................................................................................................
> > > > > [Storage Objects: 1]
> > > > > >   |   o-
> > > > > r0 ...................................................................................................
> > > > > [(6.0GiB) activated]
> > > > > >   o-
> > > > >
> > iscsi .........................................................................................................
> > > > > ... [Targets: 0]
> > > > > >   o-
> > > > >
> > loopback ..................................................................................................
> > > > > ....... [Targets: 0]
> > > > > >   o-
> > > > >
> > vhost .......................................................................................................
> > > > > ..... [Targets: 1]
> > > > > >     o-
> > > > >
> > naa.50014057133e25dc ............................................................................
> > > > > .................. [TPGs: 1]
> > > > > >       o-
> > > > > tpg1 ...............................................................................................
> > > > > [naa.5001405a70ac3421]
> > > > > >         o-
> > > > >
> > acls .........................................................................................................
> > .
> > > > > [ACLs: 0]
> > > > > >         o-
> > > > >
> > luns .........................................................................................................
> > .
> > > > > [LUNs: 1]
> > > > > >           o-
> > > > >
> > lun0 .....................................................................................................
> > > > > [ramdisk/r0]
> > > > > >
> > > > > > Regards,
> > > > > > baiqing
> > > > > > > -----Original Message-----
> > > > > > > From: Asias He [mailto:asias@redhat.com]
> > > > > > > Sent: Thursday, June 20, 2013 9:34 AM
> > > > > > > To: Libaiqing
> > > > > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > supporting
> > > > > the
> > > > > > > tcm_vhost Linux kernel module
> > > > > > >
> > > > > > > On Wed, Jun 19, 2013 at 12:55:10PM +0000, Libaiqing wrote:
> > > > > > > > Hi paolo,
> > > > > > > >   The vhost-scsi device can be used as boot device?
> > > > > > > >   I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
> > > > > > > >   Could you give me some advise to debug this problem ? I can
> > > > > provide
> > > > > > > more information if need.
> > > > > > >
> > > > > > > Boot from vhost-scsi is supposed to work. The seabios you used
> > should
> > > > > be
> > > > > > > fine which contains the fixes for vhost-scsi.
> > > > > > >
> > > > > > > Instead of playing with the /sys/kernel/config/target directly, I
> > really
> > > > > > > recommend using targetcli utils.
> > > > > > >
> > > > > > > Nab, I think we really should write some docs for people to use
> > > > > > > vhost-scsi.
> > > > > > >
> > > > > > > This is how I install and use targetcli in RHEL6. Note you need
> > upstream
> > > > > > > kernel and qemu bits for vhost-scsi.
> > > > > > >
> > > > > > > # yum groupinstall  'Development tools'
> > > > > > > # yum install python-devel epydoc python-simpleparse
> > > > > > >
> > > > > > > # git clone git://github.com/agrover/rtslib-fb.git
> > > > > > > # git clone git://github.com/agrover/targetcli-fb.git
> > > > > > > # git clone git://github.com/agrover/configshell-fb.git
> > > > > > > # for i in rtslib-fb configshell-fb targetcli-fb; do
> > > > > > >   	make -C $i rpm
> > > > > > >   	yum localinstall $i/dist/*.noarch.rpm
> > > > > > >   done
> > > > > > >
> > > > > > > In targetcli, create a backstore and vhost wwpn, e.g.
> > > > > > > # targetcli
> > > > > > > /> /backstores/ramdisk create r0 1g
> > > > > > > /> /vhost create
> > > > > > > /> cd /vhost/naa.500140527cb6616b/tpg1/luns
> > > > > > > /> create /backstores/ramdisk/r0
> > > > > > >
> > > > > > > # qemu -device vhost-scsi-pci,wwpn=naa.500140527cb6616b ...
> > > > > > >
> > > > > > > Hope this helps.
> > > > > > >
> > > > > > > > Regards,
> > > > > > > > baiqing
> > > > > > > >
> > > > > > > > > -----Original Message-----
> > > > > > > > > From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
> > > > > > > > >
> > [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org]
> > > > > On
> > > > > > > > > Behalf Of Paolo Bonzini
> > > > > > > > > Sent: Tuesday, May 28, 2013 4:01 PM
> > > > > > > > > To: Wenchao Xia
> > > > > > > > > Cc: asias@redhat.com; qemu-devel@nongnu.org;
> > > > > nab@linux-iscsi.org;
> > > > > > > > > Michael S. Tsirkin
> > > > > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > > > > supporting
> > > > > > > the
> > > > > > > > > tcm_vhost Linux kernel module
> > > > > > > > >
> > > > > > > > > Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> > > > > > > > > >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > > > > > > > > >> >
> > > > > > > > > >> > The WWPN specified in configfs is passed to "-device
> > > > > > > vhost-scsi-pci".
> > > > > > > > > >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now,
> > so it is
> > > > > not
> > > > > > > > > >> > available from the QEMU command-line.  Instead, I
> > hardcode it
> > > > > to
> > > > > > > > > zero.
> > > > > > > > > >> >
> > > > > > > > > > Hi, Paolo
> > > > > > > > > >   Any document about how to config it correctly in configfs,
> > > > > before
> > > > > > > > > > invoking qemu with the WWPN number?
> > > > > > > > >
> > > > > > > > > Unfortunately no, but vhost-scsi doesn't have many knobs
> > (unlike
> > > > > > > > > iSCSI for example) so it's quite simple.  Here is an example:
> > > > > > > > >
> > > > > > > > > cd /sys/kernel/config/target
> > > > > > > > > mkdir -p core/fileio_0/fileio
> > > > > > > > > echo
> > > > > > >
> > 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> > > > > > > > > core/fileio_0/fileio/control
> > > > > > > > > echo 1 > core/fileio_0/fileio/enable
> > > > > > > > > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> > > > > > > > > cd vhost/naa.600140554cf3a18e/tpgt_0
> > > > > > > > > ln -sf ../../../../../core/fileio_0/fileio/
> > lun/lun_0/virtual_scsi_port
> > > > > > > > > echo naa.60014053226f0388 > nexus
> > > > > > > > >
> > > > > > > > > The "nexus" value is the initiator WWN.
> > naa.600140554cf3a18e is
> > > > > the
> > > > > > > > > target WWN that you have to pass to "-device vhost-scsi-pci".
> > > > > > > > >
> > > > > > > > > Paolo
> > > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Asias
> > > > >
> > > > > --
> > > > > Asias
> > >
> > > --
> > > Asias
> > 
> > --
> > Asias
Vadim Rozenfeld July 5, 2013, 11:17 a.m. UTC | #25
Hi Asias,

Windows driver should be able to support as many logical units and targets
as reported by QEMU. In case of VIRTIO_SCSI_S_BAD_TARGET it will just propagate
the relevant SRB error code to the port driver.
In any case, I will try reproducing this problem on my system. 

Best,
Vadim.

----- Original Message -----
From: "Asias He" <asias@redhat.com>
To: "Libaiqing" <libaiqing@huawei.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>, "Wenchao Xia" <xiawenc@linux.vnet.ibm.com>, qemu-devel@nongnu.org, nab@linux-iscsi.org, "Michael S. Tsirkin" <mst@redhat.com>, "Haofeng" <haofeng@huawei.com>, "Vadim Rozenfeld" <vrozenfe@redhat.com>, "Yan Vugenfirer" <yvugenfi@redhat.com>
Sent: Friday, July 5, 2013 4:52:05 PM
Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the tcm_vhost Linux kernel module

[CCing Vadim and Yan]

On Thu, Jul 04, 2013 at 07:00:49AM +0000, Libaiqing wrote:
> Hi asias,
>     1 Window can not boot from vhost-scsi device;
>     2 A non-bootable vhost-scsi device can not be driven by windows guest.(I used the driver virtio-win-0.1-59 version.)
>     
>     Do you have any plan about these?

I can reproduce this issue on win2003 (Linux guest works fine). The guest
hangs in the boot process. OS is on virito-blk disk, vhost-scsi is
attached as the second disk.

Guest probes from target 0 to 255. Only target 1 is available.
vhost-scsi sends VIRTIO_SCSI_S_BAD_TARGET back to target 0 and 255 except
tareget 1. Howerver, from the log we can see, guest is sending to target
0 again and hangs afterwards.

Vadim and Yan, any ideas?

[ 3109.954237] br0: port 2(tap0) entered disabled state
[ 3109.954387] device tap0 left promiscuous mode
[ 3109.954389] br0: port 2(tap0) entered disabled state
[ 3119.534136] device tap0 entered promiscuous mode
[ 3119.534169] br0: port 2(tap0) entered forwarding state
[ 3119.534180] br0: port 2(tap0) entered forwarding state
[ 3120.138334] vhost_scsi_ctl_handle_kick: The handling func for control queue.
[ 3120.138666] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.138669] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
[ 3120.138671] target=0, tpg=          (null)
[ 3120.138672] send bad target head=0, out=1
[ 3120.138673] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.139219] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.139221] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
[ 3120.139223] target=1, tpg=ffff88021f8fc800
[ 3120.139225] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 36, data_direction: 2
[ 3120.139226] vhost_scsi got command opcode: 0x12, lun: 0
[ 3120.139228] vhost_scsi_map_iov_to_sgl sg ffff8802242bde60 sgl_count 1 is_err 0
[ 3120.139229] Mapping 1 iovecs for 1 pages
[ 3120.139233] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.139261] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
[ 3120.139470] vhost_get_vq_desc: head: 0, out: 1 in: 1
[ 3120.139472] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006bd9, len: 51
[ 3120.139474] target=1, tpg=ffff88021f8fc800
[ 3120.139475] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 0, data_direction: 3
[ 3120.139476] vhost_scsi got command opcode: 0x0, lun: 0
[ 3120.139480] vhost_get_vq_desc: head: 128, out: 1 in: 1
[ 3120.139487] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
[ 3120.139554] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.139557] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
[ 3120.139558] target=1, tpg=ffff88021f8fc800
[ 3120.139560] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 8, data_direction: 2
[ 3120.139561] vhost_scsi got command opcode: 0x25, lun: 0
[ 3120.139563] vhost_scsi_map_iov_to_sgl sg ffff8802242bde60 sgl_count 1 is_err 0
[ 3120.139564] Mapping 1 iovecs for 1 pages
[ 3120.139568] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.139575] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
[ 3120.139783] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.139785] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
[ 3120.139787] target=2, tpg=          (null)
[ 3120.139788] send bad target head=0, out=1
[ 3120.139789] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.139938] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.139940] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51

...

[ 3120.170209] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.170304] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.170305] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
[ 3120.170306] target=255, tpg=          (null)
[ 3120.170306] send bad target head=0, out=1
[ 3120.170307] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.474648] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.474652] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f280efe85, len: 51
[ 3120.474654] target=1, tpg=ffff88021f8fc800
[ 3120.474656] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 512, data_direction: 2
[ 3120.474658] vhost_scsi got command opcode: 0x28, lun: 0
[ 3120.474660] vhost_scsi_map_iov_to_sgl sg ffff880208f70d40 sgl_count 2 is_err 0
[ 3120.474662] Mapping 1 iovecs for 2 pages
[ 3120.474666] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.474680] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
[ 3120.532843] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.532845] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f280efe85, len: 51
[ 3120.532847] target=1, tpg=ffff88021f8fc800
[ 3120.532848] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 512, data_direction: 2
[ 3120.532850] vhost_scsi got command opcode: 0x28, lun: 0
[ 3120.532852] vhost_scsi_map_iov_to_sgl sg ffff8802242bde60 sgl_count 1 is_err 0
[ 3120.532853] Mapping 1 iovecs for 1 pages
[ 3120.532857] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.532863] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
[ 3120.532889] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3120.532891] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f280efe85, len: 51
[ 3120.532892] target=1, tpg=ffff88021f8fc800
[ 3120.532894] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 512, data_direction: 2
[ 3120.532895] vhost_scsi got command opcode: 0x28, lun: 0
[ 3120.532897] vhost_scsi_map_iov_to_sgl sg ffff8802242bde60 sgl_count 1 is_err 0
[ 3120.532898] Mapping 1 iovecs for 1 pages
[ 3120.532901] vhost_get_vq_desc: head: 128, out: 1 in: 2
[ 3120.532906] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
[ 3123.852940] vhost_scsi_ctl_handle_kick: The handling func for control queue.
[ 3123.853694] vhost_get_vq_desc: head: 0, out: 1 in: 2
[ 3123.853696] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f2e6c53ac, len: 51
[ 3123.853697] target=0, tpg=          (null)
[ 3123.853698] send bad target head=0, out=1
[ 3123.853700] vhost_get_vq_desc: head: 128, out: 1 in: 2

> Thanks,
> Baiqing.
> > -----Original Message-----
> > From: Asias He [mailto:asias@redhat.com]
> > Sent: Wednesday, July 03, 2013 4:09 PM
> > To: Libaiqing
> > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> > tcm_vhost Linux kernel module
> > 
> > On Wed, Jul 03, 2013 at 11:23:26AM +0800, Asias He wrote:
> > > On Fri, Jun 21, 2013 at 10:16:48AM +0000, Libaiqing wrote:
> > > > Hi Asias,
> > > >
> > > > > -----Original Message-----
> > > > > From: Asias He [mailto:asias@redhat.com]
> > > > > Sent: Thursday, June 20, 2013 5:39 PM
> > > > > To: Libaiqing
> > > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > supporting the
> > > > > tcm_vhost Linux kernel module
> > > > >
> > > > > On Thu, Jun 20, 2013 at 08:49:50AM +0000, Libaiqing wrote:
> > > > > > Hi Asias,
> > > > > >     Thanks for your config.
> > > > > >     According to you config,I test booting from vhost device with
> > > > > upstream kernel and qemu,but failed.
> > > > > >
> > > > > >     1 installing guest from cdrom,ok.
> > > > > >     2 booting vhost-scsi,guest fs error occurs.
> > > > > >     3 using fileio backstores,the error is same..
> > > > > >     4 rebooting guest,a log printed:
> > > > > >      (qemu) hw/scsi/virtio-scsi.c:533:virtio_scsi_handle_event:
> > Object
> > > > > 0x7fccae7f2c88 is not an instance of type virtio-scsi-device
> > > > >
> > > > > Paolo, I remember you fixed a similar issue?
> > > > >
> > > > > >     5 using upstream seabios,core dumped.
> > > > > >
> > > > > >     Could you give me some advise to debug this problem ? I can
> > provide
> > > > > more information if need.
> > > > >
> > > > > Can you show me qemu commit id you used? Can you verity that if
> > using the
> > > > > host kernel for guest helps? Does booting directly (without the install
> > > > > and reboot process) work?
> > > > Qemu commit id is "commit
> > 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427".
> > > >
> > > > Guest kernel updateing is useless.
> > > >
> > > > Booting directly doesn't work too.
> > >
> > >
> > > Hello Libaiqing,
> > >
> > > Sorry for the delay. I will try to reproduce it myself.
> > 
> > I tried 1.5.1 and qemu.git/master and your particular commit
> > 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427.
> > 
> > All work well for me. I used 3.10.0-rc6 as both and guest kernel.
> > 
> > >
> > > >
> > > > > > The qemu cmd:
> > > > > > [root@fedora121 x86_64-softmmu]# ./qemu-system-x86_64
> > -enable-kvm
> > > > > -name fedora   -M pc -m 1024 -smp 2   -drive
> > > > > file=/home/fedora18.iso,if=ide,media=cdrom -device
> > > > > vhost-scsi-pci,wwpn=naa.50014057133e25dc  -monitor stdio   -vga
> > qxl
> > > > > -vnc :1
> > > > > >
> > > > > > The vnc output:
> > > > > > Dracut-initqueue[189]:/dev/mapper/fedora-root:UNEXPECTED
> > > > > INCONSISTENCY;RUN FSCK MANUALLY.
> > > > > > Dracut-initqueue[189]: Warning: e2fsck returned with 4
> > > > > > Dracut-initqueue[189]: Warning: ***An error occurred during the file
> > > > > system check.
> > > > > >
> > > > > > The guest kernel log:
> > > > > > Kernel: virtio-pci 0000:00:04.0: irq 40 for MSI/MSI-X
> > > > > > Kernel: virtio-pci 0000:00:04.0: irq 41 for MSI/MSI-X
> > > > > > Kernel: virtio-pci 0000:00:04.0: irq 42 for MSI/MSI-X
> > > > > > Kernel: virtio-pci 0000:00:04.0: irq 43 for MSI/MSI-X
> > > > > > Kernel: scsi2 : Virtio SCSI HBA
> > > > > > Kernel: scsi 2:0:1:0: Direct-Access LIO-ORG r0
> > > > > > Kernel: sd 2:0:1:0: Attached scsi generic sg1 type 0
> > > > > > Kernel: sd 2:0:1:0: [sda]1258912 512-byte logical .....
> > > > > > Kernel: sd 2:0:1:0: [sda]write protect is off
> > > > > > Kernel: sd 2:0:1:0: [sda]Mode sense :43 00 00 08
> > > > > > Kernel: sd 2:0:1:0: [sda]write cache: disabled, read .....
> > > > > > Kernel: sda sda1 sda2
> > > > > > Kernel: sd 2:0:1:0: [sda] Attached SCSI disk
> > > > > > Dracut-initqueue[189]: Scanning devices sda2 for LVM
> > > > > > Dracut-initqueue[189]: inactive '/dev/fedora/swap'...
> > > > > > Dracut-initqueue[189]: inactive '/dev/fedora/root'...
> > > > > >
> > > > > > The info of host:
> > > > > > [root@fedora121 x86_64-softmmu]# uname -a
> > > > > > Linux fedora121 3.10.0-rc6 #1 SMP Wed Jun 19 19:34:24 CST 2013
> > x86_64
> > > > > x86_64 x86_64 GNU/Linux
> > > > > > [root@fedora121 x86_64-softmmu]# lsmod |grep vhost_scsi
> > > > > > vhost_scsi             49456  5
> > > > > > target_core_mod       282163  14
> > > > >
> > target_core_iblock,target_core_pscsi,iscsi_target_mod,target_core_file,vh
> > > > > ost_scsi
> > > > > > [root@fedora121 x86_64-softmmu]# targetcli
> > > > > > targetcli shell version v2.1.fb26
> > > > > > Copyright 2011 by RisingTide Systems LLC and others.
> > > > > > For help on commands, type 'help'.
> > > > > >
> > > > > > /> ls
> > > > > > o-
> > > > >
> > / ..............................................................................................................
> > > > > ........... [...]
> > > > > >   o-
> > > > >
> > backstores ...............................................................................................
> > > > > ............... [...]
> > > > > >   | o-
> > > > >
> > block ..................................................................................................
> > > > > [Storage Objects: 0]
> > > > > >   | o-
> > > > >
> > fileio .................................................................................................
> > > > > [Storage Objects: 0]
> > > > > >   | o-
> > > > >
> > pscsi ..................................................................................................
> > > > > [Storage Objects: 0]
> > > > > >   | o-
> > > > >
> > ramdisk ................................................................................................
> > > > > [Storage Objects: 1]
> > > > > >   |   o-
> > > > > r0 ...................................................................................................
> > > > > [(6.0GiB) activated]
> > > > > >   o-
> > > > >
> > iscsi .........................................................................................................
> > > > > ... [Targets: 0]
> > > > > >   o-
> > > > >
> > loopback ..................................................................................................
> > > > > ....... [Targets: 0]
> > > > > >   o-
> > > > >
> > vhost .......................................................................................................
> > > > > ..... [Targets: 1]
> > > > > >     o-
> > > > >
> > naa.50014057133e25dc ............................................................................
> > > > > .................. [TPGs: 1]
> > > > > >       o-
> > > > > tpg1 ...............................................................................................
> > > > > [naa.5001405a70ac3421]
> > > > > >         o-
> > > > >
> > acls .........................................................................................................
> > .
> > > > > [ACLs: 0]
> > > > > >         o-
> > > > >
> > luns .........................................................................................................
> > .
> > > > > [LUNs: 1]
> > > > > >           o-
> > > > >
> > lun0 .....................................................................................................
> > > > > [ramdisk/r0]
> > > > > >
> > > > > > Regards,
> > > > > > baiqing
> > > > > > > -----Original Message-----
> > > > > > > From: Asias He [mailto:asias@redhat.com]
> > > > > > > Sent: Thursday, June 20, 2013 9:34 AM
> > > > > > > To: Libaiqing
> > > > > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > supporting
> > > > > the
> > > > > > > tcm_vhost Linux kernel module
> > > > > > >
> > > > > > > On Wed, Jun 19, 2013 at 12:55:10PM +0000, Libaiqing wrote:
> > > > > > > > Hi paolo,
> > > > > > > >   The vhost-scsi device can be used as boot device?
> > > > > > > >   I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
> > > > > > > >   Could you give me some advise to debug this problem ? I can
> > > > > provide
> > > > > > > more information if need.
> > > > > > >
> > > > > > > Boot from vhost-scsi is supposed to work. The seabios you used
> > should
> > > > > be
> > > > > > > fine which contains the fixes for vhost-scsi.
> > > > > > >
> > > > > > > Instead of playing with the /sys/kernel/config/target directly, I
> > really
> > > > > > > recommend using targetcli utils.
> > > > > > >
> > > > > > > Nab, I think we really should write some docs for people to use
> > > > > > > vhost-scsi.
> > > > > > >
> > > > > > > This is how I install and use targetcli in RHEL6. Note you need
> > upstream
> > > > > > > kernel and qemu bits for vhost-scsi.
> > > > > > >
> > > > > > > # yum groupinstall  'Development tools'
> > > > > > > # yum install python-devel epydoc python-simpleparse
> > > > > > >
> > > > > > > # git clone git://github.com/agrover/rtslib-fb.git
> > > > > > > # git clone git://github.com/agrover/targetcli-fb.git
> > > > > > > # git clone git://github.com/agrover/configshell-fb.git
> > > > > > > # for i in rtslib-fb configshell-fb targetcli-fb; do
> > > > > > >   	make -C $i rpm
> > > > > > >   	yum localinstall $i/dist/*.noarch.rpm
> > > > > > >   done
> > > > > > >
> > > > > > > In targetcli, create a backstore and vhost wwpn, e.g.
> > > > > > > # targetcli
> > > > > > > /> /backstores/ramdisk create r0 1g
> > > > > > > /> /vhost create
> > > > > > > /> cd /vhost/naa.500140527cb6616b/tpg1/luns
> > > > > > > /> create /backstores/ramdisk/r0
> > > > > > >
> > > > > > > # qemu -device vhost-scsi-pci,wwpn=naa.500140527cb6616b ...
> > > > > > >
> > > > > > > Hope this helps.
> > > > > > >
> > > > > > > > Regards,
> > > > > > > > baiqing
> > > > > > > >
> > > > > > > > > -----Original Message-----
> > > > > > > > > From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
> > > > > > > > >
> > [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org]
> > > > > On
> > > > > > > > > Behalf Of Paolo Bonzini
> > > > > > > > > Sent: Tuesday, May 28, 2013 4:01 PM
> > > > > > > > > To: Wenchao Xia
> > > > > > > > > Cc: asias@redhat.com; qemu-devel@nongnu.org;
> > > > > nab@linux-iscsi.org;
> > > > > > > > > Michael S. Tsirkin
> > > > > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > > > > supporting
> > > > > > > the
> > > > > > > > > tcm_vhost Linux kernel module
> > > > > > > > >
> > > > > > > > > Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> > > > > > > > > >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > > > > > > > > >> >
> > > > > > > > > >> > The WWPN specified in configfs is passed to "-device
> > > > > > > vhost-scsi-pci".
> > > > > > > > > >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now,
> > so it is
> > > > > not
> > > > > > > > > >> > available from the QEMU command-line.  Instead, I
> > hardcode it
> > > > > to
> > > > > > > > > zero.
> > > > > > > > > >> >
> > > > > > > > > > Hi, Paolo
> > > > > > > > > >   Any document about how to config it correctly in configfs,
> > > > > before
> > > > > > > > > > invoking qemu with the WWPN number?
> > > > > > > > >
> > > > > > > > > Unfortunately no, but vhost-scsi doesn't have many knobs
> > (unlike
> > > > > > > > > iSCSI for example) so it's quite simple.  Here is an example:
> > > > > > > > >
> > > > > > > > > cd /sys/kernel/config/target
> > > > > > > > > mkdir -p core/fileio_0/fileio
> > > > > > > > > echo
> > > > > > >
> > 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> > > > > > > > > core/fileio_0/fileio/control
> > > > > > > > > echo 1 > core/fileio_0/fileio/enable
> > > > > > > > > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> > > > > > > > > cd vhost/naa.600140554cf3a18e/tpgt_0
> > > > > > > > > ln -sf ../../../../../core/fileio_0/fileio/
> > lun/lun_0/virtual_scsi_port
> > > > > > > > > echo naa.60014053226f0388 > nexus
> > > > > > > > >
> > > > > > > > > The "nexus" value is the initiator WWN.
> > naa.600140554cf3a18e is
> > > > > the
> > > > > > > > > target WWN that you have to pass to "-device vhost-scsi-pci".
> > > > > > > > >
> > > > > > > > > Paolo
> > > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Asias
> > > > >
> > > > > --
> > > > > Asias
> > >
> > > --
> > > Asias
> > 
> > --
> > Asias
Libaiqing July 8, 2013, 12:59 a.m. UTC | #26
Hi paolo,
   Sorry for the late reply.
   LVM partition is in guest.So when booting for vhost-scsi,the guest always reports the fs is broken,and enters the emergency mode.
   
   I can provide more information if need.

Thanks
Baiqing.
> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Thursday, July 04, 2013 7:24 PM
> To: Libaiqing
> Cc: Asias He; Wenchao Xia; qemu-devel@nongnu.org; nab@linux-iscsi.org;
> Michael S. Tsirkin; Haofeng
> Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> tcm_vhost Linux kernel module
> 
> Il 03/07/2013 14:33, Libaiqing ha scritto:
> > Hi asias,
> >     I got the rootcause:guest was installed on raw img with lvm
> partition,which vhost does not support.
> 
> You mean LVM in the host or the guest?  I guess in the host, but I'd
> rather make sure because otherwise you've found a bug.
> 
> Paolo
> 
> >     Now vhost-scsi can be used as bootable device.
Asias He July 10, 2013, 1:50 a.m. UTC | #27
On Fri, Jul 05, 2013 at 07:17:59AM -0400, Vadim Rozenfeld wrote:
> Hi Asias,
> 
> Windows driver should be able to support as many logical units and targets
> as reported by QEMU. In case of VIRTIO_SCSI_S_BAD_TARGET it will just propagate
> the relevant SRB error code to the port driver.
> In any case, I will try reproducing this problem on my system. 

Thanks, let me know if you have issue to setup the vhost-scsi
environment. In the other mail of this thread, I wrote a howto to setup
up vhost-scsi in RHEL6.

> Best,
> Vadim.
> 
> ----- Original Message -----
> From: "Asias He" <asias@redhat.com>
> To: "Libaiqing" <libaiqing@huawei.com>
> Cc: "Paolo Bonzini" <pbonzini@redhat.com>, "Wenchao Xia" <xiawenc@linux.vnet.ibm.com>, qemu-devel@nongnu.org, nab@linux-iscsi.org, "Michael S. Tsirkin" <mst@redhat.com>, "Haofeng" <haofeng@huawei.com>, "Vadim Rozenfeld" <vrozenfe@redhat.com>, "Yan Vugenfirer" <yvugenfi@redhat.com>
> Sent: Friday, July 5, 2013 4:52:05 PM
> Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the tcm_vhost Linux kernel module
> 
> [CCing Vadim and Yan]
> 
> On Thu, Jul 04, 2013 at 07:00:49AM +0000, Libaiqing wrote:
> > Hi asias,
> >     1 Window can not boot from vhost-scsi device;
> >     2 A non-bootable vhost-scsi device can not be driven by windows guest.(I used the driver virtio-win-0.1-59 version.)
> >     
> >     Do you have any plan about these?
> 
> I can reproduce this issue on win2003 (Linux guest works fine). The guest
> hangs in the boot process. OS is on virito-blk disk, vhost-scsi is
> attached as the second disk.
> 
> Guest probes from target 0 to 255. Only target 1 is available.
> vhost-scsi sends VIRTIO_SCSI_S_BAD_TARGET back to target 0 and 255 except
> tareget 1. Howerver, from the log we can see, guest is sending to target
> 0 again and hangs afterwards.
> 
> Vadim and Yan, any ideas?
> 
> [ 3109.954237] br0: port 2(tap0) entered disabled state
> [ 3109.954387] device tap0 left promiscuous mode
> [ 3109.954389] br0: port 2(tap0) entered disabled state
> [ 3119.534136] device tap0 entered promiscuous mode
> [ 3119.534169] br0: port 2(tap0) entered forwarding state
> [ 3119.534180] br0: port 2(tap0) entered forwarding state
> [ 3120.138334] vhost_scsi_ctl_handle_kick: The handling func for control queue.
> [ 3120.138666] vhost_get_vq_desc: head: 0, out: 1 in: 2
> [ 3120.138669] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
> [ 3120.138671] target=0, tpg=          (null)
> [ 3120.138672] send bad target head=0, out=1
> [ 3120.138673] vhost_get_vq_desc: head: 128, out: 1 in: 2
> [ 3120.139219] vhost_get_vq_desc: head: 0, out: 1 in: 2
> [ 3120.139221] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
> [ 3120.139223] target=1, tpg=ffff88021f8fc800
> [ 3120.139225] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 36, data_direction: 2
> [ 3120.139226] vhost_scsi got command opcode: 0x12, lun: 0
> [ 3120.139228] vhost_scsi_map_iov_to_sgl sg ffff8802242bde60 sgl_count 1 is_err 0
> [ 3120.139229] Mapping 1 iovecs for 1 pages
> [ 3120.139233] vhost_get_vq_desc: head: 128, out: 1 in: 2
> [ 3120.139261] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
> [ 3120.139470] vhost_get_vq_desc: head: 0, out: 1 in: 1
> [ 3120.139472] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006bd9, len: 51
> [ 3120.139474] target=1, tpg=ffff88021f8fc800
> [ 3120.139475] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 0, data_direction: 3
> [ 3120.139476] vhost_scsi got command opcode: 0x0, lun: 0
> [ 3120.139480] vhost_get_vq_desc: head: 128, out: 1 in: 1
> [ 3120.139487] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
> [ 3120.139554] vhost_get_vq_desc: head: 0, out: 1 in: 2
> [ 3120.139557] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
> [ 3120.139558] target=1, tpg=ffff88021f8fc800
> [ 3120.139560] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 8, data_direction: 2
> [ 3120.139561] vhost_scsi got command opcode: 0x25, lun: 0
> [ 3120.139563] vhost_scsi_map_iov_to_sgl sg ffff8802242bde60 sgl_count 1 is_err 0
> [ 3120.139564] Mapping 1 iovecs for 1 pages
> [ 3120.139568] vhost_get_vq_desc: head: 128, out: 1 in: 2
> [ 3120.139575] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
> [ 3120.139783] vhost_get_vq_desc: head: 0, out: 1 in: 2
> [ 3120.139785] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
> [ 3120.139787] target=2, tpg=          (null)
> [ 3120.139788] send bad target head=0, out=1
> [ 3120.139789] vhost_get_vq_desc: head: 128, out: 1 in: 2
> [ 3120.139938] vhost_get_vq_desc: head: 0, out: 1 in: 2
> [ 3120.139940] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
> 
> ...
> 
> [ 3120.170209] vhost_get_vq_desc: head: 128, out: 1 in: 2
> [ 3120.170304] vhost_get_vq_desc: head: 0, out: 1 in: 2
> [ 3120.170305] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f28006c15, len: 51
> [ 3120.170306] target=255, tpg=          (null)
> [ 3120.170306] send bad target head=0, out=1
> [ 3120.170307] vhost_get_vq_desc: head: 128, out: 1 in: 2
> [ 3120.474648] vhost_get_vq_desc: head: 0, out: 1 in: 2
> [ 3120.474652] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f280efe85, len: 51
> [ 3120.474654] target=1, tpg=ffff88021f8fc800
> [ 3120.474656] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 512, data_direction: 2
> [ 3120.474658] vhost_scsi got command opcode: 0x28, lun: 0
> [ 3120.474660] vhost_scsi_map_iov_to_sgl sg ffff880208f70d40 sgl_count 2 is_err 0
> [ 3120.474662] Mapping 1 iovecs for 2 pages
> [ 3120.474666] vhost_get_vq_desc: head: 128, out: 1 in: 2
> [ 3120.474680] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
> [ 3120.532843] vhost_get_vq_desc: head: 0, out: 1 in: 2
> [ 3120.532845] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f280efe85, len: 51
> [ 3120.532847] target=1, tpg=ffff88021f8fc800
> [ 3120.532848] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 512, data_direction: 2
> [ 3120.532850] vhost_scsi got command opcode: 0x28, lun: 0
> [ 3120.532852] vhost_scsi_map_iov_to_sgl sg ffff8802242bde60 sgl_count 1 is_err 0
> [ 3120.532853] Mapping 1 iovecs for 1 pages
> [ 3120.532857] vhost_get_vq_desc: head: 128, out: 1 in: 2
> [ 3120.532863] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
> [ 3120.532889] vhost_get_vq_desc: head: 0, out: 1 in: 2
> [ 3120.532891] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f280efe85, len: 51
> [ 3120.532892] target=1, tpg=ffff88021f8fc800
> [ 3120.532894] Allocated tv_cmd: ffff880223cbf800 exp_data_len: 512, data_direction: 2
> [ 3120.532895] vhost_scsi got command opcode: 0x28, lun: 0
> [ 3120.532897] vhost_scsi_map_iov_to_sgl sg ffff8802242bde60 sgl_count 1 is_err 0
> [ 3120.532898] Mapping 1 iovecs for 1 pages
> [ 3120.532901] vhost_get_vq_desc: head: 128, out: 1 in: 2
> [ 3120.532906] vhost_scsi_complete_cmd_work tv_cmd ffff880223cbf800 resid 0 status 0x0
> [ 3123.852940] vhost_scsi_ctl_handle_kick: The handling func for control queue.
> [ 3123.853694] vhost_get_vq_desc: head: 0, out: 1 in: 2
> [ 3123.853696] Calling __copy_from_user: vq->iov[0].iov_base: 00007f8f2e6c53ac, len: 51
> [ 3123.853697] target=0, tpg=          (null)
> [ 3123.853698] send bad target head=0, out=1
> [ 3123.853700] vhost_get_vq_desc: head: 128, out: 1 in: 2
> 
> > Thanks,
> > Baiqing.
> > > -----Original Message-----
> > > From: Asias He [mailto:asias@redhat.com]
> > > Sent: Wednesday, July 03, 2013 4:09 PM
> > > To: Libaiqing
> > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device supporting the
> > > tcm_vhost Linux kernel module
> > > 
> > > On Wed, Jul 03, 2013 at 11:23:26AM +0800, Asias He wrote:
> > > > On Fri, Jun 21, 2013 at 10:16:48AM +0000, Libaiqing wrote:
> > > > > Hi Asias,
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Asias He [mailto:asias@redhat.com]
> > > > > > Sent: Thursday, June 20, 2013 5:39 PM
> > > > > > To: Libaiqing
> > > > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > > supporting the
> > > > > > tcm_vhost Linux kernel module
> > > > > >
> > > > > > On Thu, Jun 20, 2013 at 08:49:50AM +0000, Libaiqing wrote:
> > > > > > > Hi Asias,
> > > > > > >     Thanks for your config.
> > > > > > >     According to you config,I test booting from vhost device with
> > > > > > upstream kernel and qemu,but failed.
> > > > > > >
> > > > > > >     1 installing guest from cdrom,ok.
> > > > > > >     2 booting vhost-scsi,guest fs error occurs.
> > > > > > >     3 using fileio backstores,the error is same..
> > > > > > >     4 rebooting guest,a log printed:
> > > > > > >      (qemu) hw/scsi/virtio-scsi.c:533:virtio_scsi_handle_event:
> > > Object
> > > > > > 0x7fccae7f2c88 is not an instance of type virtio-scsi-device
> > > > > >
> > > > > > Paolo, I remember you fixed a similar issue?
> > > > > >
> > > > > > >     5 using upstream seabios,core dumped.
> > > > > > >
> > > > > > >     Could you give me some advise to debug this problem ? I can
> > > provide
> > > > > > more information if need.
> > > > > >
> > > > > > Can you show me qemu commit id you used? Can you verity that if
> > > using the
> > > > > > host kernel for guest helps? Does booting directly (without the install
> > > > > > and reboot process) work?
> > > > > Qemu commit id is "commit
> > > 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427".
> > > > >
> > > > > Guest kernel updateing is useless.
> > > > >
> > > > > Booting directly doesn't work too.
> > > >
> > > >
> > > > Hello Libaiqing,
> > > >
> > > > Sorry for the delay. I will try to reproduce it myself.
> > > 
> > > I tried 1.5.1 and qemu.git/master and your particular commit
> > > 4eda32f588086b6cd0ec2be6a7a6c131f8c2b427.
> > > 
> > > All work well for me. I used 3.10.0-rc6 as both and guest kernel.
> > > 
> > > >
> > > > >
> > > > > > > The qemu cmd:
> > > > > > > [root@fedora121 x86_64-softmmu]# ./qemu-system-x86_64
> > > -enable-kvm
> > > > > > -name fedora   -M pc -m 1024 -smp 2   -drive
> > > > > > file=/home/fedora18.iso,if=ide,media=cdrom -device
> > > > > > vhost-scsi-pci,wwpn=naa.50014057133e25dc  -monitor stdio   -vga
> > > qxl
> > > > > > -vnc :1
> > > > > > >
> > > > > > > The vnc output:
> > > > > > > Dracut-initqueue[189]:/dev/mapper/fedora-root:UNEXPECTED
> > > > > > INCONSISTENCY;RUN FSCK MANUALLY.
> > > > > > > Dracut-initqueue[189]: Warning: e2fsck returned with 4
> > > > > > > Dracut-initqueue[189]: Warning: ***An error occurred during the file
> > > > > > system check.
> > > > > > >
> > > > > > > The guest kernel log:
> > > > > > > Kernel: virtio-pci 0000:00:04.0: irq 40 for MSI/MSI-X
> > > > > > > Kernel: virtio-pci 0000:00:04.0: irq 41 for MSI/MSI-X
> > > > > > > Kernel: virtio-pci 0000:00:04.0: irq 42 for MSI/MSI-X
> > > > > > > Kernel: virtio-pci 0000:00:04.0: irq 43 for MSI/MSI-X
> > > > > > > Kernel: scsi2 : Virtio SCSI HBA
> > > > > > > Kernel: scsi 2:0:1:0: Direct-Access LIO-ORG r0
> > > > > > > Kernel: sd 2:0:1:0: Attached scsi generic sg1 type 0
> > > > > > > Kernel: sd 2:0:1:0: [sda]1258912 512-byte logical .....
> > > > > > > Kernel: sd 2:0:1:0: [sda]write protect is off
> > > > > > > Kernel: sd 2:0:1:0: [sda]Mode sense :43 00 00 08
> > > > > > > Kernel: sd 2:0:1:0: [sda]write cache: disabled, read .....
> > > > > > > Kernel: sda sda1 sda2
> > > > > > > Kernel: sd 2:0:1:0: [sda] Attached SCSI disk
> > > > > > > Dracut-initqueue[189]: Scanning devices sda2 for LVM
> > > > > > > Dracut-initqueue[189]: inactive '/dev/fedora/swap'...
> > > > > > > Dracut-initqueue[189]: inactive '/dev/fedora/root'...
> > > > > > >
> > > > > > > The info of host:
> > > > > > > [root@fedora121 x86_64-softmmu]# uname -a
> > > > > > > Linux fedora121 3.10.0-rc6 #1 SMP Wed Jun 19 19:34:24 CST 2013
> > > x86_64
> > > > > > x86_64 x86_64 GNU/Linux
> > > > > > > [root@fedora121 x86_64-softmmu]# lsmod |grep vhost_scsi
> > > > > > > vhost_scsi             49456  5
> > > > > > > target_core_mod       282163  14
> > > > > >
> > > target_core_iblock,target_core_pscsi,iscsi_target_mod,target_core_file,vh
> > > > > > ost_scsi
> > > > > > > [root@fedora121 x86_64-softmmu]# targetcli
> > > > > > > targetcli shell version v2.1.fb26
> > > > > > > Copyright 2011 by RisingTide Systems LLC and others.
> > > > > > > For help on commands, type 'help'.
> > > > > > >
> > > > > > > /> ls
> > > > > > > o-
> > > > > >
> > > / ..............................................................................................................
> > > > > > ........... [...]
> > > > > > >   o-
> > > > > >
> > > backstores ...............................................................................................
> > > > > > ............... [...]
> > > > > > >   | o-
> > > > > >
> > > block ..................................................................................................
> > > > > > [Storage Objects: 0]
> > > > > > >   | o-
> > > > > >
> > > fileio .................................................................................................
> > > > > > [Storage Objects: 0]
> > > > > > >   | o-
> > > > > >
> > > pscsi ..................................................................................................
> > > > > > [Storage Objects: 0]
> > > > > > >   | o-
> > > > > >
> > > ramdisk ................................................................................................
> > > > > > [Storage Objects: 1]
> > > > > > >   |   o-
> > > > > > r0 ...................................................................................................
> > > > > > [(6.0GiB) activated]
> > > > > > >   o-
> > > > > >
> > > iscsi .........................................................................................................
> > > > > > ... [Targets: 0]
> > > > > > >   o-
> > > > > >
> > > loopback ..................................................................................................
> > > > > > ....... [Targets: 0]
> > > > > > >   o-
> > > > > >
> > > vhost .......................................................................................................
> > > > > > ..... [Targets: 1]
> > > > > > >     o-
> > > > > >
> > > naa.50014057133e25dc ............................................................................
> > > > > > .................. [TPGs: 1]
> > > > > > >       o-
> > > > > > tpg1 ...............................................................................................
> > > > > > [naa.5001405a70ac3421]
> > > > > > >         o-
> > > > > >
> > > acls .........................................................................................................
> > > .
> > > > > > [ACLs: 0]
> > > > > > >         o-
> > > > > >
> > > luns .........................................................................................................
> > > .
> > > > > > [LUNs: 1]
> > > > > > >           o-
> > > > > >
> > > lun0 .....................................................................................................
> > > > > > [ramdisk/r0]
> > > > > > >
> > > > > > > Regards,
> > > > > > > baiqing
> > > > > > > > -----Original Message-----
> > > > > > > > From: Asias He [mailto:asias@redhat.com]
> > > > > > > > Sent: Thursday, June 20, 2013 9:34 AM
> > > > > > > > To: Libaiqing
> > > > > > > > Cc: Paolo Bonzini; Wenchao Xia; qemu-devel@nongnu.org;
> > > > > > > > nab@linux-iscsi.org; Michael S. Tsirkin; Haofeng
> > > > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > > supporting
> > > > > > the
> > > > > > > > tcm_vhost Linux kernel module
> > > > > > > >
> > > > > > > > On Wed, Jun 19, 2013 at 12:55:10PM +0000, Libaiqing wrote:
> > > > > > > > > Hi paolo,
> > > > > > > > >   The vhost-scsi device can be used as boot device?
> > > > > > > > >   I tested with your config + 3.10 rc6 + seabios 1.7.2.2,but failed.
> > > > > > > > >   Could you give me some advise to debug this problem ? I can
> > > > > > provide
> > > > > > > > more information if need.
> > > > > > > >
> > > > > > > > Boot from vhost-scsi is supposed to work. The seabios you used
> > > should
> > > > > > be
> > > > > > > > fine which contains the fixes for vhost-scsi.
> > > > > > > >
> > > > > > > > Instead of playing with the /sys/kernel/config/target directly, I
> > > really
> > > > > > > > recommend using targetcli utils.
> > > > > > > >
> > > > > > > > Nab, I think we really should write some docs for people to use
> > > > > > > > vhost-scsi.
> > > > > > > >
> > > > > > > > This is how I install and use targetcli in RHEL6. Note you need
> > > upstream
> > > > > > > > kernel and qemu bits for vhost-scsi.
> > > > > > > >
> > > > > > > > # yum groupinstall  'Development tools'
> > > > > > > > # yum install python-devel epydoc python-simpleparse
> > > > > > > >
> > > > > > > > # git clone git://github.com/agrover/rtslib-fb.git
> > > > > > > > # git clone git://github.com/agrover/targetcli-fb.git
> > > > > > > > # git clone git://github.com/agrover/configshell-fb.git
> > > > > > > > # for i in rtslib-fb configshell-fb targetcli-fb; do
> > > > > > > >   	make -C $i rpm
> > > > > > > >   	yum localinstall $i/dist/*.noarch.rpm
> > > > > > > >   done
> > > > > > > >
> > > > > > > > In targetcli, create a backstore and vhost wwpn, e.g.
> > > > > > > > # targetcli
> > > > > > > > /> /backstores/ramdisk create r0 1g
> > > > > > > > /> /vhost create
> > > > > > > > /> cd /vhost/naa.500140527cb6616b/tpg1/luns
> > > > > > > > /> create /backstores/ramdisk/r0
> > > > > > > >
> > > > > > > > # qemu -device vhost-scsi-pci,wwpn=naa.500140527cb6616b ...
> > > > > > > >
> > > > > > > > Hope this helps.
> > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > baiqing
> > > > > > > > >
> > > > > > > > > > -----Original Message-----
> > > > > > > > > > From: qemu-devel-bounces+libaiqing=huawei.com@nongnu.org
> > > > > > > > > >
> > > [mailto:qemu-devel-bounces+libaiqing=huawei.com@nongnu.org]
> > > > > > On
> > > > > > > > > > Behalf Of Paolo Bonzini
> > > > > > > > > > Sent: Tuesday, May 28, 2013 4:01 PM
> > > > > > > > > > To: Wenchao Xia
> > > > > > > > > > Cc: asias@redhat.com; qemu-devel@nongnu.org;
> > > > > > nab@linux-iscsi.org;
> > > > > > > > > > Michael S. Tsirkin
> > > > > > > > > > Subject: Re: [Qemu-devel] [PATCH 6/9] vhost-scsi: new device
> > > > > > supporting
> > > > > > > > the
> > > > > > > > > > tcm_vhost Linux kernel module
> > > > > > > > > >
> > > > > > > > > > Il 28/05/2013 09:13, Wenchao Xia ha scritto:
> > > > > > > > > > >> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > > > > > > > > > >> >
> > > > > > > > > > >> > The WWPN specified in configfs is passed to "-device
> > > > > > > > vhost-scsi-pci".
> > > > > > > > > > >> > The tgpt field of the SET_ENDPOINT ioctl is obsolete now,
> > > so it is
> > > > > > not
> > > > > > > > > > >> > available from the QEMU command-line.  Instead, I
> > > hardcode it
> > > > > > to
> > > > > > > > > > zero.
> > > > > > > > > > >> >
> > > > > > > > > > > Hi, Paolo
> > > > > > > > > > >   Any document about how to config it correctly in configfs,
> > > > > > before
> > > > > > > > > > > invoking qemu with the WWPN number?
> > > > > > > > > >
> > > > > > > > > > Unfortunately no, but vhost-scsi doesn't have many knobs
> > > (unlike
> > > > > > > > > > iSCSI for example) so it's quite simple.  Here is an example:
> > > > > > > > > >
> > > > > > > > > > cd /sys/kernel/config/target
> > > > > > > > > > mkdir -p core/fileio_0/fileio
> > > > > > > > > > echo
> > > > > > > >
> > > 'fd_dev_name=/home/pbonzini/test.img,fd_dev_size=5905580032' >
> > > > > > > > > > core/fileio_0/fileio/control
> > > > > > > > > > echo 1 > core/fileio_0/fileio/enable
> > > > > > > > > > mkdir -p vhost/naa.600140554cf3a18e/tpgt_0/lun/lun_0
> > > > > > > > > > cd vhost/naa.600140554cf3a18e/tpgt_0
> > > > > > > > > > ln -sf ../../../../../core/fileio_0/fileio/
> > > lun/lun_0/virtual_scsi_port
> > > > > > > > > > echo naa.60014053226f0388 > nexus
> > > > > > > > > >
> > > > > > > > > > The "nexus" value is the initiator WWN.
> > > naa.600140554cf3a18e is
> > > > > > the
> > > > > > > > > > target WWN that you have to pass to "-device vhost-scsi-pci".
> > > > > > > > > >
> > > > > > > > > > Paolo
> > > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Asias
> > > > > >
> > > > > > --
> > > > > > Asias
> > > >
> > > > --
> > > > Asias
> > > 
> > > --
> > > Asias
> 
> -- 
> Asias
diff mbox

Patch

diff --git a/configure b/configure
index ed49f91..51a6c56 100755
--- a/configure
+++ b/configure
@@ -179,6 +179,7 @@  libattr=""
 xfs=""
 
 vhost_net="no"
+vhost_scsi="no"
 kvm="no"
 gprof="no"
 debug_tcg="no"
@@ -543,6 +544,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
@@ -870,6 +872,10 @@  for opt do
   ;;
   --enable-vhost-net) vhost_net="yes"
   ;;
+  --disable-vhost-scsi) vhost_scsi="no"
+  ;;
+  --enable-vhost-scsi) vhost_scsi="yes"
+  ;;
   --disable-glx) glx="no"
   ;;
   --enable-glx) glx="yes"
@@ -3553,6 +3559,7 @@  echo "sigev_thread_id   $sigev_thread_id"
 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 ($spice_protocol_version/$spice_server_version)"
@@ -3836,6 +3843,9 @@  fi
 if test "$virtfs" = "yes" ; then
   echo "CONFIG_VIRTFS=y" >> $config_host_mak
 fi
+if test "$vhost_scsi" = "yes" ; then
+  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
+fi
 if test "$blobs" = "yes" ; then
   echo "INSTALL_BLOBS=yes" >> $config_host_mak
 fi
diff --git a/hw/scsi/Makefile.objs b/hw/scsi/Makefile.objs
index eaec6c8..121ddc5 100644
--- a/hw/scsi/Makefile.objs
+++ b/hw/scsi/Makefile.objs
@@ -6,4 +6,8 @@  common-obj-$(CONFIG_VMW_PVSCSI_SCSI_PCI) += vmw_pvscsi.o
 common-obj-$(CONFIG_ESP) += esp.o
 common-obj-$(CONFIG_ESP_PCI) += esp-pci.o
 obj-$(CONFIG_PSERIES) += spapr_vscsi.o
-obj-$(CONFIG_VIRTIO) += virtio-scsi.o
+
+ifeq ($(CONFIG_VIRTIO),y)
+obj-y += virtio-scsi.o
+obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o
+endif
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
new file mode 100644
index 0000000..3dd1a0f
--- /dev/null
+++ b/hw/scsi/vhost-scsi.c
@@ -0,0 +1,288 @@ 
+/*
+ * vhost_scsi host device
+ *
+ * Copyright IBM, Corp. 2011
+ *
+ * Authors:
+ *  Stefan Hajnoczi   <stefanha@linux.vnet.ibm.com>
+ *
+ * Changes for QEMU mainline + tcm_vhost kernel upstream:
+ *  Nicholas Bellinger <nab@risingtidesystems.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+
+#include <sys/ioctl.h>
+#include "config.h"
+#include "qemu/queue.h"
+#include "monitor/monitor.h"
+#include "migration/migration.h"
+#include "hw/virtio/vhost-scsi.h"
+#include "hw/virtio/vhost.h"
+#include "hw/virtio/virtio-scsi.h"
+
+static int vhost_scsi_set_endpoint(VHostSCSI *s)
+{
+    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
+    struct vhost_scsi_target backend;
+    int ret;
+
+    memset(&backend, 0, sizeof(backend));
+    pstrcpy(backend.vhost_wwpn, sizeof(backend.vhost_wwpn), vs->conf.wwpn);
+    ret = ioctl(s->dev.control, VHOST_SCSI_SET_ENDPOINT, &backend);
+    if (ret < 0) {
+        return -errno;
+    }
+    return 0;
+}
+
+static void vhost_scsi_clear_endpoint(VHostSCSI *s)
+{
+    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
+    struct vhost_scsi_target backend;
+
+    memset(&backend, 0, sizeof(backend));
+    pstrcpy(backend.vhost_wwpn, sizeof(backend.vhost_wwpn), vs->conf.wwpn);
+    ioctl(s->dev.control, VHOST_SCSI_CLEAR_ENDPOINT, &backend);
+}
+
+static int vhost_scsi_start(VHostSCSI *s)
+{
+    int ret, abi_version, i;
+    VirtIODevice *vdev = VIRTIO_DEVICE(s);
+
+    if (!vdev->binding->set_guest_notifiers) {
+        error_report("binding does not support guest notifiers");
+        return -ENOSYS;
+    }
+
+    ret = ioctl(s->dev.control, VHOST_SCSI_GET_ABI_VERSION, &abi_version);
+    if (ret < 0) {
+        return -errno;
+    }
+    if (abi_version > VHOST_SCSI_ABI_VERSION) {
+        error_report("vhost-scsi: The running tcm_vhost kernel abi_version:"
+                     " %d is greater than vhost_scsi userspace supports: %d, please"
+                     " upgrade your version of QEMU\n", abi_version,
+                     VHOST_SCSI_ABI_VERSION);
+        return -ENOSYS;
+    }
+
+    ret = vhost_dev_enable_notifiers(&s->dev, vdev);
+    if (ret < 0) {
+        return ret;
+    }
+
+    s->dev.acked_features = vdev->guest_features;
+    ret = vhost_dev_start(&s->dev, vdev);
+    if (ret < 0) {
+        error_report("Error start vhost dev");
+        goto err_notifiers;
+    }
+
+    ret = vhost_scsi_set_endpoint(s);
+    if (ret < 0) {
+        error_report("Error set vhost-scsi endpoint");
+        goto err_vhost_stop;
+    }
+
+    ret = vdev->binding->set_guest_notifiers(vdev->binding_opaque, s->dev.nvqs, true);
+    if (ret < 0) {
+        error_report("Error binding guest notifier");
+        goto err_endpoint;
+    }
+
+    /* guest_notifier_mask/pending not used yet, so just unmask
+     * everything here.  virtio-pci will do the right thing by
+     * enabling/disabling irqfd.
+     */
+    for (i = 0; i < s->dev.nvqs; i++) {
+        vhost_virtqueue_mask(&s->dev, vdev, i, false);
+    }
+
+    return ret;
+
+err_endpoint:
+    vhost_scsi_clear_endpoint(s);
+err_vhost_stop:
+    vhost_dev_stop(&s->dev, vdev);
+err_notifiers:
+    vhost_dev_disable_notifiers(&s->dev, vdev);
+    return ret;
+}
+
+static void vhost_scsi_stop(VHostSCSI *s)
+{
+    VirtIODevice *vdev = VIRTIO_DEVICE(s);
+    int ret = 0;
+
+    if (!vdev->binding->set_guest_notifiers) {
+        ret = vdev->binding->set_guest_notifiers(vdev->binding_opaque,
+                                                 s->dev.nvqs, false);
+        if (ret < 0) {
+                error_report("vhost guest notifier cleanup failed: %d\n", ret);
+        }
+    }
+    assert(ret >= 0);
+
+    vhost_scsi_clear_endpoint(s);
+    vhost_dev_stop(&s->dev, vdev);
+    vhost_dev_disable_notifiers(&s->dev, vdev);
+}
+
+static uint32_t vhost_scsi_get_features(VirtIODevice *vdev,
+                                        uint32_t features)
+{
+    VHostSCSI *s = VHOST_SCSI(vdev);
+
+    /* Clear features not supported by host kernel. */
+    if (!(s->dev.features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY))) {
+        features &= ~(1 << VIRTIO_F_NOTIFY_ON_EMPTY);
+    }
+    if (!(s->dev.features & (1 << VIRTIO_RING_F_INDIRECT_DESC))) {
+        features &= ~(1 << VIRTIO_RING_F_INDIRECT_DESC);
+    }
+    if (!(s->dev.features & (1 << VIRTIO_RING_F_EVENT_IDX))) {
+        features &= ~(1 << VIRTIO_RING_F_EVENT_IDX);
+    }
+    if (!(s->dev.features & (1 << VIRTIO_SCSI_F_HOTPLUG))) {
+        features &= ~(1 << VIRTIO_SCSI_F_HOTPLUG);
+    }
+
+    return features;
+}
+
+static void vhost_scsi_set_config(VirtIODevice *vdev,
+                                  const uint8_t *config)
+{
+    VirtIOSCSIConfig *scsiconf = (VirtIOSCSIConfig *)config;
+    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
+
+    if ((uint32_t) ldl_raw(&scsiconf->sense_size) != vs->sense_size ||
+        (uint32_t) ldl_raw(&scsiconf->cdb_size) != vs->cdb_size) {
+        error_report("vhost-scsi does not support changing the sense data and CDB sizes");
+        exit(1);
+    }
+}
+
+static void vhost_scsi_set_status(VirtIODevice *vdev, uint8_t val)
+{
+    VHostSCSI *s = (VHostSCSI *)vdev;
+    bool start = (val & VIRTIO_CONFIG_S_DRIVER_OK);
+
+    if (s->dev.started == start) {
+        return;
+    }
+
+    if (start) {
+        int ret;
+
+        ret = vhost_scsi_start(s);
+        if (ret < 0) {
+            error_report("virtio-scsi: unable to start vhost: %s\n",
+                         strerror(-ret));
+
+            /* There is no userspace virtio-scsi fallback so exit */
+            exit(1);
+        }
+    } else {
+        vhost_scsi_stop(s);
+    }
+}
+
+static int vhost_scsi_init(VirtIODevice *vdev)
+{
+    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
+    VHostSCSI *s = VHOST_SCSI(vdev);
+    int vhostfd = -1;
+    int ret;
+
+    if (!vs->conf.wwpn) {
+        error_report("vhost-scsi: missing wwpn\n");
+        return -EINVAL;
+    }
+
+    if (vs->conf.vhostfd) {
+        vhostfd = monitor_handle_fd_param(cur_mon, vs->conf.vhostfd);
+        if (vhostfd == -1) {
+            error_report("vhost-scsi: unable to parse vhostfd\n");
+            return -EINVAL;
+        }
+    }
+
+    ret = virtio_scsi_common_init(vs);
+    if (ret < 0) {
+        return ret;
+    }
+
+    vdev->get_features = vhost_scsi_get_features;
+    vdev->set_config = vhost_scsi_set_config;
+    vdev->set_status = vhost_scsi_set_status;
+
+    s->dev.nvqs = VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues;
+    s->dev.vqs = g_new(struct vhost_virtqueue, s->dev.nvqs);
+    s->dev.vq_index = 0;
+
+    ret = vhost_dev_init(&s->dev, vhostfd, "/dev/vhost-scsi", true);
+    if (ret < 0) {
+        error_report("vhost-scsi: vhost initialization failed: %s\n",
+                strerror(-ret));
+        return ret;
+    }
+    s->dev.backend_features = 0;
+
+    error_setg(&s->migration_blocker,
+            "vhost-scsi does not support migration");
+    migrate_add_blocker(s->migration_blocker);
+
+    return 0;
+}
+
+static int vhost_scsi_exit(DeviceState *qdev)
+{
+    VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
+    VHostSCSI *s = VHOST_SCSI(qdev);
+    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(qdev);
+
+    migrate_del_blocker(s->migration_blocker);
+    error_free(s->migration_blocker);
+
+    /* This will stop vhost backend. */
+    vhost_scsi_set_status(vdev, 0);
+
+    g_free(s->dev.vqs);
+    return virtio_scsi_common_exit(vs);
+}
+
+static Property vhost_scsi_properties[] = {
+    DEFINE_VHOST_SCSI_PROPERTIES(VHostSCSI, parent_obj.conf),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void vhost_scsi_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
+    dc->exit = vhost_scsi_exit;
+    dc->props = vhost_scsi_properties;
+    vdc->init = vhost_scsi_init;
+    vdc->get_features = vhost_scsi_get_features;
+    vdc->set_config = vhost_scsi_set_config;
+    vdc->set_status = vhost_scsi_set_status;
+}
+
+static const TypeInfo vhost_scsi_info = {
+    .name = TYPE_VHOST_SCSI,
+    .parent = TYPE_VIRTIO_SCSI_COMMON,
+    .instance_size = sizeof(VHostSCSI),
+    .class_init = vhost_scsi_class_init,
+};
+
+static void virtio_register_types(void)
+{
+    type_register_static(&vhost_scsi_info);
+}
+
+type_init(virtio_register_types)
diff --git a/include/hw/virtio/vhost-scsi.h b/include/hw/virtio/vhost-scsi.h
new file mode 100644
index 0000000..85cc031
--- /dev/null
+++ b/include/hw/virtio/vhost-scsi.h
@@ -0,0 +1,73 @@ 
+/*
+ * vhost_scsi host device
+ *
+ * Copyright IBM, Corp. 2011
+ *
+ * Authors:
+ *  Stefan Hajnoczi   <stefanha@linux.vnet.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+
+#ifndef VHOST_SCSI_H
+#define VHOST_SCSI_H
+
+#include "qemu-common.h"
+#include "hw/qdev.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/vhost.h"
+
+/*
+ * Used by QEMU userspace to ensure a consistent vhost-scsi ABI.
+ *
+ * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate +
+ *            RFC-v2 vhost-scsi userspace.  Add GET_ABI_VERSION ioctl usage
+ * ABI Rev 1: January 2013. Ignore vhost_tpgt filed in struct vhost_scsi_target.
+ * 	      All the targets under vhost_wwpn can be seen and used by guest.
+ */
+
+#define VHOST_SCSI_ABI_VERSION 1
+
+/* TODO #include <linux/vhost.h> properly */
+/* For VHOST_SCSI_SET_ENDPOINT/VHOST_SCSI_CLEAR_ENDPOINT ioctl */
+struct vhost_scsi_target {
+    int abi_version;
+    char vhost_wwpn[224];
+    unsigned short vhost_tpgt;
+    unsigned short reserved;
+};
+
+enum vhost_scsi_vq_list {
+    VHOST_SCSI_VQ_CONTROL = 0,
+    VHOST_SCSI_VQ_EVENT = 1,
+    VHOST_SCSI_VQ_NUM_FIXED = 2,
+};
+
+#define VHOST_VIRTIO 0xAF
+#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target)
+#define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
+#define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int)
+
+#define TYPE_VHOST_SCSI "vhost-scsi"
+#define VHOST_SCSI(obj) \
+        OBJECT_CHECK(VHostSCSI, (obj), TYPE_VHOST_SCSI)
+
+typedef struct VHostSCSI {
+    VirtIOSCSICommon parent_obj;
+
+    Error *migration_blocker;
+
+    struct vhost_dev dev;
+} VHostSCSI;
+
+#define DEFINE_VHOST_SCSI_PROPERTIES(_state, _conf_field) \
+    DEFINE_PROP_STRING("vhostfd", _state, _conf_field.vhostfd), \
+    DEFINE_PROP_STRING("wwpn", _state, _conf_field.wwpn), \
+    DEFINE_PROP_UINT32("num_queues", _state, _conf_field.num_queues, 1), \
+    DEFINE_PROP_UINT32("max_sectors", _state, _conf_field.max_sectors, 0xFFFF), \
+    DEFINE_PROP_UINT32("cmd_per_lun", _state, _conf_field.cmd_per_lun, 128)
+
+
+#endif
diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
index 4a961b9..4db346b 100644
--- a/include/hw/virtio/virtio-scsi.h
+++ b/include/hw/virtio/virtio-scsi.h
@@ -151,6 +151,8 @@  struct VirtIOSCSIConf {
     uint32_t num_queues;
     uint32_t max_sectors;
     uint32_t cmd_per_lun;
+    char *vhostfd;
+    char *wwpn;
 };
 
 typedef struct VirtIOSCSICommon {