qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH memory v2 8/9] memory: MemoryRegion: Add may-ove


From: Peter Crosthwaite
Subject: Re: [Qemu-devel] [PATCH memory v2 8/9] memory: MemoryRegion: Add may-overlap and priority props
Date: Mon, 2 Jun 2014 12:44:09 +1000

On Tue, May 27, 2014 at 7:04 PM, Peter Crosthwaite
<address@hidden> wrote:
> 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).
>
> Signed-off-by: Peter Crosthwaite <address@hidden>
> ---
> changed since v1:
> Converted priority to signed type
>
>  include/exec/memory.h |  2 +-
>  memory.c              | 57 
> +++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 58 insertions(+), 1 deletion(-)
>
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index 371c066..117c0d3 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -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;
> diff --git a/memory.c b/memory.c
> index a95bb1e..ee761a2 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -955,6 +955,55 @@ static void memory_region_release_container(Object *obj, 
> const char *name,
>      }
>  }
>
> +static void memory_region_get_priority(Object *obj, Visitor *v, void *opaque,
> +                                       const char *name, Error **errp)
> +{
> +    MemoryRegion *mr = MEMORY_REGION(obj);
> +    Error *local_err = NULL;
> +    uint32_t value = mr->addr;

That's a copy paste error. Fixed. Also change type to int32_t to
support signed priorities via QOM setters/getters.

Regards,
Peter

> +
> +    visit_type_uint32(v, &value, name, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +    }
> +}
> +
> +static void memory_region_set_priority(Object *obj, Visitor *v, void *opaque,
> +                                       const char *name, Error **errp)
> +{
> +    MemoryRegion *mr = MEMORY_REGION(obj);
> +    Error *local_err = NULL;
> +    uint32_t value;
> +
> +    visit_type_uint32(v, &value, name, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        return;
> +    }
> +
> +    if (mr->priority != value) {
> +        mr->priority = value;
> +        memory_region_readd_subregion(mr);
> +    }
> +}
> +
> +static bool memory_region_get_may_overlap(Object *obj, Error **errp)
> +{
> +    MemoryRegion *mr = MEMORY_REGION(obj);
> +
> +    return mr->may_overlap;
> +}
> +
> +static void memory_region_set_may_overlap(Object *obj, bool value, Error 
> **errp)
> +{
> +    MemoryRegion *mr = MEMORY_REGION(obj);
> +
> +    if (mr->may_overlap != value) {
> +        mr->may_overlap = value;
> +        memory_region_readd_subregion(mr);
> +    }
> +}
> +
>  static void memory_region_initfn(Object *obj)
>  {
>      MemoryRegion *mr = MEMORY_REGION(obj);
> @@ -980,6 +1029,14 @@ static void memory_region_initfn(Object *obj)
>                          memory_region_get_addr,
>                          memory_region_set_addr,
>                          NULL, NULL, &error_abort);
> +    object_property_add(OBJECT(mr), "priority", "uint32",
> +                        memory_region_get_priority,
> +                        memory_region_set_priority,
> +                        NULL, NULL, &error_abort);
> +    object_property_add_bool(OBJECT(mr), "may-overlap",
> +                             memory_region_get_may_overlap,
> +                             memory_region_set_may_overlap,
> +                             &error_abort);
>  }
>
>  static uint64_t unassigned_mem_read(void *opaque, hwaddr addr,
> --
> 1.9.3.1.ga73a6ad
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]