[libvirt] [PATCH] esx: Reduce code duplication in generator

--- src/esx/esx_vi_generator.py | 430 ++++++++++++------------------------------- 1 file changed, 118 insertions(+), 312 deletions(-) diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py index 7130624..547eef6 100755 --- a/src/esx/esx_vi_generator.py +++ b/src/esx/esx_vi_generator.py @@ -440,8 +440,7 @@ class Type: return string - -class Object(Type): +class GenericObject(Type): FEATURE__DYNAMIC_CAST = (1 << 1) FEATURE__LIST = (1 << 2) FEATURE__DEEP_COPY = (1 << 3) @@ -450,16 +449,36 @@ class Object(Type): FEATURE__DESERIALIZE = (1 << 6) - def __init__(self, name, extends, properties, features=0, extended_by=None): + def __init__(self, name, category, managed, generic_objects_by_name): Type.__init__(self, "struct", name) - self.extends = extends - self.features = features - self.properties = properties - self.extended_by = extended_by - self.candidate_for_dynamic_cast = False + self.category = category + self.managed = managed + self.generic_objects_by_name = generic_objects_by_name + + + def generate_comment(self): + comment = separator + comment += " * %s: %s\n" % (self.category, self.name) + + if self.extends is not None: + comment += " * %s extends %s\n" \ + % (' ' * len(self.category), self.extends) + + first = True if self.extended_by is not None: - self.extended_by.sort() + for extended_by in self.extended_by: + if first: + comment += " * %s extended by %s\n" \ + % (' ' * len(self.category), extended_by) + first = False + else: + comment += " * %s %s\n" \ + % (' ' * len(self.category), extended_by) + + comment += " */\n\n" + + return comment def generate_struct_members(self, add_banner=False, struct_gap=False): @@ -469,7 +488,7 @@ class Object(Type): members += "\n" if self.extends is not None: - members += objects_by_name[self.extends] \ + members += self.generic_objects_by_name[self.extends] \ .generate_struct_members(add_banner=True, struct_gap=False) + "\n" @@ -499,7 +518,7 @@ class Object(Type): % (suffix, extended_by) for extended_by in self.extended_by: - source += objects_by_name[extended_by] \ + source += self.generic_objects_by_name[extended_by] \ .generate_dispatch(suffix, False) return source @@ -509,7 +528,7 @@ class Object(Type): source = "" if self.extends is not None: - source += objects_by_name[self.extends] \ + source += self.generic_objects_by_name[self.extends] \ .generate_free_code(add_banner=True) + "\n" if self.extends is not None or add_banner: @@ -535,7 +554,7 @@ class Object(Type): source = "" if self.extends is not None: - source += objects_by_name[self.extends] \ + source += self.generic_objects_by_name[self.extends] \ .generate_validate_code(add_banner=True) + "\n" if self.extends is not None or add_banner: @@ -547,7 +566,7 @@ class Object(Type): string = "" for property in self.properties: - string += property.generate_validate_code() + string += property.generate_validate_code(self.managed) if len(string) < 1: source += " /* no required properties */\n" @@ -557,6 +576,20 @@ class Object(Type): return source + +class Object(GenericObject): + def __init__(self, name, extends, properties, features=0, extended_by=None): + GenericObject.__init__(self, name, 'VI Object', False, objects_by_name) + self.extends = extends + self.features = features + self.properties = properties + self.extended_by = extended_by + self.candidate_for_dynamic_cast = False + + if self.extended_by is not None: + self.extended_by.sort() + + def generate_dynamic_cast_code(self, is_first=True): source = "" @@ -642,23 +675,7 @@ class Object(Type): def generate_header(self): - header = separator - header += " * VI Object: %s\n" % self.name - - if self.extends is not None: - header += " * extends %s\n" % self.extends - - first = True - - if self.extended_by is not None: - for extended_by in self.extended_by: - if first: - header += " * extended by %s\n" % extended_by - first = False - else: - header += " * %s\n" % extended_by - - header += " */\n\n" + header = self.generate_comment() # struct header += "struct _esxVI_%s {\n" % self.name @@ -762,57 +779,37 @@ class Object(Type): source += "ESX_VI__TEMPLATE__ALLOC(%s)\n\n" % self.name # free + source += "/* esxVI_%s_Free */\n" % self.name + if self.extended_by is None: - source += "/* esxVI_%s_Free */\n" % self.name source += "ESX_VI__TEMPLATE__FREE(%s,\n" % self.name - source += "{\n" - - if self.features & Object.FEATURE__LIST: - if self.extends is not None: - # avoid "dereferencing type-punned pointer will break - # strict-aliasing rules" warnings - source += " esxVI_%s *next = (esxVI_%s *)item->_next;\n\n" \ - % (self.extends, self.extends) - source += " esxVI_%s_Free(&next);\n" % self.extends - source += " item->_next = (esxVI_%s *)next;\n\n" % self.name - else: - source += " esxVI_%s_Free(&item->_next);\n\n" % self.name - - source += self.generate_free_code() - - source += "})\n\n" else: - source += "/* esxVI_%s_Free */\n" % self.name source += "ESX_VI__TEMPLATE__DYNAMIC_FREE(%s,\n" % self.name source += "{\n" - source += self.generate_dispatch('FREE') - source += "},\n" - source += "{\n" - if self.features & Object.FEATURE__LIST: - if self.extends is not None: - # avoid "dereferencing type-punned pointer will break - # strict-aliasing rules" warnings - source += " esxVI_%s *next = (esxVI_%s *)item->_next;\n\n" \ - % (self.extends, self.extends) - source += " esxVI_%s_Free(&next);\n" % self.extends - source += " item->_next = (esxVI_%s *)next;\n\n" % self.name - else: - source += " esxVI_%s_Free(&item->_next);\n\n" % self.name + source += "{\n" - source += self.generate_free_code() + if self.features & Object.FEATURE__LIST: + if self.extends is not None: + # avoid "dereferencing type-punned pointer will break + # strict-aliasing rules" warnings + source += " esxVI_%s *next = (esxVI_%s *)item->_next;\n\n" \ + % (self.extends, self.extends) + source += " esxVI_%s_Free(&next);\n" % self.extends + source += " item->_next = (esxVI_%s *)next;\n\n" % self.name + else: + source += " esxVI_%s_Free(&item->_next);\n\n" % self.name - source += "})\n\n" + source += self.generate_free_code() + source += "})\n\n" # validate source += "/* esxVI_%s_Validate */\n" % self.name source += "ESX_VI__TEMPLATE__VALIDATE(%s,\n" % self.name source += "{\n" - source += self.generate_validate_code() - source += "})\n\n" # dynamic cast @@ -821,9 +818,7 @@ class Object(Type): source += "/* esxVI_%s_DynamicCast */\n" % self.name source += "ESX_VI__TEMPLATE__DYNAMIC_CAST(%s,\n" % self.name source += "{\n" - source += self.generate_dynamic_cast_code() - source += "})\n\n" else: report_error("cannot add dynamic cast support for an untyped object") @@ -834,39 +829,25 @@ class Object(Type): source += "ESX_VI__TEMPLATE__LIST__APPEND(%s)\n\n" % self.name # deep copy - if self.extended_by is None: - if self.features & Object.FEATURE__DEEP_COPY: - source += "/* esxVI_%s_DeepCopy */\n" % self.name - source += "ESX_VI__TEMPLATE__DEEP_COPY(%s,\n" % self.name - source += "{\n" - - source += self.generate_deep_copy_code() - - source += "})\n\n" + if self.features & Object.FEATURE__DEEP_COPY: + source += "/* esxVI_%s_DeepCopy */\n" % self.name - if self.features & Object.FEATURE__LIST: - source += "/* esxVI_%s_DeepCopyList */\n" % self.name - source += "ESX_VI__TEMPLATE__LIST__DEEP_COPY(%s)\n\n" \ - % self.name - else: - if self.features & Object.FEATURE__DEEP_COPY: - source += "/* esxVI_%s_DeepCopy */\n" % self.name + if self.extended_by is None: + source += "ESX_VI__TEMPLATE__DEEP_COPY(%s,\n" % self.name + else: source += "ESX_VI__TEMPLATE__DYNAMIC_DEEP_COPY(%s,\n" % self.name source += "{\n" - source += self.generate_dispatch('DEEP_COPY') - source += "},\n" - source += "{\n" - - source += self.generate_deep_copy_code() - source += "})\n\n" + source += "{\n" + source += self.generate_deep_copy_code() + source += "})\n\n" - if self.features & Object.FEATURE__LIST: - source += "/* esxVI_%s_DeepCopyList */\n" % self.name - source += "ESX_VI__TEMPLATE__LIST__DEEP_COPY(%s)\n\n" \ - % self.name + if self.features & Object.FEATURE__LIST: + source += "/* esxVI_%s_DeepCopyList */\n" % self.name + source += "ESX_VI__TEMPLATE__LIST__DEEP_COPY(%s)\n\n" \ + % self.name # cast from any type if self.features & Object.FEATURE__ANY_TYPE: @@ -879,9 +860,7 @@ class Object(Type): source += "ESX_VI__TEMPLATE__DYNAMIC_CAST_FROM_ANY_TYPE(%s,\n" \ % self.name source += "{\n" - source += self.generate_dispatch('CAST_FROM_ANY_TYPE') - source += "})\n\n" if self.features & Object.FEATURE__LIST: @@ -890,75 +869,47 @@ class Object(Type): % self.name # serialize - if self.extended_by is None: - if self.features & Object.FEATURE__SERIALIZE: - source += "/* esxVI_%s_Serialize */\n" % self.name - source += "ESX_VI__TEMPLATE__SERIALIZE(%s,\n" % self.name - source += "{\n" - - source += self.generate_serialize_code() - - source += "})\n\n" + if self.features & Object.FEATURE__SERIALIZE: + source += "/* esxVI_%s_Serialize */\n" % self.name - if self.features & Object.FEATURE__LIST: - source += "/* esxVI_%s_SerializeList */\n" % self.name - source += "ESX_VI__TEMPLATE__LIST__SERIALIZE(%s)\n\n" \ - % self.name - else: - if self.features & Object.FEATURE__SERIALIZE: - source += "/* esxVI_%s_Serialize */\n" % self.name + if self.extended_by is None: + source += "ESX_VI__TEMPLATE__SERIALIZE(%s,\n" % self.name + else: source += "ESX_VI__TEMPLATE__DYNAMIC_SERIALIZE(%s,\n" % self.name source += "{\n" - source += self.generate_dispatch('SERIALIZE') - source += "},\n" - source += "{\n" - - source += self.generate_serialize_code() - source += "})\n\n" + source += "{\n" + source += self.generate_serialize_code() + source += "})\n\n" - if self.features & Object.FEATURE__LIST: - source += "/* esxVI_%s_SerializeList */\n" % self.name - source += "ESX_VI__TEMPLATE__LIST__SERIALIZE(%s)\n\n" \ - % self.name + if self.features & Object.FEATURE__LIST: + source += "/* esxVI_%s_SerializeList */\n" % self.name + source += "ESX_VI__TEMPLATE__LIST__SERIALIZE(%s)\n\n" \ + % self.name # deserialize - if self.extended_by is None: - if self.features & Object.FEATURE__DESERIALIZE: - source += "/* esxVI_%s_Deserialize */\n" % self.name - source += "ESX_VI__TEMPLATE__DESERIALIZE(%s,\n" % self.name - source += "{\n" - - source += self.generate_deserialize_code() - - source += "})\n\n" + if self.features & Object.FEATURE__DESERIALIZE: + source += "/* esxVI_%s_Deserialize */\n" % self.name - if self.features & Object.FEATURE__LIST: - source += "/* esxVI_%s_DeserializeList */\n" % self.name - source += "ESX_VI__TEMPLATE__LIST__DESERIALIZE(%s)\n\n" \ - % self.name - else: - if self.features & Object.FEATURE__DESERIALIZE: - source += "/* esxVI_%s_Deserialize */\n" % self.name + if self.extended_by is None: + source += "ESX_VI__TEMPLATE__DESERIALIZE(%s,\n" % self.name + else: source += "ESX_VI__TEMPLATE__DYNAMIC_DESERIALIZE(%s,\n" \ % self.name source += "{\n" - source += self.generate_dispatch('DESERIALIZE') - source += "},\n" - source += "{\n" - - source += self.generate_deserialize_code() - source += "})\n\n" + source += "{\n" + source += self.generate_deserialize_code() + source += "})\n\n" - if self.features & Object.FEATURE__LIST: - source += "/* esxVI_%s_DeserializeList */\n" % self.name - source += "ESX_VI__TEMPLATE__LIST__DESERIALIZE(%s)\n\n" \ - % self.name + if self.features & Object.FEATURE__LIST: + source += "/* esxVI_%s_DeserializeList */\n" % self.name + source += "ESX_VI__TEMPLATE__LIST__DESERIALIZE(%s)\n\n" \ + % self.name source += "\n\n" @@ -966,12 +917,10 @@ class Object(Type): -class ManagedObject(Type): - FEATURE__LIST = (1 << 2) - - +class ManagedObject(GenericObject): def __init__(self, name, extends, properties, features=0, extended_by=None): - Type.__init__(self, "struct", name) + GenericObject.__init__(self, name, 'VI Managed Object', True, + managed_objects_by_name) self.extends = extends self.features = features self.properties = properties @@ -981,100 +930,6 @@ class ManagedObject(Type): self.extended_by.sort() - def generate_struct_members(self, add_banner=False, struct_gap=False): - members = "" - - if struct_gap: - members += "\n" - - if self.extends is not None: - members += managed_objects_by_name[self.extends] \ - .generate_struct_members(add_banner=True) + "\n" - - if self.extends is not None or add_banner: - members += " /* %s */\n" % self.name - - for property in self.properties: - members += property.generate_struct_member() - - if len(self.properties) < 1: - members += " /* no properties */\n" - - return members - - - def generate_dispatch(self, suffix, is_first=True): - source = "" - - if self.extended_by is not None: - if not is_first: - source += "\n" - - source += " /* %s */\n" % self.name - - for extended_by in self.extended_by: - source += " ESX_VI__TEMPLATE__DISPATCH__%s(%s)\n" \ - % (suffix, extended_by) - - for extended_by in self.extended_by: - source += managed_objects_by_name[extended_by] \ - .generate_dispatch(suffix, False) - - return source - - - def generate_free_code(self, add_banner=False): - source = "" - - if self.extends is not None: - source += managed_objects_by_name[self.extends] \ - .generate_free_code(add_banner=True) + "\n" - - if self.extends is not None or add_banner: - source += " /* %s */\n" % self.name - - if len(self.properties) < 1: - source += " /* no properties */\n" - else: - string = "" - - for property in self.properties: - string += property.generate_free_code() - - if len(string) < 1: - source += " /* no properties to be freed */\n" - else: - source += string - - return source - - - def generate_validate_code(self, add_banner=False): - source = "" - - if self.extends is not None: - source += managed_objects_by_name[self.extends] \ - .generate_validate_code(add_banner=True) + "\n" - - if self.extends is not None or add_banner: - source += " /* %s */\n" % self.name - - if len(self.properties) < 1: - source += " /* no properties */\n" - else: - string = "" - - for property in self.properties: - string += property.generate_validate_code(managed=True) - - if len(string) < 1: - source += " /* no required properties */\n" - else: - source += string - - return source - - def generate_lookup_code1(self, add_banner=False): source = "" @@ -1127,30 +982,6 @@ class ManagedObject(Type): return source - def generate_comment(self): - comment = separator - comment += " * VI Managed Object: %s\n" % self.name - - if self.extends is not None: - comment += " * extends %s\n" % self.extends - - first = True - - if self.extended_by is not None: - for extended_by in self.extended_by: - if first: - comment += " * extended by %s\n" \ - % extended_by - first = False - else: - comment += " * %s\n" \ - % extended_by - - comment += " */\n\n" - - return comment - - def generate_header(self): header = self.generate_comment() @@ -1169,7 +1000,6 @@ class ManagedObject(Type): "/* required */\n") header += "\n" header += self.generate_struct_members() - header += "};\n\n" # functions @@ -1213,53 +1043,32 @@ class ManagedObject(Type): source += "ESX_VI__TEMPLATE__ALLOC(%s)\n\n" % self.name # free + source += "/* esxVI_%s_Free */\n" % self.name + if self.extended_by is None: - source += "/* esxVI_%s_Free */\n" % self.name source += "ESX_VI__TEMPLATE__FREE(%s,\n" % self.name - source += "{\n" - - if self.features & ManagedObject.FEATURE__LIST: - if self.extends is not None: - # avoid "dereferencing type-punned pointer will break - # strict-aliasing rules" warnings - source += " esxVI_%s *next = (esxVI_%s *)item->_next;\n\n" \ - % (self.extends, self.extends) - source += " esxVI_%s_Free(&next);\n" % self.extends - source += " item->_next = (esxVI_%s *)next;\n\n" % self.name - else: - source += " esxVI_%s_Free(&item->_next);\n" % self.name - - source += " esxVI_ManagedObjectReference_Free(&item->_reference);\n\n" - - source += self.generate_free_code() - - source += "})\n\n" else: - source += "/* esxVI_%s_Free */\n" % self.name source += "ESX_VI__TEMPLATE__DYNAMIC_FREE(%s,\n" % self.name source += "{\n" - source += self.generate_dispatch('FREE') - source += "},\n" - source += "{\n" - - if self.features & ManagedObject.FEATURE__LIST: - if self.extends is not None: - # avoid "dereferencing type-punned pointer will break - # strict-aliasing rules" warnings - source += " esxVI_%s *next = (esxVI_%s *)item->_next;\n\n" \ - % (self.extends, self.extends) - source += " esxVI_%s_Free(&next);\n" % self.extends - source += " item->_next = (esxVI_%s *)next;\n\n" % self.name - else: - source += " esxVI_%s_Free(&item->_next);\n" % self.name - source += " esxVI_ManagedObjectReference_Free(&item->_reference);\n\n" + source += "{\n" - source += self.generate_free_code() + if self.features & ManagedObject.FEATURE__LIST: + if self.extends is not None: + # avoid "dereferencing type-punned pointer will break + # strict-aliasing rules" warnings + source += " esxVI_%s *next = (esxVI_%s *)item->_next;\n\n" \ + % (self.extends, self.extends) + source += " esxVI_%s_Free(&next);\n" % self.extends + source += " item->_next = (esxVI_%s *)next;\n\n" % self.name + else: + source += " esxVI_%s_Free(&item->_next);\n" % self.name - source += "})\n\n" + source += " esxVI_ManagedObjectReference_Free(&item->_reference);\n\n" + source += self.generate_free_code() + source += "})\n\n" # validate source += "/* esxVI_%s_Validate */\n" % self.name @@ -1319,8 +1128,6 @@ class Enum(Type): header = separator header += " * VI Enum: %s\n" % self.name header += " */\n\n" - - # enum header += "enum _esxVI_%s {\n" % self.name header += " esxVI_%s_Undefined = 0,\n" % self.name @@ -1354,7 +1161,6 @@ class Enum(Type): source = separator source += " * VI Enum: %s\n" % self.name source += " */\n\n" - source += "static const esxVI_Enumeration _esxVI_%s_Enumeration = {\n" \ % self.name source += " esxVI_Type_%s, {\n" % self.name -- 1.7.9.5

