Updated the variable names to match vSphere terminology. Signed-off-by: Ata E Husain Bohra <ata.husain@xxxxxxxxxxx> --- src/esx/esx_interface_driver.c | 179 ++++++++++++++++++++-------------------- src/esx/esx_vi.c | 30 +++---- src/esx/esx_vi.h | 6 +- 3 files changed, 107 insertions(+), 108 deletions(-) diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c index 0b07259..ab8c13b 100644 --- a/src/esx/esx_interface_driver.c +++ b/src/esx/esx_interface_driver.c @@ -75,31 +75,32 @@ static int esxNumOfInterfaces(virConnectPtr conn) { esxPrivate *priv = conn->interfacePrivateData; - esxVI_HostVirtualNic *virtualNicList = NULL; - const esxVI_HostVirtualNic *virtualNic = NULL; + esxVI_HostVirtualNic *hostVirtualNicList = NULL; + const esxVI_HostVirtualNic *hostVirtualNic = NULL; int count = 0; if (esxVI_EnsureSession(priv->primary) < 0 || - esxVI_LookupVirtualNicList(priv->primary, &virtualNicList) < 0) { + esxVI_LookupHostVirtualNicList(priv->primary, + &hostVirtualNicList) < 0) { goto cleanup; } - if (virtualNicList == NULL) { - ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + if (hostVirtualNicList == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not retrieve vNic List")); goto cleanup; } - for (virtualNic = virtualNicList; - virtualNic != NULL; - virtualNic = virtualNic->_next) { + for (hostVirtualNic = hostVirtualNicList; + hostVirtualNic != NULL; + hostVirtualNic = hostVirtualNic->_next) { count++; } cleanup: - esxVI_HostVirtualNic_Free(&virtualNicList); + esxVI_HostVirtualNic_Free(&hostVirtualNicList); return count; } @@ -119,27 +120,27 @@ static int esxListInterfaces(virConnectPtr conn, char **names, int maxnames) { esxPrivate *priv = conn->interfacePrivateData; - esxVI_HostVirtualNic *virtualNicList = NULL; - const esxVI_HostVirtualNic *virtualNic = NULL; + esxVI_HostVirtualNic *hostVirtualNicList = NULL; + const esxVI_HostVirtualNic *hostVirtualNic = NULL; int result = -1; int i = 0; if (esxVI_EnsureSession(priv->primary) < 0 || - esxVI_LookupVirtualNicList(priv->primary, - &virtualNicList) < 0) { + esxVI_LookupHostVirtualNicList(priv->primary, + &hostVirtualNicList) < 0) { goto cleanup; } - if (virtualNicList == NULL) { - ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + if (hostVirtualNicList == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not retrieve vNIC List")); goto cleanup; } - for (i= 0, virtualNic = virtualNicList; - virtualNic != NULL && i < maxnames; - ++i, virtualNic = virtualNic->_next) { - names[i] = strdup(virtualNic->device); + for (i= 0, hostVirtualNic = hostVirtualNicList; + hostVirtualNic != NULL && i < maxnames; + ++i, hostVirtualNic = hostVirtualNic->_next) { + names[i] = strdup(hostVirtualNic->device); if (names[i] == NULL) { for(;i >=0;--i) { @@ -152,7 +153,7 @@ esxListInterfaces(virConnectPtr conn, char **names, int maxnames) result = i; cleanup: - esxVI_HostVirtualNic_Free(&virtualNicList); + esxVI_HostVirtualNic_Free(&hostVirtualNicList); return result; } @@ -174,41 +175,42 @@ static virInterfacePtr esxInterfaceLookupByName(virConnectPtr conn, const char *name) { esxPrivate *priv = conn->interfacePrivateData; - esxVI_HostVirtualNic *virtualNicList = NULL; - const esxVI_HostVirtualNic *virtualNic = NULL; + esxVI_HostVirtualNic *hostVirtualNicList = NULL; + const esxVI_HostVirtualNic *hostVirtualNic = NULL; virInterfacePtr ret = NULL; if (esxVI_EnsureSession(priv->primary) < 0 || - esxVI_LookupVirtualNicList(priv->primary, - &virtualNicList) < 0) { + esxVI_LookupHostVirtualNicList(priv->primary, + &hostVirtualNicList) < 0) { goto cleanup; } - if (virtualNicList == 0) { - ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + if (hostVirtualNicList == 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not retrieve vNIC List")); goto cleanup; } - for(virtualNic = virtualNicList; - virtualNic != NULL; - virtualNic = virtualNic->_next) { - if (STREQ(virtualNic->device, name)) { - if (virtualNic->spec == NULL || - virtualNic->spec->mac == NULL) { - ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + for(hostVirtualNic = hostVirtualNicList; + hostVirtualNic != NULL; + hostVirtualNic = hostVirtualNic->_next) { + if (STREQ(hostVirtualNic->device, name)) { + if (hostVirtualNic->spec == NULL || + hostVirtualNic->spec->mac == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Malformed HostVirtualNicSpec")); goto cleanup; } - ret = virGetInterface(conn, virtualNic->device, virtualNic->spec->mac); + ret = virGetInterface(conn, hostVirtualNic->device, + hostVirtualNic->spec->mac); break; } } cleanup: - esxVI_HostVirtualNic_Free(&virtualNicList); + esxVI_HostVirtualNic_Free(&hostVirtualNicList); return ret; } @@ -219,41 +221,42 @@ static virInterfacePtr esxInterfaceLookupByMACString(virConnectPtr conn, const char *mac) { esxPrivate *priv = conn->interfacePrivateData; - esxVI_HostVirtualNic *virtualNicList = NULL; - const esxVI_HostVirtualNic *virtualNic = NULL; + esxVI_HostVirtualNic *hostVirtualNicList = NULL; + const esxVI_HostVirtualNic *hostVirtualNic = NULL; virInterfacePtr ret = NULL; if (esxVI_EnsureSession(priv->primary) < 0 || - esxVI_LookupVirtualNicList(priv->primary, - &virtualNicList) < 0) { + esxVI_LookupHostVirtualNicList(priv->primary, + &hostVirtualNicList) < 0) { goto cleanup; } - if (virtualNicList == 0) { - ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + if (hostVirtualNicList == 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not retrieve vNIC List")); goto cleanup; } - for(virtualNic = virtualNicList; - virtualNic != NULL; - virtualNic = virtualNic->_next) { - if (virtualNic->spec == NULL || - virtualNic->spec->mac == NULL) { - ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + for(hostVirtualNic = hostVirtualNicList; + hostVirtualNic != NULL; + hostVirtualNic = hostVirtualNic->_next) { + if (hostVirtualNic->spec == NULL || + hostVirtualNic->spec->mac == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Malformed HostVirtualNicSpec")); goto cleanup; } - if (STREQ(virtualNic->spec->mac, mac)) { - ret = virGetInterface(conn, virtualNic->device, virtualNic->spec->mac); + if (STREQ(hostVirtualNic->spec->mac, mac)) { + ret = virGetInterface(conn, hostVirtualNic->device, + hostVirtualNic->spec->mac); break; } } cleanup: - esxVI_HostVirtualNic_Free(&virtualNicList); + esxVI_HostVirtualNic_Free(&hostVirtualNicList); return ret; } @@ -264,14 +267,14 @@ static char* esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) { esxPrivate *priv = iface->conn->interfacePrivateData; - esxVI_HostVirtualNic *virtualNicList = NULL; - const esxVI_HostVirtualNic *virtualNic = NULL; + esxVI_HostVirtualNic *hostVirtualNicList = NULL; + const esxVI_HostVirtualNic *hostVirtualNic = NULL; esxVI_PhysicalNic *physicalNicList = NULL; const esxVI_PhysicalNic *physicalNic = NULL; esxVI_PhysicalNic *matchingPhysicalNicList = NULL; esxVI_HostIpRouteConfig *ipRouteConfig = NULL; esxVI_HostPortGroup *portGroupList = NULL; - esxVI_HostVirtualSwitch *virtualSwitchList = NULL; + esxVI_HostVirtualSwitch *hostVirtualSwitchList = NULL; esxVI_String *propertyNameList = NULL; esxVI_ObjectContent *hostSystem = NULL; esxVI_DynamicProperty *dynamicProperty = NULL; @@ -304,7 +307,7 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "config.network.vnic")) { if (esxVI_HostVirtualNic_CastListFromAnyType( - dynamicProperty->val, &virtualNicList) < 0) { + dynamicProperty->val, &hostVirtualNicList) < 0) { goto cleanup; } } else if (STREQ(dynamicProperty->name, @@ -315,7 +318,7 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) } } else if (STREQ(dynamicProperty->name, "config.network.vswitch")) { if (esxVI_HostVirtualSwitch_CastListFromAnyType - (dynamicProperty->val, &virtualSwitchList) < 0) { + (dynamicProperty->val, &hostVirtualSwitchList) < 0) { goto cleanup; } } else if (STREQ(dynamicProperty->name, "config.network.pnic")) { @@ -333,36 +336,36 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) } } - if (!virtualNicList || + if (!hostVirtualNicList || !ipRouteConfig || - !virtualSwitchList || + !hostVirtualSwitchList || !portGroupList) { - ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to retrieve network parameters")); goto cleanup; } - for (virtualNic = virtualNicList; - virtualNic != NULL; - virtualNic = virtualNic->_next) { - if (STREQ(virtualNic->device, iface->name)) { + for (hostVirtualNic = hostVirtualNicList; + hostVirtualNic != NULL; + hostVirtualNic = hostVirtualNic->_next) { + if (STREQ(hostVirtualNic->device, iface->name)) { break; } } - if (virtualNic == NULL) { - ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + if (hostVirtualNic == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not find Interface")); goto cleanup; } - if (esxVI_LookupPhysicalNicFromPortGroup(virtualNic->portgroup, + if (esxVI_LookupPhysicalNicFromPortGroup(hostVirtualNic->portgroup, portGroupList, - virtualSwitchList, + hostVirtualSwitchList, physicalNicList, &matchingPhysicalNicList) < 0) { - ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No Physical NIC found matching Virtual NIC's portgroup")); goto cleanup; } @@ -377,24 +380,24 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) } def->type = VIR_INTERFACE_TYPE_BRIDGE; - def->name = strdup(virtualNic->device); - if (virtualNic->spec->mtu && virtualNic->spec->mtu->value) { - def->mtu = virtualNic->spec->mtu->value; + def->name = strdup(hostVirtualNic->device); + if (hostVirtualNic->spec->mtu && hostVirtualNic->spec->mtu->value) { + def->mtu = hostVirtualNic->spec->mtu->value; } else { def->mtu = 1500; } def->startmode = VIR_INTERFACE_START_ONBOOT; - if (!use_static && virtualNic->spec->mac) { - def->mac = strdup(virtualNic->spec->mac); + if (!use_static && hostVirtualNic->spec->mac) { + def->mac = strdup(hostVirtualNic->spec->mac); } /* TODO - Handle VLAN (via portgroup?) */ - if (virtualNic->spec->ip->subnetMask && - *virtualNic->spec->ip->subnetMask && - inet_aton(virtualNic->spec->ip->subnetMask, &addr) == 0) { - ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + if (hostVirtualNic->spec->ip->subnetMask && + *hostVirtualNic->spec->ip->subnetMask && + inet_aton(hostVirtualNic->spec->ip->subnetMask, &addr) == 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Error parsing netmask")); goto cleanup; } @@ -424,13 +427,13 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) } def->protos[i]->family = strdup("ipv4"); - if (virtualNic->spec->ip->dhcp == 1) { + if (hostVirtualNic->spec->ip->dhcp == 1) { def->protos[i]->dhcp = 1; } def->protos[i]->nips = 1; - if (virtualNic->spec->ip->dhcp != 1 || !use_static) { - if (virtualNic->spec->ip->ipAddress && - *virtualNic->spec->ip->ipAddress) { + if (hostVirtualNic->spec->ip->dhcp != 1 || !use_static) { + if (hostVirtualNic->spec->ip->ipAddress && + *hostVirtualNic->spec->ip->ipAddress) { int j =0; if (VIR_ALLOC_N(def->protos[i]->ips, def->protos[i]->nips) < 0) { @@ -444,7 +447,7 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) goto cleanup; } def->protos[i]->ips[0]->address = - strdup(virtualNic->spec->ip->ipAddress); + strdup(hostVirtualNic->spec->ip->ipAddress); def->protos[i]->ips[0]->prefix = masklen; def->protos[i]->gateway = strdup(ipRouteConfig->defaultGateway); @@ -493,11 +496,11 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) } cleanup: - esxVI_HostVirtualNic_Free(&virtualNicList); + esxVI_HostVirtualNic_Free(&hostVirtualNicList); esxVI_PhysicalNic_Free(&physicalNicList); esxVI_PhysicalNic_Free(&matchingPhysicalNicList); esxVI_HostPortGroup_Free(&portGroupList); - esxVI_HostVirtualSwitch_Free(&virtualSwitchList); + esxVI_HostVirtualSwitch_Free(&hostVirtualSwitchList); esxVI_HostIpRouteConfig_Free(&ipRouteConfig); esxVI_ObjectContent_Free(&hostSystem); esxVI_String_Free(&propertyNameList); @@ -517,7 +520,7 @@ esxInterfaceUndefine(virInterfacePtr iface) priv->primary, priv->primary->hostSystem->configManager->networkSystem, iface->name) < 0) { - ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Error deleting interface")); return -1; } @@ -528,10 +531,8 @@ esxInterfaceUndefine(virInterfacePtr iface) static int -esxInterfaceCreate(virInterfacePtr iface, unsigned int flags) +esxInterfaceCreate(virInterfacePtr iface ATTRIBUTE_UNUSED, unsigned int flags) { - iface->conn->interfacePrivateData = NULL; - virCheckFlags(0, -1); /* ESX interfaces are always active */ @@ -541,10 +542,8 @@ esxInterfaceCreate(virInterfacePtr iface, unsigned int flags) static int -esxInterfaceDestroy(virInterfacePtr iface, unsigned int flags) +esxInterfaceDestroy(virInterfacePtr iface ATTRIBUTE_UNUSED, unsigned int flags) { - iface->conn->interfacePrivateData = NULL; - virCheckFlags(0, -1); /* ESX interfaces can not be deactivated */ diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index e5f92b2..41c9be3 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -4570,8 +4570,8 @@ esxVI_LookupManagedObjectHelper(esxVI_Context *ctx, } int -esxVI_LookupVirtualNicList(esxVI_Context* ctx, - esxVI_HostVirtualNic** virtualNicList) +esxVI_LookupHostVirtualNicList(esxVI_Context* ctx, + esxVI_HostVirtualNic** hostVirtualNicList) { int result = -1; esxVI_String *propertyNameList = NULL; @@ -4585,7 +4585,7 @@ esxVI_LookupVirtualNicList(esxVI_Context* ctx, } if (hostSystem == NULL) { - ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not retrieve the HostSystem object")); goto cleanup; @@ -4596,7 +4596,7 @@ esxVI_LookupVirtualNicList(esxVI_Context* ctx, dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "config.network.vnic")) { if (esxVI_HostVirtualNic_CastListFromAnyType(dynamicProperty->val, - virtualNicList) < 0) { + hostVirtualNicList) < 0) { goto cleanup; } break; @@ -4618,20 +4618,20 @@ int esxVI_LookupPhysicalNicFromPortGroup( const char *portgroup, const esxVI_HostPortGroup *portGroupList, - const esxVI_HostVirtualSwitch *virtualSwitchList, + const esxVI_HostVirtualSwitch *hostVirtualSwitchList, const esxVI_PhysicalNic *physicalNicList, esxVI_PhysicalNic **ret_physicalNicList) { int result = -1; const esxVI_HostPortGroup *portGroup = NULL; - const esxVI_HostVirtualSwitch *virtualSwitch = NULL; + const esxVI_HostVirtualSwitch *hostVirtualSwitch = NULL; esxVI_PhysicalNic *matchingPhysicalNicList = NULL; const esxVI_PhysicalNic *physicalNic = NULL; esxVI_PhysicalNic *tempPhysicalNic = NULL; const esxVI_String *pnicKey = NULL; if (portgroup == NULL) { - ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No Portgroup found!")); goto cleanup; } @@ -4646,28 +4646,28 @@ esxVI_LookupPhysicalNicFromPortGroup( } if (portGroup == NULL) { - ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not find Host port group")); goto cleanup; } /* Go through all the virtual switches to find the one that matches */ - for (virtualSwitch = virtualSwitchList; - virtualSwitch != NULL; - virtualSwitch = virtualSwitch->_next) { - if (STREQ(portGroup->spec->vswitchName, virtualSwitch->name)) { + for (hostVirtualSwitch = hostVirtualSwitchList; + hostVirtualSwitch != NULL; + hostVirtualSwitch = hostVirtualSwitch->_next) { + if (STREQ(portGroup->spec->vswitchName, hostVirtualSwitch->name)) { break; } } - if (virtualSwitch == NULL) { - ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", + if (hostVirtualSwitch == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not find Virtual Switch")); goto cleanup; } /* Go through all physical nics */ - for (pnicKey = virtualSwitch->pnic; + for (pnicKey = hostVirtualSwitch->pnic; pnicKey != NULL; pnicKey = pnicKey->_next) { /* O(n^2), but probably faster than a hash due to small N */ diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h index 54b53ec..9f75d84 100644 --- a/src/esx/esx_vi.h +++ b/src/esx/esx_vi.h @@ -499,13 +499,13 @@ int esxVI_ParseHostCpuIdInfo(esxVI_ParsedHostCpuIdInfo *parsedHostCpuIdInfo, int esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersion); -int esxVI_LookupVirtualNicList(esxVI_Context* ctx, - esxVI_HostVirtualNic** virtualNicList); +int esxVI_LookupHostVirtualNicList(esxVI_Context* ctx, + esxVI_HostVirtualNic** virtualNicList); int esxVI_LookupPhysicalNicFromPortGroup( const char *portgroup, const esxVI_HostPortGroup *portGroupList, - const esxVI_HostVirtualSwitch *virtualSwitchList, + const esxVI_HostVirtualSwitch *hostVirtualSwitchList, const esxVI_PhysicalNic *physicalNicList, esxVI_PhysicalNic **ret_physicalNicList); -- 1.7.9.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list