diff mbox

[v6,20/33] dimm: introduce realize callback

Message ID 1446184587-142784-21-git-send-email-guangrong.xiao@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Xiao Guangrong Oct. 30, 2015, 5:56 a.m. UTC
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(+)

Comments

Vladimir Sementsov-Ogievskiy Oct. 31, 2015, 11:22 a.m. UTC | #1
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 mbox

Patch

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;