Patchwork [02/66] scsi: keep device alive while it has requests

login
register
mail settings
Submitter Paolo Bonzini
Date July 4, 2013, 3:12 p.m.
Message ID <1372950842-32422-3-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/256910/
State New
Headers show

Comments

Paolo Bonzini - July 4, 2013, 3:12 p.m.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi/scsi-bus.c | 4 ++++
 1 file changed, 4 insertions(+)

Patch

diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 53ea906..e443193 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -516,6 +516,8 @@  SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d,
     req->status = -1;
     req->sense_len = 0;
     req->ops = reqops;
+    object_ref(OBJECT(d));
+    object_ref(OBJECT(req->bus->qbus.parent));
     trace_scsi_req_alloc(req->dev->id, req->lun, req->tag);
     return req;
 }
@@ -1505,6 +1507,8 @@  void scsi_req_unref(SCSIRequest *req)
         if (req->ops->free_req) {
             req->ops->free_req(req);
         }
+        object_unref(OBJECT(req->dev));
+        object_unref(OBJECT(bus->qbus.parent));
         g_free(req);
     }
 }