Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
On Mon, Jun 09, 2014 at 10:44:02AM +0800, Hu Tao wrote: On Fri, Jun 06, 2014 at 02:48:15PM +0200, Igor Mammedov wrote: On Fri, 6 Jun 2014 17:29:38 +0800 Hu Tao hu...@cn.fujitsu.com wrote: On Fri, May 30, 2014 at 09:59:55AM +0200, Igor Mammedov wrote: On Fri, 30 May 2014 00:05:51 +1000 Peter Crosthwaite peter.crosthwa...@xilinx.com wrote: On Tue, May 27, 2014 at 11:01 PM, Igor Mammedov imamm...@redhat.com wrote: Provides framework for splitting host RAM allocation/ policies into a separate backend that could be used by devices. Initially only legacy RAM backend is provided, which uses memory_region_init_ram() allocator and compatible with every CLI option that affects memory_region_init_ram(). Signed-off-by: Igor Mammedov imamm...@redhat.com Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- v4: - don't use nonexisting anymore error_is_set() v3: - fix path leak use object_get_canonical_path_component() for getting object name v2: - reuse UserCreatable interface instead of custom callbacks --- backends/Makefile.objs |2 + backends/hostmem-ram.c | 54 ++ backends/hostmem.c | 113 ++ include/sysemu/hostmem.h | 60 4 files changed, 229 insertions(+), 0 deletions(-) create mode 100644 backends/hostmem-ram.c create mode 100644 backends/hostmem.c create mode 100644 include/sysemu/hostmem.h diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 591ddcf..7fb7acd 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -6,3 +6,5 @@ common-obj-$(CONFIG_BRLAPI) += baum.o baum.o-cflags := $(SDL_CFLAGS) common-obj-$(CONFIG_TPM) += tpm.o + +common-obj-y += hostmem.o hostmem-ram.o diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c new file mode 100644 index 000..cbf7e5a --- /dev/null +++ b/backends/hostmem-ram.c @@ -0,0 +1,54 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include qom/object_interfaces.h + +#define TYPE_MEMORY_BACKEND_RAM memory-ram + + +static void +ram_backend_memory_init(UserCreatable *uc, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(uc); +char *path; + +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(backend-mr, OBJECT(backend), path, Passing the full canonical path as the name of memory region is redundant as that information is already passed via the owner argument. It should just be a shorthand. + backend-size); +g_free(path); +} + +static void +ram_backend_class_init(ObjectClass *oc, void *data) +{ +UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + +ucc-complete = ram_backend_memory_init; +} + +static const TypeInfo ram_backend_info = { +.name = TYPE_MEMORY_BACKEND_RAM, +.parent = TYPE_MEMORY_BACKEND, +.class_init = ram_backend_class_init, +}; + +static void register_types(void) +{ +type_register_static(ram_backend_info); +} + +type_init(register_types); diff --git a/backends/hostmem.c b/backends/hostmem.c new file mode 100644 index 000..8a34b0f --- /dev/null +++ b/backends/hostmem.c @@ -0,0 +1,113 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include sysemu/sysemu.h +#include qapi/visitor.h +#include qapi/qmp/qerror.h +#include qemu/config-file.h +#include qom/object_interfaces.h + +static void +hostmemory_backend_get_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend =
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
On Mon, Jun 9, 2014 at 12:44 PM, Hu Tao hu...@cn.fujitsu.com wrote: On Fri, Jun 06, 2014 at 02:48:15PM +0200, Igor Mammedov wrote: On Fri, 6 Jun 2014 17:29:38 +0800 Hu Tao hu...@cn.fujitsu.com wrote: On Fri, May 30, 2014 at 09:59:55AM +0200, Igor Mammedov wrote: On Fri, 30 May 2014 00:05:51 +1000 Peter Crosthwaite peter.crosthwa...@xilinx.com wrote: On Tue, May 27, 2014 at 11:01 PM, Igor Mammedov imamm...@redhat.com wrote: Provides framework for splitting host RAM allocation/ policies into a separate backend that could be used by devices. Initially only legacy RAM backend is provided, which uses memory_region_init_ram() allocator and compatible with every CLI option that affects memory_region_init_ram(). Signed-off-by: Igor Mammedov imamm...@redhat.com Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- v4: - don't use nonexisting anymore error_is_set() v3: - fix path leak use object_get_canonical_path_component() for getting object name v2: - reuse UserCreatable interface instead of custom callbacks --- backends/Makefile.objs |2 + backends/hostmem-ram.c | 54 ++ backends/hostmem.c | 113 ++ include/sysemu/hostmem.h | 60 4 files changed, 229 insertions(+), 0 deletions(-) create mode 100644 backends/hostmem-ram.c create mode 100644 backends/hostmem.c create mode 100644 include/sysemu/hostmem.h diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 591ddcf..7fb7acd 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -6,3 +6,5 @@ common-obj-$(CONFIG_BRLAPI) += baum.o baum.o-cflags := $(SDL_CFLAGS) common-obj-$(CONFIG_TPM) += tpm.o + +common-obj-y += hostmem.o hostmem-ram.o diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c new file mode 100644 index 000..cbf7e5a --- /dev/null +++ b/backends/hostmem-ram.c @@ -0,0 +1,54 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include qom/object_interfaces.h + +#define TYPE_MEMORY_BACKEND_RAM memory-ram + + +static void +ram_backend_memory_init(UserCreatable *uc, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(uc); +char *path; + +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(backend-mr, OBJECT(backend), path, Passing the full canonical path as the name of memory region is redundant as that information is already passed via the owner argument. It should just be a shorthand. + backend-size); +g_free(path); +} + +static void +ram_backend_class_init(ObjectClass *oc, void *data) +{ +UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + +ucc-complete = ram_backend_memory_init; +} + +static const TypeInfo ram_backend_info = { +.name = TYPE_MEMORY_BACKEND_RAM, +.parent = TYPE_MEMORY_BACKEND, +.class_init = ram_backend_class_init, +}; + +static void register_types(void) +{ +type_register_static(ram_backend_info); +} + +type_init(register_types); diff --git a/backends/hostmem.c b/backends/hostmem.c new file mode 100644 index 000..8a34b0f --- /dev/null +++ b/backends/hostmem.c @@ -0,0 +1,113 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include sysemu/sysemu.h +#include qapi/visitor.h +#include qapi/qmp/qerror.h +#include qemu/config-file.h +#include qom/object_interfaces.h + +static void +hostmemory_backend_get_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +uint64_t value = backend-size; + +visit_type_size(v, value, name, errp); +} + +static void
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
On Mon, Jun 09, 2014 at 06:54:54PM +1000, Peter Crosthwaite wrote: On Mon, Jun 9, 2014 at 12:44 PM, Hu Tao hu...@cn.fujitsu.com wrote: On Fri, Jun 06, 2014 at 02:48:15PM +0200, Igor Mammedov wrote: On Fri, 6 Jun 2014 17:29:38 +0800 Hu Tao hu...@cn.fujitsu.com wrote: On Fri, May 30, 2014 at 09:59:55AM +0200, Igor Mammedov wrote: On Fri, 30 May 2014 00:05:51 +1000 Peter Crosthwaite peter.crosthwa...@xilinx.com wrote: On Tue, May 27, 2014 at 11:01 PM, Igor Mammedov imamm...@redhat.com wrote: Provides framework for splitting host RAM allocation/ policies into a separate backend that could be used by devices. Initially only legacy RAM backend is provided, which uses memory_region_init_ram() allocator and compatible with every CLI option that affects memory_region_init_ram(). Signed-off-by: Igor Mammedov imamm...@redhat.com Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- v4: - don't use nonexisting anymore error_is_set() v3: - fix path leak use object_get_canonical_path_component() for getting object name v2: - reuse UserCreatable interface instead of custom callbacks --- backends/Makefile.objs |2 + backends/hostmem-ram.c | 54 ++ backends/hostmem.c | 113 ++ include/sysemu/hostmem.h | 60 4 files changed, 229 insertions(+), 0 deletions(-) create mode 100644 backends/hostmem-ram.c create mode 100644 backends/hostmem.c create mode 100644 include/sysemu/hostmem.h diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 591ddcf..7fb7acd 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -6,3 +6,5 @@ common-obj-$(CONFIG_BRLAPI) += baum.o baum.o-cflags := $(SDL_CFLAGS) common-obj-$(CONFIG_TPM) += tpm.o + +common-obj-y += hostmem.o hostmem-ram.o diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c new file mode 100644 index 000..cbf7e5a --- /dev/null +++ b/backends/hostmem-ram.c @@ -0,0 +1,54 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include qom/object_interfaces.h + +#define TYPE_MEMORY_BACKEND_RAM memory-ram + + +static void +ram_backend_memory_init(UserCreatable *uc, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(uc); +char *path; + +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(backend-mr, OBJECT(backend), path, Passing the full canonical path as the name of memory region is redundant as that information is already passed via the owner argument. It should just be a shorthand. + backend-size); +g_free(path); +} + +static void +ram_backend_class_init(ObjectClass *oc, void *data) +{ +UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + +ucc-complete = ram_backend_memory_init; +} + +static const TypeInfo ram_backend_info = { +.name = TYPE_MEMORY_BACKEND_RAM, +.parent = TYPE_MEMORY_BACKEND, +.class_init = ram_backend_class_init, +}; + +static void register_types(void) +{ +type_register_static(ram_backend_info); +} + +type_init(register_types); diff --git a/backends/hostmem.c b/backends/hostmem.c new file mode 100644 index 000..8a34b0f --- /dev/null +++ b/backends/hostmem.c @@ -0,0 +1,113 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include sysemu/sysemu.h +#include qapi/visitor.h +#include qapi/qmp/qerror.h +#include qemu/config-file.h +#include qom/object_interfaces.h + +static void +hostmemory_backend_get_size(Object *obj, Visitor *v, void *opaque, +const char *name,
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
On Fri, Jun 06, 2014 at 02:48:15PM +0200, Igor Mammedov wrote: On Fri, 6 Jun 2014 17:29:38 +0800 Hu Tao hu...@cn.fujitsu.com wrote: On Fri, May 30, 2014 at 09:59:55AM +0200, Igor Mammedov wrote: On Fri, 30 May 2014 00:05:51 +1000 Peter Crosthwaite peter.crosthwa...@xilinx.com wrote: On Tue, May 27, 2014 at 11:01 PM, Igor Mammedov imamm...@redhat.com wrote: Provides framework for splitting host RAM allocation/ policies into a separate backend that could be used by devices. Initially only legacy RAM backend is provided, which uses memory_region_init_ram() allocator and compatible with every CLI option that affects memory_region_init_ram(). Signed-off-by: Igor Mammedov imamm...@redhat.com Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- v4: - don't use nonexisting anymore error_is_set() v3: - fix path leak use object_get_canonical_path_component() for getting object name v2: - reuse UserCreatable interface instead of custom callbacks --- backends/Makefile.objs |2 + backends/hostmem-ram.c | 54 ++ backends/hostmem.c | 113 ++ include/sysemu/hostmem.h | 60 4 files changed, 229 insertions(+), 0 deletions(-) create mode 100644 backends/hostmem-ram.c create mode 100644 backends/hostmem.c create mode 100644 include/sysemu/hostmem.h diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 591ddcf..7fb7acd 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -6,3 +6,5 @@ common-obj-$(CONFIG_BRLAPI) += baum.o baum.o-cflags := $(SDL_CFLAGS) common-obj-$(CONFIG_TPM) += tpm.o + +common-obj-y += hostmem.o hostmem-ram.o diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c new file mode 100644 index 000..cbf7e5a --- /dev/null +++ b/backends/hostmem-ram.c @@ -0,0 +1,54 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include qom/object_interfaces.h + +#define TYPE_MEMORY_BACKEND_RAM memory-ram + + +static void +ram_backend_memory_init(UserCreatable *uc, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(uc); +char *path; + +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(backend-mr, OBJECT(backend), path, Passing the full canonical path as the name of memory region is redundant as that information is already passed via the owner argument. It should just be a shorthand. + backend-size); +g_free(path); +} + +static void +ram_backend_class_init(ObjectClass *oc, void *data) +{ +UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + +ucc-complete = ram_backend_memory_init; +} + +static const TypeInfo ram_backend_info = { +.name = TYPE_MEMORY_BACKEND_RAM, +.parent = TYPE_MEMORY_BACKEND, +.class_init = ram_backend_class_init, +}; + +static void register_types(void) +{ +type_register_static(ram_backend_info); +} + +type_init(register_types); diff --git a/backends/hostmem.c b/backends/hostmem.c new file mode 100644 index 000..8a34b0f --- /dev/null +++ b/backends/hostmem.c @@ -0,0 +1,113 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include sysemu/sysemu.h +#include qapi/visitor.h +#include qapi/qmp/qerror.h +#include qemu/config-file.h +#include qom/object_interfaces.h + +static void +hostmemory_backend_get_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +uint64_t value = backend-size; + +visit_type_size(v, value, name, errp); +} + +static void +hostmemory_backend_set_size(Object *obj, Visitor *v, void
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
On Fri, May 30, 2014 at 09:59:55AM +0200, Igor Mammedov wrote: On Fri, 30 May 2014 00:05:51 +1000 Peter Crosthwaite peter.crosthwa...@xilinx.com wrote: On Tue, May 27, 2014 at 11:01 PM, Igor Mammedov imamm...@redhat.com wrote: Provides framework for splitting host RAM allocation/ policies into a separate backend that could be used by devices. Initially only legacy RAM backend is provided, which uses memory_region_init_ram() allocator and compatible with every CLI option that affects memory_region_init_ram(). Signed-off-by: Igor Mammedov imamm...@redhat.com Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- v4: - don't use nonexisting anymore error_is_set() v3: - fix path leak use object_get_canonical_path_component() for getting object name v2: - reuse UserCreatable interface instead of custom callbacks --- backends/Makefile.objs |2 + backends/hostmem-ram.c | 54 ++ backends/hostmem.c | 113 ++ include/sysemu/hostmem.h | 60 4 files changed, 229 insertions(+), 0 deletions(-) create mode 100644 backends/hostmem-ram.c create mode 100644 backends/hostmem.c create mode 100644 include/sysemu/hostmem.h diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 591ddcf..7fb7acd 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -6,3 +6,5 @@ common-obj-$(CONFIG_BRLAPI) += baum.o baum.o-cflags := $(SDL_CFLAGS) common-obj-$(CONFIG_TPM) += tpm.o + +common-obj-y += hostmem.o hostmem-ram.o diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c new file mode 100644 index 000..cbf7e5a --- /dev/null +++ b/backends/hostmem-ram.c @@ -0,0 +1,54 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include qom/object_interfaces.h + +#define TYPE_MEMORY_BACKEND_RAM memory-ram + + +static void +ram_backend_memory_init(UserCreatable *uc, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(uc); +char *path; + +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(backend-mr, OBJECT(backend), path, Passing the full canonical path as the name of memory region is redundant as that information is already passed via the owner argument. It should just be a shorthand. + backend-size); +g_free(path); +} + +static void +ram_backend_class_init(ObjectClass *oc, void *data) +{ +UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + +ucc-complete = ram_backend_memory_init; +} + +static const TypeInfo ram_backend_info = { +.name = TYPE_MEMORY_BACKEND_RAM, +.parent = TYPE_MEMORY_BACKEND, +.class_init = ram_backend_class_init, +}; + +static void register_types(void) +{ +type_register_static(ram_backend_info); +} + +type_init(register_types); diff --git a/backends/hostmem.c b/backends/hostmem.c new file mode 100644 index 000..8a34b0f --- /dev/null +++ b/backends/hostmem.c @@ -0,0 +1,113 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include sysemu/sysemu.h +#include qapi/visitor.h +#include qapi/qmp/qerror.h +#include qemu/config-file.h +#include qom/object_interfaces.h + +static void +hostmemory_backend_get_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +uint64_t value = backend-size; + +visit_type_size(v, value, name, errp); +} + +static void +hostmemory_backend_set_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +Error *local_err = NULL; +uint64_t value; + +if (memory_region_size(backend-mr)) { +error_setg(local_err, cannot change property value\n); +goto out; +} + +visit_type_size(v, value, name, errp); +if (local_err) { +
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
On Fri, 6 Jun 2014 17:29:38 +0800 Hu Tao hu...@cn.fujitsu.com wrote: On Fri, May 30, 2014 at 09:59:55AM +0200, Igor Mammedov wrote: On Fri, 30 May 2014 00:05:51 +1000 Peter Crosthwaite peter.crosthwa...@xilinx.com wrote: On Tue, May 27, 2014 at 11:01 PM, Igor Mammedov imamm...@redhat.com wrote: Provides framework for splitting host RAM allocation/ policies into a separate backend that could be used by devices. Initially only legacy RAM backend is provided, which uses memory_region_init_ram() allocator and compatible with every CLI option that affects memory_region_init_ram(). Signed-off-by: Igor Mammedov imamm...@redhat.com Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- v4: - don't use nonexisting anymore error_is_set() v3: - fix path leak use object_get_canonical_path_component() for getting object name v2: - reuse UserCreatable interface instead of custom callbacks --- backends/Makefile.objs |2 + backends/hostmem-ram.c | 54 ++ backends/hostmem.c | 113 ++ include/sysemu/hostmem.h | 60 4 files changed, 229 insertions(+), 0 deletions(-) create mode 100644 backends/hostmem-ram.c create mode 100644 backends/hostmem.c create mode 100644 include/sysemu/hostmem.h diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 591ddcf..7fb7acd 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -6,3 +6,5 @@ common-obj-$(CONFIG_BRLAPI) += baum.o baum.o-cflags := $(SDL_CFLAGS) common-obj-$(CONFIG_TPM) += tpm.o + +common-obj-y += hostmem.o hostmem-ram.o diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c new file mode 100644 index 000..cbf7e5a --- /dev/null +++ b/backends/hostmem-ram.c @@ -0,0 +1,54 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include qom/object_interfaces.h + +#define TYPE_MEMORY_BACKEND_RAM memory-ram + + +static void +ram_backend_memory_init(UserCreatable *uc, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(uc); +char *path; + +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(backend-mr, OBJECT(backend), path, Passing the full canonical path as the name of memory region is redundant as that information is already passed via the owner argument. It should just be a shorthand. + backend-size); +g_free(path); +} + +static void +ram_backend_class_init(ObjectClass *oc, void *data) +{ +UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + +ucc-complete = ram_backend_memory_init; +} + +static const TypeInfo ram_backend_info = { +.name = TYPE_MEMORY_BACKEND_RAM, +.parent = TYPE_MEMORY_BACKEND, +.class_init = ram_backend_class_init, +}; + +static void register_types(void) +{ +type_register_static(ram_backend_info); +} + +type_init(register_types); diff --git a/backends/hostmem.c b/backends/hostmem.c new file mode 100644 index 000..8a34b0f --- /dev/null +++ b/backends/hostmem.c @@ -0,0 +1,113 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include sysemu/sysemu.h +#include qapi/visitor.h +#include qapi/qmp/qerror.h +#include qemu/config-file.h +#include qom/object_interfaces.h + +static void +hostmemory_backend_get_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +uint64_t value = backend-size; + +visit_type_size(v, value, name, errp); +} + +static void +hostmemory_backend_set_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +Error *local_err = NULL; +uint64_t value; + +
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
On Fri, 30 May 2014 00:05:51 +1000 Peter Crosthwaite peter.crosthwa...@xilinx.com wrote: On Tue, May 27, 2014 at 11:01 PM, Igor Mammedov imamm...@redhat.com wrote: Provides framework for splitting host RAM allocation/ policies into a separate backend that could be used by devices. Initially only legacy RAM backend is provided, which uses memory_region_init_ram() allocator and compatible with every CLI option that affects memory_region_init_ram(). Signed-off-by: Igor Mammedov imamm...@redhat.com Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- v4: - don't use nonexisting anymore error_is_set() v3: - fix path leak use object_get_canonical_path_component() for getting object name v2: - reuse UserCreatable interface instead of custom callbacks --- backends/Makefile.objs |2 + backends/hostmem-ram.c | 54 ++ backends/hostmem.c | 113 ++ include/sysemu/hostmem.h | 60 4 files changed, 229 insertions(+), 0 deletions(-) create mode 100644 backends/hostmem-ram.c create mode 100644 backends/hostmem.c create mode 100644 include/sysemu/hostmem.h diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 591ddcf..7fb7acd 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -6,3 +6,5 @@ common-obj-$(CONFIG_BRLAPI) += baum.o baum.o-cflags := $(SDL_CFLAGS) common-obj-$(CONFIG_TPM) += tpm.o + +common-obj-y += hostmem.o hostmem-ram.o diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c new file mode 100644 index 000..cbf7e5a --- /dev/null +++ b/backends/hostmem-ram.c @@ -0,0 +1,54 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include qom/object_interfaces.h + +#define TYPE_MEMORY_BACKEND_RAM memory-ram + + +static void +ram_backend_memory_init(UserCreatable *uc, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(uc); +char *path; + +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(backend-mr, OBJECT(backend), path, Passing the full canonical path as the name of memory region is redundant as that information is already passed via the owner argument. It should just be a shorthand. + backend-size); +g_free(path); +} + +static void +ram_backend_class_init(ObjectClass *oc, void *data) +{ +UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + +ucc-complete = ram_backend_memory_init; +} + +static const TypeInfo ram_backend_info = { +.name = TYPE_MEMORY_BACKEND_RAM, +.parent = TYPE_MEMORY_BACKEND, +.class_init = ram_backend_class_init, +}; + +static void register_types(void) +{ +type_register_static(ram_backend_info); +} + +type_init(register_types); diff --git a/backends/hostmem.c b/backends/hostmem.c new file mode 100644 index 000..8a34b0f --- /dev/null +++ b/backends/hostmem.c @@ -0,0 +1,113 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include sysemu/sysemu.h +#include qapi/visitor.h +#include qapi/qmp/qerror.h +#include qemu/config-file.h +#include qom/object_interfaces.h + +static void +hostmemory_backend_get_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +uint64_t value = backend-size; + +visit_type_size(v, value, name, errp); +} + +static void +hostmemory_backend_set_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +Error *local_err = NULL; +uint64_t value; + +if (memory_region_size(backend-mr)) { +error_setg(local_err, cannot change property value\n); +goto out; +} + +visit_type_size(v, value, name, errp); +if (local_err) { +goto out; +} +if (!value) { +error_setg(local_err, Property '%s.%s' doesn't take value '% + PRIu64 ', object_get_typename(obj), name , value); +goto out; +} +
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
On Thu, 29 May 2014 10:41:32 -0600 Eric Blake ebl...@redhat.com wrote: On 05/27/2014 07:01 AM, Igor Mammedov wrote: Provides framework for splitting host RAM allocation/ policies into a separate backend that could be used by devices. Initially only legacy RAM backend is provided, which uses memory_region_init_ram() allocator and compatible with every CLI option that affects memory_region_init_ram(). Signed-off-by: Igor Mammedov imamm...@redhat.com Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- v4: - don't use nonexisting anymore error_is_set() v3: - fix path leak use object_get_canonical_path_component() for getting object name v2: - reuse UserCreatable interface instead of custom callbacks --- +++ b/backends/hostmem-ram.c @@ -0,0 +1,54 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc This patch has been in the queue for a while. Is it worth listing 2013-2014 here and in other new files? ok +hostmemory_backend_set_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +Error *local_err = NULL; +uint64_t value; + +if (memory_region_size(backend-mr)) { +error_setg(local_err, cannot change property value\n); Error messages should not include trailing newline. ok +goto out; +} + +visit_type_size(v, value, name, errp); +if (local_err) { local_err is guaranteed NULL at this point. Or did you mean to pass local_err instead of errp to visit_type_size? yep, visit_type_size() should take local_err +goto out; +} +if (!value) { +error_setg(local_err, Property '%s.%s' doesn't take value '% + PRIu64 ', object_get_typename(obj), name , value); No space before comma. there is no space before comma and there shouldn't be one since it's an end of an argument. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org -- Regards, Igor
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
Igor Mammedov imamm...@redhat.com writes: On Thu, 29 May 2014 10:41:32 -0600 Eric Blake ebl...@redhat.com wrote: On 05/27/2014 07:01 AM, Igor Mammedov wrote: [...] +goto out; +} +if (!value) { +error_setg(local_err, Property '%s.%s' doesn't take value '% + PRIu64 ', object_get_typename(obj), name , value); No space before comma. there is no space before comma and there shouldn't be one since it's an end of an argument. Look again, at the comma separating the last two arguments.
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
On Fri, 30 May 2014 10:21:04 +0200 Markus Armbruster arm...@redhat.com wrote: Igor Mammedov imamm...@redhat.com writes: On Thu, 29 May 2014 10:41:32 -0600 Eric Blake ebl...@redhat.com wrote: On 05/27/2014 07:01 AM, Igor Mammedov wrote: [...] +goto out; +} +if (!value) { +error_setg(local_err, Property '%s.%s' doesn't take value '% + PRIu64 ', object_get_typename(obj), name , value); No space before comma. there is no space before comma and there shouldn't be one since it's an end of an argument. Look again, at the comma separating the last two arguments. Sorry, blind me. -- Regards, Igor
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
On Tue, May 27, 2014 at 11:01 PM, Igor Mammedov imamm...@redhat.com wrote: Provides framework for splitting host RAM allocation/ policies into a separate backend that could be used by devices. Initially only legacy RAM backend is provided, which uses memory_region_init_ram() allocator and compatible with every CLI option that affects memory_region_init_ram(). Signed-off-by: Igor Mammedov imamm...@redhat.com Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- v4: - don't use nonexisting anymore error_is_set() v3: - fix path leak use object_get_canonical_path_component() for getting object name v2: - reuse UserCreatable interface instead of custom callbacks --- backends/Makefile.objs |2 + backends/hostmem-ram.c | 54 ++ backends/hostmem.c | 113 ++ include/sysemu/hostmem.h | 60 4 files changed, 229 insertions(+), 0 deletions(-) create mode 100644 backends/hostmem-ram.c create mode 100644 backends/hostmem.c create mode 100644 include/sysemu/hostmem.h diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 591ddcf..7fb7acd 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -6,3 +6,5 @@ common-obj-$(CONFIG_BRLAPI) += baum.o baum.o-cflags := $(SDL_CFLAGS) common-obj-$(CONFIG_TPM) += tpm.o + +common-obj-y += hostmem.o hostmem-ram.o diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c new file mode 100644 index 000..cbf7e5a --- /dev/null +++ b/backends/hostmem-ram.c @@ -0,0 +1,54 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include qom/object_interfaces.h + +#define TYPE_MEMORY_BACKEND_RAM memory-ram + + +static void +ram_backend_memory_init(UserCreatable *uc, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(uc); +char *path; + +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(backend-mr, OBJECT(backend), path, Passing the full canonical path as the name of memory region is redundant as that information is already passed via the owner argument. It should just be a shorthand. + backend-size); +g_free(path); +} + +static void +ram_backend_class_init(ObjectClass *oc, void *data) +{ +UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + +ucc-complete = ram_backend_memory_init; +} + +static const TypeInfo ram_backend_info = { +.name = TYPE_MEMORY_BACKEND_RAM, +.parent = TYPE_MEMORY_BACKEND, +.class_init = ram_backend_class_init, +}; + +static void register_types(void) +{ +type_register_static(ram_backend_info); +} + +type_init(register_types); diff --git a/backends/hostmem.c b/backends/hostmem.c new file mode 100644 index 000..8a34b0f --- /dev/null +++ b/backends/hostmem.c @@ -0,0 +1,113 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include sysemu/sysemu.h +#include qapi/visitor.h +#include qapi/qmp/qerror.h +#include qemu/config-file.h +#include qom/object_interfaces.h + +static void +hostmemory_backend_get_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +uint64_t value = backend-size; + +visit_type_size(v, value, name, errp); +} + +static void +hostmemory_backend_set_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +Error *local_err = NULL; +uint64_t value; + +if (memory_region_size(backend-mr)) { +error_setg(local_err, cannot change property value\n); +goto out; +} + +visit_type_size(v, value, name, errp); +if (local_err) { +goto out; +} +if (!value) { +error_setg(local_err, Property '%s.%s' doesn't take value '% + PRIu64 ', object_get_typename(obj), name , value); +goto out; +} +backend-size = value; +out: +error_propagate(errp, local_err); +} + +static void hostmemory_backend_initfn(Object *obj) can you just call this _init and .. +{ +object_property_add(obj, size, int, +
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
Il 29/05/2014 16:05, Peter Crosthwaite ha scritto: +path = object_get_canonical_path_component(OBJECT(backend)); +memory_region_init_ram(backend-mr, OBJECT(backend), path, Passing the full canonical path as the name of memory region is redundant as that information is already passed via the owner argument. It should just be a shorthand. It's not the full canonical path, it's basically the id. Paolo
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
Il 29/05/2014 17:39, Peter Crosthwaite ha scritto: It's not the full canonical path, it's basically the id. Fair enough. Although its still redundant though isn't it? Should we ever clean up messages etc in memory api to include both owner and name this is going to come out: foo/bar/baz:baz or some such. Yeah. But it's not exposed in any way, we can change it later. Paolo Then again, if we are only worried about getting a sane shorthand, perhaps what Igor has done here is a sane default for the memory API when passed a NULL name?
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
On Fri, May 30, 2014 at 1:25 AM, Paolo Bonzini pbonz...@redhat.com wrote: Il 29/05/2014 16:05, Peter Crosthwaite ha scritto: +path = object_get_canonical_path_component(OBJECT(backend)); +memory_region_init_ram(backend-mr, OBJECT(backend), path, Passing the full canonical path as the name of memory region is redundant as that information is already passed via the owner argument. It should just be a shorthand. It's not the full canonical path, it's basically the id. Fair enough. Although its still redundant though isn't it? Should we ever clean up messages etc in memory api to include both owner and name this is going to come out: foo/bar/baz:baz or some such. Then again, if we are only worried about getting a sane shorthand, perhaps what Igor has done here is a sane default for the memory API when passed a NULL name? Regards, Peter Paolo
Re: [Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
On 05/27/2014 07:01 AM, Igor Mammedov wrote: Provides framework for splitting host RAM allocation/ policies into a separate backend that could be used by devices. Initially only legacy RAM backend is provided, which uses memory_region_init_ram() allocator and compatible with every CLI option that affects memory_region_init_ram(). Signed-off-by: Igor Mammedov imamm...@redhat.com Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- v4: - don't use nonexisting anymore error_is_set() v3: - fix path leak use object_get_canonical_path_component() for getting object name v2: - reuse UserCreatable interface instead of custom callbacks --- +++ b/backends/hostmem-ram.c @@ -0,0 +1,54 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc This patch has been in the queue for a while. Is it worth listing 2013-2014 here and in other new files? +hostmemory_backend_set_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +Error *local_err = NULL; +uint64_t value; + +if (memory_region_size(backend-mr)) { +error_setg(local_err, cannot change property value\n); Error messages should not include trailing newline. +goto out; +} + +visit_type_size(v, value, name, errp); +if (local_err) { local_err is guaranteed NULL at this point. Or did you mean to pass local_err instead of errp to visit_type_size? +goto out; +} +if (!value) { +error_setg(local_err, Property '%s.%s' doesn't take value '% + PRIu64 ', object_get_typename(obj), name , value); No space before comma. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
[Qemu-devel] [PATCH v3 05/34] add memdev backend infrastructure
Provides framework for splitting host RAM allocation/ policies into a separate backend that could be used by devices. Initially only legacy RAM backend is provided, which uses memory_region_init_ram() allocator and compatible with every CLI option that affects memory_region_init_ram(). Signed-off-by: Igor Mammedov imamm...@redhat.com Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- v4: - don't use nonexisting anymore error_is_set() v3: - fix path leak use object_get_canonical_path_component() for getting object name v2: - reuse UserCreatable interface instead of custom callbacks --- backends/Makefile.objs |2 + backends/hostmem-ram.c | 54 ++ backends/hostmem.c | 113 ++ include/sysemu/hostmem.h | 60 4 files changed, 229 insertions(+), 0 deletions(-) create mode 100644 backends/hostmem-ram.c create mode 100644 backends/hostmem.c create mode 100644 include/sysemu/hostmem.h diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 591ddcf..7fb7acd 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -6,3 +6,5 @@ common-obj-$(CONFIG_BRLAPI) += baum.o baum.o-cflags := $(SDL_CFLAGS) common-obj-$(CONFIG_TPM) += tpm.o + +common-obj-y += hostmem.o hostmem-ram.o diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c new file mode 100644 index 000..cbf7e5a --- /dev/null +++ b/backends/hostmem-ram.c @@ -0,0 +1,54 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include qom/object_interfaces.h + +#define TYPE_MEMORY_BACKEND_RAM memory-ram + + +static void +ram_backend_memory_init(UserCreatable *uc, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(uc); +char *path; + +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(backend-mr, OBJECT(backend), path, + backend-size); +g_free(path); +} + +static void +ram_backend_class_init(ObjectClass *oc, void *data) +{ +UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + +ucc-complete = ram_backend_memory_init; +} + +static const TypeInfo ram_backend_info = { +.name = TYPE_MEMORY_BACKEND_RAM, +.parent = TYPE_MEMORY_BACKEND, +.class_init = ram_backend_class_init, +}; + +static void register_types(void) +{ +type_register_static(ram_backend_info); +} + +type_init(register_types); diff --git a/backends/hostmem.c b/backends/hostmem.c new file mode 100644 index 000..8a34b0f --- /dev/null +++ b/backends/hostmem.c @@ -0,0 +1,113 @@ +/* + * QEMU Host Memory Backend + * + * Copyright (C) 2013 Red Hat Inc + * + * Authors: + * Igor Mammedov imamm...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include sysemu/hostmem.h +#include sysemu/sysemu.h +#include qapi/visitor.h +#include qapi/qmp/qerror.h +#include qemu/config-file.h +#include qom/object_interfaces.h + +static void +hostmemory_backend_get_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +uint64_t value = backend-size; + +visit_type_size(v, value, name, errp); +} + +static void +hostmemory_backend_set_size(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); +Error *local_err = NULL; +uint64_t value; + +if (memory_region_size(backend-mr)) { +error_setg(local_err, cannot change property value\n); +goto out; +} + +visit_type_size(v, value, name, errp); +if (local_err) { +goto out; +} +if (!value) { +error_setg(local_err, Property '%s.%s' doesn't take value '% + PRIu64 ', object_get_typename(obj), name , value); +goto out; +} +backend-size = value; +out: +error_propagate(errp, local_err); +} + +static void hostmemory_backend_initfn(Object *obj) +{ +object_property_add(obj, size, int, +hostmemory_backend_get_size, +hostmemory_backend_set_size, NULL, NULL, NULL); +} + +static void hostmemory_backend_finalize(Object *obj) +{ +HostMemoryBackend *backend = MEMORY_BACKEND(obj); + +if (memory_region_size(backend-mr)) { +memory_region_destroy(backend-mr); +} +} + +static void +hostmemory_backend_memory_init(UserCreatable *uc, Error **errp) +{ +error_setg(errp, memory_init is not implemented for type