From: David Hildenbrand <david@redhat.com>
To: "Maciej S. Szmigiero" <mail@maciej.szmigiero.name>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Eduardo Habkost <eduardo@habkost.net>
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Eric Blake" <eblake@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH v7 5/7] qapi: Add query-memory-devices support to hv-balloon
Date: Wed, 27 Sep 2023 12:52:16 +0200 [thread overview]
Message-ID: <1de1dcaf-7419-96f8-8ac5-eee5f1e336c4@redhat.com> (raw)
In-Reply-To: <a9f908446234de087ab5857f53a9449173f809dc.1693240836.git.maciej.szmigiero@oracle.com>
On 28.08.23 18:48, Maciej S. Szmigiero wrote:
> From: "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>
>
> Used by the driver to report its provided memory state information.
>
> Co-developed-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
> ---
> hw/core/machine-hmp-cmds.c | 15 +++++++++++++++
> hw/hyperv/hv-balloon.c | 27 +++++++++++++++++++++++++-
> qapi/machine.json | 39 ++++++++++++++++++++++++++++++++++++--
> 3 files changed, 78 insertions(+), 3 deletions(-)
>
> diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
> index c3e55ef9e9cd..7b06ed35decb 100644
> --- a/hw/core/machine-hmp-cmds.c
> +++ b/hw/core/machine-hmp-cmds.c
> @@ -247,6 +247,7 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
> MemoryDeviceInfo *value;
> PCDIMMDeviceInfo *di;
> SgxEPCDeviceInfo *se;
> + HvBalloonDeviceInfo *hi;
>
> for (info = info_list; info; info = info->next) {
> value = info->value;
> @@ -304,6 +305,20 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
> monitor_printf(mon, " node: %" PRId64 "\n", se->node);
> monitor_printf(mon, " memdev: %s\n", se->memdev);
> break;
> + case MEMORY_DEVICE_INFO_KIND_HV_BALLOON:
> + hi = value->u.hv_balloon.data;
> + monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
> + MemoryDeviceInfoKind_str(value->type),
> + hi->id ? hi->id : "");
> + if (hi->has_memaddr) {
> + monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n",
> + hi->memaddr);
> + }
> + monitor_printf(mon, " max-size: %" PRIu64 "\n", hi->max_size);
> + if (hi->memdev) {
> + monitor_printf(mon, " memdev: %s\n", hi->memdev);
> + }
> + break;
> default:
> g_assert_not_reached();
> }
> diff --git a/hw/hyperv/hv-balloon.c b/hw/hyperv/hv-balloon.c
> index 4d87f99375b5..c384f23a3b5e 100644
> --- a/hw/hyperv/hv-balloon.c
> +++ b/hw/hyperv/hv-balloon.c
> @@ -1622,6 +1622,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)
> {
> @@ -1709,5 +1734,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;
> }
> diff --git a/qapi/machine.json b/qapi/machine.json
> index a08b6576cac6..5ede977cf2bc 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -1265,6 +1265,29 @@
> }
> }
>
> +##
> +# @HvBalloonDeviceInfo:
> +#
> +# hv-balloon provided memory state information
> +#
> +# @id: device's ID
> +#
> +# @memaddr: physical address in memory, where device is mapped
> +#
> +# @max-size: the maximum size of memory that the device can provide
> +#
> +# @memdev: memory backend linked with device
> +#
> +# Since: 8.2
> +##
> +{ 'struct': 'HvBalloonDeviceInfo',
> + 'data': { '*id': 'str',
> + '*memaddr': 'size',
> + 'max-size': 'size',
> + '*memdev': 'str'
> + }
> +}
> +
> ##
> # @MemoryDeviceInfoKind:
> #
> @@ -1276,10 +1299,13 @@
> #
> # @sgx-epc: since 6.2.
> #
> +# @hv-balloon: since 8.2.
> +#
> # Since: 2.1
> ##
> { 'enum': 'MemoryDeviceInfoKind',
> - 'data': [ 'dimm', 'nvdimm', 'virtio-pmem', 'virtio-mem', 'sgx-epc' ] }
> + 'data': [ 'dimm', 'nvdimm', 'virtio-pmem', 'virtio-mem', 'sgx-epc',
> + 'hv-balloon' ] }
>
> ##
> # @PCDIMMDeviceInfoWrapper:
> @@ -1313,6 +1339,14 @@
> { 'struct': 'SgxEPCDeviceInfoWrapper',
> 'data': { 'data': 'SgxEPCDeviceInfo' } }
>
> +##
> +# @HvBalloonDeviceInfoWrapper:
> +#
> +# Since: 8.2
> +##
> +{ 'struct': 'HvBalloonDeviceInfoWrapper',
> + 'data': { 'data': 'HvBalloonDeviceInfo' } }
> +
> ##
> # @MemoryDeviceInfo:
> #
> @@ -1327,7 +1361,8 @@
> 'nvdimm': 'PCDIMMDeviceInfoWrapper',
> 'virtio-pmem': 'VirtioPMEMDeviceInfoWrapper',
> 'virtio-mem': 'VirtioMEMDeviceInfoWrapper',
> - 'sgx-epc': 'SgxEPCDeviceInfoWrapper'
> + 'sgx-epc': 'SgxEPCDeviceInfoWrapper',
> + 'hv-balloon': 'HvBalloonDeviceInfoWrapper'
> }
> }
>
>
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2023-09-27 10:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-28 16:48 [PATCH v7 0/7] Hyper-V Dynamic Memory Protocol driver (hv-balloon 🎈️) Maciej S. Szmigiero
2023-08-28 16:48 ` [PATCH v7 1/7] memory-device: Support empty memory devices Maciej S. Szmigiero
2023-08-28 16:48 ` [PATCH v7 2/7] memory-device: Drop size alignment check Maciej S. Szmigiero
2023-08-28 16:48 ` [PATCH v7 3/7] Add Hyper-V Dynamic Memory Protocol definitions Maciej S. Szmigiero
2023-09-27 10:54 ` David Hildenbrand
2023-08-28 16:48 ` [PATCH v7 4/7] Add a Hyper-V Dynamic Memory Protocol driver (hv-balloon) Maciej S. Szmigiero
2023-08-28 16:48 ` [PATCH v7 5/7] qapi: Add query-memory-devices support to hv-balloon Maciej S. Szmigiero
2023-09-25 11:16 ` Markus Armbruster
2023-09-27 10:52 ` David Hildenbrand [this message]
2023-08-28 16:48 ` [PATCH v7 6/7] qapi: Add HV_BALLOON_STATUS_REPORT event and its QMP query command Maciej S. Szmigiero
2023-09-25 11:49 ` Markus Armbruster
2023-09-25 17:12 ` Maciej S. Szmigiero
2023-09-26 6:38 ` Markus Armbruster
2023-08-28 16:48 ` [PATCH v7 7/7] hw/i386/pc: Support hv-balloon Maciej S. Szmigiero
2023-09-27 10:49 ` David Hildenbrand
2023-10-18 8:00 ` [PATCH v7 0/7] Hyper-V Dynamic Memory Protocol driver (hv-balloon 🎈) David Hildenbrand
2023-10-18 8:45 ` Maciej S. Szmigiero
2023-10-18 9:28 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1de1dcaf-7419-96f8-8ac5-eee5f1e336c4@redhat.com \
--to=david@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=mail@maciej.szmigiero.name \
--cc=marcandre.lureau@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).