From: Igor Mammedov <imammedo@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
dgilbert@redhat.com, "Richard Henderson" <rth@twiddle.net>,
"Andreas Färber" <afaerber@suse.de>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Artyom Tarasenko" <atar4qemu@gmail.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>
Subject: Re: [Qemu-devel] [PATCH 9/9] hostmem-ram: use whole path for memory region name with >= 3.1
Date: Mon, 29 Oct 2018 16:16:41 +0100 [thread overview]
Message-ID: <20181029140003.328c7f01@redhat.com> (raw)
In-Reply-To: <20180912125531.32131-10-marcandre.lureau@redhat.com>
On Wed, 12 Sep 2018 16:55:31 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> hostmem-file and hostmem-memfd use the whole object path
maybe add something along the lines:
consisting from user supplied 'id' and ...
> for the
> memory region name, but hostname-ram uses only the path component (the
> basename):
so path component would mean a concrete thing.
>
> qemu -m 1024 -object memory-backend-ram,id=mem,size=1G -numa node,memdev=mem -monitor stdio
> (qemu) info ramblock
> Block Name PSize Offset Used Total
> mem 4 KiB 0x0000000000000000 0x0000000040000000 0x0000000040000000
>
> qemu -m 1024 -object memory-backend-file,id=mem,size=1G,mem-path=/tmp/foo -numa node,memdev=mem -monitor stdio
> (qemu) info ramblock
> Block Name PSize Offset Used Total
> /objects/mem 4 KiB 0x0000000000000000 0x0000000040000000 0x0000000040000000
>
> qemu -m 1024 -object memory-backend-memfd,id=mem,size=1G -numa node,memdev=mem -monitor stdio
> (qemu) info ramblock
> Block Name PSize Offset Used Total
> /objects/mem 4 KiB 0x0000000000000000 0x0000000040000000 0x0000000040000000
>
> Use the whole path name with >= 3.1. Having a consistent naming allow
> to migrate to different hostmem backends.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> include/hw/compat.h | 6 +++++-
> backends/hostmem-ram.c | 47 ++++++++++++++++++++++++++++++++++++++----
> 2 files changed, 48 insertions(+), 5 deletions(-)
>
> diff --git a/include/hw/compat.h b/include/hw/compat.h
> index 6f4d5fc647..8ce7a7057b 100644
> --- a/include/hw/compat.h
> +++ b/include/hw/compat.h
> @@ -2,7 +2,11 @@
> #define HW_COMPAT_H
>
> #define HW_COMPAT_3_0 \
> - /* empty */
> + {\
> + .driver = "memory-backend-ram",\
> + .property = "x-component-name",\
> + .value = "true",\
> + },
>
> #define HW_COMPAT_2_12 \
> {\
> diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c
> index 7ddd08d370..a9eb99cf1b 100644
> --- a/backends/hostmem-ram.c
> +++ b/backends/hostmem-ram.c
> @@ -16,21 +16,56 @@
>
> #define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram"
>
> +typedef struct RamMemoryBackend {
> + HostMemoryBackend parent;
> +
> + bool component_name;
> +} RamMemoryBackend;
> +
> +#define RAM_BACKEND(obj) \
> + OBJECT_CHECK(RamMemoryBackend, (obj), TYPE_MEMORY_BACKEND_RAM)
> +
> +static char *
> +ram_backend_get_name(RamMemoryBackend *self)
> +{
> + /* < 3.1 use the component as memory region name */
I'd drop comment here, it belongs more to HW_COMPAT_...
> + if (self->component_name) {
> + return object_get_canonical_path_component(OBJECT(self));
> + }
> +
> + return object_get_canonical_path(OBJECT(self));
> +}
>
> static void
> ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
> {
> - char *path;
> + char *name;
>
> if (!backend->size) {
> error_setg(errp, "can't create backend with size 0");
> return;
> }
>
> - path = object_get_canonical_path_component(OBJECT(backend));
> - memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), path,
> + name = ram_backend_get_name(RAM_BACKEND(backend));
> + memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), name,
> backend->size, backend->share, errp);
> - g_free(path);
> + g_free(name);
> +}
> +
> +static bool
> +ram_backend_get_component_name(Object *obj, Error **errp)
> +{
> + RamMemoryBackend *self = RAM_BACKEND(obj);
> +
> + return self->component_name;
> +}
> +
> +static void
> +ram_backend_set_component_name(Object *obj, bool value, Error **errp)
> +{
> + RamMemoryBackend *self = RAM_BACKEND(obj);
> +
> + self->component_name = value;
> }
>
> static void
> @@ -39,11 +74,15 @@ ram_backend_class_init(ObjectClass *oc, void *data)
> HostMemoryBackendClass *bc = MEMORY_BACKEND_CLASS(oc);
>
> bc->alloc = ram_backend_memory_alloc;
> + object_class_property_add_bool(oc, "x-component-name",
If we would convert initial RAM to backend/frontend model,
we would actually need to keep current ramblock naming scheme for
ram_backend and even do this /i.e. non path variant/ for other
backends to keep migration stream compatible.
How about adding this property to generic memory-backend and
naming it something like 'x-use-canonical-path-for-ramblock-id'
I wonder if there is a point to use path for ramblock at all,
considering that it is single name space for all backends anyways.
Maybe by default we should just use 'id' everywhere?
> + ram_backend_get_component_name,
> + ram_backend_set_component_name, &error_abort);
+ object_class_property_set_description(...)
> }
>
> static const TypeInfo ram_backend_info = {
> .name = TYPE_MEMORY_BACKEND_RAM,
> .parent = TYPE_MEMORY_BACKEND,
> + .instance_size = sizeof(RamMemoryBackend),
> .class_init = ram_backend_class_init,
> };
>
next prev parent reply other threads:[~2018-10-29 15:17 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-12 12:55 [Qemu-devel] [PATCH 0/9] hostmem-ram: use whole path for region name with >= 3.1 Marc-André Lureau
2018-09-12 12:55 ` [Qemu-devel] [PATCH 1/9] qom/user-creatable: add a few helper macros Marc-André Lureau
2018-10-22 14:33 ` Igor Mammedov
2018-10-26 15:13 ` Eduardo Habkost
2018-10-29 9:56 ` Igor Mammedov
2018-10-30 1:37 ` Eduardo Habkost
2018-10-30 9:26 ` Marc-André Lureau
2018-10-30 14:22 ` Igor Mammedov
2018-10-30 23:07 ` Eduardo Habkost
2018-11-01 12:16 ` Igor Mammedov
2018-11-01 15:02 ` Eduardo Habkost
2018-11-01 15:46 ` Igor Mammedov
2018-09-12 12:55 ` [Qemu-devel] [PATCH 2/9] accel: register global_props like machine globals Marc-André Lureau
2018-10-22 14:47 ` Igor Mammedov
2018-10-22 14:47 ` [Qemu-devel] " Igor Mammedov
2018-09-12 12:55 ` [Qemu-devel] [PATCH 3/9] qdev: move qdev_prop_register_global_list() to tests Marc-André Lureau
2018-10-22 14:51 ` Igor Mammedov
2018-09-12 12:55 ` [Qemu-devel] [PATCH 4/9] qom/globals: move qdev globals to qom Marc-André Lureau
2018-09-12 12:55 ` [Qemu-devel] [PATCH 5/9] qom/globals: generalize object_property_set_globals() Marc-André Lureau
2018-10-29 13:11 ` Igor Mammedov
2018-10-30 12:16 ` Marc-André Lureau
2018-10-30 14:05 ` Igor Mammedov
2018-09-12 12:55 ` [Qemu-devel] [PATCH 6/9] qom/object: set globals when initializing object Marc-André Lureau
2018-10-29 12:20 ` Igor Mammedov
2018-09-12 12:55 ` [Qemu-devel] [PATCH 7/9] tests: add user-creatable test to test-qdev-global-props Marc-André Lureau
2018-09-12 12:55 ` [Qemu-devel] [PATCH 8/9] hw/i386: add pc-i440fx-3.1 & pc-q35-3.1 Marc-André Lureau
2018-09-12 12:55 ` [Qemu-devel] [PATCH 9/9] hostmem-ram: use whole path for memory region name with >= 3.1 Marc-André Lureau
2018-09-13 10:19 ` Dr. David Alan Gilbert
2018-10-29 15:16 ` Igor Mammedov [this message]
2018-10-02 10:24 ` [Qemu-devel] [PATCH 0/9] hostmem-ram: use whole path for " Marc-André Lureau
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=20181029140003.328c7f01@redhat.com \
--to=imammedo@redhat.com \
--cc=afaerber@suse.de \
--cc=atar4qemu@gmail.com \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.