Skip to content

Commit b82526c

Browse files
Li Fengbonzini
Li Feng
authored andcommitted
vhost-scsi: support inflight io track
Qemu will send GET_INFLIGHT_FD and SET_INFLIGH_FD to backend, and the backend setup the inflight memory to track the io. Change-Id: I805d6189996f7a1b44c65f0b12ef7473b1789510 Signed-off-by: Li Feng <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent ffb716f commit b82526c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

hw/scsi/vhost-scsi-common.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ int vhost_scsi_common_start(VHostSCSICommon *vsc)
3232
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
3333
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
3434

35+
VirtIOSCSICommon *vs = (VirtIOSCSICommon *)vsc;
36+
3537
if (!k->set_guest_notifiers) {
3638
error_report("binding does not support guest notifiers");
3739
return -ENOSYS;
@@ -49,6 +51,23 @@ int vhost_scsi_common_start(VHostSCSICommon *vsc)
4951
}
5052

5153
vsc->dev.acked_features = vdev->guest_features;
54+
55+
assert(vsc->inflight == NULL);
56+
vsc->inflight = g_new0(struct vhost_inflight, 1);
57+
ret = vhost_dev_get_inflight(&vsc->dev,
58+
vs->conf.virtqueue_size,
59+
vsc->inflight);
60+
if (ret < 0) {
61+
error_report("Error get inflight: %d", -ret);
62+
goto err_guest_notifiers;
63+
}
64+
65+
ret = vhost_dev_set_inflight(&vsc->dev, vsc->inflight);
66+
if (ret < 0) {
67+
error_report("Error set inflight: %d", -ret);
68+
goto err_guest_notifiers;
69+
}
70+
5271
ret = vhost_dev_start(&vsc->dev, vdev);
5372
if (ret < 0) {
5473
error_report("Error start vhost dev");
@@ -66,6 +85,9 @@ int vhost_scsi_common_start(VHostSCSICommon *vsc)
6685
return ret;
6786

6887
err_guest_notifiers:
88+
g_free(vsc->inflight);
89+
vsc->inflight = NULL;
90+
6991
k->set_guest_notifiers(qbus->parent, vsc->dev.nvqs, false);
7092
err_host_notifiers:
7193
vhost_dev_disable_notifiers(&vsc->dev, vdev);
@@ -89,6 +111,11 @@ void vhost_scsi_common_stop(VHostSCSICommon *vsc)
89111
}
90112
assert(ret >= 0);
91113

114+
if (vsc->inflight) {
115+
vhost_dev_free_inflight(vsc->inflight);
116+
vsc->inflight = NULL;
117+
}
118+
92119
vhost_dev_disable_notifiers(&vsc->dev, vdev);
93120
}
94121

include/hw/virtio/vhost-scsi-common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ struct VHostSCSICommon {
3535
int lun;
3636
uint64_t host_features;
3737
bool migratable;
38+
39+
struct vhost_inflight *inflight;
3840
};
3941

4042
int vhost_scsi_common_start(VHostSCSICommon *vsc);

0 commit comments

Comments
 (0)