Message ID | 1446184587-142784-21-git-send-email-guangrong.xiao@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 30.10.2015 08:56, Xiao Guangrong wrote: > 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(+) > > diff --git a/hw/mem/dimm.c b/hw/mem/dimm.c > index 44447d1..0ae23ce 100644 > --- a/hw/mem/dimm.c > +++ b/hw/mem/dimm.c > @@ -426,6 +426,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"); > @@ -438,6 +439,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) > diff --git a/include/hw/mem/dimm.h b/include/hw/mem/dimm.h > index 50f768a..72ec24c 100644 > --- a/include/hw/mem/dimm.h > +++ b/include/hw/mem/dimm.h > @@ -65,6 +65,7 @@ typedef struct DIMMDeviceClass { > DeviceClass parent_class; > > /* public */ > + void (*realize)(DIMMDevice *dimm, Error **errp); > MemoryRegion *(*get_memory_region)(DIMMDevice *dimm); > } DIMMDeviceClass; > Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
diff --git a/hw/mem/dimm.c b/hw/mem/dimm.c index 44447d1..0ae23ce 100644 --- a/hw/mem/dimm.c +++ b/hw/mem/dimm.c @@ -426,6 +426,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"); @@ -438,6 +439,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) diff --git a/include/hw/mem/dimm.h b/include/hw/mem/dimm.h index 50f768a..72ec24c 100644 --- a/include/hw/mem/dimm.h +++ b/include/hw/mem/dimm.h @@ -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(+)