On 05/01/2013 12:44 PM, Matthias Bolte wrote:
--- src/esx/esx_vi_generator.py | 430 ++++++++++++------------------------------- 1 file changed, 118 insertions(+), 312 deletions(-)
My python is weak, so I reviewed this by comparing the generated files before and after this patch; added comments in the generated code are nice, but there are also some added frees. Are these additions intentional to fix a leak, or are they representing a bug in your patch? If intentional, then this is 1.0.5 material if you improve the commit message and push in time; if accidental and no real bug is being fixed, then a v2 should wait until after the release. Here's the difference in generated files: diff -ur src/esx.bak/esx_vi_types.generated.c src/esx/esx_vi_types.generated.c --- src/esx.bak/esx_vi_types.generated.c 2013-05-01 21:20:40.749653184 -0600 +++ src/esx/esx_vi_types.generated.c 2013-05-01 21:21:43.270214170 -0600 @@ -515,6 +515,7 @@ /* esxVI_DatastoreInfo_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(DatastoreInfo, { + /* DatastoreInfo */ ESX_VI__TEMPLATE__DISPATCH__FREE(LocalDatastoreInfo) ESX_VI__TEMPLATE__DISPATCH__FREE(NasDatastoreInfo) ESX_VI__TEMPLATE__DISPATCH__FREE(VmfsDatastoreInfo) @@ -583,7 +584,11 @@ /* esxVI_Description_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(Description, { + /* Description */ ESX_VI__TEMPLATE__DISPATCH__FREE(ElementDescription) + + /* ElementDescription */ + ESX_VI__TEMPLATE__DISPATCH__FREE(ExtendedElementDescription) }, { esxVI_Description_Free(&item->_next); @@ -739,6 +744,7 @@ /* esxVI_ElementDescription_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(ElementDescription, { + /* ElementDescription */ ESX_VI__TEMPLATE__DISPATCH__FREE(ExtendedElementDescription) }, { @@ -808,6 +814,7 @@ /* esxVI_EntityEventArgument_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(EntityEventArgument, { + /* EntityEventArgument */ ESX_VI__TEMPLATE__DISPATCH__FREE(VmEventArgument) }, { @@ -855,7 +862,11 @@ /* esxVI_EventArgument_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(EventArgument, { + /* EventArgument */ ESX_VI__TEMPLATE__DISPATCH__FREE(EntityEventArgument) + + /* EntityEventArgument */ + ESX_VI__TEMPLATE__DISPATCH__FREE(VmEventArgument) }, { /* no properties */ @@ -1018,6 +1029,7 @@ /* esxVI_FileInfo_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(FileInfo, { + /* FileInfo */ ESX_VI__TEMPLATE__DISPATCH__FREE(FloppyImageFileInfo) ESX_VI__TEMPLATE__DISPATCH__FREE(FolderFileInfo) ESX_VI__TEMPLATE__DISPATCH__FREE(IsoImageFileInfo) @@ -1026,6 +1038,9 @@ ESX_VI__TEMPLATE__DISPATCH__FREE(VmLogFileInfo) ESX_VI__TEMPLATE__DISPATCH__FREE(VmNvramFileInfo) ESX_VI__TEMPLATE__DISPATCH__FREE(VmSnapshotFileInfo) + + /* VmConfigFileInfo */ + ESX_VI__TEMPLATE__DISPATCH__FREE(TemplateConfigFileInfo) }, { esxVI_FileInfo_Free(&item->_next); @@ -1108,6 +1123,7 @@ /* esxVI_FileQuery_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(FileQuery, { + /* FileQuery */ ESX_VI__TEMPLATE__DISPATCH__FREE(FloppyImageFileQuery) ESX_VI__TEMPLATE__DISPATCH__FREE(FolderFileQuery) ESX_VI__TEMPLATE__DISPATCH__FREE(IsoImageFileQuery) @@ -1116,6 +1132,9 @@ ESX_VI__TEMPLATE__DISPATCH__FREE(VmLogFileQuery) ESX_VI__TEMPLATE__DISPATCH__FREE(VmNvramFileQuery) ESX_VI__TEMPLATE__DISPATCH__FREE(VmSnapshotFileQuery) + + /* VmConfigFileQuery */ + ESX_VI__TEMPLATE__DISPATCH__FREE(TemplateConfigFileQuery) }, { esxVI_FileQuery_Free(&item->_next); @@ -1822,7 +1841,11 @@ /* esxVI_HostDevice_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(HostDevice, { + /* HostDevice */ ESX_VI__TEMPLATE__DISPATCH__FREE(ScsiLun) + + /* ScsiLun */ + ESX_VI__TEMPLATE__DISPATCH__FREE(HostScsiDisk) }, { esxVI_HostDevice_Free(&item->_next); @@ -2104,6 +2127,7 @@ /* esxVI_HostFileSystemVolume_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(HostFileSystemVolume, { + /* HostFileSystemVolume */ ESX_VI__TEMPLATE__DISPATCH__FREE(HostNasVolume) ESX_VI__TEMPLATE__DISPATCH__FREE(HostVmfsVolume) }, @@ -2150,6 +2174,7 @@ /* esxVI_HostHostBusAdapter_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(HostHostBusAdapter, { + /* HostHostBusAdapter */ ESX_VI__TEMPLATE__DISPATCH__FREE(HostBlockHba) ESX_VI__TEMPLATE__DISPATCH__FREE(HostFibreChannelHba) ESX_VI__TEMPLATE__DISPATCH__FREE(HostInternetScsiHba) @@ -4153,6 +4178,7 @@ /* esxVI_HostTargetTransport_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(HostTargetTransport, { + /* HostTargetTransport */ ESX_VI__TEMPLATE__DISPATCH__FREE(HostBlockAdapterTargetTransport) ESX_VI__TEMPLATE__DISPATCH__FREE(HostFibreChannelTargetTransport) ESX_VI__TEMPLATE__DISPATCH__FREE(HostInternetScsiTargetTransport) @@ -4459,6 +4485,7 @@ /* esxVI_HostVirtualSwitchBridge_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(HostVirtualSwitchBridge, { + /* HostVirtualSwitchBridge */ ESX_VI__TEMPLATE__DISPATCH__FREE(HostVirtualSwitchAutoBridge) ESX_VI__TEMPLATE__DISPATCH__FREE(HostVirtualSwitchBondBridge) ESX_VI__TEMPLATE__DISPATCH__FREE(HostVirtualSwitchSimpleBridge) @@ -5147,6 +5174,7 @@ /* esxVI_OptionType_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(OptionType, { + /* OptionType */ ESX_VI__TEMPLATE__DISPATCH__FREE(ChoiceOption) }, { @@ -5182,6 +5210,7 @@ /* esxVI_OptionValue_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(OptionValue, { + /* OptionValue */ ESX_VI__TEMPLATE__DISPATCH__FREE(HostInternetScsiHbaParamValue) }, { @@ -5358,6 +5387,7 @@ /* esxVI_PerfEntityMetricBase_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(PerfEntityMetricBase, { + /* PerfEntityMetricBase */ ESX_VI__TEMPLATE__DISPATCH__FREE(PerfEntityMetric) }, { @@ -5512,6 +5542,7 @@ /* esxVI_PerfMetricSeries_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(PerfMetricSeries, { + /* PerfMetricSeries */ ESX_VI__TEMPLATE__DISPATCH__FREE(PerfMetricIntSeries) }, { @@ -6042,6 +6073,7 @@ /* esxVI_ScsiLun_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(ScsiLun, { + /* ScsiLun */ ESX_VI__TEMPLATE__DISPATCH__FREE(HostScsiDisk) }, { @@ -6320,6 +6352,7 @@ /* esxVI_SelectionSpec_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(SelectionSpec, { + /* SelectionSpec */ ESX_VI__TEMPLATE__DISPATCH__FREE(TraversalSpec) }, { @@ -6869,6 +6902,7 @@ /* esxVI_VirtualDiskSpec_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(VirtualDiskSpec, { + /* VirtualDiskSpec */ ESX_VI__TEMPLATE__DISPATCH__FREE(DeviceBackedVirtualDiskSpec) ESX_VI__TEMPLATE__DISPATCH__FREE(FileBackedVirtualDiskSpec) }, @@ -7156,6 +7190,7 @@ /* esxVI_VmConfigFileInfo_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(VmConfigFileInfo, { + /* VmConfigFileInfo */ ESX_VI__TEMPLATE__DISPATCH__FREE(TemplateConfigFileInfo) }, { @@ -7228,6 +7263,7 @@ /* esxVI_VmConfigFileQuery_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(VmConfigFileQuery, { + /* VmConfigFileQuery */ ESX_VI__TEMPLATE__DISPATCH__FREE(TemplateConfigFileQuery) }, { @@ -8140,6 +8176,7 @@ /* esxVI_ManagedEntity_Free */ ESX_VI__TEMPLATE__DYNAMIC_FREE(ManagedEntity, { + /* ManagedEntity */ ESX_VI__TEMPLATE__DISPATCH__FREE(ComputeResource) ESX_VI__TEMPLATE__DISPATCH__FREE(Datacenter) ESX_VI__TEMPLATE__DISPATCH__FREE(Folder) -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

