Re: [PATCH 4/6] qom/object: add object_class_get_list_by_name_prefix

2026-04-29 Thread Pierrick Bouvier
On 4/29/2026 1:48 AM, Daniel P. Berrangé wrote:
> On Wed, Apr 29, 2026 at 12:36:03PM +0400, [email protected] wrote:
>> On Tue, 28 Apr 2026 16:45:17 -0700, Pierrick Bouvier 
>>  wrote:
>>> diff --git a/include/qom/object.h b/include/qom/object.h
>>> index 510885218ba..a6d7b3874a7 100644
>>> --- a/include/qom/object.h
>>> +++ b/include/qom/object.h
>>> @@ -1033,6 +1033,19 @@ GSList *object_class_get_list(const char 
>>> *implements_type,
>>>  GSList *object_class_get_list_sorted(const char *implements_type,
>>>bool include_abstract);
>>>  
>>> +/**
>>> + * object_class_get_list:
>>
>> Should be "object_class_get_list_by_name_prefix:".
>>
>>> + * @name_prefix: Name prefix for type to filter for.
>>> + * @include_abstract: Whether to include abstract classes.
>>> + *
>>> + * To the opposite of object_class_get_list, only matching types are
>>
>> Suggest "Unlike object_class_get_list,"
>>
>>>
>>> diff --git a/qom/object.c b/qom/object.c
>>> index f981e270440..14527108a2e 100644
>>> --- a/qom/object.c
>>> +++ b/qom/object.c
>>> @@ -1062,6 +1062,30 @@ static void object_class_foreach_tramp(gpointer key, 
>>> gpointer value,
>>>  data->fn(k, data->opaque);
>>>  }
>>>  
>>> +static void object_class_foreach_match_name_prefix(gpointer key, gpointer 
>>> value,
>>> +   gpointer opaque)
>>> +{
>>> +OCFData *data = opaque;
>>> +TypeImpl *type = value;
>>> +ObjectClass *k;
>>> +
>>> +const char *name_prefix = data->implements_type;
>>
>> Perhaps the "implements_type" field should be renamed.
>>
>>> [ ... skip 11 lines ... ]
>>> +}
>>> +
>>> +data->fn(k, data->opaque);
>>> +}
>>> +
>>>  void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
>>
>> I wonder if we introduce MODULE_INIT_TARGET_INFO, is this all needed?
>> since only TargetInfo types would be registered..
> 
> Yeah, i feel like this patch should be redundant if we provide  a
> separate initializer for early types to get registered.
>

You're both right, this patch is not necessary anymore.
Since only target-info QOM types are registered after this step, we can
safely call object_class_get_list.

> Daniel
> 

Regards,
Pierrick



Re: [PATCH 4/6] qom/object: add object_class_get_list_by_name_prefix

2026-04-29 Thread Daniel P . Berrangé
On Wed, Apr 29, 2026 at 12:36:03PM +0400, [email protected] wrote:
> On Tue, 28 Apr 2026 16:45:17 -0700, Pierrick Bouvier 
>  wrote:
> > diff --git a/include/qom/object.h b/include/qom/object.h
> > index 510885218ba..a6d7b3874a7 100644
> > --- a/include/qom/object.h
> > +++ b/include/qom/object.h
> > @@ -1033,6 +1033,19 @@ GSList *object_class_get_list(const char 
> > *implements_type,
> >  GSList *object_class_get_list_sorted(const char *implements_type,
> >bool include_abstract);
> >  
> > +/**
> > + * object_class_get_list:
> 
> Should be "object_class_get_list_by_name_prefix:".
> 
> > + * @name_prefix: Name prefix for type to filter for.
> > + * @include_abstract: Whether to include abstract classes.
> > + *
> > + * To the opposite of object_class_get_list, only matching types are
> 
> Suggest "Unlike object_class_get_list,"
> 
> >
> > diff --git a/qom/object.c b/qom/object.c
> > index f981e270440..14527108a2e 100644
> > --- a/qom/object.c
> > +++ b/qom/object.c
> > @@ -1062,6 +1062,30 @@ static void object_class_foreach_tramp(gpointer key, 
> > gpointer value,
> >  data->fn(k, data->opaque);
> >  }
> >  
> > +static void object_class_foreach_match_name_prefix(gpointer key, gpointer 
> > value,
> > +   gpointer opaque)
> > +{
> > +OCFData *data = opaque;
> > +TypeImpl *type = value;
> > +ObjectClass *k;
> > +
> > +const char *name_prefix = data->implements_type;
> 
> Perhaps the "implements_type" field should be renamed.
> 
> > [ ... skip 11 lines ... ]
> > +}
> > +
> > +data->fn(k, data->opaque);
> > +}
> > +
> >  void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
> 
> I wonder if we introduce MODULE_INIT_TARGET_INFO, is this all needed?
> since only TargetInfo types would be registered..

Yeah, i feel like this patch should be redundant if we provide  a
separate initializer for early types to get registered.

Daniel




Re: [PATCH 4/6] qom/object: add object_class_get_list_by_name_prefix

2026-04-29 Thread marcandre . lureau
On Tue, 28 Apr 2026 16:45:17 -0700, Pierrick Bouvier 
 wrote:
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 510885218ba..a6d7b3874a7 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -1033,6 +1033,19 @@ GSList *object_class_get_list(const char 
> *implements_type,
>  GSList *object_class_get_list_sorted(const char *implements_type,
>bool include_abstract);
>  
> +/**
> + * object_class_get_list:

Should be "object_class_get_list_by_name_prefix:".

> + * @name_prefix: Name prefix for type to filter for.
> + * @include_abstract: Whether to include abstract classes.
> + *
> + * To the opposite of object_class_get_list, only matching types are

Suggest "Unlike object_class_get_list,"

>
> diff --git a/qom/object.c b/qom/object.c
> index f981e270440..14527108a2e 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -1062,6 +1062,30 @@ static void object_class_foreach_tramp(gpointer key, 
> gpointer value,
>  data->fn(k, data->opaque);
>  }
>  
> +static void object_class_foreach_match_name_prefix(gpointer key, gpointer 
> value,
> +   gpointer opaque)
> +{
> +OCFData *data = opaque;
> +TypeImpl *type = value;
> +ObjectClass *k;
> +
> +const char *name_prefix = data->implements_type;

Perhaps the "implements_type" field should be renamed.

> [ ... skip 11 lines ... ]
> +}
> +
> +data->fn(k, data->opaque);
> +}
> +
>  void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),

I wonder if we introduce MODULE_INIT_TARGET_INFO, is this all needed?
since only TargetInfo types would be registered..

Suggest: "Unlike object_class_get_list,"

Suggest: "Unlike object_class_get_list,"

-- 
Marc-André Lureau