diff options
author | Shivaprasad G Bhat <sbhat@linux.ibm.com> | 2020-02-09 22:56:02 -0600 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2020-02-21 09:15:03 +1100 |
commit | 3f350f6bb36233be50fc2bc18dc78b6a948a5dbe (patch) | |
tree | 2307a1b3b0fb3ba7687ed10d3dfe94b8ae691b14 /util/nvdimm-utils.c | |
parent | a78492681995ad4b46a2b6e30bb36935dff5ffb1 (diff) |
mem: move nvdimm_device_list to utilities
nvdimm_device_list is required for parsing the list for devices
in subsequent patches. Move it to common utility area.
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <158131055857.2897.15658377276504711773.stgit@lep8c.aus.stglabs.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'util/nvdimm-utils.c')
-rw-r--r-- | util/nvdimm-utils.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/util/nvdimm-utils.c b/util/nvdimm-utils.c new file mode 100644 index 0000000000..5cc768ca47 --- /dev/null +++ b/util/nvdimm-utils.c @@ -0,0 +1,29 @@ +#include "qemu/nvdimm-utils.h" +#include "hw/mem/nvdimm.h" + +static int nvdimm_device_list(Object *obj, void *opaque) +{ + GSList **list = opaque; + + if (object_dynamic_cast(obj, TYPE_NVDIMM)) { + *list = g_slist_append(*list, DEVICE(obj)); + } + + object_child_foreach(obj, nvdimm_device_list, opaque); + return 0; +} + +/* + * inquire NVDIMM devices and link them into the list which is + * returned to the caller. + * + * Note: it is the caller's responsibility to free the list to avoid + * memory leak. + */ +GSList *nvdimm_get_device_list(void) +{ + GSList *list = NULL; + + object_child_foreach(qdev_get_machine(), nvdimm_device_list, &list); + return list; +} |