From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDKEN-0000ov-Kd for qemu-devel@nongnu.org; Mon, 19 Jan 2015 16:51:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDKEK-0005Lt-Ez for qemu-devel@nongnu.org; Mon, 19 Jan 2015 16:51:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57771) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDKEK-0005Lj-7F for qemu-devel@nongnu.org; Mon, 19 Jan 2015 16:51:28 -0500 Date: Mon, 19 Jan 2015 23:51:20 +0200 From: "Michael S. Tsirkin" Message-ID: <20150119215120.GA11452@redhat.com> References: <1421673818-11224-1-git-send-email-arei.gonglei@huawei.com> <1421673818-11224-5-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1421673818-11224-5-git-send-email-arei.gonglei@huawei.com> Subject: Re: [Qemu-devel] [PATCH 4/4] vhost-scsi: add an ioctl interface to get target id List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com Cc: pbonzini@redhat.com, weidong.huang@huawei.com, qemu-devel@nongnu.org, subo7@huawei.com, peter.huangpeng@huawei.com On Mon, Jan 19, 2015 at 09:23:38PM +0800, arei.gonglei@huawei.com wrote: > From: Gonglei > > 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 > Signed-off-by: Bo Su 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 >