Il 23/05/2013 17:27, Asias He ha scritto:
> On Thu, May 23, 2013 at 04:58:05PM +0200, Paolo Bonzini wrote:
>> Il 23/05/2013 16:48, Badari Pulavarty ha scritto:
>>>> The common virtio-scsi code in QEMU should guard against this.  In
>>>> virtio-blk data plane I hit a similar case and ended up starting the
>>>> data plane thread (equivalent to vhost here) *before* the status
>>>> register is set to DRIVER_OK.
>>>
>>> Thats exactly what my debug in vhost_scsi_set_status() shows.
>>>
>>> set status started 0 val 0
>>> set status started 0 val 0
>>> set status started 0 val 0
>>> set status started 0 val 0
>>> set status started 0 val 0
>>> set status started 0 val 3
>>> Program received signal SIGSEGV, Segmentation fault.
>>>
>>> We never got a chance to call vhost_scsi_start() as we are waiting
>>> for DRIVER_OK.
> 
> Reproduced the SIGSEGV and verified that replacing the bios.bin with the
> one from seabios.git makes the guest boot.

This should fix it:

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 08dd3f3..3139355 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -266,7 +266,7 @@ fail:
 
 static void virtio_scsi_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
 {
-    VirtIOSCSI *s = (VirtIOSCSI *)vdev;
+    VirtIOSCSI *s = VIRTIO_SCSI(vdev);
     VirtIOSCSIReq *req;
 
     while ((req = virtio_scsi_pop_req(s, vq))) {
@@ -347,9 +347,8 @@ static void virtio_scsi_fail_cmd_req(VirtIOSCSIReq *req)
 
 static void virtio_scsi_handle_cmd(VirtIODevice *vdev, VirtQueue *vq)
 {
-    /* use non-QOM casts in the data path */
-    VirtIOSCSI *s = (VirtIOSCSI *)vdev;
-    VirtIOSCSICommon *vs = &s->parent_obj;
+    VirtIOSCSI *s = VIRTIO_SCSI(vdev);
+    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
 
     VirtIOSCSIReq *req;
     int n;

Paolo


Reply via email to