[PATCH kvmtool 05/16] virtio/scsi: Move VHOST_SCSI_SET_ENDPOINT to device start

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

 



The vhost driver expects virtqueues to be operational by the time we
call SET_ENDPOINT. We currently do it too early. Device start, which
happens when the driver writes the DRIVER_OK status, is a good time to
do this.

Signed-off-by: Jean-Philippe Brucker <jean-philippe@xxxxxxxxxx>
---
 virtio/scsi.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/virtio/scsi.c b/virtio/scsi.c
index 29acf57c..2bc1ec20 100644
--- a/virtio/scsi.c
+++ b/virtio/scsi.c
@@ -56,6 +56,13 @@ static void notify_status(struct kvm *kvm, void *dev, u32 status)
 	struct virtio_device *vdev = &sdev->vdev;
 	struct virtio_scsi_config *conf = &sdev->config;
 
+	if (status & VIRTIO__STATUS_START) {
+		int r = ioctl(sdev->vhost_fd, VHOST_SCSI_SET_ENDPOINT,
+			      &sdev->target);
+		if (r != 0)
+			die("VHOST_SCSI_SET_ENDPOINT failed %d", errno);
+	}
+
 	if (!(status & VIRTIO__STATUS_CONFIG))
 		return;
 
@@ -93,20 +100,12 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq)
 static void notify_vq_gsi(struct kvm *kvm, void *dev, u32 vq, u32 gsi)
 {
 	struct scsi_dev *sdev = dev;
-	int r;
 
 	if (sdev->vhost_fd == 0)
 		return;
 
 	virtio_vhost_set_vring_call(kvm, sdev->vhost_fd, vq, gsi,
 				    &sdev->vqs[vq]);
-
-	if (vq > 0)
-		return;
-
-	r = ioctl(sdev->vhost_fd, VHOST_SCSI_SET_ENDPOINT, &sdev->target);
-	if (r != 0)
-		die("VHOST_SCSI_SET_ENDPOINT failed %d", errno);
 }
 
 static void notify_vq_eventfd(struct kvm *kvm, void *dev, u32 vq, u32 efd)
-- 
2.40.0




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux