Hi Matthias,

As promised, below is the patch demonstrating the issue. One thing I lied was its not enum that I missed but I missed one of the data objects extended.
------------------------------
 Patch is only to demonstrate the misleading error warning if
one extended data objects is not defined and an attempt to
"CastFromAny" is done on the base object.

HostHostBusAdapter is extended by:
HostBlockHba, HostInternetScsiHba, HostFibreChannelHba and HostParallelScsiHba.

In this demo, definition of HostParallelHba is missing from esx_vi_generator.input.

Signed-off-by: Ata E Husain Bohra <ata.husain@hotmail.com>
---
src/esx/esx_storage_driver.c | 40 ++++++++-
src/esx/esx_vi_generator.input | 187 ++++++++++++++++++++++++++++++++++++++++
src/esx/esx_vi_generator.py | 2 +
3 files changed, 226 insertions(+), 3 deletions(-)

diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c
index 9b64891..963bd42 100644
--- a/src/esx/esx_storage_driver.c
+++ b/src/esx/esx_storage_driver.c
@@ -238,12 +238,46 @@ esxNumberOfDefinedStoragePools(virConnectPtr conn ATTRIBUTE_UNUSED)


static int
-esxListDefinedStoragePools(virConnectPtr conn ATTRIBUTE_UNUSED,
+esxListDefinedStoragePools(virConnectPtr conn,
char **const names ATTRIBUTE_UNUSED,
int maxnames ATTRIBUTE_UNUSED)
{
- /* ESX storage pools are always active */
- return 0;
+ esxPrivate *priv = conn->storagePrivateData;
+ esxVI_DynamicProperty *dynamicProperty = NULL;
+ esxVI_ObjectContent *hostSystem = NULL;
+ esxVI_String *propertyNameList = NULL;
+ esxVI_HostHostBusAdapter *hostAdapterList = NULL;
+ int result = -1;
+
+ if (esxVI_String_AppendValueToList(&propertyNameList,
+ "config.storageDevice.hostBusAdapter\0") < 0 ||
+ esxVI_LookupHostSystemProperties(priv->primary,
+ propertyNameList, &hostSystem) < 0) {
+ goto cleanup;
+ }
+
+ for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
+ dynamicProperty = dynamicProperty->_next) {
+ if (STREQ(dynamicProperty->name,
+ "config.storageDevice.hostBusAdapter")) {
+ if (esxVI_HostHostBusAdapter_CastListFromAnyType(
+ dynamicProperty->val, &hostAdapterList) < 0 ||
+ hostAdapterList == NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Could not cast HostHostBusAdapter from AnyType"));
+ goto cleanup;
+ }
+ }
+ }
+
+ result = 0;
+
+cleanup:
+ esxVI_String_Free(&propertyNameList);
+ esxVI_ObjectContent_Free(&hostSystem);
+ esxVI_HostHostBusAdapter_Free(&hostAdapterList);
+
+ return result;
}


diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input
index 1a67a8c..85f0749 100644
--- a/src/esx/esx_vi_generator.input
+++ b/src/esx/esx_vi_generator.input
@@ -58,6 +58,14 @@ enum AutoStartWaitHeartbeatSetting
end


+enum FibreChannelPortType
+ fabric
+ loop
+ pointToPoint
+ unknown
+end
+
+
enum ManagedEntityStatus
gray
green
@@ -263,6 +271,11 @@ object HostAutoStartManagerConfig
end


+
+object HostBlockHba extends HostHostBusAdapter
+end
+
+
object HostConfigManager
ManagedObjectReference cpuScheduler o
ManagedObjectReference datastoreSystem o
@@ -310,6 +323,15 @@ object HostDatastoreBrowserSearchSpec
end


+
+object HostFibreChannelHba extends HostHostBusAdapter
+ Long nodeWorldWideName r
+ FibreChannelPortType portType r
+ Long portWorldWideName r
+ Long speed r
+end
+
+
object HostFileSystemVolume
String type r
String name r
@@ -317,6 +339,160 @@ object HostFileSystemVolume
end


