Skip to contentSkip to conversation

Fix booting tcm_vhost + seabios

PATCH In review Asias He 5 participants 10 messages Mar 15, 2013 – Mar 19, 2013

Subsystems (2)
lore
Share & tools
lore

Asias He

author
#0 lore raw

cover Fix booting tcm_vhost + seabios

Asias He (2):
virtio-scsi: Set _DRIVER_OK flag before scsi target scanning
virtio-scsi: Pack struct virtio_scsi_{req_cmd,resp_cmd}

 src/virtio-scsi.c | 5 +++--
 src/virtio-scsi.h | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
1.8.1.4
author
#1 lore raw

PATCH 1/2 virtio-scsi: Set _DRIVER_OK flag before scsi target scanning

Before we start scsi target scanning, we need to set the VIRTIO_CONFIG_S_DRIVER_OK flag so the device can do setup properly.

This fix a bug when booting tcm_vhost with seabios.

---
 src/virtio-scsi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
src/virtio-scsi.c +3 -2
index 879ddfb..4de1255 100644
@@ -147,6 +147,9 @@ init_virtio_scsi(struct pci_device *pci)
         goto fail;
     }
 
+    vp_set_status(ioaddr, VIRTIO_CONFIG_S_ACKNOWLEDGE |
+                  VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_DRIVER_OK);
+
     int i, tot;
     for (tot = 0, i = 0; i < 256; i++)
         tot += virtio_scsi_scan_target(pci, ioaddr, vq, i);
@@ -154,8 +157,6 @@ init_virtio_scsi(struct pci_device *pci)
     if (!tot)
         goto fail;
 
-    vp_set_status(ioaddr, VIRTIO_CONFIG_S_ACKNOWLEDGE |
-                  VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_DRIVER_OK);
     return;
 
 fail:
Signature · 1 line
1.8.1.4
maintainer Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] virtio-scsi: Set _DRIVER_OK flag before scsi target scanning

Quoted 7 lines · Asias He

Before we start scsi target scanning, we need to set the VIRTIO_CONFIG_S_DRIVER_OK flag so the device can do setup properly.

This fix a bug when booting tcm_vhost with seabios.

Quoted 29 lines
---
 src/virtio-scsi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
src/virtio-scsi.c +3 -2
index 879ddfb..4de1255 100644
@@ -147,6 +147,9 @@ init_virtio_scsi(struct pci_device *pci)
         goto fail;
     }
 
+    vp_set_status(ioaddr, VIRTIO_CONFIG_S_ACKNOWLEDGE |
+                  VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_DRIVER_OK);
+
     int i, tot;
     for (tot = 0, i = 0; i < 256; i++)
         tot += virtio_scsi_scan_target(pci, ioaddr, vq, i);
@@ -154,8 +157,6 @@ init_virtio_scsi(struct pci_device *pci)
     if (!tot)
         goto fail;
 
-    vp_set_status(ioaddr, VIRTIO_CONFIG_S_ACKNOWLEDGE |
-                  VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_DRIVER_OK);
     return;
 
 fail:
Signature · 1 line
1.8.1.4
author
#3 lore raw

PATCH 2/2 virtio-scsi: Pack struct virtio_scsi_{req_cmd,resp_cmd}

In reply to Asias He

Device needs the exact size of these data structure. Prevent padding.

This fixes guest hang when booting seabios + tcm_vhost.

---
 src/virtio-scsi.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/virtio-scsi.h +2 -2
index bbfbf30..96c3701 100644
@@ -26,7 +26,7 @@ struct virtio_scsi_req_cmd {
     u8 prio;
     u8 crn;
     char cdb[VIRTIO_SCSI_CDB_SIZE];
-};
+} __attribute__((packed));
 
 /* This is the first element of the "in" scatter-gather list. */
 struct virtio_scsi_resp_cmd {
@@ -36,7 +36,7 @@ struct virtio_scsi_resp_cmd {
     u8 status;
     u8 response;
     u8 sense[VIRTIO_SCSI_SENSE_SIZE];
-};
+} __attribute__((packed));
 
 #define VIRTIO_SCSI_S_OK            0
 
Signature · 1 line
1.8.1.4
maintainer Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] virtio-scsi: Pack struct virtio_scsi_{req_cmd, resp_cmd}

Il 15/03/2013 02:45, Asias He ha scritto:

Quoted 24 lines

Device needs the exact size of these data structure. Prevent padding.

This fixes guest hang when booting seabios + tcm_vhost.

