On 04.02.2016 15:23, Cornelia Huck wrote:
On Thu, 4 Feb 2016 14:37:22 +0300
Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> wrote:
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 <vsement...@virtuozzo.com>
CC: Stefan Hajnoczi <stefa...@redhat.com>
CC: Xiao Guangrong <guangrong.x...@linux.intel.com>
CC: "Michael S. Tsirkin" <m...@redhat.com>
CC: Igor Mammedov <imamm...@redhat.com>
CC: Eric Blake <ebl...@redhat.com>
CC: Markus Armbruster <arm...@redhat.com>
---
hw/virtio/virtio-balloon.c | 23 ++++++-----------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 6a4c4d2..b9c1964 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -296,26 +296,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);
This will break the build for !CONFIG_MEM_HOTPLUG, as you didn't
provide a stubbed-out version of this function.
Ok, thanks, will add.
Also: it is already broken because of pc_dimm_memory_plug and
pc_dimm_memory_unplug
+ for (item = list; item; item = g_slist_next(item)) {
+ PCDIMMDevice *dimm = item->data;
+ size += object_property_get_int(OBJECT(dimm), PC_DIMM_SIZE_PROP, NULL);
}
- qapi_free_MemoryDeviceInfoList(info_list);
+ g_slist_free(list);
return size;
}
--
Best regards,
Vladimir