+object HostHostBusAdapter
+ Int bus r
+ String device r
+ String driver o
+ String key o
+ String model r
+ String pci o
+ String status r
+end
+
+
+
+object HostInternetScsiHba extends HostHostBusAdapter
+ HostInternetScsiHbaAuthenticationCapabilities authenticationCapabilities r
+ HostInternetScsiHbaAuthenticationProperties authenticationProperties r
+ HostInternetScsiHbaDiscoveryCapabilities discoveryCapabilities r
+ HostInternetScsiHbaDiscoveryProperties discoveryProperties r
+ HostInternetScsiHbaIPCapabilities ipCapabilities r
+ HostInternetScsiHbaIPProperties ipProperties r
+ String iScsiName r
+ Boolean isSoftwareBased r
+ HostInternetScsiHbaParamValue advancedOptions ol
+ HostInternetScsiHbaSendTarget configuredSendTarget ol
+ HostInternetScsiHbaStaticTarget configuredStaticTarget ol
+ Int currentSpeedMb o
+ HostInternetScsiHbaDigestCapabilities digestCapabilities o
+ HostInternetScsiHbaDigestProperties digestProperties o
+ String iScsiAlias o
+ Int maxSpeedMb o
+ OptionDef supportedAdvancedOptions ol
+end
+
+
+
+object HostInternetScsiHbaAuthenticationCapabilities
+ Boolean chapAuthSettable r
+ Boolean krb5AuthSettable r
+ Boolean spkmAuthSettable r
+ Boolean srpAuthSettable r
+ Boolean mutualChapSettable o
+ Boolean targetChapSettable o
+ Boolean targetMutualChapSettable o
+end
+
+
+object HostInternetScsiHbaAuthenticationProperties
+ Boolean chapAuthEnabled r
+ String chapAuthenticationType o
+ Boolean chapInherited o
+ String chapName o
+ String chapSecret o
+ String mutualChapAuthenticationType o
+ Boolean mutualChapInherited o
+ String mutualChapName o
+ String mutualChapSecret o
+end
+
+
+object HostInternetScsiHbaDigestCapabilities
+ Boolean dataDigestSettable o
+ Boolean headerDigestSettable o
+ Boolean targetDataDigestSettable o
+ Boolean targetHeaderDigestSettable o
+end
+
+
+object HostInternetScsiHbaDigestProperties
+ Boolean dataDigestInherited o
+ String dataDigestType o
+ Boolean headerDigestInherited o
+ String headerDigestType o
+end
+
+
+object HostInternetScsiHbaDiscoveryCapabilities
+ Boolean iSnsDiscoverySettable r
+ Boolean sendTargetsDiscoverySettable r
+ Boolean slpDiscoverySettable r
+ Boolean staticTargetDiscoverySettable r
+end
+
+
+object HostInternetScsiHbaDiscoveryProperties
+ Boolean iSnsDiscoveryEnabled r
+ Boolean sendTargetsDiscoveryEnabled r
+ Boolean slpDiscoveryEnabled r
+ Boolean staticTargetDiscoveryEnabled r
+ String iSnsDiscoveryMethod o
+ String iSnsHost o
+ String slpDiscoveryMethod o
+ String slpHost o
+end
+
+object HostInternetScsiHbaIPCapabilities
+ Boolean addressSettable r
+ Boolean alternateDnsServerAddressSettable r
+ Boolean defaultGatewaySettable r
+ Boolean ipConfigurationMethodSettable r
+ Boolean primaryDnsServerAddressSettable r
+ Boolean subnetMaskSettable r
+ Boolean arpRedirectSettable o
+ Boolean hostNameAsTargetAddress o
+ Boolean ipv6Supported o
+ Boolean mtuSettable o
+ Boolean nameAliasSettable o
+end
+
+
+object HostInternetScsiHbaIPProperties
+ Boolean dhcpConfigurationEnabled r
+ String address o
+ String alternateDnsServerAddress o
+ Boolean arpRedirectEnabled o
+ String defaultGateway o
+ String ipv6Address o
+ String ipv6DefaultGateway o
+ Boolean jumboFramesEnabled o
+ String mac o
+ Int mtu o
+ String primaryDnsServerAddress o
+ String subnetMask o
+end
+
+
+object HostInternetScsiHbaParamValue extends OptionValue
+ Boolean isInherited o
+end
+
+
+object HostInternetScsiHbaSendTarget
+ String address r
+ HostInternetScsiHbaParamValue advancedOptions ol
+ HostInternetScsiHbaAuthenticationProperties authenticationProperties o
+ HostInternetScsiHbaDigestProperties digestProperties o
+ String parent o
+ Int port o
+ OptionDef supportedAdvancedOptions ol
+end
+
+
+object HostInternetScsiHbaStaticTarget
+ String address r
+ String iScsiName r
+ HostInternetScsiHbaParamValue advancedOptions ol
+ HostInternetScsiHbaAuthenticationProperties authenticationProperties o
+ HostInternetScsiHbaDigestProperties digestProperties o
+ String parent o
+ Int port o
+ OptionDef supportedAdvancedOptions ol
+end
+
+
+
+
object HostMountInfo
String path o
String accessMode r
@@ -394,11 +570,22 @@ object ObjectUpdate
end


