Re: [PATCH] vhost-scsi: introduce an ioctl to get the minimum tpgt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2015/1/26 21:13, Gonglei (Arei) wrote:

> From: Gonglei <arei.gonglei@xxxxxxxxxx>
> 
> In order to support to assign a boot order for
> vhost-scsi device, we should get the tpgt for
> user level (such as Qemu). and at present, we
> only support the minimum tpgt can boot.
> 

Ping...

> Signed-off-by: Gonglei <arei.gonglei@xxxxxxxxxx>
> Signed-off-by: Bo Su <subo7@xxxxxxxxxx>
> ---
>  drivers/vhost/scsi.c       | 41 +++++++++++++++++++++++++++++++++++++++++
>  include/uapi/linux/vhost.h |  2 ++
>  2 files changed, 43 insertions(+)
> 
> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> index d695b16..12e79b9 100644
> --- a/drivers/vhost/scsi.c
> +++ b/drivers/vhost/scsi.c
> @@ -1522,6 +1522,38 @@ err_dev:
>  	return ret;
>  }
>  
> +static int vhost_scsi_get_first_tpgt(
> +		struct vhost_scsi *vs,
> +		struct vhost_scsi_target *t)
> +{
> +	struct tcm_vhost_tpg *tv_tpg;
> +	struct tcm_vhost_tport *tv_tport;
> +	int tpgt = -1;
> +
> +	mutex_lock(&tcm_vhost_mutex);
> +	mutex_lock(&vs->dev.mutex);
> +
> +	list_for_each_entry(tv_tpg, &tcm_vhost_list, tv_tpg_list) {
> +		tv_tport = tv_tpg->tport;
> +
> +		if (!strcmp(tv_tport->tport_name, t->vhost_wwpn)) {
> +			if (tpgt < 0)
> +				tpgt = tv_tpg->tport_tpgt;
> +			else if (tpgt > tv_tpg->tport_tpgt)
> +				tpgt = tv_tpg->tport_tpgt;
> +		}
> +	}
> +
> +	mutex_unlock(&vs->dev.mutex);
> +	mutex_unlock(&tcm_vhost_mutex);
> +
> +	if (tpgt < 0)
> +		return -ENXIO;
> +
> +	t->vhost_tpgt = tpgt;
> +	return 0;
> +}
> +
>  static int vhost_scsi_set_features(struct vhost_scsi *vs, u64 features)
>  {
>  	struct vhost_virtqueue *vq;
> @@ -1657,6 +1689,15 @@ vhost_scsi_ioctl(struct file *f,
>  		if (put_user(events_missed, eventsp))
>  			return -EFAULT;
>  		return 0;
> +	case VHOST_SCSI_GET_TPGT:
> +		if (copy_from_user(&backend, argp, sizeof(backend)))
> +			return -EFAULT;
> +		r = vhost_scsi_get_first_tpgt(vs, &backend);
> +		if (r < 0)
> +			return r;
> +		if (copy_to_user(argp, &backend, sizeof(backend)))
> +			return -EFAULT;
> +		return 0;
>  	case VHOST_GET_FEATURES:
>  		features = VHOST_SCSI_FEATURES;
>  		if (copy_to_user(featurep, &features, sizeof features))
> diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
> index bb6a5b4..5d350f7 100644
> --- a/include/uapi/linux/vhost.h
> +++ b/include/uapi/linux/vhost.h
> @@ -155,4 +155,6 @@ struct vhost_scsi_target {
>  #define VHOST_SCSI_SET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x43, __u32)
>  #define VHOST_SCSI_GET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x44, __u32)
>  
> +#define VHOST_SCSI_GET_TPGT _IOW(VHOST_VIRTIO, 0x45, struct vhost_scsi_target)
> +
>  #endif



_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization




[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux