Skip to contentSkip to conversation

vhost-user-scsi: implement handle_output

PATCH In review Felipe Franciosi 4 participants 10 messages Oct 17, 2019 – Oct 22, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost-user-scsi: implement handle_output

Originally, vhost-user-scsi did not implement a handle_output callback as that didn't seem necessary. Turns out it is.

Depending on which other devices are presented to a VM, SeaBIOS may decide to map vhost-user-scsi devices on the 64-bit range of the address space. As a result, SeaBIOS will kick VQs via the config space. Those land on Qemu (not the vhost backend) and are missed, causing the VM not to boot. This fixes the issue by getting Qemu to post the notification.

---
 hw/scsi/vhost-user-scsi.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
hw/scsi/vhost-user-scsi.c +5 -4
index 6a6c15dd32..13278ed151 100644
@@ -62,8 +62,9 @@ static void vhost_user_scsi_set_status(VirtIODevice *vdev, uint8_t status)
     }
 }
 
-static void vhost_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq)
+static void vhost_handle_output(VirtIODevice *vdev, VirtQueue *vq)
 {
+    event_notifier_set(virtio_queue_get_host_notifier(vq));
 }
 
 static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
@@ -80,9 +81,9 @@ static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    virtio_scsi_common_realize(dev, vhost_dummy_handle_output,
-                               vhost_dummy_handle_output,
-                               vhost_dummy_handle_output, &err);
+    virtio_scsi_common_realize(dev, vhost_handle_output,
+                               vhost_handle_output,
+                               vhost_handle_output, &err);
     if (err != NULL) {
         error_propagate(errp, err);
         return;
Signature · 1 line
2.20.1
#1 lore raw
Quoted 10 lines · Felipe Franciosi

Originally, vhost-user-scsi did not implement a handle_output callback as that didn't seem necessary. Turns out it is.

Depending on which other devices are presented to a VM, SeaBIOS may decide to map vhost-user-scsi devices on the 64-bit range of the address space. As a result, SeaBIOS will kick VQs via the config space. Those land on Qemu (not the vhost backend) and are missed, causing the VM not to boot. This fixes the issue by getting Qemu to post the notification.

Should we fix this in vhost-user-blk too?

Thanks,
Yongji

Quoted 36 lines
---
 hw/scsi/vhost-user-scsi.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
hw/scsi/vhost-user-scsi.c +5 -5
index 6a6c15dd32..13278ed151 100644
@@ -62,8 +62,9 @@ static void vhost_user_scsi_set_status(VirtIODevice *vdev, uint8_t status)
     }
 }
 
-static void vhost_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq)
+static void vhost_handle_output(VirtIODevice *vdev, VirtQueue *vq)
 {
+    event_notifier_set(virtio_queue_get_host_notifier(vq));
 }
 
 static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
@@ -80,9 +81,9 @@ static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    virtio_scsi_common_realize(dev, vhost_dummy_handle_output,
-                               vhost_dummy_handle_output,
-                               vhost_dummy_handle_output, &err);
+    virtio_scsi_common_realize(dev, vhost_handle_output,
+                               vhost_handle_output,
+                               vhost_handle_output, &err);
     if (err != NULL) {
         error_propagate(errp, err);
         return;
--

2.20.1

#2 lore raw
Quoted 9 lines · Yongji Xie
Quoted 4 lines · Felipe Franciosi

Originally, vhost-user-scsi did not implement a handle_output callback as that didn't seem necessary. Turns out it is.

Quoted 7 lines
Quoted 6 lines

Depending on which other devices are presented to a VM, SeaBIOS may decide to map vhost-user-scsi devices on the 64-bit range of the address space. As a result, SeaBIOS will kick VQs via the config space. Those land on Qemu (not the vhost backend) and are missed, causing the VM not to boot. This fixes the issue by getting Qemu to post the notification.

Should we fix this in vhost-user-blk too?

I'm not sure vhost-user-blk suffers from the same problem. Certainly vhost-scsi does, but I'd prefer to tackle that separately because I can't trivially test it. If it breaks something there, we can revert it without affecting a valid fix for vhost-user-scsi.

I can send that patch immediately after this is queued (or resend a v2 including both patches separately if maintainers prefer that).

F.

Quoted 40 lines

Thanks,
Yongji

Quoted 36 lines

---
hw/scsi/vhost-user-scsi.c | 9 +++++----

1 file changed, 5 insertions(+), 4 deletions(-)
hw/scsi/vhost-user-scsi.c +5 -5
index 6a6c15dd32..13278ed151 100644
@@ -62,8 +62,9 @@ static void vhost_user_scsi_set_status(VirtIODevice *vdev, uint8_t status)
    }
 }
 