+object OptionDef extends ElementDescription
+ OptionType optionType r
+end
+
+
object OptionType
Boolean valueIsReadonly o
end


+object OptionValue
+ String key r
+ AnyType value r
+end
+
+
object PerfCounterInfo
Int key r
ElementDescription nameInfo r
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index 8a128df..54df7ab 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -1519,6 +1519,8 @@ additional_object_features = { "AutoStartDefaults" : Object.FEATURE__AN
Object.FEATURE__ANY_TYPE,
"HostDatastoreBrowserSearchResults" : Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE,
+ "HostHostBusAdapter" : Object.FEATURE__LIST |
+ Object.FEATURE__ANY_TYPE,
"ManagedObjectReference" : Object.FEATURE__ANY_TYPE,
"ObjectContent" : Object.FEATURE__DEEP_COPY,
"ResourcePoolResourceUsage" : Object.FEATURE__ANY_TYPE,
--
1.7.9.5
-----------------------

Thanks!
Ata


> From: ata.husain@hotmail.com
> To: matthias.bolte@googlemail.com
> Date: Wed, 18 Jul 2012 12:28:16 -0700
> CC: libvirt-list@redhat.com
> Subject: Re: [libvirt] ESX: failure while performing "CastFromAnyType"
>
> Hi Matthias,
>
> I modified the code significantly from that point, but I think it should be
> still reproducible. I will give it a try and reproduce the issue to share
> the patch sometime later today or tomorrow.
>
> Thanks!
> Ata
>
> -----Original Message-----
> From: Matthias Bolte
> Sent: Wednesday, July 18, 2012 12:19 PM
> To: Ata E Husain Bohra
> Cc: libvirt-list@redhat.com
> Subject: Re: [libvirt] ESX: failure while performing "CastFromAnyType"
>
> Hi,
>
> do you have a patch that allows me to reproduce this problem? So I can
> improve the error reporting here?
>
> Regards,
> Matthias
>
> 2012/7/18 Ata E Husain Bohra <ata.husain@hotmail.com>:
> > Just want to drop this note, so no one else gets bother with my query. I
> > was
> > able to find the reason and its fixed. It seems one of the ENUMs deep
> > inside
> > one of the structures was not defined. I am not sure if single step is the
> > only way to solve such issues, as ESX_VI_ERROR never provided any useful
> > information.
> >
> > Thanks!
> > Ata
> >
> > From: Ata E Husain Bohra
> > Sent: Monday, July 16, 2012 2:59 PM
> > To: LIbvirt
> > Subject: [libvirt] ESX: failure while performing "CastFromAnyType"
> >
> > Hi All,
> >
> > I am trying to extend “iscsi” support for iSCSI driver, currently am stuck
> > at getting iSCSI target list from the hypervisor. I am using hostSystem
> > object (propertyNameList is set to “config.storageDevice.hostBusAdapter”)
> > to
> > retrieve list of “HostHostBusAdapter” from ESX, but the call fails to
> > perform “CastFromAnyType” from ObjectContent –> HostHostBusAdapter. The
> > esx_vi_generator.input object definition looks like this:
> >
> > object HostHostBusAdapter
> > String key
> > o
> > String device
> > r
> > Int bus
> > r
> > String status
> > r
> > String model
> > r
> > String driver
> > o
> > String pci
> > o
> > end
> >
> > esx_vi_generaor.py is modified as follows:
> >
> > "HostHostBusAdapter" : Object.FEATURE__ANY_TYPE |
> > Object.FEATURE__LIST,
> >
> > Using gdb, I see the failure occurs at:
> > esx/esx_vi.c:esxVI_List_CastFromAnyType(..) line 1631:
> >
> > ..
> > if (esxVI_AnyType_Deserialize(childNode, &childAnyType) < 0 ||
> > castFromAnyTypeFunc(childAnyType, &item) < 0 ||
> > esxVI_List_Append(list, item) < 0) {
> > goto cleanup;
> > }
> > ..
> >
> > In one of my earlier patches (subject: Add routines to interface driver) I
> > patched esx_vi_generator.py to deserialize “string list”; as the patch is
> > still under review I manually applied the branch to this branch but no
> > change (did not expect change as structure does not contain any list
> > object). I am wondering what else is missing to make it work.
> >
> > Any suggestion how to debug/fix this issue is highly appreciated.
> >
> > Thanks!
> > Ata
> >
> > ________________________________
> > --
> > libvir-list mailing list
> > libvir-list@redhat.com
> > https://www.redhat.com/mailman/listinfo/libvir-list
> >
> >
> > --
> > libvir-list mailing list
> > libvir-list@redhat.com
> > https://www.redhat.com/mailman/listinfo/libvir-list
>
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list