Skip to contentSkip to conversation

virtio-scsi: scsi events must be converted to target endianness

PATCH In review Greg Kurz 2 participants 2 messages Jun 30, 2014

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

PATCH 1/1 virtio-scsi: scsi events must be converted to target endianness

From: Cédric Le Goater <[email protected]>

Virtio SCSI Events need to be byteswapped before being pushed when host and guest have a different endianness. Not doing so breaks hotplug of virtio scsi disks, with the following error message being printed in the guest console:

virtio_scsi: Unsupport virtio scsi event 1000000

This issue got uncovered while testing disk hotplug with a PowerKVM ppc64le guest. I have checked that this issue also affects a x86_64 guest run on a ppc64 host.

[ Ported from PowerKVM,
Greg Kurz <[email protected]> ]

---
 hw/scsi/virtio-scsi.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/scsi/virtio-scsi.c +2 -2
index 0b0a331..5568479 100644
@@ -591,8 +591,8 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
 
     evt = &req->resp.event;
     memset(evt, 0, sizeof(VirtIOSCSIEvent));
-    evt->event = event;
-    evt->reason = reason;
+    evt->event = virtio_tswap32(vdev, event);
+    evt->reason = virtio_tswap32(vdev, reason);
     if (!dev) {
         assert(event == VIRTIO_SCSI_T_EVENTS_MISSED);
     } else {
#1 lore raw

Il 30/06/2014 17:17, Greg Kurz ha scritto:

Quoted 29 lines

From: Cédric Le Goater <[email protected]>

Virtio SCSI Events need to be byteswapped before being pushed when host and guest have a different endianness. Not doing so breaks hotplug of virtio scsi disks, with the following error message being printed in the guest console:

virtio_scsi: Unsupport virtio scsi event 1000000

This issue got uncovered while testing disk hotplug with a PowerKVM ppc64le guest. I have checked that this issue also affects a x86_64 guest run on a ppc64 host.

[ Ported from PowerKVM,
Greg Kurz <[email protected]> ]

---
 hw/scsi/virtio-scsi.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/scsi/virtio-scsi.c +0 -0
index 0b0a331..5568479 100644

hw/scsi/virtio-scsi.c static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev, · line 598

Quoted 10 lines
hw/scsi/virtio-scsi.c +2 -2
@@ -591,8 +591,8 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
 
     evt = &req->resp.event;
     memset(evt, 0, sizeof(VirtIOSCSIEvent));
-    evt->event = event;
-    evt->reason = reason;
+    evt->event = virtio_tswap32(vdev, event);
+    evt->reason = virtio_tswap32(vdev, reason);
     if (!dev) {
         assert(event == VIRTIO_SCSI_T_EVENTS_MISSED);
     } else {

Applying to scsi-next branch, thanks.