On 07/07/2017 13:58, Peter Maydell wrote: >>> >>> memory_region_init_ram(mr, owner, name, ram_size, &err); >>> if (err) { >>> error_propagate(errp, err); >>> return; >>> } >>> /* Note that owner_dev may be NULL if owner is not a DeviceState; >>> * in that case this is equivalent to calling >>> vmstate_register_ram_global(). >>> */ >>> owner_dev = object_dynamic_cast(owner, TYPE_DEVICE); >>> vmstate_register_ram(mr, owner_dev); >> Maybe, for memory_region_init_ram only, the owner argument can be made a >> DeviceState (or NULL)? > Hmm. I don't much like the way that breaks the symmetry of the > API with the other memory region init functions, and it makes > it harder to script the conversion. I'd rather keep it as an > Object*, especially since the only purpose of the pointer is to > make the RAM name unique for migration purposes.
In that case, I would assert the object is a device and add a TODO to support non-device objects. Paolo > (Better still would be if we had a uniquification mechanism > for Objects...)