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>
This commit is contained in:
Vladimir Sementsov-Ogievskiy 2016-02-10 11:49:25 +03:00 committed by Michael S. Tsirkin
parent 39de99843e
commit e8dc06d225

View File

@ -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) static ram_addr_t get_current_ram_size(void)
{ {
MemoryDeviceInfoList *info_list = NULL; GSList *list = NULL, *item;
MemoryDeviceInfoList **prev = &info_list;
MemoryDeviceInfoList *info;
ram_addr_t size = ram_size; ram_addr_t size = ram_size;
qmp_pc_dimm_device_list(qdev_get_machine(), &prev); pc_dimm_build_list(qdev_get_machine(), &list);
for (info = info_list; info; info = info->next) { for (item = list; item; item = g_slist_next(item)) {
MemoryDeviceInfo *value = info->value; Object *obj = OBJECT(item->data);
size += object_property_get_int(obj, PC_DIMM_SIZE_PROP, &error_abort);
if (value) {
switch (value->type) {
case MEMORY_DEVICE_INFO_KIND_DIMM:
size += value->u.dimm->size;
break;
default:
break;
}
}
} }
qapi_free_MemoryDeviceInfoList(info_list); g_slist_free(list);
return size; return size;
} }