nvdimm-utils.c 697 B

123456789101112131415161718192021222324252627282930
  1. #include "qemu/osdep.h"
  2. #include "qemu/nvdimm-utils.h"
  3. #include "hw/mem/nvdimm.h"
  4. static int nvdimm_device_list(Object *obj, void *opaque)
  5. {
  6. GSList **list = opaque;
  7. if (object_dynamic_cast(obj, TYPE_NVDIMM)) {
  8. *list = g_slist_append(*list, DEVICE(obj));
  9. }
  10. object_child_foreach(obj, nvdimm_device_list, opaque);
  11. return 0;
  12. }
  13. /*
  14. * inquire NVDIMM devices and link them into the list which is
  15. * returned to the caller.
  16. *
  17. * Note: it is the caller's responsibility to free the list to avoid
  18. * memory leak.
  19. */
  20. GSList *nvdimm_get_device_list(void)
  21. {
  22. GSList *list = NULL;
  23. object_child_foreach(qdev_get_machine(), nvdimm_device_list, &list);
  24. return list;
  25. }