2013/5/2 Eric Blake <eblake@redhat.com>:
On 05/01/2013 12:44 PM, Matthias Bolte wrote:
--- src/esx/esx_vi_generator.py | 430 ++++++++++++------------------------------- 1 file changed, 118 insertions(+), 312 deletions(-)
My python is weak, so I reviewed this by comparing the generated files before and after this patch; added comments in the generated code are nice, but there are also some added frees. Are these additions intentional to fix a leak, or are they representing a bug in your patch? If intentional, then this is 1.0.5 material if you improve the commit message and push in time; if accidental and no real bug is being fixed, then a v2 should wait until after the release.
The changes in the generated files you're seeing here are intended, but they are coming from another patch that I pushed yesterday: http://libvirt.org/git/?p=libvirt.git;a=commit;h=4e650435edeb2870c907721ea8b... This refactoring patch should not change the output at all. And it didn't in my test. -- Matthias Bolte http://photron.blogspot.com

On 05/02/2013 07:09 AM, Matthias Bolte wrote:
2013/5/2 Eric Blake <eblake@redhat.com>:
On 05/01/2013 12:44 PM, Matthias Bolte wrote:
--- src/esx/esx_vi_generator.py | 430 ++++++++++++------------------------------- 1 file changed, 118 insertions(+), 312 deletions(-)
My python is weak, so I reviewed this by comparing the generated files before and after this patch; added comments in the generated code are nice, but there are also some added frees. Are these additions intentional to fix a leak, or are they representing a bug in your patch? If intentional, then this is 1.0.5 material if you improve the commit message and push in time; if accidental and no real bug is being fixed, then a v2 should wait until after the release.
The changes in the generated files you're seeing here are intended, but they are coming from another patch that I pushed yesterday:
http://libvirt.org/git/?p=libvirt.git;a=commit;h=4e650435edeb2870c907721ea8b...
This refactoring patch should not change the output at all. And it didn't in my test.
Then that must be an effect of me grabbing my snapshot at the wrong point when swapping between incremental builds. I'll try again, and sorry for the hassle that my confusion caused... -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 05/02/2013 07:56 AM, Eric Blake wrote:
On 05/02/2013 07:09 AM, Matthias Bolte wrote:
2013/5/2 Eric Blake <eblake@redhat.com>:
On 05/01/2013 12:44 PM, Matthias Bolte wrote:
--- src/esx/esx_vi_generator.py | 430 ++++++++++++------------------------------- 1 file changed, 118 insertions(+), 312 deletions(-)
My python is weak, so I reviewed this by comparing the generated files before and after this patch; added comments in the generated code are nice, but there are also some added frees. Are these additions intentional to fix a leak, or are they representing a bug in your patch? If intentional, then this is 1.0.5 material if you improve the commit message and push in time; if accidental and no real bug is being fixed, then a v2 should wait until after the release.
The changes in the generated files you're seeing here are intended, but they are coming from another patch that I pushed yesterday:
http://libvirt.org/git/?p=libvirt.git;a=commit;h=4e650435edeb2870c907721ea8b...
This refactoring patch should not change the output at all. And it didn't in my test.
Then that must be an effect of me grabbing my snapshot at the wrong point when swapping between incremental builds. I'll try again, and sorry for the hassle that my confusion caused...
Indeed; once I grabbed the correct diff, I see no change in the output files. And now that the release is out, it's no longer a risk of violating freeze. ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

