On Wed, Jul 25, 2012 at 3:37 PM, Paolo Bonzini <pbonz...@redhat.com> wrote: > Il 25/07/2012 09:03, Stefan Hajnoczi ha scritto: >> From: Liu Ping Fan <pingf...@linux.vnet.ibm.com> >> >> iohandler/bh/timer may use DeviceState when its refcnt=0, > > It's not clear how to me. The only reference to devices from an > iohandler/bh/timer can be in the opaque. Now, if you have a > iohandler/bh/timer whose opaque is a DeviceState, you should bump the > refcount before setting it up, and unref after tearing it down. > Yes, I admit refcnt is a good solution, but I think it means that we will fix it with each device's bh. And this way seems lazy.
Thanx pingfan > See for example how hw/scsi-disk.c bumps the refcount of a request > before starting asynchronous I/O and calls unref at the end of the > asynchronous I/O callback. > > Paolo