diff options
author | Maciej S. Szmigiero <maciej.szmigiero@oracle.com> | 2023-08-23 23:31:35 +0200 |
---|---|---|
committer | Maciej S. Szmigiero <maciej.szmigiero@oracle.com> | 2023-11-06 14:08:10 +0100 |
commit | 16dff2f9bb877bd1e147b5c5d9966d5a1d336c8c (patch) | |
tree | 9b7430bcdd16d689bd67c8c851b7a4c68e5c8d37 /hw/hyperv | |
parent | 99a4706ae81efa51b21871af643626730a6719d4 (diff) |
qapi: Add query-memory-devices support to hv-balloon
Used by the driver to report its provided memory state information.
Co-developed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Diffstat (limited to 'hw/hyperv')
-rw-r--r-- | hw/hyperv/hv-balloon.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/hw/hyperv/hv-balloon.c b/hw/hyperv/hv-balloon.c index 5999f1127d..44a8d15cc8 100644 --- a/hw/hyperv/hv-balloon.c +++ b/hw/hyperv/hv-balloon.c @@ -1625,6 +1625,31 @@ static MemoryRegion *hv_balloon_md_get_memory_region(MemoryDeviceState *md, return balloon->mr; } +static void hv_balloon_md_fill_device_info(const MemoryDeviceState *md, + MemoryDeviceInfo *info) +{ + HvBalloonDeviceInfo *hi = g_new0(HvBalloonDeviceInfo, 1); + const HvBalloon *balloon = HV_BALLOON(md); + DeviceState *dev = DEVICE(md); + + if (dev->id) { + hi->id = g_strdup(dev->id); + } + + if (balloon->hostmem) { + hi->memdev = object_get_canonical_path(OBJECT(balloon->hostmem)); + hi->memaddr = balloon->addr; + hi->has_memaddr = true; + hi->max_size = memory_region_size(balloon->mr); + /* TODO: expose current provided size or something else? */ + } else { + hi->max_size = 0; + } + + info->u.hv_balloon.data = hi; + info->type = MEMORY_DEVICE_INFO_KIND_HV_BALLOON; +} + static void hv_balloon_decide_memslots(MemoryDeviceState *md, unsigned int limit) { @@ -1712,5 +1737,5 @@ static void hv_balloon_class_init(ObjectClass *klass, void *data) mdc->get_memory_region = hv_balloon_md_get_memory_region; mdc->decide_memslots = hv_balloon_decide_memslots; mdc->get_memslots = hv_balloon_get_memslots; - /* implement fill_device_info */ + mdc->fill_device_info = hv_balloon_md_fill_device_info; } |