2013/5/2 Eric Blake <eblake@redhat.com>:
On 05/02/2013 07:56 AM, Eric Blake wrote:
On 05/02/2013 07:09 AM, Matthias Bolte wrote:
2013/5/2 Eric Blake <eblake@redhat.com>:
On 05/01/2013 12:44 PM, Matthias Bolte wrote:
--- src/esx/esx_vi_generator.py | 430 ++++++++++++------------------------------- 1 file changed, 118 insertions(+), 312 deletions(-)
My python is weak, so I reviewed this by comparing the generated files before and after this patch; added comments in the generated code are nice, but there are also some added frees. Are these additions intentional to fix a leak, or are they representing a bug in your patch? If intentional, then this is 1.0.5 material if you improve the commit message and push in time; if accidental and no real bug is being fixed, then a v2 should wait until after the release.
The changes in the generated files you're seeing here are intended, but they are coming from another patch that I pushed yesterday:
http://libvirt.org/git/?p=libvirt.git;a=commit;h=4e650435edeb2870c907721ea8b...
This refactoring patch should not change the output at all. And it didn't in my test.
Then that must be an effect of me grabbing my snapshot at the wrong point when swapping between incremental builds. I'll try again, and sorry for the hassle that my confusion caused...
Indeed; once I grabbed the correct diff, I see no change in the output files. And now that the release is out, it's no longer a risk of violating freeze.
ACK.
Thanks, pushed. -- Matthias Bolte http://photron.blogspot.com
participants (2)
-
Eric Blake
-
Matthias Bolte