diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2016-02-10 11:49:25 +0300 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2016-02-25 13:14:18 +0200 |
commit | e8dc06d225b0a7bbe3dc54495ae001b786a54ee5 (patch) | |
tree | 3f87861c49f2198990b056ed4f00a7893e20bf26 | |
parent | 39de99843e4c15504812e12807728339c54b9194 (diff) |
virtio-balloon: rewrite get_current_ram_size()
Use pc_dimm_built_list() instead of qmp_pc_dimm_device_list()
Actually, Qapi is not related to this internal helper.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r-- | hw/virtio/virtio-balloon.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index d6d7e96aa4..388e87336a 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -307,26 +307,15 @@ static void virtio_balloon_get_config(VirtIODevice *vdev, uint8_t *config_data) static ram_addr_t get_current_ram_size(void) { - MemoryDeviceInfoList *info_list = NULL; - MemoryDeviceInfoList **prev = &info_list; - MemoryDeviceInfoList *info; + GSList *list = NULL, *item; ram_addr_t size = ram_size; - qmp_pc_dimm_device_list(qdev_get_machine(), &prev); - for (info = info_list; info; info = info->next) { - MemoryDeviceInfo *value = info->value; - - if (value) { - switch (value->type) { - case MEMORY_DEVICE_INFO_KIND_DIMM: - size += value->u.dimm->size; - break; - default: - break; - } - } + pc_dimm_build_list(qdev_get_machine(), &list); + for (item = list; item; item = g_slist_next(item)) { + Object *obj = OBJECT(item->data); + size += object_property_get_int(obj, PC_DIMM_SIZE_PROP, &error_abort); } - qapi_free_MemoryDeviceInfoList(info_list); + g_slist_free(list); return size; } |