qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 01/11] qdev: Add qdev_prop_set_array()


From: Markus Armbruster
Subject: Re: [PATCH 01/11] qdev: Add qdev_prop_set_array()
Date: Fri, 22 Sep 2023 16:25:34 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> On 8/9/23 16:36, Kevin Wolf wrote:
>> Instead of exposing the ugly hack of how we represent arrays in qdev (a
>> static "foo-len" property and after it is set, dynamically created
>> "foo[i]" properties) to boards, add an interface that allows setting the
>> whole array at once.
>> Once all internal users of devices with array properties have been
>> converted to use this function, we can change the implementation to move
>> away from this hack.
>> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>> ---
>>   include/hw/qdev-properties.h |  3 +++
>>   hw/core/qdev-properties.c    | 21 +++++++++++++++++++++
>>   2 files changed, 24 insertions(+)
>
>
>> +void qdev_prop_set_array(DeviceState *dev, const char *name, QList *values)
>> +{
>> +    const QListEntry *entry;
>> +    g_autofree char *prop_len = g_strdup_printf("len-%s", name);
>> +    uint32_t i = 0;
>
> "unsigned"? Anyway,

Yes, or even plain int.  It all gets replaced in the last patch, though.

> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>
>> +
>> +    object_property_set_int(OBJECT(dev), prop_len, qlist_size(values),
>> +                            &error_abort);
>> +
>> +    QLIST_FOREACH_ENTRY(values, entry) {
>> +        g_autofree char *prop_idx = g_strdup_printf("%s[%u]", name, i);
>> +        object_property_set_qobject(OBJECT(dev), prop_idx, entry->value,
>> +                                    &error_abort);
>> +        i++;
>> +    }
>> +
>> +    qobject_unref(values);
>> +}




reply via email to

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