Skip to contentSkip to conversation

dataplane: support viostor virtio-pci status bit setting

PATCH Applied Stefan Hajnoczi 4 participants 7 messages Jan 17, 2013 – Jan 21, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dataplane: support viostor virtio-pci status bit setting

The viostor virtio-blk driver for Windows does not use the VIRTIO_CONFIG_S_DRIVER bit. It only sets the VIRTIO_CONFIG_S_DRIVER_OK bit.

The viostor driver refreshes the virtio-pci status byte sometimes while the guest is running. We misinterpret 0x4 (VIRTIO_CONFIG_S_DRIVER_OK) as an indication that virtio-blk-data-plane should be stopped since 0x2 (VIRTIO_CONFIG_S_DRIVER) is missing. The result is that the device becomes unresponsive.

---
 hw/virtio-blk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio-blk.c +2 -1
index df57b35..34913ee 100644
@@ -571,7 +571,8 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status)
     uint32_t features;
 
 #ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
-    if (s->dataplane && !(status & VIRTIO_CONFIG_S_DRIVER)) {
+    if (s->dataplane && !(status & (VIRTIO_CONFIG_S_DRIVER |
+                                    VIRTIO_CONFIG_S_DRIVER_OK))) {
         virtio_blk_data_plane_stop(s->dataplane);
     }
 #endif
Signature · 1 line
1.8.0.2
#1 lore raw
Quoted 11 lines · Stefan Hajnoczi

The viostor virtio-blk driver for Windows does not use the VIRTIO_CONFIG_S_DRIVER bit. It only sets the VIRTIO_CONFIG_S_DRIVER_OK bit.

The viostor driver refreshes the virtio-pci status byte sometimes while the guest is running. We misinterpret 0x4 (VIRTIO_CONFIG_S_DRIVER_OK) as an indication that virtio-blk-data-plane should be stopped since 0x2 (VIRTIO_CONFIG_S_DRIVER) is missing. The result is that the device becomes unresponsive.

I think you actually want

  if (s->dataplane && !(status & VIRTIO_CONFIG_S_DRIVER_OK)))

so stop on any error.

This is also consistent with what vhost-net does.

Quoted 20 lines
---
 hw/virtio-blk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio-blk.c +2 -1
index df57b35..34913ee 100644
@@ -571,7 +571,8 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status)
     uint32_t features;
 
 #ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
-    if (s->dataplane && !(status & VIRTIO_CONFIG_S_DRIVER)) {
+    if (s->dataplane && !(status & (VIRTIO_CONFIG_S_DRIVER |
+                                    VIRTIO_CONFIG_S_DRIVER_OK))) {
         virtio_blk_data_plane_stop(s->dataplane);
     }
 #endif
Signature · 1 line
1.8.0.2
#2 lore raw
Quoted 13 lines · Michael S. Tsirkin
Quoted 11 lines · Stefan Hajnoczi

The viostor virtio-blk driver for Windows does not use the VIRTIO_CONFIG_S_DRIVER bit. It only sets the VIRTIO_CONFIG_S_DRIVER_OK bit.

The viostor driver refreshes the virtio-pci status byte sometimes while the guest is running. We misinterpret 0x4 (VIRTIO_CONFIG_S_DRIVER_OK) as an indication that virtio-blk-data-plane should be stopped since 0x2 (VIRTIO_CONFIG_S_DRIVER) is missing. The result is that the device becomes unresponsive.

Quoted 7 lines

I think you actually want

  if (s->dataplane && !(status & VIRTIO_CONFIG_S_DRIVER_OK)))

so stop on any error.

This is also consistent with what vhost-net does.

We can't do that because of the Linux virtio quirk where it begins using virtqueues before VIRTIO_CONFIG_S_DRIVER_OK. I original checked VIRTIO_CONFIG_S_DRIVER_OK but I'm pretty sure I hit a situation where the status would still be set ~DRIVER_OK after the first kick - this would stop data plane and the vring last indices would no longer be in sync when it started again.

So I think it's most robust to check both DRIVER and DRIVER_OK.

Stefan

#3 lore raw
In reply to Stefan Hajnoczi
Quoted 10 lines · Stefan Hajnoczi

The viostor virtio-blk driver for Windows does not use the VIRTIO_CONFIG_S_DRIVER bit. It only sets the VIRTIO_CONFIG_S_DRIVER_OK bit.

The viostor driver refreshes the virtio-pci status byte sometimes while the guest is running. We misinterpret 0x4 (VIRTIO_CONFIG_S_DRIVER_OK) as an indication that virtio-blk-data-plane should be stopped since 0x2 (VIRTIO_CONFIG_S_DRIVER) is missing. The result is that the device becomes unresponsive.

Quoted 4 lines
---
 hw/virtio-blk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

#4 lore raw
Quoted 4 lines · Stefan Hajnoczi
Quoted 3 lines · Stefan Hajnoczi

The viostor virtio-blk driver for Windows does not use the VIRTIO_CONFIG_S_DRIVER bit. It only sets the VIRTIO_CONFIG_S_DRIVER_OK bit.

Will be added in the next build.
Thank you,
Vadim.

Quoted 17 lines
Quoted 7 lines

The viostor driver refreshes the virtio-pci status byte sometimes while the guest is running. We misinterpret 0x4 (VIRTIO_CONFIG_S_DRIVER_OK) as an indication that virtio-blk-data-plane should be stopped since 0x2 (VIRTIO_CONFIG_S_DRIVER) is missing. The result is that the device becomes unresponsive.

Quoted 5 lines

---

 hw/virtio-blk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

#5 lore raw
Quoted 6 lines · Vadim Rozenfeld
Quoted 4 lines · Stefan Hajnoczi
Quoted 3 lines · Stefan Hajnoczi

The viostor virtio-blk driver for Windows does not use the VIRTIO_CONFIG_S_DRIVER bit. It only sets the VIRTIO_CONFIG_S_DRIVER_OK bit.

Will be added in the next build.

Nice, thanks. For compatibility with existing viostor drivers QEMU will carry this patch.

Stefan

#6 lore raw
Quoted 6 lines · Stefan Hajnoczi
Quoted 5 lines · Vadim Rozenfeld
Quoted 4 lines · Stefan Hajnoczi
Quoted 3 lines · Stefan Hajnoczi

The viostor virtio-blk driver for Windows does not use the VIRTIO_CONFIG_S_DRIVER bit. It only sets the VIRTIO_CONFIG_S_DRIVER_OK bit.

Quoted 6 lines
Quoted 1 line

Will be added in the next build.

Nice, thanks. For compatibility with existing viostor drivers QEMU will carry this patch.

Stefan

I still think it's wrong: when DRIVER_OK is cleared you should stop device I think even if DRIVER is set.
This patch keeps dataplane running if DRIVER is set.