Re: [PATCH 3/4] device-core: use atomic_set on .realized property

2020-05-11 Thread Maxim Levitsky
On Mon, 2020-05-11 at 13:11 +0200, Paolo Bonzini wrote: > On 11/05/20 13:00, Maxim Levitsky wrote: > > On second thought, I think both cases matter, after I examined the device > > removal case. > > In device removal case, the device is first un-realized and then removed > > from the bus, > > so

Re: [PATCH 3/4] device-core: use atomic_set on .realized property

2020-05-11 Thread Paolo Bonzini
On 11/05/20 13:00, Maxim Levitsky wrote: > On second thought, I think both cases matter, after I examined the device > removal case. > In device removal case, the device is first un-realized and then removed from > the bus, > so just like in device hotplug case, the scsi_device_find can give you

Re: [PATCH 3/4] device-core: use atomic_set on .realized property

2020-05-11 Thread Maxim Levitsky
On Mon, 2020-05-04 at 13:22 +0200, Paolo Bonzini wrote: > On 04/05/20 12:45, Stefan Hajnoczi wrote: > > > @@ -983,7 +983,7 @@ static void device_set_realized(Object *obj, bool > > > value, Error **errp) > > > } > > > > > > assert(local_err == NULL); > > > -dev->realized = value; >

Re: [PATCH 3/4] device-core: use atomic_set on .realized property

2020-05-04 Thread Maxim Levitsky
On Mon, 2020-05-04 at 13:22 +0200, Paolo Bonzini wrote: > On 04/05/20 12:45, Stefan Hajnoczi wrote: > > > @@ -983,7 +983,7 @@ static void device_set_realized(Object *obj, bool > > > value, Error **errp) > > > } > > > > > > assert(local_err == NULL); > > > -dev->realized = value; >

Re: [PATCH 3/4] device-core: use atomic_set on .realized property

2020-05-04 Thread Paolo Bonzini
On 04/05/20 12:45, Stefan Hajnoczi wrote: >> @@ -983,7 +983,7 @@ static void device_set_realized(Object *obj, bool value, >> Error **errp) >> } >> >> assert(local_err == NULL); >> -dev->realized = value; >> +atomic_set(&dev->realized, value); > A memory barrier is probably need

Re: [PATCH 3/4] device-core: use atomic_set on .realized property

2020-05-04 Thread Stefan Hajnoczi
On Thu, Apr 16, 2020 at 11:36:23PM +0300, Maxim Levitsky wrote: > Some code might race with placement of new devices on a bus. > We currently first place a (unrealized) device on the bus > and then realize it. > > As a workaround, users that scan the child device list, can > check the realized pro

[PATCH 3/4] device-core: use atomic_set on .realized property

2020-04-16 Thread Maxim Levitsky
Some code might race with placement of new devices on a bus. We currently first place a (unrealized) device on the bus and then realize it. As a workaround, users that scan the child device list, can check the realized property to see if it is safe to access such a device. Use an atomic write here