-static void vhost_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq)
+static void vhost_handle_output(VirtIODevice *vdev, VirtQueue *vq)
 {
+    event_notifier_set(virtio_queue_get_host_notifier(vq));
 }
 
 static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
@@ -80,9 +81,9 @@ static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
        return;
    }
 
-    virtio_scsi_common_realize(dev, vhost_dummy_handle_output,
-                               vhost_dummy_handle_output,
-                               vhost_dummy_handle_output, &err);
+    virtio_scsi_common_realize(dev, vhost_handle_output,
+                               vhost_handle_output,
+                               vhost_handle_output, &err);
    if (err != NULL) {
        error_propagate(errp, err);
        return;
--

2.20.1

#3 lore raw
Quoted 16 lines · Felipe Franciosi
Quoted 16 lines · Yongji Xie
Quoted 10 lines · Felipe Franciosi

Originally, vhost-user-scsi did not implement a handle_output callback as that didn't seem necessary. Turns out it is.

Depending on which other devices are presented to a VM, SeaBIOS may decide to map vhost-user-scsi devices on the 64-bit range of the address space. As a result, SeaBIOS will kick VQs via the config space. Those land on Qemu (not the vhost backend) and are missed, causing the VM not to boot. This fixes the issue by getting Qemu to post the notification.

Quoted 3 lines
Quoted 1 line

Should we fix this in vhost-user-blk too?

I'm not sure vhost-user-blk suffers from the same problem. Certainly

Actually I found vhost-user-blk has the same problem in a mutilple GPUs passthough environment.

Thanks,
Yongji

#4 lore raw
Quoted 21 lines · Yongji Xie
Quoted 16 lines · Felipe Franciosi
Quoted 16 lines · Yongji Xie
Quoted 10 lines · Felipe Franciosi

Originally, vhost-user-scsi did not implement a handle_output callback as that didn't seem necessary. Turns out it is.

Depending on which other devices are presented to a VM, SeaBIOS may decide to map vhost-user-scsi devices on the 64-bit range of the address space. As a result, SeaBIOS will kick VQs via the config space. Those land on Qemu (not the vhost backend) and are missed, causing the VM not to boot. This fixes the issue by getting Qemu to post the notification.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Should we fix this in vhost-user-blk too?

I'm not sure vhost-user-blk suffers from the same problem. Certainly

Actually I found vhost-user-blk has the same problem in a mutilple GPUs passthough environment.

Let's Cc Changpeng for comments. I'm not familiar with that code.

In any case, I still think we should merge this and fix other implementations separately. That allows us to revert patches individually if anything else breaks.

F.

Quoted 3 lines

Thanks,
Yongji

#5 lore raw

There is some logic in vhost_user_blk_handle_output() for now, it's not empty as vhost-user-scsi. There should be other issue if it can't start from SeaBIOS.

Quoted 49 lines

-----Original Message-----
From: Felipe Franciosi [mailto:[email protected]]
Sent: Monday, October 21, 2019 4:00 PM
To: Yongji Xie <[email protected]>; Liu, Changpeng <[email protected]>
Cc: Stefan Hajnoczi <[email protected]>; Alex Williamson <[email protected]>; Dr . David Alan Gilbert <[email protected]>; [email protected]
Subject: Re: [PATCH] vhost-user-scsi: implement handle_output

Quoted 19 lines · Yongji Xie
Quoted 16 lines · Felipe Franciosi
Quoted 16 lines · Yongji Xie
Quoted 10 lines · Felipe Franciosi

Originally, vhost-user-scsi did not implement a handle_output callback as that didn't seem necessary. Turns out it is.

Depending on which other devices are presented to a VM, SeaBIOS may decide to map vhost-user-scsi devices on the 64-bit range of the address space. As a result, SeaBIOS will kick VQs via the config space. Those land on Qemu (not the vhost backend) and are missed, causing the VM not to boot. This fixes the issue by getting Qemu to post the notification.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Should we fix this in vhost-user-blk too?

I'm not sure vhost-user-blk suffers from the same problem. Certainly

Actually I found vhost-user-blk has the same problem in a mutilple GPUs passthough environment.

Let's Cc Changpeng for comments. I'm not familiar with that code.

In any case, I still think we should merge this and fix other implementations separately. That allows us to revert patches individually if anything else breaks.

F.

Quoted 3 lines

Thanks,
Yongji

#6 lore raw
Quoted 4 lines · Changpeng

There is some logic in vhost_user_blk_handle_output() for now, it's not empty as vhost-user-scsi. There should be other issue if it can't start from SeaBIOS.

No, it's the same issue. We can see the notify is triggered from the VIRTIO_PCI_CAP_PCI_CFG region in configuration space. And looks like seabios also support this notify mode:

void vp_init_simple(struct vp_device *vp, struct pci_device *pci) {
....
vp_cap->mode = (addr > 0xffffffffll) ?

                    VP_ACCESS_PCICFG : VP_ACCESS_MMIO;

....
}

Thanks,
Yongji

#7 lore raw
In reply to Liu, Changpeng
Quoted 1 line · Changpeng

There is some logic in vhost_user_blk_handle_output() for now, it's not empty as vhost-user-scsi.

The purpose of the vhost_user_blk_handle_output() code is to deal with legacy drivers that violate the VIRTIO spec by accessing virtqueues before VIRTIO Device Initialization is complete. It needs to stay.

The patch I posted should work together with vhost_user_blk_handle_output() though and handle the case that Felipe discovered.

Stefan

#8 lore raw
In reply to Felipe Franciosi
Quoted 26 lines · Felipe Franciosi
Quoted 26 lines · Yongji Xie
Quoted 19 lines · Felipe Franciosi
Quoted 10 lines · Yongji Xie
Quoted 4 lines · Felipe Franciosi

Originally, vhost-user-scsi did not implement a handle_output callback as that didn't seem necessary. Turns out it is.

Quoted 7 lines
Quoted 6 lines

Depending on which other devices are presented to a VM, SeaBIOS may decide to map vhost-user-scsi devices on the 64-bit range of the address space. As a result, SeaBIOS will kick VQs via the config space. Those land on Qemu (not the vhost backend) and are missed, causing the VM not to boot. This fixes the issue by getting Qemu to post the notification.

Should we fix this in vhost-user-blk too?

I'm not sure vhost-user-blk suffers from the same problem. Certainly

Quoted 9 lines
Quoted 2 lines

Actually I found vhost-user-blk has the same problem in a mutilple GPUs passthough environment.

Let's Cc Changpeng for comments. I'm not familiar with that code.

In any case, I still think we should merge this and fix other implementations separately. That allows us to revert patches individually if anything else breaks.

It's OK for me.

Thanks,
Yongji

#9 lore raw
In reply to Felipe Franciosi
Quoted 19 lines · Felipe Franciosi

Originally, vhost-user-scsi did not implement a handle_output callback as that didn't seem necessary. Turns out it is.

Depending on which other devices are presented to a VM, SeaBIOS may decide to map vhost-user-scsi devices on the 64-bit range of the address space. As a result, SeaBIOS will kick VQs via the config space. Those land on Qemu (not the vhost backend) and are missed, causing the VM not to boot. This fixes the issue by getting Qemu to post the notification.

---
 hw/scsi/vhost-user-scsi.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
hw/scsi/vhost-user-scsi.c +0 -0
index 6a6c15dd32..13278ed151 100644

hw/scsi/vhost-user-scsi.c static void vhost_user_scsi_set_status(VirtIODevice *vdev, uint8_t status) · line 68

Quoted 8 lines
hw/scsi/vhost-user-scsi.c +2 -1
@@ -62,8 +62,9 @@ static void vhost_user_scsi_set_status(VirtIODevice *vdev, uint8_t status)
     }
 }
 
-static void vhost_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq)
+static void vhost_handle_output(VirtIODevice *vdev, VirtQueue *vq)
 {
+    event_notifier_set(virtio_queue_get_host_notifier(vq));
 }

It would be nice to fix this in hw/virtio/virtio.c:virtio_queue_notify() so that all devices are automatically covered.

I'll send a patch and CC you.

Stefan