---
 src/virtio-scsi.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/virtio-scsi.h +1 -1
index bbfbf30..96c3701 100644
@@ -26,7 +26,7 @@ struct virtio_scsi_req_cmd {
     u8 prio;
     u8 crn;
     char cdb[VIRTIO_SCSI_CDB_SIZE];
-};
+} __attribute__((packed));
 
 /* This is the first element of the "in" scatter-gather list. */
 struct virtio_scsi_resp_cmd {

src/virtio-scsi.h struct virtio_scsi_resp_cmd { · line 42

Quoted 8 lines
src/virtio-scsi.h +1 -1
@@ -36,7 +36,7 @@ struct virtio_scsi_resp_cmd {
     u8 status;
     u8 response;
     u8 sense[VIRTIO_SCSI_SENSE_SIZE];
-};
+} __attribute__((packed));
 
 #define VIRTIO_SCSI_S_OK            0
 
maintainer Acked-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] virtio-scsi: Pack struct virtio_scsi_{req_cmd,resp_cmd}

In reply to Asias He
Quoted 5 lines · Asias He

Device needs the exact size of these data structure. Prevent padding.

This fixes guest hang when booting seabios + tcm_vhost.

Quoted 28 lines
---
 src/virtio-scsi.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/virtio-scsi.h +2 -2
index bbfbf30..96c3701 100644
@@ -26,7 +26,7 @@ struct virtio_scsi_req_cmd {
     u8 prio;
     u8 crn;
     char cdb[VIRTIO_SCSI_CDB_SIZE];
-};
+} __attribute__((packed));
 
 /* This is the first element of the "in" scatter-gather list. */
 struct virtio_scsi_resp_cmd {
@@ -36,7 +36,7 @@ struct virtio_scsi_resp_cmd {
     u8 status;
     u8 response;
     u8 sense[VIRTIO_SCSI_SENSE_SIZE];
-};
+} __attribute__((packed));
 
 #define VIRTIO_SCSI_S_OK            0
 
Signature · 1 line
1.8.1.4
#6 lore raw
In reply to Asias He
Quoted 3 lines · Asias He

Asias He (2):
virtio-scsi: Set _DRIVER_OK flag before scsi target scanning
virtio-scsi: Pack struct virtio_scsi_{req_cmd,resp_cmd}

Thanks. I pushed these patches.

-Kevin

#7 lore raw
In reply to Asias He
Quoted 3 lines · Asias He

Asias He (2):
virtio-scsi: Set _DRIVER_OK flag before scsi target scanning
virtio-scsi: Pack struct virtio_scsi_{req_cmd,resp_cmd}

Thanks. I pushed these patches.

-Kevin

#8 lore raw
In reply to Asias He
Quoted 8 lines · Asias He

Asias He (2):
virtio-scsi: Set _DRIVER_OK flag before scsi target scanning
virtio-scsi: Pack struct virtio_scsi_{req_cmd,resp_cmd}

 src/virtio-scsi.c | 5 +++--
 src/virtio-scsi.h | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

Hi Asias,

Thanks for taking the initiative on this, and nice work tracking both of these stubborn bugs down.

So with these out of the way, we're good to go for an RFC of Paolo's vhost-scsi-pci code for upstream QEMU, yes..?

I'll have some extra bandwidth this week to spend time on the RFC if you'd like, otherwise I'm happy with you making the upstream QEMU push for Paolo's code.

Whatever works best for you. :)

Thank you,

--nab

author
#9 lore raw
Quoted 15 lines · Nicholas A. Bellinger
Quoted 8 lines · Asias He

Asias He (2):
virtio-scsi: Set _DRIVER_OK flag before scsi target scanning
virtio-scsi: Pack struct virtio_scsi_{req_cmd,resp_cmd}

 src/virtio-scsi.c | 5 +++--
 src/virtio-scsi.h | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

Hi Asias,

Thanks for taking the initiative on this, and nice work tracking both of these stubborn bugs down.

Quoted 8 lines

So with these out of the way, we're good to go for an RFC of Paolo's vhost-scsi-pci code for upstream QEMU, yes..?

I'll have some extra bandwidth this week to spend time on the RFC if you'd like, otherwise I'm happy with you making the upstream QEMU push for Paolo's code.

Whatever works best for you. :)

Nice, Nicholas, go ahead. I have sent out the WIP V3 for you ;-)

Quoted 6 lines

Thank you,

--nab

Signature · 1 line
Asias