Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-05 Thread Avi Kivity
On 09/05/2012 03:02 PM, Jan Kiszka wrote: > On 2012-09-05 13:25, Avi Kivity wrote: >> On 09/05/2012 02:11 PM, Jan Kiszka wrote: >>> On 2012-09-05 12:53, Avi Kivity wrote: On 09/05/2012 01:36 PM, Jan Kiszka wrote: >> >> My current preference is MemoryRegionOps::ref(MemoryRegion *mr) (an

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-05 Thread Jan Kiszka
On 2012-09-05 13:25, Avi Kivity wrote: > On 09/05/2012 02:11 PM, Jan Kiszka wrote: >> On 2012-09-05 12:53, Avi Kivity wrote: >>> On 09/05/2012 01:36 PM, Jan Kiszka wrote: > > My current preference is MemoryRegionOps::ref(MemoryRegion *mr) (and a > corresponding unref), which has the fol

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-05 Thread Avi Kivity
On 09/05/2012 02:11 PM, Jan Kiszka wrote: > On 2012-09-05 12:53, Avi Kivity wrote: >> On 09/05/2012 01:36 PM, Jan Kiszka wrote: My current preference is MemoryRegionOps::ref(MemoryRegion *mr) (and a corresponding unref), which has the following requirements: - if the refcou

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-05 Thread Jan Kiszka
On 2012-09-05 12:53, Avi Kivity wrote: > On 09/05/2012 01:36 PM, Jan Kiszka wrote: >>> >>> My current preference is MemoryRegionOps::ref(MemoryRegion *mr) (and a >>> corresponding unref), which has the following requirements: >>> >>> - if the refcount is nonzero, MemoryRegion::opaque is safe to use

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-05 Thread Avi Kivity
On 09/05/2012 01:36 PM, Jan Kiszka wrote: >> >> My current preference is MemoryRegionOps::ref(MemoryRegion *mr) (and a >> corresponding unref), which has the following requirements: >> >> - if the refcount is nonzero, MemoryRegion::opaque is safe to use >> - if the refcount is nonzero, the Memory

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-05 Thread Jan Kiszka
On 2012-09-05 11:52, Avi Kivity wrote: > On 09/05/2012 11:19 AM, liu ping fan wrote: >> [...] >>> We could externalize the refcounting and push it into device code. This >>> means: >>> >>>memory_region_init_io(&s->mem, dev) >>> >>>... >>> >>>object_

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-05 Thread Avi Kivity
On 09/05/2012 11:19 AM, liu ping fan wrote: > [...] >>> >> We could externalize the refcounting and push it into device code. This >> means: >> >>memory_region_init_io(&s->mem, dev) >> >>... >> >>object_ref(dev) >>memory_region_add_subregion(...,

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-05 Thread liu ping fan
[...] >> > We could externalize the refcounting and push it into device code. This > means: > >memory_region_init_io(&s->mem, dev) > >... > >object_ref(dev) >memory_region_add_subregion(..., &dev->mr) > >... > >memory_regi

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-03 Thread liu ping fan
On Mon, Sep 3, 2012 at 6:06 PM, liu ping fan wrote: > On Mon, Sep 3, 2012 at 4:52 PM, Avi Kivity wrote: >> On 09/03/2012 10:44 AM, liu ping fan wrote: > If we make the refcount/lock internal to the region, we must remove the opaque, since the region won't protect it.

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-03 Thread liu ping fan
On Mon, Sep 3, 2012 at 6:16 PM, Avi Kivity wrote: > On 09/03/2012 01:06 PM, liu ping fan wrote: >> On Mon, Sep 3, 2012 at 4:52 PM, Avi Kivity wrote: >>> On 09/03/2012 10:44 AM, liu ping fan wrote: >> > > If we make the refcount/lock internal to the region, we must remove the > opa

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-03 Thread Avi Kivity
On 09/03/2012 01:06 PM, liu ping fan wrote: > On Mon, Sep 3, 2012 at 4:52 PM, Avi Kivity wrote: >> On 09/03/2012 10:44 AM, liu ping fan wrote: > If we make the refcount/lock internal to the region, we must remove the opaque, since the region won't protect it. Replacing

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-03 Thread liu ping fan
On Mon, Sep 3, 2012 at 4:52 PM, Avi Kivity wrote: > On 09/03/2012 10:44 AM, liu ping fan wrote: >>> >>> If we make the refcount/lock internal to the region, we must remove the >>> opaque, since the region won't protect it. >>> >>> Replacing the opaque with container_of(mr) doesn't help, since

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-03 Thread Avi Kivity
On 08/29/2012 08:41 PM, Jan Kiszka wrote: >>> >>> memory_region_transaction_commit (or calls that trigger this) will have >>> to wait. That is required as the caller may start fiddling with the >>> region right afterward. >> >> However, it may be running within an mmio dispatch, so it may wait for

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-03 Thread Avi Kivity
On 09/03/2012 10:44 AM, liu ping fan wrote: >>> >> >> If we make the refcount/lock internal to the region, we must remove the >> opaque, since the region won't protect it. >> >> Replacing the opaque with container_of(mr) doesn't help, since we can't >> refcount mr, only mr->impl. >> > I think you m

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-03 Thread liu ping fan
On Sat, Sep 1, 2012 at 4:46 PM, Avi Kivity wrote: > On 08/30/2012 12:08 AM, Jan Kiszka wrote: >> >>> >> >>> We are dispatching according to the memory region (parameters, op >> >>> handlers, opaques). If we end up in device object is not decided at this >> >>> level. A memory region describes a di

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-01 Thread Avi Kivity
On 09/01/2012 01:57 AM, Jan Kiszka wrote: > On 2012-09-01 10:31, Avi Kivity wrote: > > On 08/29/2012 10:49 AM, Jan Kiszka wrote: > >>> > >>> Let's experiment with refcounting MemoryRegion. We can move the entire > >>> contents of MemoryRegion to MemoryRegionImpl, add a reference count (to > >>> Me

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-01 Thread Jan Kiszka
On 2012-09-01 10:31, Avi Kivity wrote: > On 08/29/2012 10:49 AM, Jan Kiszka wrote: >>> >>> Let's experiment with refcounting MemoryRegion. We can move the entire >>> contents of MemoryRegion to MemoryRegionImpl, add a reference count (to >>> MemoryRegionImpl), and change MemoryRegion to contain a

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-01 Thread Avi Kivity
On 08/30/2012 12:08 AM, Jan Kiszka wrote: > >>> > >>> We are dispatching according to the memory region (parameters, op > >>> handlers, opaques). If we end up in device object is not decided at this > >>> level. A memory region describes a dispatchable area - not to confuse > >>> with a device that

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-09-01 Thread Avi Kivity
On 08/29/2012 10:49 AM, Jan Kiszka wrote: > > > > Let's experiment with refcounting MemoryRegion. We can move the entire > > contents of MemoryRegion to MemoryRegionImpl, add a reference count (to > > MemoryRegionImpl), and change MemoryRegion to contain a pointer to the > > refcounted MemoryRegi

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-30 Thread liu ping fan
On Thu, Aug 30, 2012 at 3:08 PM, Jan Kiszka wrote: > On 2012-08-30 07:54, liu ping fan wrote: >> On Thu, Aug 30, 2012 at 1:40 AM, Avi Kivity wrote: >>> On 08/29/2012 10:30 AM, Jan Kiszka wrote: On 2012-08-29 19:23, Avi Kivity wrote: > On 08/28/2012 02:42 AM, Jan Kiszka wrote: >>

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-30 Thread Jan Kiszka
On 2012-08-30 07:54, liu ping fan wrote: > On Thu, Aug 30, 2012 at 1:40 AM, Avi Kivity wrote: >> On 08/29/2012 10:30 AM, Jan Kiszka wrote: >>> On 2012-08-29 19:23, Avi Kivity wrote: On 08/28/2012 02:42 AM, Jan Kiszka wrote: > > Let's not talk about devices or MMIO dispatching. I think

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-29 Thread liu ping fan
On Thu, Aug 30, 2012 at 1:40 AM, Avi Kivity wrote: > On 08/29/2012 10:30 AM, Jan Kiszka wrote: >> On 2012-08-29 19:23, Avi Kivity wrote: >> > On 08/28/2012 02:42 AM, Jan Kiszka wrote: >> >> >> >> Let's not talk about devices or MMIO dispatching. I think the problem is >> >> way more generic, and w

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-29 Thread Jan Kiszka
On 2012-08-29 19:40, Avi Kivity wrote: > On 08/29/2012 10:30 AM, Jan Kiszka wrote: >> On 2012-08-29 19:23, Avi Kivity wrote: >>> On 08/28/2012 02:42 AM, Jan Kiszka wrote: Let's not talk about devices or MMIO dispatching. I think the problem is way more generic, and we will face it mu

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-29 Thread Jan Kiszka
On 2012-08-29 19:27, Avi Kivity wrote: > On 08/29/2012 10:21 AM, Jan Kiszka wrote: >> On 2012-08-29 19:13, Avi Kivity wrote: >>> On 08/27/2012 06:01 PM, Jan Kiszka wrote: On 2012-08-27 22:53, Avi Kivity wrote: > On 08/27/2012 12:38 PM, Jan Kiszka wrote: Even worse, apply

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-29 Thread Avi Kivity
On 08/29/2012 10:30 AM, Jan Kiszka wrote: > On 2012-08-29 19:23, Avi Kivity wrote: > > On 08/28/2012 02:42 AM, Jan Kiszka wrote: > >> > >> Let's not talk about devices or MMIO dispatching. I think the problem is > >> way more generic, and we will face it multiple times in QEMU. > > > > The proble

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-29 Thread Avi Kivity
On 08/29/2012 10:21 AM, Jan Kiszka wrote: > On 2012-08-29 19:13, Avi Kivity wrote: > > On 08/27/2012 06:01 PM, Jan Kiszka wrote: > >> On 2012-08-27 22:53, Avi Kivity wrote: > >>> On 08/27/2012 12:38 PM, Jan Kiszka wrote: > >> Even worse, apply > >> restrictions on how the dispatched objects

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-29 Thread Jan Kiszka
On 2012-08-29 19:23, Avi Kivity wrote: > On 08/28/2012 02:42 AM, Jan Kiszka wrote: >> >> Let's not talk about devices or MMIO dispatching. I think the problem is >> way more generic, and we will face it multiple times in QEMU. > > The problem exists outside qemu as well. It is one of the reasons

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-29 Thread Avi Kivity
On 08/28/2012 02:42 AM, Jan Kiszka wrote: > > Let's not talk about devices or MMIO dispatching. I think the problem is > way more generic, and we will face it multiple times in QEMU. The problem exists outside qemu as well. It is one of the reasons for the popularity of garbage collection IMO, a

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-29 Thread Jan Kiszka
On 2012-08-29 19:13, Avi Kivity wrote: > On 08/27/2012 06:01 PM, Jan Kiszka wrote: >> On 2012-08-27 22:53, Avi Kivity wrote: >>> On 08/27/2012 12:38 PM, Jan Kiszka wrote: >> Even worse, apply >> restrictions on how the dispatched objects, the regions, have to be >> treated because of th

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-29 Thread Avi Kivity
On 08/27/2012 06:01 PM, Jan Kiszka wrote: > On 2012-08-27 22:53, Avi Kivity wrote: > > On 08/27/2012 12:38 PM, Jan Kiszka wrote: > Even worse, apply > restrictions on how the dispatched objects, the regions, have to be > treated because of this. > >>> > >>> Please elaborate. > >> > >

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-28 Thread Paolo Bonzini
Il 28/08/2012 11:42, Jan Kiszka ha scritto: > Context A Context B > - - > object = lookup() > deregister(object) > modify(object) -> invalid state > ...

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-28 Thread Jan Kiszka
On 2012-08-28 05:38, liu ping fan wrote: > On Tue, Aug 28, 2012 at 11:09 AM, liu ping fan wrote: >> On Tue, Aug 28, 2012 at 3:38 AM, Jan Kiszka wrote: >>> On 2012-08-27 20:52, Avi Kivity wrote: On 08/27/2012 11:39 AM, Jan Kiszka wrote: > On 2012-08-27 20:20, Avi Kivity wrote: >> On 0

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread liu ping fan
On Tue, Aug 28, 2012 at 11:09 AM, liu ping fan wrote: > On Tue, Aug 28, 2012 at 3:38 AM, Jan Kiszka wrote: >> On 2012-08-27 20:52, Avi Kivity wrote: >>> On 08/27/2012 11:39 AM, Jan Kiszka wrote: On 2012-08-27 20:20, Avi Kivity wrote: > On 08/27/2012 11:17 AM, Jan Kiszka wrote: >> On

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread liu ping fan
On Tue, Aug 28, 2012 at 3:38 AM, Jan Kiszka wrote: > On 2012-08-27 20:52, Avi Kivity wrote: >> On 08/27/2012 11:39 AM, Jan Kiszka wrote: >>> On 2012-08-27 20:20, Avi Kivity wrote: On 08/27/2012 11:17 AM, Jan Kiszka wrote: > On 2012-08-27 20:09, Avi Kivity wrote: >> On 08/27/2012 10:14

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Jan Kiszka
On 2012-08-27 22:53, Avi Kivity wrote: > On 08/27/2012 12:38 PM, Jan Kiszka wrote: Even worse, apply restrictions on how the dispatched objects, the regions, have to be treated because of this. >>> >>> Please elaborate. >> >> The fact that you can't manipulate a memory region object

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Paolo Bonzini
Il 27/08/2012 22:58, Avi Kivity ha scritto: >> > It's best to start this conversion using very coarse locking. There's >> > no need to start with ultra fine grain locking. > How does it work? You have to drop this main loop lock to dispatch the > callback, so the data structure you use for dispat

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Avi Kivity
On 08/27/2012 12:17 PM, Anthony Liguori wrote: > Avi Kivity writes: > > > On 08/27/2012 09:24 AM, Anthony Liguori wrote: > >> > > >> > I'm sure we should leave existing code alone wherever possible, focusing > >> > on providing alternative versions for those paths that matter. Example: > >> > Most

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Avi Kivity
On 08/27/2012 12:38 PM, Jan Kiszka wrote: > >> Even worse, apply > >> restrictions on how the dispatched objects, the regions, have to be > >> treated because of this. > > > > Please elaborate. > > The fact that you can't manipulate a memory region object arbitrarily > after removing it from the m

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Jan Kiszka
On 2012-08-27 20:52, Avi Kivity wrote: > On 08/27/2012 11:39 AM, Jan Kiszka wrote: >> On 2012-08-27 20:20, Avi Kivity wrote: >>> On 08/27/2012 11:17 AM, Jan Kiszka wrote: On 2012-08-27 20:09, Avi Kivity wrote: > On 08/27/2012 10:14 AM, Jan Kiszka wrote: >>> >>> Deregistration is fi

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Jan Kiszka
On 2012-08-27 21:17, Anthony Liguori wrote: > Avi Kivity writes: > >> On 08/27/2012 09:24 AM, Anthony Liguori wrote: I'm sure we should leave existing code alone wherever possible, focusing on providing alternative versions for those paths that matter. Example: Most timers are

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Anthony Liguori
Avi Kivity writes: > On 08/27/2012 09:24 AM, Anthony Liguori wrote: >> > >> > I'm sure we should leave existing code alone wherever possible, focusing >> > on providing alternative versions for those paths that matter. Example: >> > Most timers are fine under BQL. But some sensitive devices (RTC

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Avi Kivity
On 08/27/2012 11:39 AM, Jan Kiszka wrote: > On 2012-08-27 20:20, Avi Kivity wrote: > > On 08/27/2012 11:17 AM, Jan Kiszka wrote: > >> On 2012-08-27 20:09, Avi Kivity wrote: > >>> On 08/27/2012 10:14 AM, Jan Kiszka wrote: > > > > Deregistration is fine, the problem is destruction. > > >

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Jan Kiszka
On 2012-08-27 20:20, Avi Kivity wrote: > On 08/27/2012 11:17 AM, Jan Kiszka wrote: >> On 2012-08-27 20:09, Avi Kivity wrote: >>> On 08/27/2012 10:14 AM, Jan Kiszka wrote: > > Deregistration is fine, the problem is destruction. > It isn't as you access memory region states that

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Avi Kivity
On 08/27/2012 09:24 AM, Anthony Liguori wrote: > > > > I'm sure we should leave existing code alone wherever possible, focusing > > on providing alternative versions for those paths that matter. Example: > > Most timers are fine under BQL. But some sensitive devices (RTC or HPET > > as clock source

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Avi Kivity
On 08/27/2012 06:19 AM, Anthony Liguori wrote: > Liu Ping Fan writes: > > > From: Liu Ping Fan > > > > Scene: > > obja lies in objA, when objA's ref->0, it will be freed, > > but at that time obja can still be in use. > > > > The real example is: > > typedef struct PCIIDEState { > > PCIDevi

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Avi Kivity
On 08/27/2012 11:17 AM, Jan Kiszka wrote: > On 2012-08-27 20:09, Avi Kivity wrote: > > On 08/27/2012 10:14 AM, Jan Kiszka wrote: > >>> > >>> Deregistration is fine, the problem is destruction. > >>> > >> > >> It isn't as you access memory region states that can change after > >> deregistration. Dev

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Jan Kiszka
On 2012-08-27 20:09, Avi Kivity wrote: > On 08/27/2012 10:14 AM, Jan Kiszka wrote: >>> >>> Deregistration is fine, the problem is destruction. >>> >> >> It isn't as you access memory region states that can change after >> deregistration. Devices can remove memory regions from the mapping, >> alter

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Avi Kivity
On 08/27/2012 10:14 AM, Jan Kiszka wrote: > > > > Deregistration is fine, the problem is destruction. > > > > It isn't as you access memory region states that can change after > deregistration. Devices can remove memory regions from the mapping, > alter and then reinsert them. The last to steps m

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Jan Kiszka
On 2012-08-27 19:09, Avi Kivity wrote: > On 08/27/2012 12:47 AM, Jan Kiszka wrote: >> On 2012-08-27 09:01, Paolo Bonzini wrote: >>> Il 25/08/2012 09:42, liu ping fan ha scritto: >> >> I don't see why MMIO dispatch should hold the IDEBus ref rather than the >> PCIIDEState. >> Wh

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Avi Kivity
On 08/27/2012 12:47 AM, Jan Kiszka wrote: > On 2012-08-27 09:01, Paolo Bonzini wrote: > > Il 25/08/2012 09:42, liu ping fan ha scritto: > > I don't see why MMIO dispatch should hold the IDEBus ref rather than the > PCIIDEState. > > >> When transfer memory_region_init_io() 3rd p

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Jan Kiszka
On 2012-08-27 18:24, Anthony Liguori wrote: > Jan Kiszka writes: > >> On 2012-08-27 17:14, Anthony Liguori wrote: >>> Jan Kiszka writes: >>> On 2012-08-27 15:19, Anthony Liguori wrote: > Liu Ping Fan writes: > >> From: Liu Ping Fan >> >> Scene: >> obja lies in ob

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Anthony Liguori
Jan Kiszka writes: > On 2012-08-27 17:14, Anthony Liguori wrote: >> Jan Kiszka writes: >> >>> On 2012-08-27 15:19, Anthony Liguori wrote: Liu Ping Fan writes: > From: Liu Ping Fan > > Scene: > obja lies in objA, when objA's ref->0, it will be freed, > but at th

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Jan Kiszka
On 2012-08-27 17:14, Anthony Liguori wrote: > Jan Kiszka writes: > >> On 2012-08-27 15:19, Anthony Liguori wrote: >>> Liu Ping Fan writes: >>> From: Liu Ping Fan Scene: obja lies in objA, when objA's ref->0, it will be freed, but at that time obja can still be in use.

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Anthony Liguori
Jan Kiszka writes: > On 2012-08-27 15:19, Anthony Liguori wrote: >> Liu Ping Fan writes: >> >>> From: Liu Ping Fan >>> >>> Scene: >>> obja lies in objA, when objA's ref->0, it will be freed, >>> but at that time obja can still be in use. >>> >>> The real example is: >>> typedef struct PCIIDE

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Jan Kiszka
On 2012-08-27 15:19, Anthony Liguori wrote: > Liu Ping Fan writes: > >> From: Liu Ping Fan >> >> Scene: >> obja lies in objA, when objA's ref->0, it will be freed, >> but at that time obja can still be in use. >> >> The real example is: >> typedef struct PCIIDEState { >> PCIDevice dev; >>

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Anthony Liguori
Liu Ping Fan writes: > From: Liu Ping Fan > > Scene: > obja lies in objA, when objA's ref->0, it will be freed, > but at that time obja can still be in use. > > The real example is: > typedef struct PCIIDEState { > PCIDevice dev; > IDEBus bus[2]; --> create in place > . > } > >

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Jan Kiszka
On 2012-08-27 10:17, liu ping fan wrote: > On Mon, Aug 27, 2012 at 3:47 PM, Jan Kiszka wrote: >> On 2012-08-27 09:01, Paolo Bonzini wrote: >>> Il 25/08/2012 09:42, liu ping fan ha scritto: >> >> I don't see why MMIO dispatch should hold the IDEBus ref rather than the >> PCIIDEState. >>

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread liu ping fan
On Mon, Aug 27, 2012 at 3:47 PM, Jan Kiszka wrote: > On 2012-08-27 09:01, Paolo Bonzini wrote: >> Il 25/08/2012 09:42, liu ping fan ha scritto: > > I don't see why MMIO dispatch should hold the IDEBus ref rather than the > PCIIDEState. > >>> When transfer memory_region_init_io() 3

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Jan Kiszka
On 2012-08-27 09:01, Paolo Bonzini wrote: > Il 25/08/2012 09:42, liu ping fan ha scritto: I don't see why MMIO dispatch should hold the IDEBus ref rather than the PCIIDEState. >> When transfer memory_region_init_io() 3rd para from void* opaque to >> Object* obj, the obj : opaq

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-27 Thread Paolo Bonzini
Il 25/08/2012 09:42, liu ping fan ha scritto: >> > >> > I don't see why MMIO dispatch should hold the IDEBus ref rather than the >> > PCIIDEState. >> > > When transfer memory_region_init_io() 3rd para from void* opaque to > Object* obj, the obj : opaque is not neccessary 1:1 map. For such > situa

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-25 Thread liu ping fan
On Fri, Aug 24, 2012 at 10:42 PM, Paolo Bonzini wrote: > Il 24/08/2012 11:49, Liu Ping Fan ha scritto: >> With this patch, we can protect PCIIDEState from disappearing during >> mmio-dispatch hold the IDEBus->ref. > > I don't see why MMIO dispatch should hold the IDEBus ref rather than the > PCIID

Re: [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-24 Thread Paolo Bonzini
Il 24/08/2012 11:49, Liu Ping Fan ha scritto: > With this patch, we can protect PCIIDEState from disappearing during > mmio-dispatch hold the IDEBus->ref. I don't see why MMIO dispatch should hold the IDEBus ref rather than the PCIIDEState. In the case of the PIIX, the BARs are set up by the PCII

[Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem

2012-08-24 Thread Liu Ping Fan
From: Liu Ping Fan Scene: obja lies in objA, when objA's ref->0, it will be freed, but at that time obja can still be in use. The real example is: typedef struct PCIIDEState { PCIDevice dev; IDEBus bus[2]; --> create in place . } When without big lock protection for mmio-dispa