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