On Wed, Jan 04, 2017 at 05:04:02PM +0000, Peter Maydell wrote: > On 4 January 2017 at 03:28, David Gibson <da...@gibson.dropbear.id.au> wrote: > > On Tue, Jan 03, 2017 at 10:02:21PM +0800, 赵小强 wrote: > >> Hi,david: > >> > >> To my understanding,what must be put in the realize function is > >> code which depends on property values. What's the benefit of > >> moving memory region initialization into realize function? I can > >> not figure out, can you make some explanations? > > > > If nothing else it's better in realize() for consistency with other > > devices. > > I'm not sure we're terribly consistent at all, really. My understanding > was about the same as 赵小强 -- put stuff in init unless it has to > go in realize because it depends on properties or might fail or > has permanent effects on the simulation. > Lots of existing devices do memory_region_init* calls in > their init functions. > We should probably write down our preferences somewhere, perhaps > http://wiki.qemu.org/Documentation/QOMConventions > > > I'm not familiar enough with the details to be sure, but I also think > > it's not safe in instance_init. Once memory regions are registered, > > the device can potentially interact with other devices in the virtual > > machine. realize() is sequenced to expect that, instance_init is not. > > Hmm, that doesn't sound right to me. The other devices will only > interact with the memory regions when the calling code has > finished doing the create/realize/map memory regions sequence -- > an MR on its own doesn't do anything unless somebody maps it into > an address space.
Huh. Ok, I guess I was wrong. Alright, 赵小强, feel free to repost addressing just the other comments and I'll merge. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature