Re: [Qemu-devel] [PATCH v3 05/21] scsi: reference-count requests

2011-05-20 Thread Paolo Bonzini
On 05/20/2011 07:48 PM, Paolo Bonzini wrote: Is there any reason to keep a free function? It's internal for SCSIDevice implementation, kind of a "base implementation" for free_req The pattern should be that people just call the function to decrement the reference count, and that frees the str

Re: [Qemu-devel] [PATCH v3 05/21] scsi: reference-count requests

2011-05-20 Thread Paolo Bonzini
On 05/20/2011 05:58 PM, Christoph Hellwig wrote: >void scsi_req_free(SCSIRequest *req) >{ > -scsi_req_dequeue(req); > +assert(req->refcount == 0); >qemu_free(req); >} Is there any reason to keep a free function? It's internal for SCSIDevice implementation, kind of

Re: [Qemu-devel] [PATCH v3 05/21] scsi: reference-count requests

2011-05-20 Thread Christoph Hellwig
> --- a/hw/scsi-bus.c > +++ b/hw/scsi-bus.c > @@ -136,6 +136,7 @@ SCSIRequest *scsi_req_alloc(size_t size, SCSIDevice *d, > uint32_t tag, uint32_t l > SCSIRequest *req; > > req = qemu_mallocz(size); > +req->refcount = 2; > req->bus = scsi_bus_from_device(d); > req->dev =

[Qemu-devel] [PATCH v3 05/21] scsi: reference-count requests

2011-05-17 Thread Paolo Bonzini
With the next patch, a device may hold SCSIRequest for an indefinite time. Split a rather big patch, and protect against access errors, by reference counting them. One such access error in fact exists (it is visible by testing the lsi driver with MALLOC_PERTURB_), and this patch provides the infr