@@ -68,6 +68,23 @@ int vhost_scsi_start(VHostSCSI *vs, VirtIODevice *vdev)
return ret;
}
+ memset(&backend, 0, sizeof(backend));
+ ret = ioctl(vs->dev.control, VHOST_SCSI_GET_ABI_VERSION, &backend);
+ if (ret < 0) {
+ ret = -errno;
+ vhost_dev_stop(&vs->dev, vdev);
+ return ret;
+ }
+ if (backend.abi_version > VHOST_SCSI_ABI_VERSION) {
+ fprintf(stderr, "The running tcm_vhost kernel abi_version: %d is greater"
+ " than vhost_scsi userspace supports: %d\n", backend.abi_version,
+ VHOST_SCSI_ABI_VERSION);
+ ret = -ENOSYS;
+ vhost_dev_stop(&vs->dev, vdev);
+ return ret;
+ }
+ printf("Using TCM_Vhost ABI version: %d\n", backend.abi_version);
+
pstrcpy((char *)backend.vhost_wwpn, sizeof(backend.vhost_wwpn), vs->wwpn);
backend.vhost_tpgt = vs->tpgt;
ret = ioctl(vs->dev.control, VHOST_SCSI_SET_ENDPOINT, &backend);
@@ -17,9 +17,19 @@
#include "qemu-common.h"
#include "qemu-option.h"
+/*
+ * 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
+
/* TODO #include <linux/vhost.h> properly */
/* For VHOST_SCSI_SET_ENDPOINT/VHOST_SCSI_CLEAR_ENDPOINT ioctl */
struct vhost_scsi_target {
+ int abi_version;
unsigned char vhost_wwpn[224];
unsigned short vhost_tpgt;
};
@@ -27,6 +37,7 @@ struct vhost_scsi_target {
#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, struct vhost_scsi_target)
VHostSCSI *find_vhost_scsi(const char *id);
const char *vhost_scsi_get_id(VHostSCSI *vs);