aboutsummaryrefslogtreecommitdiff
path: root/hw/mem
diff options
context:
space:
mode:
Diffstat (limited to 'hw/mem')
-rw-r--r--hw/mem/pc-dimm.c91
1 files changed, 52 insertions, 39 deletions
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 6e74b61cb6..51350d9c2d 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -20,6 +20,7 @@
#include "qemu/osdep.h"
#include "hw/mem/pc-dimm.h"
+#include "hw/mem/nvdimm.h"
#include "qapi/error.h"
#include "qemu/config-file.h"
#include "qapi/visitor.h"
@@ -162,45 +163,6 @@ uint64_t get_plugged_memory_size(void)
return pc_existing_dimms_capacity(&error_abort);
}
-int qmp_pc_dimm_device_list(Object *obj, void *opaque)
-{
- MemoryDeviceInfoList ***prev = opaque;
-
- if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
- DeviceState *dev = DEVICE(obj);
-
- if (dev->realized) {
- MemoryDeviceInfoList *elem = g_new0(MemoryDeviceInfoList, 1);
- MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
- PCDIMMDeviceInfo *di = g_new0(PCDIMMDeviceInfo, 1);
- DeviceClass *dc = DEVICE_GET_CLASS(obj);
- PCDIMMDevice *dimm = PC_DIMM(obj);
-
- if (dev->id) {
- di->has_id = true;
- di->id = g_strdup(dev->id);
- }
- di->hotplugged = dev->hotplugged;
- di->hotpluggable = dc->hotpluggable;
- di->addr = dimm->addr;
- di->slot = dimm->slot;
- di->node = dimm->node;
- di->size = object_property_get_uint(OBJECT(dimm), PC_DIMM_SIZE_PROP,
- NULL);
- di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
-
- info->u.dimm.data = di;
- elem->value = info;
- elem->next = NULL;
- **prev = elem;
- *prev = &elem->next;
- }
- }
-
- object_child_foreach(obj, qmp_pc_dimm_device_list, opaque);
- return 0;
-}
-
static int pc_dimm_slot2bitmap(Object *obj, void *opaque)
{
unsigned long *bitmap = opaque;
@@ -276,6 +238,57 @@ static int pc_dimm_built_list(Object *obj, void *opaque)
return 0;
}
+MemoryDeviceInfoList *qmp_pc_dimm_device_list(void)
+{
+ GSList *dimms = NULL, *item;
+ MemoryDeviceInfoList *list = NULL, *prev = NULL;
+
+ object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &dimms);
+
+ for (item = dimms; item; item = g_slist_next(item)) {
+ PCDIMMDevice *dimm = PC_DIMM(item->data);
+ Object *obj = OBJECT(dimm);
+ MemoryDeviceInfoList *elem = g_new0(MemoryDeviceInfoList, 1);
+ MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
+ PCDIMMDeviceInfo *di = g_new0(PCDIMMDeviceInfo, 1);
+ bool is_nvdimm = object_dynamic_cast(obj, TYPE_NVDIMM);
+ DeviceClass *dc = DEVICE_GET_CLASS(obj);
+ DeviceState *dev = DEVICE(obj);
+
+ if (dev->id) {
+ di->has_id = true;
+ di->id = g_strdup(dev->id);
+ }
+ di->hotplugged = dev->hotplugged;
+ di->hotpluggable = dc->hotpluggable;
+ di->addr = dimm->addr;
+ di->slot = dimm->slot;
+ di->node = dimm->node;
+ di->size = object_property_get_uint(obj, PC_DIMM_SIZE_PROP, NULL);
+ di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
+
+ if (!is_nvdimm) {
+ info->u.dimm.data = di;
+ info->type = MEMORY_DEVICE_INFO_KIND_DIMM;
+ } else {
+ info->u.nvdimm.data = di;
+ info->type = MEMORY_DEVICE_INFO_KIND_NVDIMM;
+ }
+ elem->value = info;
+ elem->next = NULL;
+ if (prev) {
+ prev->next = elem;
+ } else {
+ list = elem;
+ }
+ prev = elem;
+ }
+
+ g_slist_free(dimms);
+
+ return list;
+}
+
uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
uint64_t address_space_size,
uint64_t *hint, uint64_t align, uint64_t size,