My pending qom and memory QOMification patches
cover My pending qom and memory QOMification patches
I'd like an ack for the first two patches, next monday I'll go ahead and send a pull request if I haven't received it yet.
Marcelo Tosatti (1):
mc146818rtc: add "rtc-time" link to "/machine/rtc"
Paolo Bonzini (6):
qom: add a generic mechanism to resolve paths
qom: allow creating an alias of a child<> property
libqtest: escape strings in QMP commands, fix leak
memory: MemoryRegion: use /machine as default owner
memory: MemoryRegion: replace owner field with QOM parent
memory: do not give a name to the internal exec.c regions
Peter Crosthwaite (6):
qom: object: remove parent pointer when unparenting
qom: object: Ignore refs/unrefs of NULL
memory: MemoryRegion: QOMify
memory: MemoryRegion: Add container and addr props
memory: MemoryRegion: Add may-overlap and priority props
memory: MemoryRegion: Add size property
Stefan Hajnoczi (1):
qom: add object_property_add_alias()
exec.c | 12 +-- hw/timer/mc146818rtc.c | 9 ++ include/exec/memory.h | 9 +- include/qom/object.h | 54 ++++++++++-- memory.c | 231 +++++++++++++++++++++++++++++++++++++++++++------ qom/object.c | 148 ++++++++++++++++++++++++------- tests/fdc-test.c | 2 +- tests/libqtest.c | 47 +++++++--- tests/qom-test.c | 6 +- tests/tmp105-test.c | 4 +- 10 files changed, 437 insertions(+), 85 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/14 qom: add object_property_add_alias()
From: Stefan Hajnoczi <[email protected]>
Sometimes an object needs to present a property which is actually on another object, or it needs to provide an alias name for an existing property.
Examples:
a.foo -> b.foo
a.old_name -> a.new_name
The new object_property_add_alias() API allows objects to alias a property on the same object or another object. The source and target names can be different.
--- include/qom/object.h | 20 ++++++++++++++++++++ qom/object.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+)
include/qom/object.h +20 -0
@@ -1231,6 +1231,26 @@ void object_property_add_uint64_ptr(Object *obj, const char *name, const uint64_t *v, Error **Errp);/** +* object_property_add_alias: +* @obj: the object to add a property to +* @name: the name of the property +* @target_obj: the object to forward property access to +* @target_name: the name of the property on the forwarded object +* @errp: if an error occurs, a pointer to an area to store the error +* +* Add an alias for a property on an object. This function will add a property +* of the same type as the forwarded property. +* +* The caller must ensure that <code>@target_obj</code> stays alive as long as +* this property exists. In the case of a child object or an alias on the same +* object this will be the case. For aliases to other objects the caller is +* responsible for taking a reference. +*/ +void object_property_add_alias (Object *obj,const char *name, +Object *target_obj,const char *target_name, +Error **errp); + +/** * object_child_foreach: * @obj: the object whose children will be navigated * @fn: the iterator function to be called
qom/object.c +51 -0
57 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 2/14 qom: add a generic mechanism to resolve paths
In reply to Paolo BonziniIt may be desirable to have custom link<> properties that do more than just store an object. Even the addition of a "check" function is not enough if setting the link has side effects or if a non-standard reference counting is preferrable.
Avoid the assumption that the opaque field of a link<> is a LinkProperty struct, by adding a generic "resolve" callback to ObjectProperty. This fixes aliases of link properties.
--- include/qom/object.h | 34 ++++++++++++++++++---- qom/object.c | 82 +++++++++++++++++++++++++++++++++------------------- 2 files changed, 82 insertions(+), 34 deletions(-)
include/qom/object.h +29 -5
@@ -304,6 +304,25 @@ typedef void (ObjectPropertyAccessor)(Object *obj, Error **errp);/** +* ObjectPropertyResolve: +* @obj: the object that owns the property +* @opaque: the opaque registered with the property +* @part: the name of the property +* +* Resolves the #Object corresponding to property @part. +* +* The returned object can also be used as a starting point +* to resolve a relative path starting with "@part". +* +* Returns: If @path is the path that led to @obj, the function +* returns the #Object corresponding to "@path/@part". +* If "@path/@part" is not a valid object path, it returns #NULL. +*/ +typedef Object *(ObjectPropertyResolve )(Object *obj, +void *opaque, +const char *part); + +/** * ObjectPropertyRelease: * @obj: the object that owns the property * @name: the name of the property
@@ -321,6 +340,7 @@ typedef struct ObjectPropertygchar *type;ObjectPropertyAccessor *get;ObjectPropertyAccessor *set; +ObjectPropertyResolve *resolve;ObjectPropertyRelease *release;void *opaque;
@@ -787,12 +807,16 @@ void object_unref(Object *obj);* destruction. This may be NULL. * @opaque: an opaque pointer to pass to the callbacks for the property * @errp: returns an error if this function fails +* +* Returns: The #ObjectProperty; this can be used to set the @resolve +* callback for child and link properties. */ -void object_property_add (Object *obj,const char *name,const char *type, -ObjectPropertyAccessor *get, -ObjectPropertyAccessor *set, -ObjectPropertyRelease *release, -void *opaque,Error **errp); +ObjectProperty *object_property_add (Object *obj,const char *name, +const char *type, +ObjectPropertyAccessor *get, +ObjectPropertyAccessor *set, +ObjectPropertyRelease *release, +void *opaque,Error **errp);void object_property_del (Object *obj,const char *name,Error **errp);
qom/object.c +53 -29
172 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 3/14 qom: allow creating an alias of a child<> property
In reply to Paolo BonziniChild properties must be unique. Fix this problem by turning their aliases into links.
The resolve function that forwards to the target property does not have any knowledge of the target property's type, so it works fine.
--- qom/object.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
qom/object.c +11 -1
@@ -1607,22 +1607,32 @@ void object_property_add_alias(Object *obj, const char *name,AliasProperty *prop;ObjectProperty *op;ObjectProperty *target_prop; +gchar *prop_type; target_prop =object_property_find (target_obj, target_name, errp);if (!target_prop) {return ; } +if (object_property_is_child (target_prop)) { + prop_type =g_strdup_printf ("link%s" , + target_prop->type +strlen ("child" )); + }else { + prop_type =g_strdup (target_prop->type); + } + prop =g_malloc (sizeof (*prop)); prop->target_obj = target_obj; prop->target_name = target_name; - op =object_property_add (obj, name, target_prop->type, + op =object_property_add (obj, name, prop_type, property_get_alias, property_set_alias, property_release_alias, alias, errp); op->resolve = property_resolve_alias; + +g_free (prop_type); }static void object_instance_init (Object *obj)
Signature · 1 line
1.8.3.1
PATCH 4/14 mc146818rtc: add "rtc-time" link to "/machine/rtc"
In reply to Paolo BonziniFrom: Marcelo Tosatti <[email protected]>
Add a link to rtc under /machine providing a stable location for management apps to query the value of the time. The link should be added by any object that sends RTC_TIME_CHANGE events.
{"execute":"qom-get","arguments":{"path":"/machine","property":"rtc-date"} }
Suggested by Paolo Bonzini and Andreas Faerber.
--- hw/timer/mc146818rtc.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/timer/mc146818rtc.c +9 -0
@@ -893,6 +893,9 @@ static void rtc_realizefn(DeviceState *dev, Error **errp)object_property_add (OBJECT (s),"date" ,"struct tm" , rtc_get_date,NULL ,NULL , s,NULL ); + +object_property_add_alias (qdev_get_machine (),"rtc-time" , +OBJECT (s),"date" ,NULL ); }ISADevice *rtc_init (ISABus *bus,int base_year,qemu_irq intercept_irq)
@@ -932,11 +935,17 @@ static void rtc_class_initfn(ObjectClass *klass, void *data) dc->cannot_instantiate_with_device_add_yet = true; } +static void rtc_finalize (Object *obj) +{ +object_property_del (qdev_get_machine (),"rtc" ,NULL ); +} +static const TypeInfo mc146818rtc_info = { .name =TYPE_MC146818_RTC , .parent =TYPE_ISA_DEVICE , .instance_size =sizeof (RTCState), .class_init = rtc_class_initfn, + .instance_finalize = rtc_finalize, };static void mc146818rtc_register_types (void )
Signature · 1 line
1.8.3.1
PATCH 5/14 qom: object: remove parent pointer when unparenting
In reply to Paolo BonziniFrom: Peter Crosthwaite <[email protected]>
Certain parts of the QOM framework test this pointer to determine if an object is parented. Nuke it when the object is unparented to allow for reuse of an object after unparenting.
--- qom/object.c | 1 + 1 file changed, 1 insertion(+)
qom/object.c +1 -0
@@ -397,6 +397,7 @@ void object_unparent(Object *obj) }if (obj->parent) {object_property_del_child (obj->parent, obj,NULL ); + obj->parent =NULL ; }object_unref (obj); }
Signature · 1 line
1.8.3.1
PATCH 6/14 qom: object: Ignore refs/unrefs of NULL
In reply to Paolo BonziniFrom: Peter Crosthwaite <[email protected]>
Just do nothing if passed NULL for a ref or unref. This avoids call sites that manage a combination of NULL or non-NULL pointers having to add iffery around every ref and unref.
--- qom/object.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
qom/object.c +8 -6
@@ -711,11 +711,17 @@ GSList *object_class_get_list(const char *implements_type,void object_ref (Object *obj) { +if (!obj) { +return ; + }atomic_inc (&obj->ref); }void object_unref (Object *obj) { +if (!obj) { +return ; + }g_assert (obj->ref >0 );/* parent always holds a reference to its children */
@@ -1160,13 +1166,9 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque,return ; } -if (new_target) { -object_ref (new_target); - } +object_ref (new_target); *child = new_target; -if (old_target !=NULL ) { -object_unref (old_target); - } +object_unref (old_target); }static Object *object_resolve_link_property (Object *parent,void *opaque,const gchar *part)
Signature · 1 line
1.8.3.1
PATCH 7/14 libqtest: escape strings in QMP commands, fix leak
In reply to Paolo Bonzinilibqtest is using g_strdup_printf to format QMP commands, but this does not work if the argument strings need to be escaped. Instead, use the fancy %-formatting functionality of QObject. The only change required in tests is that strings have to be formatted as %s, not '%s' or \"%s\". Luckily this usage of parameterized QMP commands is not that frequent.
The leak is in socket_sendf. Since we are extracting the send loop to a new function, fix it now.
--- tests/fdc-test.c | 2 +- tests/libqtest.c | 47 +++++++++++++++++++++++++++++++++++++---------- tests/qom-test.c | 6 +++--- tests/tmp105-test.c | 4 ++-- 4 files changed, 43 insertions(+), 16 deletions(-)
tests/fdc-test.c +1 -1
@@ -291,7 +291,7 @@ static void test_media_insert(void)/* Insert media in drive. DSKCHK should not be reset until a step pulse * is sent. */ qmp_discard_response ("{'execute':'change', 'arguments':{" -" 'device':'floppy0', 'target': '%s' }}" , +" 'device':'floppy0', 'target': %s }}" , test_image);qmp_discard_response ("" );/* ignore event (FIXME open -> open transition?!) */
tests/libqtest.c +37 -10
78 lines not on this page · raw message
tests/qom-test.c +3 -3
@@ -53,7 +53,7 @@ static void test_properties(const char *path, bool recurse)g_test_message ("Obtaining properties of %s" , path); response =qmp ("{ 'execute': 'qom-list'," -" 'arguments': { 'path': '%s' } }" , path); +" 'arguments': { 'path': %s } }" , path);g_assert (response);if (!recurse) {
@@ -76,8 +76,8 @@ static void test_properties(const char *path, bool recurse)const char *prop =qdict_get_str (tuple,"name" );g_test_message ("Testing property %s.%s" , path, prop); response =qmp ("{ 'execute': 'qom-get'," -" 'arguments': { 'path': '%s'," -" 'property': '%s' } }" , +" 'arguments': { 'path': %s," +" 'property': %s } }" , path, prop);/* qom-get may fail but should not, e.g., segfault. */ g_assert (response);
tests/tmp105-test.c +2 -2
@@ -69,7 +69,7 @@ static int qmp_tmp105_get_temperature(const char *id)QDict *response;int ret; - response =qmp ("{ 'execute': 'qom-get', 'arguments': { 'path': '%s', " + response =qmp ("{ 'execute': 'qom-get', 'arguments': { 'path': %s, " "'property': 'temperature' } }" , id);g_assert (qdict_haskey (response,"return" )); ret =qdict_get_int (response,"return" );
@@ -81,7 +81,7 @@ static void qmp_tmp105_set_temperature(const char *id, int value) {QDict *response; - response =qmp ("{ 'execute': 'qom-set', 'arguments': { 'path': '%s', " + response =qmp ("{ 'execute': 'qom-set', 'arguments': { 'path': %s, " "'property': 'temperature', 'value': %d } }" , id, value);g_assert (qdict_haskey (response,"return" ));QDECREF (response);
Signature · 1 line
1.8.3.1
PATCH 8/14 memory: MemoryRegion: use /machine as default owner
In reply to Paolo BonziniThis will be added (after QOMification) as the QOM parent.
--- memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
memory.c +1 -1
@@ -849,7 +849,7 @@ void memory_region_init(MemoryRegion *mr, { mr->ops = &unassigned_mem_ops; mr->opaque =NULL ; - mr->owner = owner; + mr->owner = owner ? owner :qdev_get_machine (); mr->iommu_ops =NULL ; mr->container =NULL ; mr->size =int128_make64 (size);
Signature · 1 line
1.8.3.1
PATCH 9/14 memory: MemoryRegion: QOMify
In reply to Paolo BonziniFrom: Peter Crosthwaite <[email protected]>
QOMify memory regions as an Object. The former init() and destroy() routines become instance_init() and instance_finalize() resp.
memory_region_init() is re-implemented to be:object_initialize() + set fields
memory_region_destroy() is re-implemented to call unparent().
--- exec.c | 4 +- include/exec/memory.h | 6 +++ memory.c | 121 +++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 109 insertions(+), 22 deletions(-)
exec.c +2 -2
@@ -883,7 +883,7 @@ static void phys_section_destroy(MemoryRegion *mr)if (mr->subpage) {subpage_t *subpage =container_of (mr, subpage_t, iomem); -memory_region_destroy (&subpage->iomem); +object_unref (OBJECT (&subpage->iomem));g_free (subpage); } }
@@ -1761,7 +1761,7 @@ static subpage_t *subpage_init(AddressSpace *as, hwaddr base) mmio->as = as; mmio->base = base;memory_region_init_io (&mmio->iomem,NULL , &subpage_ops, mmio, -"subpage" ,TARGET_PAGE_SIZE ); +NULL ,TARGET_PAGE_SIZE ); mmio->iomem.subpage = true;#if defined(DEBUG_SUBPAGE ) printf("%s: %p base " TARGET_FMT_plx " len %08x\n", __func__,
include/exec/memory.h +6 -0
@@ -32,10 +32,15 @@#include "qemu/int128.h" #include "qemu/notify.h" #include "qapi/error.h" +#include "qom/object.h" #define MAX_PHYS_ADDR_SPACE_BITS 62#define MAX_PHYS_ADDR (((hwaddr)1 << MAX_PHYS_ADDR_SPACE_BITS) - 1) +#define TYPE_MEMORY_REGION "qemu:memory-region" +#define MEMORY_REGION (obj) \ + OBJECT_CHECK(MemoryRegion, (obj), TYPE_MEMORY_REGION) +typedef struct MemoryRegionOps MemoryRegionOps ;typedef struct MemoryRegionMmio MemoryRegionMmio ;
@@ -131,6 +136,7 @@ typedef struct CoalescedMemoryRange CoalescedMemoryRange;typedef struct MemoryRegionIoeventfd MemoryRegionIoeventfd ;struct MemoryRegion { +Object parent_obj;/* All fields are private - violators will be prosecuted */ const MemoryRegionOps *ops;const MemoryRegionIOMMUOps *iommu_ops;
memory.c +101 -20
170 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 10/14 memory: MemoryRegion: replace owner field with QOM parent
In reply to Paolo BonziniThe two are now the same.
--- include/exec/memory.h | 1 - memory.c | 35 +++++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 11 deletions(-)
include/exec/memory.h +0 -1
@@ -141,7 +141,6 @@ struct MemoryRegion {const MemoryRegionOps *ops;const MemoryRegionIOMMUOps *iommu_ops;void *opaque; -struct Object *owner;MemoryRegion *container;Int128 size;hwaddr addr;
memory.c +25 -10
@@ -905,9 +905,11 @@ void memory_region_init(MemoryRegion *mr,const char *name, uint64_t size) { - object_initialize(mr, sizeof(*mr), TYPE_MEMORY_REGION); + if (!owner) { + owner = qdev_get_machine(); + } - mr->owner = owner ? owner :qdev_get_machine (); +object_initialize (mr,sizeof (*mr),TYPE_MEMORY_REGION ); mr->size =int128_make64 (size);if (size ==UINT64_MAX ) { mr->size =int128_2_64 ();
@@ -915,7 +917,7 @@ void memory_region_init(MemoryRegion *mr, mr->name =g_strdup (name);if (name) { -object_property_add_child_array (mr->owner, name,OBJECT (mr)); +object_property_add_child_array (owner, name,OBJECT (mr));object_unref (OBJECT (mr)); } }
@@ -1187,24 +1189,37 @@ void memory_region_destroy(MemoryRegion *mr)Object *memory_region_owner (MemoryRegion *mr) { -return mr->owner; +Object *obj =OBJECT (mr); +return obj->parent; }void memory_region_ref (MemoryRegion *mr) { -if (mr && mr->owner) { -object_ref (mr->owner); +/* MMIO callbacks most likely will access data that belongs +* to the owner, hence the need to ref/unref the owner whenever +* the memory region is in use. +* +* The memory region is a child of its owner. As long as the +* owner doesn't call unparent itself on the memory region, +* ref-ing the owner will also keep the memory region alive. +* Memory regions without an owner are supposed to never go away, +* but we still ref/unref them for debugging purposes. +*/ +Object *obj =OBJECT (mr); +if (obj && obj->parent) { +object_ref (obj->parent); }else { -object_ref (OBJECT (mr)); +object_ref (obj); } }void memory_region_unref (MemoryRegion *mr) { -if (mr && mr->owner) { -object_unref (mr->owner); +Object *obj =OBJECT (mr); +if (obj && obj->parent) { +object_unref (obj->parent); }else { -object_unref (OBJECT (mr)); +object_unref (obj); } }
Signature · 1 line
1.8.3.1
PATCH 11/14 memory: MemoryRegion: Add container and addr props
In reply to Paolo BonziniFrom: Peter Crosthwaite <[email protected]>
Expose the already existing .parent and .addr fields as QOM properties. .parent (i.e. the field describing the memory region that contains this one in Memory hierachy) is renamed "container". This is to avoid confusion with the QOM parent.
[Remove setters. Do not unref parent on releasing the property. Clean
up error propagation. - Paolo]
--- memory.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
memory.c +46 -0
@@ -16,6 +16,7 @@#include "exec/memory.h" #include "exec/address-spaces.h" #include "exec/ioport.h" +#include "qapi/visitor.h" #include "qemu/bitops.h" #include "qom/object.h" #include "trace.h"
@@ -922,9 +923,42 @@ void memory_region_init(MemoryRegion *mr, } } +static void memory_region_get_addr (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +MemoryRegion *mr =MEMORY_REGION (obj); +uint64_t value = mr->addr; + +visit_type_uint64 (v, &value, name, errp); +} + +static void memory_region_get_container (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +MemoryRegion *mr =MEMORY_REGION (obj); +gchar *path = (gchar *)"" ; + +if (mr->container) { + path =object_get_canonical_path (OBJECT (mr->container)); + } +visit_type_str (v, &path, name, errp); +if (mr->container) { +g_free (path); + } +} + +static Object *memory_region_resolve_container (Object *obj,void *opaque, +const char *part) +{ +MemoryRegion *mr =MEMORY_REGION (obj); + +return OBJECT (mr->container); +} +static void memory_region_initfn (Object *obj) {MemoryRegion *mr =MEMORY_REGION (obj); +ObjectProperty *op; mr->ops = &unassigned_mem_ops; mr->enabled = true;
@@ -932,6 +966,18 @@ static void memory_region_initfn(Object *obj) mr->destructor = memory_region_destructor_none;QTAILQ_INIT (&mr->subregions);QTAILQ_INIT (&mr->coalesced); + + op =object_property_add (OBJECT (mr),"container" , +"link<" TYPE_MEMORY_REGION ">" , + memory_region_get_container, +NULL ,/* memory_region_set_container */ +NULL ,NULL , &error_abort); + op->resolve = memory_region_resolve_container; + +object_property_add (OBJECT (mr),"addr" ,"uint64" , + memory_region_get_addr, +NULL ,/* memory_region_set_addr */ +NULL ,NULL , &error_abort); } static uint64_t unassigned_mem_read(void *opaque, hwaddr addr,
Signature · 1 line
1.8.3.1
PATCH 12/14 memory: MemoryRegion: Add may-overlap and priority props
In reply to Paolo BonziniFrom: Peter Crosthwaite <[email protected]>
QOM propertyify the .may-overlap and .priority fields. The setters will re-add the memory as a subregion if needed (i.e. the values change when the memory region is already contained).
--- include/exec/memory.h | 2 +- memory.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-)
include/exec/memory.h +1 -1
@@ -157,7 +157,7 @@ struct MemoryRegion {bool flush_coalesced_mmio;MemoryRegion *alias;hwaddr alias_offset; -int priority; +int32_t priority;bool may_overlap; QTAILQ_HEAD(subregions, MemoryRegion) subregions;QTAILQ_ENTRY (MemoryRegion) subregions_link;
memory.c +24 -0
@@ -955,6 +955,22 @@ static Object *memory_region_resolve_container(Object *obj, void *opaque,return OBJECT (mr->container); } +static void memory_region_get_priority (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +MemoryRegion *mr =MEMORY_REGION (obj); +int32_t value = mr->priority; + +visit_type_int32 (v, &value, name, errp); +} + +static bool memory_region_get_may_overlap (Object *obj,Error **errp) +{ +MemoryRegion *mr =MEMORY_REGION (obj); + +return mr->may_overlap; +} +static void memory_region_initfn (Object *obj) {MemoryRegion *mr =MEMORY_REGION (obj);
@@ -978,6 +994,14 @@ static void memory_region_initfn(Object *obj) memory_region_get_addr,NULL ,/* memory_region_set_addr */ NULL, NULL, &error_abort); +object_property_add (OBJECT (mr),"priority" ,"uint32" , + memory_region_get_priority, +NULL ,/* memory_region_set_priority */ +NULL ,NULL , &error_abort); +object_property_add_bool (OBJECT (mr),"may-overlap" , + memory_region_get_may_overlap, +NULL ,/* memory_region_set_may_overlap */ + &error_abort); } static uint64_t unassigned_mem_read(void *opaque, hwaddr addr,
Signature · 1 line
1.8.3.1
PATCH 13/14 memory: MemoryRegion: Add size property
In reply to Paolo BonziniFrom: Peter Crosthwaite <[email protected]>
To allow devices to dynamically resize the device. The motivation is to allow devices with variable size to init their memory_region without size early and then correctly populate size at realize() time.
--- memory.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
memory.c +13 -0
@@ -971,6 +971,15 @@ static bool memory_region_get_may_overlap(Object *obj, Error **errp)return mr->may_overlap; } +static void memory_region_get_size (Object *obj,Visitor *v,void *opaque, +const char *name,Error **errp) +{ +MemoryRegion *mr =MEMORY_REGION (obj); +uint64_t value =memory_region_size (mr); + +visit_type_uint64 (v, &value, name, errp); +} +static void memory_region_initfn (Object *obj) {MemoryRegion *mr =MEMORY_REGION (obj);
@@ -1002,6 +1011,10 @@ static void memory_region_initfn(Object *obj) memory_region_get_may_overlap,NULL ,/* memory_region_set_may_overlap */ &error_abort); +object_property_add (OBJECT (mr),"size" ,"uint64" , + memory_region_get_size, +NULL ,/* memory_region_set_size, */ +NULL ,NULL , &error_abort); } static uint64_t unassigned_mem_read(void *opaque, hwaddr addr,
Signature · 1 line
1.8.3.1
PATCH 14/14 memory: do not give a name to the internal exec.c regions
In reply to Paolo BonziniThere is no need to have them visible under /machine.
--- exec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
exec.c +4 -4
@@ -1794,13 +1794,13 @@ MemoryRegion *iotlb_to_region(AddressSpace *as, hwaddr index)static void io_mem_init (void ) { -memory_region_init_io (&io_mem_rom,NULL , &unassigned_mem_ops,NULL ,"rom" ,UINT64_MAX ); +memory_region_init_io (&io_mem_rom,NULL , &unassigned_mem_ops,NULL ,NULL ,UINT64_MAX );memory_region_init_io (&io_mem_unassigned,NULL , &unassigned_mem_ops,NULL , -"unassigned" ,UINT64_MAX ); +NULL ,UINT64_MAX );memory_region_init_io (&io_mem_notdirty,NULL , ¬dirty_mem_ops,NULL , -"notdirty" ,UINT64_MAX ); +NULL ,UINT64_MAX );memory_region_init_io (&io_mem_watch,NULL , &watch_mem_ops,NULL , -"watch" ,UINT64_MAX ); +NULL ,UINT64_MAX ); }static void mem_begin (MemoryListener *listener)
Signature · 1 line
1.8.3.1