From patchwork Tue Jul 24 01:26:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 1229871 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 8C1F5DFFB5 for ; Tue, 24 Jul 2012 01:29:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755102Ab2GXB3Y (ORCPT ); Mon, 23 Jul 2012 21:29:24 -0400 Received: from mail.linux-iscsi.org ([67.23.28.174]:46254 "EHLO linux-iscsi.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755049Ab2GXB3X (ORCPT ); Mon, 23 Jul 2012 21:29:23 -0400 Received: from linux-iscsi.org (localhost [127.0.0.1]) by linux-iscsi.org (Postfix) with ESMTP id 0190922D9D7; Tue, 24 Jul 2012 01:26:23 +0000 (UTC) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , lf-virt , kvm-devel , qemu-devel , Stefan Hajnoczi , Zhi Yong Wu , Anthony Liguori , Paolo Bonzini , "Michael S. Tsirkin" , Christoph Hellwig , Jens Axboe , Hannes Reinecke , Greg Kroah-Hartman , Nicholas Bellinger , Zhi Yong Wu Subject: [PATCH] tcm_vhost: Expose ABI version via VHOST_SCSI_GET_ABI_VERSION Date: Tue, 24 Jul 2012 01:26:20 +0000 Message-Id: <1343093180-5598-1-git-send-email-nab@linux-iscsi.org> X-Mailer: git-send-email 1.7.2.5 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nicholas Bellinger As requested by Anthony, here is a patch against target-pending/for-next-merge to expose an ABI version to userspace via a new VHOST_SCSI_GET_ABI_VERSION ioctl operation. As mentioned in the comment, ABI Rev 0 is for pre 2012 out-of-tree code, and ABI Rev 1 (the current rev) is for current WIP v3.6 kernel merge candiate code. I think this is what you had in mind, and hopefully it will make MST happy too. The incremental vhost-scsi patches against Zhi's QEMU are going out shortly ahead of cutting a new vhost-scsi RFC over the next days. Please have a look and let me know if you have any concerns here. Thanks! Reported-by: Anthony Liguori Cc: Stefan Hajnoczi Cc: Michael S. Tsirkin Cc: Paolo Bonzini Cc: Zhi Yong Wu Signed-off-by: Nicholas Bellinger --- drivers/vhost/tcm_vhost.c | 9 +++++++++ drivers/vhost/tcm_vhost.h | 11 +++++++++++ 2 files changed, 20 insertions(+), 0 deletions(-) diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c index dc7e024..3f04169 100644 --- a/drivers/vhost/tcm_vhost.c +++ b/drivers/vhost/tcm_vhost.c @@ -977,6 +977,15 @@ static long vhost_scsi_ioctl(struct file *f, unsigned int ioctl, return -EFAULT; return vhost_scsi_clear_endpoint(vs, &backend); + case VHOST_SCSI_GET_ABI_VERSION: + if (copy_from_user(&backend, argp, sizeof backend)) + return -EFAULT; + + backend.abi_version = VHOST_SCSI_ABI_VERSION; + + if (copy_to_user(argp, &backend, sizeof backend)) + return -EFAULT; + return 0; case VHOST_GET_FEATURES: features = VHOST_FEATURES; if (copy_to_user(featurep, &features, sizeof features)) diff --git a/drivers/vhost/tcm_vhost.h b/drivers/vhost/tcm_vhost.h index e942df9..3d5378f 100644 --- a/drivers/vhost/tcm_vhost.h +++ b/drivers/vhost/tcm_vhost.h @@ -80,7 +80,17 @@ struct tcm_vhost_tport { #include +/* + * Used by QEMU userspace to ensure a consistent vhost-scsi ABI. + * + * ABI Rev 0: All pre 2012 revisions used by prototype out-of-tree code + * ABI Rev 1: 2012 version for v3.6 kernel merge candiate + */ + +#define VHOST_SCSI_ABI_VERSION 1 + struct vhost_scsi_target { + int abi_version; unsigned char vhost_wwpn[TRANSPORT_IQN_LEN]; unsigned short vhost_tpgt; }; @@ -88,3 +98,4 @@ struct vhost_scsi_target { /* VHOST_SCSI specific defines */ #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, struct vhost_scsi_target)