2013/5/20 Eric Blake <eblake(a)redhat.com>:
On 05/18/2013 04:03 PM, Matthias Bolte wrote:
> VI objects support inheritance with subtype polymorphism. For example the
> FileInfo object type is extended by FloppyImageFileInfo, FolderFileInfo
> etc. Then SearchDatastore_Task returns an array of FileInfo objects and
> depending on the represented file the FileInfo is actually a FolderFileInfo
> or FloppyImageFileInfo etc. The actual type information is stored as XML
> attribute that allows clients such as libvirt to distinguish between the
> actual types. esxVI_GetActualObjectType is used to extract the actual type.
>
> I assumed that this mechanism would be used for all VI object types that
> have subtypes. But this is not the case. It seems only to be used for types
> that are actually used as generic base type such as FileInfo. But it is not
> used for types that got extended later such as ElementDescription that was
> extended by ExtendedElementDescription (added in vSphere API 4.0) or that
> are not meant to be used with subtype polymorphism.
>
> This breaks the deserialization of types that contain ElementDescription
> properties such as PerfCounterInfo or ChoiceOption, because the code
> expects an ElementDescription object to have an XML attribute named type
> that is not present, since ExtendedElementDescription was added to the
> esx_vi_generator.input in commit 60f0f55ee4686fecbffc5fb32f90863427d02a14.
> This in turn break virtual machine question handling and auto answering.
>
> Fix this by using the base type if no XML type attribute is present.
> ---
> src/esx/esx_vi_types.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
> index 1a26556..c55396c 100644
> --- a/src/esx/esx_vi_types.c
> +++ b/src/esx/esx_vi_types.c
> @@ -720,10 +720,9 @@ esxVI_GetActualObjectType(xmlNodePtr node, esxVI_Type baseType,
> BAD_CAST
"http://www.w3.org/2001/XMLSchema-instance");
>
> if (type == NULL) {
> - virReportError(VIR_ERR_INTERNAL_ERROR,
> - _("%s is missing 'type' property"),
> - esxVI_Type_ToString(baseType));
> - return -1;
> + // no actual type specified, use base type instead
Use /**/, not //
> + *actualType = baseType;
> + return 0;
> }
ACK with comment fixed.
Comment style changed and pushed, thanks.
--
Matthias Bolte
http://photron.blogspot.com