Skip to content

Commit

Permalink
pc-dimm: introduce realize callback
Browse files Browse the repository at this point in the history
nvdimm needs to  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>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
Xiao Guangrong authored and mstsirkin committed Jun 7, 2016
1 parent 3c3e88a commit 9f318f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hw/mem/pc-dimm.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ static void pc_dimm_init(Object *obj)
static void pc_dimm_realize(DeviceState *dev, Error **errp)
{
PCDIMMDevice *dimm = PC_DIMM(dev);
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);

if (!dimm->hostmem) {
error_setg(errp, "'" PC_DIMM_MEMDEV_PROP "' property is not set");
Expand All @@ -412,6 +413,10 @@ static void pc_dimm_realize(DeviceState *dev, Error **errp)
dimm->node, nb_numa_nodes ? nb_numa_nodes : 1);
return;
}

if (ddc->realize) {
ddc->realize(dimm, errp);
}
}

static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm)
Expand Down
3 changes: 3 additions & 0 deletions include/hw/mem/pc-dimm.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ typedef struct PCDIMMDevice {

/**
* PCDIMMDeviceClass:
* @realize: called after common dimm is realized so that the dimm based
* devices get the chance to do specified operations.
* @get_memory_region: returns #MemoryRegion associated with @dimm which
* is directly mapped into the physical address space of guest
*/
Expand All @@ -66,6 +68,7 @@ typedef struct PCDIMMDeviceClass {
DeviceClass parent_class;

/* public */
void (*realize)(PCDIMMDevice *dimm, Error **errp);
MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm);
} PCDIMMDeviceClass;

Expand Down

0 comments on commit 9f318f8

Please sign in to comment.