Re: [PATCH 1/7] libvirt.h: consolidate typed parameter handling

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

 



2011/5/18 Hu Tao <hutao@xxxxxxxxxxxxxx>:
> On Tue, May 17, 2011 at 04:42:09PM -0600, Eric Blake wrote:
>> * include/libvirt/libvirt.h.in (virTypedParameterType)
>> (VIR_TYPED_PARAM_FIELD_LENGTH, _virTypedParameter): New enum,
>> macro, and type.
>> (virSchedParameter, virBlkioParameter, virMemoryParameter):
>> Rewrite in terms of a common type, while keeping all old public
>> names for backwards compatibility.
>> (struct _virSchedParameter, struct _virBlkioParameter)
>> (struct _virMemoryParameter): Delete - these are private names.
>> * python/generator.py (enum): Cope with the refactoring.
>> ---
>> Âinclude/libvirt/libvirt.h.in | Â144 +++++++++++++++++++++++------------------
>> Âpython/generator.py     Â|  12 ++++
>> Â2 files changed, 93 insertions(+), 63 deletions(-)
>>
>> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
>> index a174201..7cd6e13 100644
>> --- a/include/libvirt/libvirt.h.in
>> +++ b/include/libvirt/libvirt.h.in
>> @@ -281,18 +281,70 @@ struct _virNodeInfo {
>> Â};
>>
>>
>> +/* Common data types shared among interfaces with name/type/value lists. Â*/
>> +
>> +/**
>> + * virTypedParameterType:
>> + *
>> + * Express the type of a virTypedParameter
>> + */
>> +typedef enum {
>> + Â ÂVIR_TYPED_PARAM_INT Â Â = 1, /* integer case */
>> + Â ÂVIR_TYPED_PARAM_UINT Â Â= 2, /* unsigned integer case */
>> + Â ÂVIR_TYPED_PARAM_LLONG Â = 3, /* long long case */
>> + Â ÂVIR_TYPED_PARAM_ULLONG Â= 4, /* unsigned long long case */
>> + Â ÂVIR_TYPED_PARAM_DOUBLE Â= 5, /* double case */
>> + Â ÂVIR_TYPED_PARAM_BOOLEAN = 6 Â/* boolean(character) case */
>> +} virTypedParameterType;
>> +
>> +/**
>> + * VIR_TYPED_PARAM_FIELD_LENGTH:
>> + *
>> + * Macro providing the field length of virTypedParameter name
>> + */
>> +#define VIR_TYPED_PARAM_FIELD_LENGTH 80
>> +
>> +/**
>> + * virTypedParameter:
>> + *
>> + * A named parameter, including a type and value.
>> + */
>> +typedef struct _virTypedParameter virTypedParameter;
>> +
>> +struct _virTypedParameter {
>> + Â Âchar field[VIR_TYPED_PARAM_FIELD_LENGTH]; Â/* parameter name */
>> + Â Âint type; Â /* parameter type, virTypedParameterType */
>
> virTypedParameterType type; ?

We typically use int even for enum values. There is probably a reason
for that but I'm not aware of it right now.

In this case we might need to stick to int for ABI compatibility,
because the old structs used int. Assuming that enum is not guaranteed
to be the same size as int by the C standard, but I don't know.

>> + Â Âunion {
>> + Â Â Â Âint i; Â Â Â Â Â Â Â Â Â Â Â/* type is INT */
>> + Â Â Â Âunsigned int ui; Â Â Â Â Â Â/* type is UINT */
>> + Â Â Â Âlong long int l; Â Â Â Â Â Â/* type is LLONG */
>> + Â Â Â Âunsigned long long int ul; Â/* type is ULLONG */
>> + Â Â Â Âdouble d; Â Â Â Â Â Â Â Â Â /* type is DOUBLE */
>> + Â Â Â Âchar b; Â Â Â Â Â Â Â Â Â Â /* type is BOOLEAN */
>> + Â Â} value; /* parameter value */
>> +};
>> +
>> +/**
>> + * virTypedParameterPtr:
>> + *
>> + * a pointer to a virTypedParameter structure.
>> + */
>> +typedef virTypedParameter *virTypedParameterPtr;
>> +
>> +/* Management of scheduler parameters */
>> +
>> Â/**
>> Â * virDomainSchedParameterType:
>> Â *
>> Â * A scheduler parameter field type
>> Â */
>> Âtypedef enum {
>> - Â ÂVIR_DOMAIN_SCHED_FIELD_INT Â Â = 1, /* integer case */
>> - Â ÂVIR_DOMAIN_SCHED_FIELD_UINT Â Â= 2, /* unsigned integer case */
>> - Â ÂVIR_DOMAIN_SCHED_FIELD_LLONG Â = 3, /* long long case */
>> - Â ÂVIR_DOMAIN_SCHED_FIELD_ULLONG Â= 4, /* unsigned long long case */
>> - Â ÂVIR_DOMAIN_SCHED_FIELD_DOUBLE Â= 5, /* double case */
>> - Â ÂVIR_DOMAIN_SCHED_FIELD_BOOLEAN = 6 Â/* boolean(character) case */
>> + Â ÂVIR_DOMAIN_SCHED_FIELD_INT Â Â = VIR_TYPED_PARAM_INT,
>> + Â ÂVIR_DOMAIN_SCHED_FIELD_UINT Â Â= VIR_TYPED_PARAM_UINT,
>> + Â ÂVIR_DOMAIN_SCHED_FIELD_LLONG Â = VIR_TYPED_PARAM_LLONG,
>> + Â ÂVIR_DOMAIN_SCHED_FIELD_ULLONG Â= VIR_TYPED_PARAM_ULLONG,
>> + Â ÂVIR_DOMAIN_SCHED_FIELD_DOUBLE Â= VIR_TYPED_PARAM_DOUBLE,
>> + Â ÂVIR_DOMAIN_SCHED_FIELD_BOOLEAN = VIR_TYPED_PARAM_BOOLEAN,
>> Â} virSchedParameterType;
>
> Can we remove VIR_DOMAIN_SCHED_FIELD_XXX and use VIR_TYPED_PARAM_XXX
> directly since parameter types are basically types like int, long, ...
> and don't depend on what parameters are?
>
> Likewise for other PARAMs in this patch.

We cannot, because the old symbols are part of the released API so we
cannot remove them without breaking backwards compatibility.

Matthias

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]