Fix and simplify the command-line parameter for virtio-scsi. Currently passing a "scsi:xxxx" parameter without the second "tpgt" argument causes kvmtool to segfault. But only the "wwpn" parameter is necessary. The tpgt parameter is ignored and was never used upstream. See linux/vhost_types.h: * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate + * RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl usage * ABI Rev 1: January 2013. Ignore vhost_tpgt field in struct vhost_scsi_target. * All the targets under vhost_wwpn can be seen and used by guset. Signed-off-by: Jean-Philippe Brucker <jean-philippe@xxxxxxxxxx> --- include/kvm/disk-image.h | 7 +------ disk/core.c | 11 ++++------- virtio/scsi.c | 2 +- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/include/kvm/disk-image.h b/include/kvm/disk-image.h index b2123838..bf602b58 100644 --- a/include/kvm/disk-image.h +++ b/include/kvm/disk-image.h @@ -48,12 +48,8 @@ struct disk_image_operations { struct disk_image_params { const char *filename; - /* - * wwpn == World Wide Port Number - * tpgt == Target Portal Group Tag - */ + /* wwpn == World Wide Port Number */ const char *wwpn; - const char *tpgt; bool readonly; bool direct; }; @@ -74,7 +70,6 @@ struct disk_image { u64 aio_inflight; #endif /* CONFIG_HAS_AIO */ const char *wwpn; - const char *tpgt; int debug_iodelay; }; diff --git a/disk/core.c b/disk/core.c index f69095d9..45681024 100644 --- a/disk/core.c +++ b/disk/core.c @@ -25,14 +25,14 @@ int disk_img_name_parser(const struct option *opt, const char *arg, int unset) if (strncmp(arg, "scsi:", 5) == 0) { sep = strstr(arg, ":"); - if (sep) - kvm->cfg.disk_image[kvm->nr_disks].wwpn = sep + 1; + kvm->cfg.disk_image[kvm->nr_disks].wwpn = sep + 1; + + /* Old invocation had two parameter. Ignore second one. */ sep = strstr(sep + 1, ":"); if (sep) { *sep = 0; - kvm->cfg.disk_image[kvm->nr_disks].tpgt = sep + 1; + cur = sep + 1; } - cur = sep + 1; } do { @@ -147,7 +147,6 @@ static struct disk_image **disk_image__open_all(struct kvm *kvm) struct disk_image **disks; const char *filename; const char *wwpn; - const char *tpgt; bool readonly; bool direct; void *err; @@ -169,14 +168,12 @@ static struct disk_image **disk_image__open_all(struct kvm *kvm) readonly = params[i].readonly; direct = params[i].direct; wwpn = params[i].wwpn; - tpgt = params[i].tpgt; if (wwpn) { disks[i] = malloc(sizeof(struct disk_image)); if (!disks[i]) return ERR_PTR(-ENOMEM); disks[i]->wwpn = wwpn; - disks[i]->tpgt = tpgt; continue; } diff --git a/virtio/scsi.c b/virtio/scsi.c index 2bc1ec20..f059fc37 100644 --- a/virtio/scsi.c +++ b/virtio/scsi.c @@ -199,7 +199,7 @@ static int virtio_scsi_init_one(struct kvm *kvm, struct disk_image *disk) .kvm = kvm, }; strlcpy((char *)&sdev->target.vhost_wwpn, disk->wwpn, sizeof(sdev->target.vhost_wwpn)); - sdev->target.vhost_tpgt = strtol(disk->tpgt, NULL, 0); + sdev->target.abi_version = VHOST_SCSI_ABI_VERSION; list_add_tail(&sdev->list, &sdevs); -- 2.40.0