[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH v3 1/3] pc-dimm: factor out MemoryDevice interface
From: |
David Hildenbrand |
Subject: |
Re: [Qemu-ppc] [PATCH v3 1/3] pc-dimm: factor out MemoryDevice interface |
Date: |
Sun, 22 Apr 2018 10:21:34 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
On 22.04.2018 06:26, David Gibson wrote:
> On Fri, Apr 20, 2018 at 02:34:54PM +0200, David Hildenbrand wrote:
>> On the qmp level, we already have the concept of memory devices:
>> "query-memory-devices"
>> Right now, we only support NVDIMM and PCDIMM.
>>
>> We want to map other devices later into the address space of the guest.
>> Such device could e.g. be virtio devices. These devices will have a
>> guest memory range assigned but won't be exposed via e.g. ACPI. We want
>> to make them look like memory device, but not glued to pc-dimm.
>>
>> Especially, it will not always be possible to have TYPE_PC_DIMM as a parent
>> class (e.g. virtio devices). Let's use an interface instead. As a first
>> part, convert handling of
>> - qmp_pc_dimm_device_list
>> - get_plugged_memory_size
>> to our new model. plug/unplug stuff etc. will follow later.
>>
>> A memory device will have to provide the following functions:
>> - get_addr(): Necessary, as the property "addr" can e.g. not be used for
>> virtio devices (already defined).
>> - get_plugged_size(): The amount this device offers to the guest as of
>> now.
>> - get_region_size(): Because this can later on be bigger than the
>> plugged size.
>> - fill_device_info(): Fill MemoryDeviceInfo, e.g. for qmp.
>>
>> Signed-off-by: David Hildenbrand <address@hidden>
>
> Reviewed-by: David Gibson <address@hidden>
>
> with the exception of some tiny nits..
>
> [snip]
>> +static gint memory_device_addr_sort(gconstpointer a, gconstpointer b)
>> +{
>> + MemoryDeviceState *md_a = MEMORY_DEVICE(a);
>> + MemoryDeviceState *md_b = MEMORY_DEVICE(b);
>
> These probably should be const MemoryDeviceState *.
Yes, that could work (depends on what the functions getting called
internally expect). Will look into it
>
>> + MemoryDeviceClass *mdc_a = MEMORY_DEVICE_GET_CLASS(a);
>> + MemoryDeviceClass *mdc_b = MEMORY_DEVICE_GET_CLASS(b);
>> + const uint64_t addr_a = mdc_a->get_addr(md_a);
>> + const uint64_t addr_b = mdc_b->get_addr(md_b);
>> +
>> + if (addr_a > addr_b) {
>> + return 1;
>> + } else if (addr_a < addr_b) {
>> + return -1;
>> + }
>> + return 0;
>> +}
>> +
>> +static int memory_device_built_list(Object *obj, void *opaque)
>
> s/built/build/ will read a bit more clearly I think.
>
Indeed, thanks!
--
Thanks,
David / dhildenb
[Qemu-ppc] [PATCH v3 1/3] pc-dimm: factor out MemoryDevice interface, David Hildenbrand, 2018/04/20
Re: [Qemu-ppc] [Qemu-devel] [PATCH v3 1/3] pc-dimm: factor out MemoryDevice interface, Pankaj Gupta, 2018/04/22
[Qemu-ppc] [PATCH v3 3/3] pc-dimm: factor out address space logic into MemoryDevice code, David Hildenbrand, 2018/04/20