@@ -429,6 +429,7 @@ static void dimm_init(Object *obj)
static void dimm_realize(DeviceState *dev, Error **errp)
{
DIMMDevice *dimm = DIMM(dev);
+ DIMMDeviceClass *ddc = DIMM_GET_CLASS(dimm);
if (!dimm->hostmem) {
error_setg(errp, "'" DIMM_MEMDEV_PROP "' property is not set");
@@ -441,6 +442,10 @@ static void dimm_realize(DeviceState *dev, Error **errp)
dimm->node, nb_numa_nodes ? nb_numa_nodes : 1);
return;
}
+
+ if (ddc->realize) {
+ ddc->realize(dimm, errp);
+ }
}
static void dimm_class_init(ObjectClass *oc, void *data)
@@ -65,6 +65,7 @@ typedef struct DIMMDeviceClass {
DeviceClass parent_class;
/* public */
+ void (*realize)(DIMMDevice *dimm, Error **errp);
MemoryRegion *(*get_memory_region)(DIMMDevice *dimm);
} DIMMDeviceClass;
nvdimm need check if the backend memory is large enough to contain label data and init its memory region when the device is realized, so introduce realize callback which is called after common dimm has been realize Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com> --- hw/mem/dimm.c | 5 +++++ include/hw/mem/dimm.h | 1 + 2 files changed, 6 insertions(+)