From: "Michael S. Tsirkin" <mst@redhat.com>
To: arei.gonglei@huawei.com
Cc: pbonzini@redhat.com, weidong.huang@huawei.com,
qemu-devel@nongnu.org, subo7@huawei.com,
peter.huangpeng@huawei.com
Subject: Re: [Qemu-devel] [PATCH 4/4] vhost-scsi: add an ioctl interface to get target id
Date: Mon, 19 Jan 2015 23:51:20 +0200 [thread overview]
Message-ID: <20150119215120.GA11452@redhat.com> (raw)
In-Reply-To: <1421673818-11224-5-git-send-email-arei.gonglei@huawei.com>
On Mon, Jan 19, 2015 at 09:23:38PM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
>
> Because vhost-scsi module do not support VHOST_SCSI_GET_TPGT
> at present, so I use "#if 0" handle it, and set the target
> default to 1. In addition, channel and lun both are 0 for
> bootable vhost-scsi device.
>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> Signed-off-by: Bo Su <subo7@huawei.com>
OK but let's see the kernel patch get accepted first.
> ---
> hw/scsi/vhost-scsi.c | 39 +++++++++++++++++++++++++++++++++++++++
> include/hw/virtio/vhost-scsi.h | 1 +
> 2 files changed, 40 insertions(+)
>
> diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
> index dc9076e..a7cd420 100644
> --- a/hw/scsi/vhost-scsi.c
> +++ b/hw/scsi/vhost-scsi.c
> @@ -201,6 +201,36 @@ static void vhost_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq)
> {
> }
>
> +static int vhost_scsi_get_target_id(VHostSCSI *s, Error **errp)
> +{
> + VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
> + const VhostOps *vhost_ops = s->dev.vhost_ops;
> + struct vhost_scsi_target backend;
> + int ret;
> +
> + memset(&backend, 0, sizeof(backend));
> + pstrcpy(backend.vhost_wwpn, sizeof(backend.vhost_wwpn), vs->conf.wwpn);
> + ret = vhost_ops->vhost_call(&s->dev, VHOST_SCSI_GET_TPGT, &backend);
> + /* Fixme: wait vhost-scsi module supporting VHOST_SCSI_GET_TPGT */
> +#if 0
> + if (ret < 0) {
> + error_setg_errno(errp, -ret,
> + "vhost-scsi: failed to get the target id");
> + return ret;
> + }
> +#elseif
> + if (ret < 0) {
> + error_report("Warning: vhost-scsi failed to get the target id: %s",
> + strerror(-ret));
> + /* set default target to 1 */
> + backend.vhost_tpgt = 1;
> + }
> +#endif
> +
> + s->target = backend.vhost_tpgt;
> + return 0;
> +}
> +
> static void vhost_scsi_realize(DeviceState *dev, Error **errp)
> {
> VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
> @@ -251,6 +281,15 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
> return;
> }
>
> + /* At present, channel and lun both are 0 for bootable vhost-scsi disk */
> + s->channel = 0;
> + s->lun = 0;
> + if (vhost_scsi_get_target_id(s, &err)) {
> + error_propagate(errp, err);
> + close(vhostfd);
> + return;
> + }
> +
> error_setg(&s->migration_blocker,
> "vhost-scsi does not support migration");
> migrate_add_blocker(s->migration_blocker);
> diff --git a/include/hw/virtio/vhost-scsi.h b/include/hw/virtio/vhost-scsi.h
> index c0056c2..a6bd031 100644
> --- a/include/hw/virtio/vhost-scsi.h
> +++ b/include/hw/virtio/vhost-scsi.h
> @@ -49,6 +49,7 @@ enum vhost_scsi_vq_list {
> #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 VHOST_SCSI_GET_TPGT _IOW(VHOST_VIRTIO, 0x45, struct vhost_scsi_target)
>
> #define TYPE_VHOST_SCSI "vhost-scsi"
> #define VHOST_SCSI(obj) \
> --
> 1.7.12.4
>
next prev parent reply other threads:[~2015-01-19 21:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-19 13:23 [Qemu-devel] [PATCH 0/4] vhost-scsi: support to assign boot order arei.gonglei
2015-01-19 13:23 ` [Qemu-devel] [PATCH 1/4] qdev: support to get a device firmware path directly arei.gonglei
2015-01-20 16:10 ` Paolo Bonzini
2015-01-21 2:14 ` Gonglei
2015-01-21 10:52 ` Paolo Bonzini
2015-01-22 1:04 ` Gonglei
2015-01-19 13:23 ` [Qemu-devel] [PATCH 2/4] vhost-scsi: add bootindex property arei.gonglei
2015-01-19 13:23 ` [Qemu-devel] [PATCH 3/4] vhost-scsi: realize the TYPE_FW_PATH_PROVIDER interface arei.gonglei
2015-01-19 13:23 ` [Qemu-devel] [PATCH 4/4] vhost-scsi: add an ioctl interface to get target id arei.gonglei
2015-01-19 21:51 ` Michael S. Tsirkin [this message]
2015-01-26 8:00 ` Gonglei
2015-01-26 9:32 ` Paolo Bonzini
2015-01-26 12:13 ` Gonglei
2015-01-26 12:16 ` Paolo Bonzini
2015-01-26 12:23 ` Gonglei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150119215120.GA11452@redhat.com \
--to=mst@redhat.com \
--cc=arei.gonglei@huawei.com \
--cc=pbonzini@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=subo7@huawei.com \
--cc=weidong.huang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.