Devel
Threads by month
- ----- 2025 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
April 2011
- 74 participants
- 270 discussions
cpumask doesn't get freed when vcpupinDef being freed, this leaks
memory.
---
src/conf/domain_conf.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1de4c7a..7b6b044 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -858,6 +858,7 @@ virDomainVcpupinDefFree(virDomainVcpupinDefPtr *def,
return;
for(i = 0; i < nvcpupin; i++) {
+ VIR_FREE(def[i]->cpumask);
VIR_FREE(def[i]);
}
--
1.7.3.1
3
2

[libvirt] [PATCH] esx: Make the parsed URI part of the private connection data
by Matthias Bolte 14 Apr '11
by Matthias Bolte 14 Apr '11
14 Apr '11
This will be used to make esxVI_Context clonable.
Also move cleanup code for esxPrivate to esxFreePrivate().
---
src/esx/esx_driver.c | 103 ++++++++++++++++++++++++-------------------------
src/esx/esx_private.h | 4 +-
2 files changed, 52 insertions(+), 55 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index ef76350..bfb3c16 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3,7 +3,7 @@
* esx_driver.c: core driver functions for managing VMware ESX hosts
*
* Copyright (C) 2010-2011 Red Hat, Inc.
- * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
+ * Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
* Copyright (C) 2009 Maximilian Wilhelm <max(a)rfc2324.org>
*
* This library is free software; you can redistribute it and/or
@@ -57,6 +57,22 @@ struct _esxVMX_Data {
+static void
+esxFreePrivate(esxPrivate **priv)
+{
+ if (priv == NULL || *priv == NULL) {
+ return;
+ }
+
+ esxVI_Context_Free(&(*priv)->host);
+ esxVI_Context_Free(&(*priv)->vCenter);
+ esxUtil_FreeParsedUri(&(*priv)->parsedUri);
+ virCapabilitiesFree((*priv)->caps);
+ VIR_FREE(*priv);
+}
+
+
+
/*
* Parse a file name from a .vmx file and convert it to datastore path format.
* A .vmx file can contain file names in various formats:
@@ -619,7 +635,6 @@ static int
esxConnectToHost(esxPrivate *priv, virConnectAuthPtr auth,
const char *hostname, int port,
const char *predefinedUsername,
- esxUtil_ParsedUri *parsedUri,
esxVI_ProductVersion expectedProductVersion,
char **vCenterIpAddress)
{
@@ -671,16 +686,16 @@ esxConnectToHost(esxPrivate *priv, virConnectAuthPtr auth,
goto cleanup;
}
- if (virAsprintf(&url, "%s://%s:%d/sdk", priv->transport, hostname,
- port) < 0) {
+ if (virAsprintf(&url, "%s://%s:%d/sdk", priv->parsedUri->transport,
+ hostname, port) < 0) {
virReportOOMError();
goto cleanup;
}
if (esxVI_Context_Alloc(&priv->host) < 0 ||
esxVI_Context_Connect(priv->host, url, ipAddress, username, password,
- parsedUri) < 0 ||
- esxVI_Context_LookupObjectsByPath(priv->host, parsedUri) < 0) {
+ priv->parsedUri) < 0 ||
+ esxVI_Context_LookupObjectsByPath(priv->host, priv->parsedUri) < 0) {
goto cleanup;
}
@@ -750,8 +765,7 @@ static int
esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
const char *hostname, int port,
const char *predefinedUsername,
- const char *hostSystemIpAddress,
- esxUtil_ParsedUri *parsedUri)
+ const char *hostSystemIpAddress)
{
int result = -1;
char ipAddress[NI_MAXHOST] = "";
@@ -761,8 +775,8 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
char *url = NULL;
if (hostSystemIpAddress == NULL &&
- (parsedUri->path_datacenter == NULL ||
- parsedUri->path_computeResource == NULL)) {
+ (priv->parsedUri->path_datacenter == NULL ||
+ priv->parsedUri->path_computeResource == NULL)) {
ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
_("Path has to specify the datacenter and compute resource"));
return -1;
@@ -801,15 +815,15 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
goto cleanup;
}
- if (virAsprintf(&url, "%s://%s:%d/sdk", priv->transport, hostname,
- port) < 0) {
+ if (virAsprintf(&url, "%s://%s:%d/sdk", priv->parsedUri->transport,
+ hostname, port) < 0) {
virReportOOMError();
goto cleanup;
}
if (esxVI_Context_Alloc(&priv->vCenter) < 0 ||
esxVI_Context_Connect(priv->vCenter, url, ipAddress, username,
- password, parsedUri) < 0) {
+ password, priv->parsedUri) < 0) {
goto cleanup;
}
@@ -829,7 +843,8 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
goto cleanup;
}
} else {
- if (esxVI_Context_LookupObjectsByPath(priv->vCenter, parsedUri) < 0) {
+ if (esxVI_Context_LookupObjectsByPath(priv->vCenter,
+ priv->parsedUri) < 0) {
goto cleanup;
}
}
@@ -896,7 +911,6 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
{
virDrvOpenStatus result = VIR_DRV_OPEN_ERROR;
esxPrivate *priv = NULL;
- esxUtil_ParsedUri *parsedUri = NULL;
char *potentialVCenterIpAddress = NULL;
char vCenterIpAddress[NI_MAXHOST] = "";
@@ -919,18 +933,15 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto cleanup;
}
- if (esxUtil_ParseUri(&parsedUri, conn->uri) < 0) {
+ if (esxUtil_ParseUri(&priv->parsedUri, conn->uri) < 0) {
goto cleanup;
}
- priv->transport = parsedUri->transport;
- parsedUri->transport = NULL;
-
priv->maxVcpus = -1;
priv->supportsVMotion = esxVI_Boolean_Undefined;
priv->supportsLongMode = esxVI_Boolean_Undefined;
- priv->autoAnswer = parsedUri->autoAnswer ? esxVI_Boolean_True
- : esxVI_Boolean_False;
+ priv->autoAnswer = priv->parsedUri->autoAnswer ? esxVI_Boolean_True
+ : esxVI_Boolean_False;
priv->usedCpuTimeCounterId = -1;
/*
@@ -942,13 +953,13 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
if (conn->uri->port == 0) {
if (STRCASEEQ(conn->uri->scheme, "vpx") ||
STRCASEEQ(conn->uri->scheme, "esx")) {
- if (STRCASEEQ(priv->transport, "https")) {
+ if (STRCASEEQ(priv->parsedUri->transport, "https")) {
conn->uri->port = 443;
} else {
conn->uri->port = 80;
}
} else { /* GSX */
- if (STRCASEEQ(priv->transport, "https")) {
+ if (STRCASEEQ(priv->parsedUri->transport, "https")) {
conn->uri->port = 8333;
} else {
conn->uri->port = 8222;
@@ -960,7 +971,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
STRCASEEQ(conn->uri->scheme, "gsx")) {
/* Connect to host */
if (esxConnectToHost(priv, auth, conn->uri->server, conn->uri->port,
- conn->uri->user, parsedUri,
+ conn->uri->user,
STRCASEEQ(conn->uri->scheme, "esx")
? esxVI_ProductVersion_ESX
: esxVI_ProductVersion_GSX,
@@ -969,8 +980,8 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
}
/* Connect to vCenter */
- if (parsedUri->vCenter != NULL) {
- if (STREQ(parsedUri->vCenter, "*")) {
+ if (priv->parsedUri->vCenter != NULL) {
+ if (STREQ(priv->parsedUri->vCenter, "*")) {
if (potentialVCenterIpAddress == NULL) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("This host is not managed by a vCenter"));
@@ -985,7 +996,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto cleanup;
}
} else {
- if (esxUtil_ResolveHostname(parsedUri->vCenter,
+ if (esxUtil_ResolveHostname(priv->parsedUri->vCenter,
vCenterIpAddress, NI_MAXHOST) < 0) {
goto cleanup;
}
@@ -996,7 +1007,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
_("This host is managed by a vCenter with IP "
"address %s, but a mismachting vCenter '%s' "
"(%s) has been specified"),
- potentialVCenterIpAddress, parsedUri->vCenter,
+ potentialVCenterIpAddress, priv->parsedUri->vCenter,
vCenterIpAddress);
goto cleanup;
}
@@ -1004,7 +1015,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
if (esxConnectToVCenter(priv, auth, vCenterIpAddress,
conn->uri->port, NULL,
- priv->host->ipAddress, parsedUri) < 0) {
+ priv->host->ipAddress) < 0) {
goto cleanup;
}
}
@@ -1013,15 +1024,13 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
} else { /* VPX */
/* Connect to vCenter */
if (esxConnectToVCenter(priv, auth, conn->uri->server, conn->uri->port,
- conn->uri->user, NULL, parsedUri) < 0) {
+ conn->uri->user, NULL) < 0) {
goto cleanup;
}
priv->primary = priv->vCenter;
}
- conn->privateData = priv;
-
/* Setup capabilities */
priv->caps = esxCapsInit(priv);
@@ -1029,20 +1038,15 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto cleanup;
}
+ conn->privateData = priv;
+
result = VIR_DRV_OPEN_SUCCESS;
cleanup:
- if (result == VIR_DRV_OPEN_ERROR && priv != NULL) {
- esxVI_Context_Free(&priv->host);
- esxVI_Context_Free(&priv->vCenter);
-
- virCapabilitiesFree(priv->caps);
-
- VIR_FREE(priv->transport);
- VIR_FREE(priv);
+ if (result == VIR_DRV_OPEN_ERROR) {
+ esxFreePrivate(&priv);
}
- esxUtil_FreeParsedUri(&parsedUri);
VIR_FREE(potentialVCenterIpAddress);
return result;
@@ -1061,8 +1065,6 @@ esxClose(virConnectPtr conn)
esxVI_Logout(priv->host) < 0) {
result = -1;
}
-
- esxVI_Context_Free(&priv->host);
}
if (priv->vCenter != NULL) {
@@ -1070,14 +1072,9 @@ esxClose(virConnectPtr conn)
esxVI_Logout(priv->vCenter) < 0) {
result = -1;
}
-
- esxVI_Context_Free(&priv->vCenter);
}
- virCapabilitiesFree(priv->caps);
-
- VIR_FREE(priv->transport);
- VIR_FREE(priv);
+ esxFreePrivate(&priv);
conn->privateData = NULL;
@@ -2627,7 +2624,7 @@ esxDomainDumpXML(virDomainPtr domain, int flags)
goto cleanup;
}
- virBufferVSprintf(&buffer, "%s://%s:%d/folder/", priv->transport,
+ virBufferVSprintf(&buffer, "%s://%s:%d/folder/", priv->parsedUri->transport,
domain->conn->uri->server, domain->conn->uri->port);
virBufferURIEncodeString(&buffer, directoryAndFileName);
virBufferAddLit(&buffer, "?dcPath=");
@@ -3078,7 +3075,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
goto cleanup;
}
- virBufferVSprintf(&buffer, "%s://%s:%d/folder/", priv->transport,
+ virBufferVSprintf(&buffer, "%s://%s:%d/folder/", priv->parsedUri->transport,
conn->uri->server, conn->uri->port);
if (directoryName != NULL) {
@@ -3960,7 +3957,7 @@ esxIsEncrypted(virConnectPtr conn)
{
esxPrivate *priv = conn->privateData;
- if (STRCASEEQ(priv->transport, "https")) {
+ if (STRCASEEQ(priv->parsedUri->transport, "https")) {
return 1;
} else {
return 0;
@@ -3974,7 +3971,7 @@ esxIsSecure(virConnectPtr conn)
{
esxPrivate *priv = conn->privateData;
- if (STRCASEEQ(priv->transport, "https")) {
+ if (STRCASEEQ(priv->parsedUri->transport, "https")) {
return 1;
} else {
return 0;
diff --git a/src/esx/esx_private.h b/src/esx/esx_private.h
index 6c7edb1..1da2552 100644
--- a/src/esx/esx_private.h
+++ b/src/esx/esx_private.h
@@ -2,7 +2,7 @@
/*
* esx_private.h: private driver struct for the VMware ESX driver
*
- * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
+ * Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -36,8 +36,8 @@ typedef struct _esxPrivate {
esxVI_Context *primary; /* points to host or vCenter */
esxVI_Context *host;
esxVI_Context *vCenter;
+ esxUtil_ParsedUri *parsedUri;
virCapsPtr caps;
- char *transport;
int32_t maxVcpus;
esxVI_Boolean supportsVMotion;
esxVI_Boolean supportsLongMode; /* aka x86_64 */
--
1.7.0.4
2
2

14 Apr '11
---
src/esx/esx_vi_types.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 9e23030..29a3c39 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -77,12 +77,12 @@
int \
esxVI_##__type##_Validate(esxVI_##__type *item) \
{ \
- const char *type_name = esxVI_Type_ToString(esxVI_Type_##__type); \
+ const char *typeName = esxVI_Type_ToString(esxVI_Type_##__type); \
\
if (item->_type <= esxVI_Type_Undefined || \
item->_type >= esxVI_Type_Other) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
- "%s object has invalid dynamic type", type_name); \
+ _("%s object has invalid dynamic type"), typeName); \
return -1; \
} \
\
@@ -293,7 +293,7 @@
childNode = childNode->next) { \
if (childNode->type != XML_ELEMENT_NODE) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
- "Wrong XML element type %d", childNode->type); \
+ _("Wrong XML element type %d"), childNode->type);\
goto failure; \
} \
\
@@ -343,22 +343,22 @@
\
if (string == NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
- "XML node doesn't contain text, expecting an " \
- _xsdType" value"); \
+ _("XML node doesn't contain text, expecting an %s " \
+ "value"), _xsdType); \
goto cleanup; \
} \
\
if (virStrToLong_ll(string, NULL, 10, &value) < 0) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
- "Unknown value '%s' for "_xsdType, string); \
+ _("Unknown value '%s' for %s"), string, _xsdType); \
goto cleanup; \
} \
\
if (((_min) != INT64_MIN && value < (_min)) \
|| ((_max) != INT64_MAX && value > (_max))) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
- "Value '%s' is not representable as "_xsdType, \
- (const char *)string); \
+ _("Value '%s' is not representable as %s"), \
+ string, _xsdType); \
goto cleanup; \
} \
\
@@ -482,8 +482,8 @@
#define ESX_VI__TEMPLATE__PROPERTY__REQUIRE(_name) \
if (item->_name == 0) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
- "%s object is missing the required '%s' property", \
- type_name, #_name); \
+ _("%s object is missing the required '%s' property"), \
+ typeName, #_name); \
return -1; \
}
--
1.7.0.4
2
2

[libvirt] [PATCH] esx: Extend VI generator to cover managed object types
by Matthias Bolte 14 Apr '11
by Matthias Bolte 14 Apr '11
14 Apr '11
Generate lookup functions for managed object types.
---
src/esx/esx_vi.c | 414 +++++++++++++++++++++++-----------------
src/esx/esx_vi.h | 2 +
src/esx/esx_vi_generator.input | 28 +++-
src/esx/esx_vi_generator.py | 411 ++++++++++++++++++++++++++++++++++++++--
src/esx/esx_vi_types.c | 349 ++++++----------------------------
src/esx/esx_vi_types.h | 102 ++---------
6 files changed, 728 insertions(+), 578 deletions(-)
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 7446ec5..fbab347 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -3,7 +3,7 @@
* esx_vi.c: client for the VMware VI API 2.5 to manage ESX hosts
*
* Copyright (C) 2010 Red Hat, Inc.
- * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
+ * Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -481,107 +481,26 @@ int
esxVI_Context_LookupObjectsByPath(esxVI_Context *ctx,
esxUtil_ParsedUri *parsedUri)
{
- int result = -1;
- esxVI_String *propertyNameList = NULL;
- char *name = NULL;
- esxVI_ObjectContent *datacenterList = NULL;
- esxVI_ObjectContent *datacenter = NULL;
- esxVI_ObjectContent *computeResourceList = NULL;
- esxVI_ObjectContent *computeResource = NULL;
char *hostSystemName = NULL;
- esxVI_ObjectContent *hostSystemList = NULL;
- esxVI_ObjectContent *hostSystem = NULL;
-
/* Lookup Datacenter */
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0"
- "vmFolder\0"
- "hostFolder\0") < 0 ||
- esxVI_LookupObjectContentByType(ctx, ctx->service->rootFolder,
- "Datacenter", propertyNameList,
- &datacenterList,
- esxVI_Occurrence_RequiredList) < 0) {
- goto cleanup;
- }
-
- if (parsedUri->path_datacenter != NULL) {
- for (datacenter = datacenterList; datacenter != NULL;
- datacenter = datacenter->_next) {
- name = NULL;
-
- if (esxVI_GetStringValue(datacenter, "name", &name,
- esxVI_Occurrence_RequiredItem) < 0) {
- goto cleanup;
- }
-
- if (STREQ(name, parsedUri->path_datacenter)) {
- break;
- }
- }
-
- if (datacenter == NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Could not find datacenter '%s'"),
- parsedUri->path_datacenter);
- goto cleanup;
- }
- } else {
- datacenter = datacenterList;
- }
-
- if (esxVI_Datacenter_CastFromObjectContent(datacenter,
- &ctx->datacenter) < 0) {
- goto cleanup;
+ if (esxVI_LookupDatacenter(ctx, parsedUri->path_datacenter,
+ ctx->service->rootFolder, NULL, &ctx->datacenter,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ return -1;
}
/* Lookup (Cluster)ComputeResource */
- esxVI_String_Free(&propertyNameList);
-
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0"
- "host\0"
- "resourcePool\0") < 0 ||
- esxVI_LookupObjectContentByType(ctx, ctx->datacenter->hostFolder,
- "ComputeResource", propertyNameList,
- &computeResourceList,
- esxVI_Occurrence_RequiredList) < 0) {
- goto cleanup;
- }
-
- if (parsedUri->path_computeResource != NULL) {
- for (computeResource = computeResourceList; computeResource != NULL;
- computeResource = computeResource->_next) {
- name = NULL;
-
- if (esxVI_GetStringValue(computeResource, "name", &name,
- esxVI_Occurrence_RequiredItem) < 0) {
- goto cleanup;
- }
-
- if (STREQ(name, parsedUri->path_computeResource)) {
- break;
- }
- }
-
- if (computeResource == NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Could not find compute resource '%s'"),
- parsedUri->path_computeResource);
- goto cleanup;
- }
- } else {
- computeResource = computeResourceList;
- }
-
- if (esxVI_ComputeResource_CastFromObjectContent(computeResource,
- &ctx->computeResource) < 0) {
- goto cleanup;
+ if (esxVI_LookupComputeResource(ctx, parsedUri->path_computeResource,
+ ctx->datacenter->hostFolder, NULL,
+ &ctx->computeResource,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ return -1;
}
if (ctx->computeResource->resourcePool == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not retrieve resource pool"));
- goto cleanup;
+ return -1;
}
/* Lookup HostSystem */
@@ -590,19 +509,7 @@ esxVI_Context_LookupObjectsByPath(esxVI_Context *ctx,
"ClusterComputeResource")) {
ESX_VI_ERROR(VIR_ERR_INVALID_ARG, "%s",
_("Path has to specify the host system"));
- goto cleanup;
- }
-
- esxVI_String_Free(&propertyNameList);
-
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0"
- "configManager\0") < 0 ||
- esxVI_LookupObjectContentByType(ctx, ctx->computeResource->_reference,
- "HostSystem", propertyNameList,
- &hostSystemList,
- esxVI_Occurrence_RequiredList) < 0) {
- goto cleanup;
+ return -1;
}
if (parsedUri->path_hostSystem != NULL ||
@@ -613,44 +520,16 @@ esxVI_Context_LookupObjectsByPath(esxVI_Context *ctx,
} else {
hostSystemName = parsedUri->path_computeResource;
}
-
- for (hostSystem = hostSystemList; hostSystem != NULL;
- hostSystem = hostSystem->_next) {
- name = NULL;
-
- if (esxVI_GetStringValue(hostSystem, "name", &name,
- esxVI_Occurrence_RequiredItem) < 0) {
- goto cleanup;
- }
-
- if (STREQ(name, hostSystemName)) {
- break;
- }
- }
-
- if (hostSystem == NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("Could not find host system '%s'"), hostSystemName);
- goto cleanup;
- }
- } else {
- hostSystem = hostSystemList;
}
- if (esxVI_HostSystem_CastFromObjectContent(hostSystem,
- &ctx->hostSystem) < 0) {
- goto cleanup;
+ if (esxVI_LookupHostSystem(ctx, hostSystemName,
+ ctx->computeResource->_reference, NULL,
+ &ctx->hostSystem,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ return -1;
}
- result = 0;
-
- cleanup:
- esxVI_String_Free(&propertyNameList);
- esxVI_ObjectContent_Free(&datacenterList);
- esxVI_ObjectContent_Free(&computeResourceList);
- esxVI_ObjectContent_Free(&hostSystemList);
-
- return result;
+ return 0;
}
int
@@ -658,67 +537,41 @@ esxVI_Context_LookupObjectsByHostSystemIp(esxVI_Context *ctx,
const char *hostSystemIpAddress)
{
int result = -1;
- esxVI_String *propertyNameList = NULL;
esxVI_ManagedObjectReference *managedObjectReference = NULL;
- esxVI_ObjectContent *hostSystem = NULL;
- esxVI_ObjectContent *computeResource = NULL;
- esxVI_ObjectContent *datacenter = NULL;
/* Lookup HostSystem */
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0"
- "configManager\0") < 0 ||
- esxVI_FindByIp(ctx, NULL, hostSystemIpAddress, esxVI_Boolean_False,
+ if (esxVI_FindByIp(ctx, NULL, hostSystemIpAddress, esxVI_Boolean_False,
&managedObjectReference) < 0 ||
- esxVI_LookupObjectContentByType(ctx, managedObjectReference,
- "HostSystem", propertyNameList,
- &hostSystem,
- esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_HostSystem_CastFromObjectContent(hostSystem,
- &ctx->hostSystem) < 0) {
+ esxVI_LookupHostSystem(ctx, NULL, managedObjectReference, NULL,
+ &ctx->hostSystem,
+ esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
}
/* Lookup (Cluster)ComputeResource */
- esxVI_String_Free(&propertyNameList);
+ if (esxVI_LookupComputeResource(ctx, NULL, ctx->hostSystem->_reference,
+ NULL, &ctx->computeResource,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ goto cleanup;
+ }
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0"
- "host\0"
- "resourcePool\0") < 0 ||
- esxVI_LookupObjectContentByType(ctx, hostSystem->obj,
- "ComputeResource", propertyNameList,
- &computeResource,
- esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_ComputeResource_CastFromObjectContent(computeResource,
- &ctx->computeResource) < 0) {
+ if (ctx->computeResource->resourcePool == NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve resource pool"));
goto cleanup;
}
/* Lookup Datacenter */
- esxVI_String_Free(&propertyNameList);
-
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "name\0"
- "vmFolder\0"
- "hostFolder\0") < 0 ||
- esxVI_LookupObjectContentByType(ctx, computeResource->obj,
- "Datacenter", propertyNameList,
- &datacenter,
- esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_Datacenter_CastFromObjectContent(datacenter,
- &ctx->datacenter) < 0) {
+ if (esxVI_LookupDatacenter(ctx, NULL, ctx->computeResource->_reference,
+ NULL, &ctx->datacenter,
+ esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
}
result = 0;
cleanup:
- esxVI_String_Free(&propertyNameList);
esxVI_ManagedObjectReference_Free(&managedObjectReference);
- esxVI_ObjectContent_Free(&hostSystem);
- esxVI_ObjectContent_Free(&computeResource);
- esxVI_ObjectContent_Free(&datacenter);
return result;
}
@@ -3872,3 +3725,204 @@ esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersio
return -1;
}
}
+
+
+
+
+#define ESX_VI__TEMPLATE__PROPERTY__CAST_FROM_ANY_TYPE_IGNORE(_name) \
+ if (STREQ(dynamicProperty->name, #_name)) { \
+ continue; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__PROPERTY__CAST_FROM_ANY_TYPE(_type, _name) \
+ if (STREQ(dynamicProperty->name, #_name)) { \
+ if (esxVI_##_type##_CastFromAnyType(dynamicProperty->val, \
+ &(*ptrptr)->_name) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ continue; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__PROPERTY__CAST_LIST_FROM_ANY_TYPE(_type, _name) \
+ if (STREQ(dynamicProperty->name, #_name)) { \
+ if (esxVI_##_type##_CastListFromAnyType(dynamicProperty->val, \
+ &(*ptrptr)->_name) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ continue; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__PROPERTY__CAST_VALUE_FROM_ANY_TYPE(_type, _name) \
+ if (STREQ(dynamicProperty->name, #_name)) { \
+ if (esxVI_##_type##_CastValueFromAnyType(dynamicProperty->val, \
+ &(*ptrptr)->_name) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ continue; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__LOOKUP(_type, _complete_properties, \
+ _cast_from_anytype) \
+ int \
+ esxVI_Lookup##_type(esxVI_Context *ctx, const char* name /* optional */, \
+ esxVI_ManagedObjectReference *root, \
+ esxVI_String *selectedPropertyNameList /* optional */,\
+ esxVI_##_type **ptrptr, esxVI_Occurrence occurrence) \
+ { \
+ int result = -1; \
+ const char *completePropertyNameValueList = _complete_properties; \
+ esxVI_String *propertyNameList = NULL; \
+ esxVI_ObjectContent *objectContent = NULL; \
+ esxVI_ObjectContent *objectContentList = NULL; \
+ esxVI_DynamicProperty *dynamicProperty = NULL; \
+ \
+ if (ptrptr == NULL || *ptrptr != NULL) { \
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", \
+ _("Invalid argument")); \
+ return -1; \
+ } \
+ \
+ propertyNameList = selectedPropertyNameList; \
+ \
+ if (propertyNameList == NULL && \
+ esxVI_String_AppendValueListToList \
+ (&propertyNameList, completePropertyNameValueList) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ if (esxVI_LookupManagedObjectHelper(ctx, name, root, #_type, \
+ propertyNameList, &objectContent, \
+ &objectContentList, \
+ occurrence) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ if (esxVI_##_type##_Alloc(ptrptr) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ if (esxVI_ManagedObjectReference_DeepCopy(&(*ptrptr)->_reference, \
+ objectContent->obj) < 0) { \
+ goto cleanup; \
+ } \
+ \
+ for (dynamicProperty = objectContent->propSet; \
+ dynamicProperty != NULL; \
+ dynamicProperty = dynamicProperty->_next) { \
+ _cast_from_anytype \
+ \
+ VIR_WARN("Unexpected '%s' property", dynamicProperty->name); \
+ } \
+ \
+ if (esxVI_##_type##_Validate(*ptrptr, selectedPropertyNameList) < 0) {\
+ goto cleanup; \
+ } \
+ \
+ result = 0; \
+ \
+ cleanup: \
+ if (result < 0) { \
+ esxVI_##_type##_Free(ptrptr); \
+ } \
+ \
+ if (propertyNameList != selectedPropertyNameList) { \
+ esxVI_String_Free(&propertyNameList); \
+ } \
+ \
+ esxVI_ObjectContent_Free(&objectContentList); \
+ \
+ return result; \
+ }
+
+
+
+static int
+esxVI_LookupManagedObjectHelper(esxVI_Context *ctx,
+ const char *name /* optional */,
+ esxVI_ManagedObjectReference *root,
+ const char *type,
+ esxVI_String *propertyNameList,
+ esxVI_ObjectContent **objectContent,
+ esxVI_ObjectContent **objectContentList,
+ esxVI_Occurrence occurrence)
+{
+ int result = -1;
+ esxVI_ObjectContent *candidate = NULL;
+ char *name_candidate;
+
+ if (objectContent == NULL || *objectContent != NULL ||
+ objectContentList == NULL || *objectContentList != NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ return -1;
+ }
+
+ if (!esxVI_String_ListContainsValue(propertyNameList, "name")) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Missing 'name' property in %s lookup"), type);
+ goto cleanup;
+ }
+
+ if (esxVI_LookupObjectContentByType(ctx, root, type, propertyNameList,
+ objectContentList,
+ esxVI_Occurrence_OptionalList) < 0) {
+ goto cleanup;
+ }
+
+ /* Search for a matching item */
+ if (name != NULL) {
+ for (candidate = *objectContentList; candidate != NULL;
+ candidate = candidate->_next) {
+ name_candidate = NULL;
+
+ if (esxVI_GetStringValue(candidate, "name", &name_candidate,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ goto cleanup;
+ }
+
+ if (STREQ(name_candidate, name)) {
+ /* Found item with matching name */
+ break;
+ }
+ }
+ } else {
+ candidate = *objectContentList;
+ }
+
+ if (candidate == NULL) {
+ if (occurrence != esxVI_Occurrence_OptionalItem) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("Could not find %s with name '%s'"), type, name);
+ goto cleanup;
+ }
+
+ result = 0;
+
+ goto cleanup;
+ }
+
+ result = 0;
+
+ cleanup:
+ if (result < 0) {
+ esxVI_ObjectContent_Free(objectContentList);
+ } else {
+ *objectContent = candidate;
+ }
+
+ return result;
+}
+
+
+
+#include "esx_vi.generated.c"
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index e150dbf..d046bf9 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -444,4 +444,6 @@ int esxVI_ParseHostCpuIdInfo(esxVI_ParsedHostCpuIdInfo *parsedHostCpuIdInfo,
int esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersion);
+# include "esx_vi.generated.h"
+
#endif /* __ESX_VI_H__ */
diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input
index 44d1d9b..98b5206 100644
--- a/src/esx/esx_vi_generator.input
+++ b/src/esx/esx_vi_generator.input
@@ -15,7 +15,7 @@
#
# Object definition:
#
-# object <name> [extends <name>]
+# [managed] object <name> [extends <name>]
# <type> <name> <occurrence>
# ...
# end
@@ -739,6 +739,32 @@ end
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Managed Objects
+#
+
+managed object ComputeResource extends ManagedEntity
+ ManagedObjectReference host ol
+ ManagedObjectReference resourcePool o
+end
+
+
+managed object Datacenter extends ManagedEntity
+ ManagedObjectReference hostFolder r
+ ManagedObjectReference vmFolder r
+end
+
+
+managed object HostSystem extends ManagedEntity
+ HostConfigManager configManager r
+end
+
+
+managed object ManagedEntity
+ String name r
+end
+
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Methods
#
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index 0fd84dd..ab127a3 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -3,7 +3,7 @@
#
# esx_vi_generator.py: generates most of the SOAP type mapping code
#
-# Copyright (C) 2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
+# Copyright (C) 2010-2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -297,10 +297,15 @@ class Property:
return " esxVI_%s_Free(&item->%s);\n" % (self.type, self.name)
- def generate_validate_code(self):
+ def generate_validate_code(self, managed=False):
+ if managed:
+ macro = "ESX_VI__TEMPLATE__PROPERTY__MANAGED_REQUIRE"
+ else:
+ macro = "ESX_VI__TEMPLATE__PROPERTY__REQUIRE"
+
if self.occurrence in [OCCURRENCE__REQUIRED_ITEM,
OCCURRENCE__REQUIRED_LIST]:
- return " ESX_VI__TEMPLATE__PROPERTY__REQUIRE(%s)\n" % self.name
+ return " %s(%s)\n" % (macro, self.name)
elif self.occurrence == OCCURRENCE__IGNORED:
return " /* FIXME: %s is currently ignored */\n" % self.name
else:
@@ -345,6 +350,18 @@ class Property:
return " ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(%s, %s)\n" % (self.type, self.name)
+ def generate_lookup_code(self):
+ if self.occurrence == OCCURRENCE__IGNORED:
+ return " ESX_VI__TEMPLATE__PROPERTY__CAST_FROM_ANY_TYPE_IGNORE(%s) /* FIXME */\n" % self.name
+ elif self.occurrence in [OCCURRENCE__REQUIRED_LIST,
+ OCCURRENCE__OPTIONAL_LIST]:
+ return " ESX_VI__TEMPLATE__PROPERTY__CAST_LIST_FROM_ANY_TYPE(%s, %s)\n" % (self.type, self.name)
+ elif self.type == "String":
+ return " ESX_VI__TEMPLATE__PROPERTY__CAST_VALUE_FROM_ANY_TYPE(String, %s)\n" % self.name
+ else:
+ return " ESX_VI__TEMPLATE__PROPERTY__CAST_FROM_ANY_TYPE(%s, %s)\n" % (self.type, self.name)
+
+
def get_type_string(self):
if self.type == "String" and \
self.occurrence not in [OCCURRENCE__REQUIRED_LIST,
@@ -572,20 +589,20 @@ class Object(Base):
def generate_header(self):
header = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
- header += " * VI Type: %s\n" % self.name
+ header += " * VI Object: %s\n" % self.name
if self.extends is not None:
- header += " * extends %s\n" % self.extends
+ 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
+ header += " * extended by %s\n" % extended_by
first = False
else:
- header += " * %s\n" % extended_by
+ header += " * %s\n" % extended_by
header += " */\n\n"
@@ -646,20 +663,20 @@ class Object(Base):
def generate_source(self):
source = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
- source += " * VI Type: %s\n" % self.name
+ source += " * VI Object: %s\n" % self.name
if self.extends is not None:
- source += " * extends %s\n" % self.extends
+ source += " * extends %s\n" % self.extends
first = True
if self.extended_by is not None:
for extended_by in self.extended_by:
if first:
- source += " * extended by %s\n" % extended_by
+ source += " * extended by %s\n" % extended_by
first = False
else:
- source += " * %s\n" % extended_by
+ source += " * %s\n" % extended_by
source += " */\n\n"
@@ -863,15 +880,303 @@ class Object(Base):
+class ManagedObject(Base):
+ FEATURE__LIST = (1 << 2)
+
+
+ def __init__(self, name, extends, properties, features=0, extended_by=None):
+ Base.__init__(self, "struct", name)
+ self.extends = extends
+ self.features = features
+ self.properties = properties
+ self.extended_by = extended_by
+
+ if self.extended_by is not None:
+ 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_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 = ""
+
+ if self.extends is not None:
+ source += managed_objects_by_name[self.extends].generate_lookup_code1(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 += " \"%s\\0\"\n" % property.name
+
+ if len(string) < 1:
+ source += " /* no properties */\n"
+ else:
+ source += string
+
+ return source
+
+
+ def generate_lookup_code2(self, add_banner=False):
+ source = ""
+
+ if self.extends is not None:
+ source += managed_objects_by_name[self.extends].generate_lookup_code2(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_lookup_code()
+
+ if len(string) < 1:
+ source += " /* no properties */\n"
+ else:
+ source += string
+
+ return source
+
+
+ def generate_comment(self):
+ comment = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
+ 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()
+
+ # struct
+ header += "struct _esxVI_%s {\n" % self.name
+
+ if self.features & Object.FEATURE__LIST:
+ header += aligned(" esxVI_%s *_next; " % self.name, "/* optional */\n")
+ else:
+ header += aligned(" esxVI_%s *_unused; " % self.name, "/* optional */\n")
+
+ header += aligned(" esxVI_Type _type; ", "/* required */\n")
+ header += aligned(" esxVI_ManagedObjectReference *_reference; ", "/* required */\n")
+ header += "\n"
+ header += self.generate_struct_members()
+
+ header += "};\n\n"
+
+ # functions
+ header += "int esxVI_%s_Alloc(esxVI_%s **item);\n" % (self.name, self.name)
+ header += "void esxVI_%s_Free(esxVI_%s **item);\n" % (self.name, self.name)
+ header += "int esxVI_%s_Validate(esxVI_%s *item, esxVI_String *selectedPropertyNameList);\n" % (self.name, self.name)
+
+ if self.features & Object.FEATURE__LIST:
+ header += "int esxVI_%s_AppendToList(esxVI_%s **list, esxVI_%s *item);\n" % (self.name, self.name, self.name)
+
+ header += "\n\n\n"
+
+ return header
+
+
+ def generate_helper_header(self):
+ header = ""
+
+ # functions
+ header += ("int esxVI_Lookup%s(esxVI_Context *ctx, " +
+ "const char *name, " +
+ "esxVI_ManagedObjectReference *root, " +
+ "esxVI_String *selectedPropertyNameList, " +
+ "esxVI_%s **item, " +
+ "esxVI_Occurrence occurrence);\n") % (self.name, self.name)
+
+ header += "\n"
+
+ return header
+
+
+ def generate_source(self):
+ source = self.generate_comment()
+
+ # functions
+ source += "/* esxVI_%s_Alloc */\n" % self.name
+ source += "ESX_VI__TEMPLATE__ALLOC(%s)\n\n" % self.name
+
+ # free
+ 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"
+
+ for extended_by in self.extended_by:
+ source += " ESX_VI__TEMPLATE__DISPATCH__FREE(%s)\n" % extended_by
+
+ 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" % self.name
+
+ source += " esxVI_ManagedObjectReference_Free(&item->_reference);\n\n"
+
+ source += self.generate_free_code()
+
+ source += "})\n\n"
+
+ # validate
+ source += "/* esxVI_%s_Validate */\n" % self.name
+ source += "ESX_VI__TEMPLATE__MANAGED_VALIDATE(%s,\n" % self.name
+ source += "{\n"
+
+ source += self.generate_validate_code()
+
+ source += "})\n\n"
+
+ # append to list
+ if self.features & ManagedObject.FEATURE__LIST:
+ source += "/* esxVI_%s_AppendToList */\n" % self.name
+ source += "ESX_VI__TEMPLATE__LIST__APPEND(%s)\n\n" % self.name
+
+ source += "\n\n"
+
+ return source
+
+
+ def generate_helper_source(self):
+ source = ""
+
+ # lookup
+ source += "/* esxVI_Lookup%s */\n" % self.name
+ source += "ESX_VI__TEMPLATE__LOOKUP(%s,\n" % self.name
+ source += "{\n"
+
+ source += self.generate_lookup_code1()
+
+ source += "},\n"
+ source += "{\n"
+
+ source += self.generate_lookup_code2()
+
+ source += "})\n\n"
+
+ source += "\n\n"
+
+ return source
@@ -962,8 +1267,13 @@ def capitalize_first(string):
def parse_object(block):
- # expected format: object <name> [extends <name>]
+ # expected format: [managed] object <name> [extends <name>]
header_items = block[0][1].split()
+ managed = False
+
+ if header_items[0] == "managed":
+ managed = True
+ del header_items[0]
if len(header_items) < 2:
report_error("line %d: invalid block header" % (number))
@@ -994,7 +1304,10 @@ def parse_object(block):
properties.append(Property(type=items[0], name=items[1],
occurrence=items[2]))
- return Object(name = name, extends = extends, properties = properties)
+ if managed:
+ return ManagedObject(name=name, extends=extends, properties=properties)
+ else:
+ return Object(name=name, extends=extends, properties=properties)
@@ -1075,6 +1388,7 @@ def is_known_type(type):
return type in predefined_objects or \
type in predefined_enums or \
type in objects_by_name or \
+ type in managed_objects_by_name or \
type in enums_by_name
@@ -1169,11 +1483,14 @@ types_header = open_and_print(os.path.join(output_dirname, "esx_vi_types.generat
types_source = open_and_print(os.path.join(output_dirname, "esx_vi_types.generated.c"))
methods_header = open_and_print(os.path.join(output_dirname, "esx_vi_methods.generated.h"))
methods_source = open_and_print(os.path.join(output_dirname, "esx_vi_methods.generated.c"))
+helpers_header = open_and_print(os.path.join(output_dirname, "esx_vi.generated.h"))
+helpers_source = open_and_print(os.path.join(output_dirname, "esx_vi.generated.c"))
number = 0
objects_by_name = {}
+managed_objects_by_name = {}
enums_by_name = {}
methods_by_name = {}
block = None
@@ -1191,7 +1508,8 @@ for line in file(input_filename, "rb").readlines():
if len(line) < 1:
continue
- if line.startswith("object") or line.startswith("enum") or line.startswith("method"):
+ if line.startswith("object") or line.startswith("managed object") or \
+ line.startswith("enum") or line.startswith("method"):
if block is not None:
report_error("line %d: nested block found" % (number))
else:
@@ -1202,6 +1520,9 @@ for line in file(input_filename, "rb").readlines():
if block[0][1].startswith("object"):
obj = parse_object(block)
objects_by_name[obj.name] = obj
+ elif block[0][1].startswith("managed object"):
+ obj = parse_object(block)
+ managed_objects_by_name[obj.name] = obj
elif block[0][1].startswith("enum"):
enum = parse_enum(block)
enums_by_name[enum.name] = enum
@@ -1268,6 +1589,30 @@ for obj in objects_by_name.values():
+for obj in managed_objects_by_name.values():
+ for property in obj.properties:
+ if property.occurrence != OCCURRENCE__IGNORED and \
+ not is_known_type(property.type):
+ report_error("object '%s' contains unknown property type '%s'" % (obj.name, property.type))
+
+ if obj.extends is not None:
+ if not is_known_type(obj.extends):
+ report_error("object '%s' extends unknown object '%s'" % (obj.name, obj.extends))
+
+ # detect extended_by relation
+ if obj.extends is not None:
+ extended_obj = managed_objects_by_name[obj.extends]
+
+ if extended_obj.extended_by is None:
+ extended_obj.extended_by = [obj.name]
+ else:
+ extended_obj.extended_by.append(obj.name)
+ extended_obj.extended_by.sort()
+
+
+
+
+
for obj in objects_by_name.values():
inherit_features(obj)
@@ -1283,6 +1628,8 @@ types_header.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
types_source.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
methods_header.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
methods_source.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
+helpers_header.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
+helpers_source.write("/* Generated by esx_vi_generator.py */\n\n\n\n")
# output enums
@@ -1306,7 +1653,7 @@ for name in names:
# output objects
types_typedef.write("\n\n\n" +
"/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n" +
- " * VI Types\n" +
+ " * VI Objects\n" +
" */\n\n")
types_typeenum.write("\n")
types_typetostring.write("\n")
@@ -1327,6 +1674,30 @@ for name in names:
+# output managed objects
+types_typedef.write("\n\n\n" +
+ "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n" +
+ " * VI Managed Objects\n" +
+ " */\n\n")
+types_typeenum.write("\n")
+types_typetostring.write("\n")
+types_typefromstring.write("\n")
+
+
+
+names = managed_objects_by_name.keys()
+names.sort()
+
+for name in names:
+ types_typedef.write(managed_objects_by_name[name].generate_typedef())
+ types_typeenum.write(managed_objects_by_name[name].generate_typeenum())
+ types_typetostring.write(managed_objects_by_name[name].generate_typetostring())
+ types_typefromstring.write(managed_objects_by_name[name].generate_typefromstring())
+ types_header.write(managed_objects_by_name[name].generate_header())
+ types_source.write(managed_objects_by_name[name].generate_source())
+
+
+
# output methods
names = methods_by_name.keys()
names.sort()
@@ -1334,3 +1705,13 @@ names.sort()
for name in names:
methods_header.write(methods_by_name[name].generate_header())
methods_source.write(methods_by_name[name].generate_source())
+
+
+
+# output helpers
+names = managed_objects_by_name.keys()
+names.sort()
+
+for name in names:
+ helpers_header.write(managed_objects_by_name[name].generate_helper_header())
+ helpers_source.write(managed_objects_by_name[name].generate_helper_source())
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index f3cdf2a..9e23030 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -3,7 +3,7 @@
* esx_vi_types.c: client for the VMware VI API 2.5 to manage ESX hosts
*
* Copyright (C) 2010 Red Hat, Inc.
- * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
+ * Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -693,6 +693,44 @@ esxVI_GetActualObjectType(xmlNodePtr node, esxVI_Type baseType,
+/*
+ * Macros to implement managed objects
+ */
+
+#define ESX_VI__TEMPLATE__PROPERTY__MANAGED_REQUIRE(_name) \
+ /* FIXME: This results in O(n^2) runtime in case of missing required, but \
+ * unselected properties. */ \
+ if (item->_name == 0 && \
+ esxVI_String_ListContainsValue(selectedPropertyNameList, #_name)) { \
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
+ _("%s object is missing the required '%s' property"), \
+ typeName, #_name); \
+ return -1; \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__MANAGED_VALIDATE(__type, _require) \
+ int \
+ esxVI_##__type##_Validate(esxVI_##__type *item, \
+ esxVI_String *selectedPropertyNameList) \
+ { \
+ const char *typeName = esxVI_Type_ToString(esxVI_Type_##__type); \
+ \
+ if (item->_type <= esxVI_Type_Undefined || \
+ item->_type >= esxVI_Type_Other) { \
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
+ _("%s object has invalid dynamic type"), typeName); \
+ return -1; \
+ } \
+ \
+ _require \
+ \
+ return 0; \
+ }
+
+
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* XSI: Type
*/
@@ -735,15 +773,6 @@ esxVI_Type_ToString(esxVI_Type type)
case esxVI_Type_ManagedObjectReference:
return "ManagedObjectReference";
- case esxVI_Type_Datacenter:
- return "Datacenter";
-
- case esxVI_Type_ComputeResource:
- return "ComputeResource";
-
- case esxVI_Type_HostSystem:
- return "HostSystem";
-
#include "esx_vi_types.generated.typetostring"
case esxVI_Type_Other:
@@ -776,12 +805,6 @@ esxVI_Type_FromString(const char *type)
return esxVI_Type_MethodFault;
} else if (STREQ(type, "ManagedObjectReference")) {
return esxVI_Type_ManagedObjectReference;
- } else if (STREQ(type, "Datacenter")) {
- return esxVI_Type_Datacenter;
- } else if (STREQ(type, "ComputeResource")) {
- return esxVI_Type_ComputeResource;
- } else if (STREQ(type, "HostSystem")) {
- return esxVI_Type_HostSystem;
}
#include "esx_vi_types.generated.typefromstring"
@@ -1050,6 +1073,20 @@ ESX_VI__TEMPLATE__VALIDATE(String,
ESX_VI__TEMPLATE__PROPERTY__REQUIRE(value)
})
+bool
+esxVI_String_ListContainsValue(esxVI_String *stringList, const char *value)
+{
+ esxVI_String *string;
+
+ for (string = stringList; string != NULL; string = string->_next) {
+ if (STREQ(string->value, value)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
/* esxVI_String_AppendToList */
ESX_VI__TEMPLATE__LIST__APPEND(String)
@@ -1452,7 +1489,7 @@ esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime,
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: Fault
+ * SOAP: Fault
*/
/* esxVI_Fault_Alloc */
@@ -1483,7 +1520,7 @@ ESX_VI__TEMPLATE__DESERIALIZE(Fault,
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: MethodFault
+ * VI Object: MethodFault
*/
/* esxVI_MethodFault_Alloc */
@@ -1528,7 +1565,7 @@ esxVI_MethodFault_Deserialize(xmlNodePtr node, esxVI_MethodFault **methodFault)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ManagedObjectReference
+ * VI Object: ManagedObjectReference
*/
/* esxVI_ManagedObjectReference_Alloc */
@@ -1632,280 +1669,6 @@ esxVI_ManagedObjectReference_Deserialize
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Managed Object: Datacenter
- * extends ManagedEntity
- */
-
-/* esxVI_Datacenter_Alloc */
-ESX_VI__TEMPLATE__ALLOC(Datacenter)
-
-/* esxVI_Datacenter_Free */
-ESX_VI__TEMPLATE__FREE(Datacenter,
-{
- esxVI_Datacenter_Free(&item->_next);
- esxVI_ManagedObjectReference_Free(&item->_reference);
-
- /* ManagedEntity */
- VIR_FREE(item->name);
-
- /* Datacenter */
- esxVI_ManagedObjectReference_Free(&item->hostFolder);
- esxVI_ManagedObjectReference_Free(&item->vmFolder);
-})
-
-/* esxVI_Datacenter_Validate */
-ESX_VI__TEMPLATE__VALIDATE(Datacenter,
-{
- /* ManagedEntity */
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(name);
-
- /* Datacenter */
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(hostFolder);
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(vmFolder);
-})
-
-int
-esxVI_Datacenter_CastFromObjectContent(esxVI_ObjectContent *objectContent,
- esxVI_Datacenter **datacenter)
-{
- esxVI_DynamicProperty *dynamicProperty = NULL;
-
- if (objectContent == NULL || datacenter == NULL || *datacenter != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
- return -1;
- }
-
- if (esxVI_Datacenter_Alloc(datacenter) < 0) {
- return -1;
- }
-
- if (esxVI_ManagedObjectReference_DeepCopy(&(*datacenter)->_reference,
- objectContent->obj) < 0) {
- goto failure;
- }
-
- for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
- dynamicProperty = dynamicProperty->_next) {
- if (STREQ(dynamicProperty->name, "name")) {
- if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
- goto failure;
- }
-
- (*datacenter)->name = strdup(dynamicProperty->val->string);
-
- if ((*datacenter)->name == NULL) {
- virReportOOMError();
- goto failure;
- }
- } else if (STREQ(dynamicProperty->name, "hostFolder")) {
- if (esxVI_ManagedObjectReference_CastFromAnyType
- (dynamicProperty->val, &(*datacenter)->hostFolder) < 0) {
- goto failure;
- }
- } else if (STREQ(dynamicProperty->name, "vmFolder")) {
- if (esxVI_ManagedObjectReference_CastFromAnyType
- (dynamicProperty->val, &(*datacenter)->vmFolder) < 0) {
- goto failure;
- }
- }
- }
-
- if (esxVI_Datacenter_Validate(*datacenter) < 0) {
- goto failure;
- }
-
- return 0;
-
- failure:
- esxVI_Datacenter_Free(datacenter);
-
- return -1;
-}
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Managed Object: ComputeResource
- * extends ManagedEntity
- */
-
-/* esxVI_ComputeResource_Alloc */
-ESX_VI__TEMPLATE__ALLOC(ComputeResource)
-
-/* esxVI_ComputeResource_Free */
-ESX_VI__TEMPLATE__FREE(ComputeResource,
-{
- esxVI_ComputeResource_Free(&item->_next);
- esxVI_ManagedObjectReference_Free(&item->_reference);
-
- /* ManagedEntity */
- VIR_FREE(item->name);
-
- /* ComputeResource */
- esxVI_ManagedObjectReference_Free(&item->host);
- esxVI_ManagedObjectReference_Free(&item->resourcePool);
-})
-
-/* esxVI_ComputeResource_Validate */
-ESX_VI__TEMPLATE__VALIDATE(ComputeResource,
-{
- /* ManagedEntity */
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(name);
-
- /* ComputeResource */
-})
-
-int
-esxVI_ComputeResource_CastFromObjectContent
- (esxVI_ObjectContent *objectContent, esxVI_ComputeResource **computeResource)
-{
- esxVI_DynamicProperty *dynamicProperty = NULL;
-
- if (objectContent == NULL || computeResource == NULL ||
- *computeResource != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
- return -1;
- }
-
- if (esxVI_ComputeResource_Alloc(computeResource) < 0) {
- return -1;
- }
-
- if (esxVI_ManagedObjectReference_DeepCopy(&(*computeResource)->_reference,
- objectContent->obj) < 0) {
- goto failure;
- }
-
- for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
- dynamicProperty = dynamicProperty->_next) {
- if (STREQ(dynamicProperty->name, "name")) {
- if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
- goto failure;
- }
-
- (*computeResource)->name = strdup(dynamicProperty->val->string);
-
- if ((*computeResource)->name == NULL) {
- virReportOOMError();
- goto failure;
- }
- } else if (STREQ(dynamicProperty->name, "host")) {
- if (esxVI_ManagedObjectReference_CastListFromAnyType
- (dynamicProperty->val, &(*computeResource)->host) < 0) {
- goto failure;
- }
- } else if (STREQ(dynamicProperty->name, "resourcePool")) {
- if (esxVI_ManagedObjectReference_CastFromAnyType
- (dynamicProperty->val, &(*computeResource)->resourcePool) < 0) {
- goto failure;
- }
- }
- }
-
- if (esxVI_ComputeResource_Validate(*computeResource) < 0) {
- goto failure;
- }
-
- return 0;
-
- failure:
- esxVI_ComputeResource_Free(computeResource);
-
- return -1;
-}
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Managed Object: HostSystem
- * extends ManagedEntity
- */
-
-/* esxVI_HostSystem_Alloc */
-ESX_VI__TEMPLATE__ALLOC(HostSystem)
-
-/* esxVI_HostSystem_Free */
-ESX_VI__TEMPLATE__FREE(HostSystem,
-{
- esxVI_HostSystem_Free(&item->_next);
- esxVI_ManagedObjectReference_Free(&item->_reference);
-
- /* ManagedEntity */
- VIR_FREE(item->name);
-
- /* HostSystem */
- esxVI_HostConfigManager_Free(&item->configManager);
-})
-
-/* esxVI_HostSystem_Validate */
-ESX_VI__TEMPLATE__VALIDATE(HostSystem,
-{
- /* ManagedEntity */
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(name);
-
- /* HostSystem */
- ESX_VI__TEMPLATE__PROPERTY__REQUIRE(configManager);
-})
-
-int
-esxVI_HostSystem_CastFromObjectContent(esxVI_ObjectContent *objectContent,
- esxVI_HostSystem **hostSystem)
-{
- esxVI_DynamicProperty *dynamicProperty = NULL;
-
- if (objectContent == NULL || hostSystem == NULL || *hostSystem != NULL) {
- ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
- return -1;
- }
-
- if (esxVI_HostSystem_Alloc(hostSystem) < 0) {
- return -1;
- }
-
- if (esxVI_ManagedObjectReference_DeepCopy(&(*hostSystem)->_reference,
- objectContent->obj) < 0) {
- goto failure;
- }
-
- for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
- dynamicProperty = dynamicProperty->_next) {
- if (STREQ(dynamicProperty->name, "name")) {
- if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
- goto failure;
- }
-
- (*hostSystem)->name = strdup(dynamicProperty->val->string);
-
- if ((*hostSystem)->name == NULL) {
- virReportOOMError();
- goto failure;
- }
- } else if (STREQ(dynamicProperty->name, "configManager")) {
- if (esxVI_HostConfigManager_CastFromAnyType
- (dynamicProperty->val, &(*hostSystem)->configManager) < 0) {
- goto failure;
- }
- }
- }
-
- if (esxVI_HostSystem_Validate(*hostSystem) < 0) {
- goto failure;
- }
-
- return 0;
-
- failure:
- esxVI_HostSystem_Free(hostSystem);
-
- return -1;
-}
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* VI Enum: VirtualMachinePowerState (Additions)
*/
diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h
index e53ccda..ac3741f 100644
--- a/src/esx/esx_vi_types.h
+++ b/src/esx/esx_vi_types.h
@@ -1,7 +1,8 @@
+
/*
* esx_vi_types.h: client for the VMware VI API 2.5 to manage ESX hosts
*
- * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte(a)googlemail.com>
+ * Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte(a)googlemail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -44,15 +45,18 @@ typedef struct _esxVI_DateTime esxVI_DateTime;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Types
+ * SOAP
*/
typedef struct _esxVI_Fault esxVI_Fault;
+
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * VI Objects
+ */
typedef struct _esxVI_MethodFault esxVI_MethodFault;
typedef struct _esxVI_ManagedObjectReference esxVI_ManagedObjectReference;
-typedef struct _esxVI_Datacenter esxVI_Datacenter;
-typedef struct _esxVI_ComputeResource esxVI_ComputeResource;
-typedef struct _esxVI_HostSystem esxVI_HostSystem;
# include "esx_vi_types.generated.typedef"
@@ -74,9 +78,6 @@ enum _esxVI_Type {
esxVI_Type_Fault,
esxVI_Type_MethodFault,
esxVI_Type_ManagedObjectReference,
- esxVI_Type_Datacenter,
- esxVI_Type_ComputeResource,
- esxVI_Type_HostSystem,
# include "esx_vi_types.generated.typeenum"
@@ -170,6 +171,7 @@ struct _esxVI_String {
int esxVI_String_Alloc(esxVI_String **string);
void esxVI_String_Free(esxVI_String **stringList);
int esxVI_String_Validate(esxVI_String *string);
+bool esxVI_String_ListContainsValue(esxVI_String *stringList, const char *value);
int esxVI_String_AppendToList(esxVI_String **stringList, esxVI_String *string);
int esxVI_String_AppendValueToList(esxVI_String **stringList,
const char *value);
@@ -264,7 +266,7 @@ int esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime,
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: Fault
+ * SOAP: Fault
*/
struct _esxVI_Fault {
@@ -283,7 +285,7 @@ int esxVI_Fault_Deserialize(xmlNodePtr node, esxVI_Fault **fault);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: MethodFault
+ * VI Object: MethodFault
*/
/*
@@ -306,7 +308,7 @@ int esxVI_MethodFault_Deserialize(xmlNodePtr node,
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Type: ManagedObjectReference
+ * VI Object: ManagedObjectReference
*/
struct _esxVI_ManagedObjectReference {
@@ -348,84 +350,6 @@ int esxVI_ManagedObjectReference_Deserialize
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Managed Object: Datacenter
- * extends ManagedEntity
- */
-
-struct _esxVI_Datacenter {
- esxVI_Datacenter *_next; /* optional */
- esxVI_Type _type; /* required */
- esxVI_ManagedObjectReference *_reference; /* required */
-
- /* ManagedEntity */
- char *name; /* required */
-
- /* Datacenter */
- esxVI_ManagedObjectReference *hostFolder; /* required */
- esxVI_ManagedObjectReference *vmFolder; /* required */
-};
-
-int esxVI_Datacenter_Alloc(esxVI_Datacenter **datacenter);
-void esxVI_Datacenter_Free(esxVI_Datacenter **datacenter);
-int esxVI_Datacenter_Validate(esxVI_Datacenter *datacenter);
-int esxVI_Datacenter_CastFromObjectContent(esxVI_ObjectContent *objectContent,
- esxVI_Datacenter **datacenter);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Managed Object: ComputeResource
- * extends ManagedEntity
- */
-
-struct _esxVI_ComputeResource {
- esxVI_ComputeResource *_next; /* optional */
- esxVI_Type _type; /* required */
- esxVI_ManagedObjectReference *_reference; /* required */
-
- /* ManagedEntity */
- char *name; /* required */
-
- /* ComputeResource */
- esxVI_ManagedObjectReference *host; /* optional, list */
- esxVI_ManagedObjectReference *resourcePool; /* optional */
-};
-
-int esxVI_ComputeResource_Alloc(esxVI_ComputeResource **computeResource);
-void esxVI_ComputeResource_Free(esxVI_ComputeResource **computeResource);
-int esxVI_ComputeResource_Validate(esxVI_ComputeResource *computeResource);
-int esxVI_ComputeResource_CastFromObjectContent
- (esxVI_ObjectContent *objectContent,
- esxVI_ComputeResource **computeResource);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Managed Object: HostSystem
- * extends ManagedEntity
- */
-
-struct _esxVI_HostSystem {
- esxVI_HostSystem *_next; /* optional */
- esxVI_Type _type; /* required */
- esxVI_ManagedObjectReference *_reference; /* required */
-
- /* ManagedEntity */
- char *name; /* required */
-
- /* HostSystem */
- esxVI_HostConfigManager *configManager; /* required */
-};
-
-int esxVI_HostSystem_Alloc(esxVI_HostSystem **hostSystem);
-void esxVI_HostSystem_Free(esxVI_HostSystem **hostSystem);
-int esxVI_HostSystem_Validate(esxVI_HostSystem *hostSystem);
-int esxVI_HostSystem_CastFromObjectContent(esxVI_ObjectContent *objectContent,
- esxVI_HostSystem **hostSystem);
-
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* VI Enum: VirtualMachinePowerState (Additions)
*/
--
1.7.0.4
2
2

14 Apr '11
Add CastFromAnyType functions for the String type.
---
src/esx/esx_vi_generator.py | 5 +--
src/esx/esx_vi_types.c | 64 +++++++++++++++++++++++++++++++-----------
src/esx/esx_vi_types.h | 2 +
3 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index 622a34a..0fd84dd 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -773,12 +773,11 @@ class Object(Base):
# cast from any type
if self.features & Object.FEATURE__ANY_TYPE:
source += "/* esxVI_%s_CastFromAnyType */\n" % self.name
- source += "ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(%s,\n" % self.name
if self.extended_by is None:
- source += "{\n"
- source += "})\n\n"
+ source += "ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(%s)\n\n" % self.name
else:
+ source += "ESX_VI__TEMPLATE__DYNAMIC_CAST_FROM_ANY_TYPE(%s,\n" % self.name
source += "{\n"
for extended_by in self.extended_by:
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index f3df2b5..f3cdf2a 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -183,32 +183,53 @@
-#define ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(_type, _dispatch) \
+#define ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE_EXTRA(_type, _dest_type, _extra, \
+ _dest_extra) \
int \
- esxVI_##_type##_CastFromAnyType(esxVI_AnyType *anyType, \
- esxVI_##_type **ptrptr) \
+ esxVI_##_type##_Cast##_dest_extra##FromAnyType(esxVI_AnyType *anyType, \
+ _dest_type **ptrptr) \
{ \
+ _dest_type *item; \
+ \
if (anyType == NULL || ptrptr == NULL || *ptrptr != NULL) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", \
_("Invalid argument")); \
return -1; \
} \
\
- switch (anyType->type) { \
- _dispatch \
+ item = *ptrptr; \
\
- case esxVI_Type_##_type: \
- break; \
+ _extra \
\
- default: \
+ return esxVI_##_type##_Deserialize##_dest_extra(anyType->node, \
+ ptrptr); \
+ }
+
+
+
+#define ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(_type) \
+ ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE_EXTRA(_type, esxVI_##_type, \
+ { \
+ if (anyType->type != esxVI_Type_##_type) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
_("Call to %s for unexpected type '%s'"), \
__FUNCTION__, anyType->other); \
return -1; \
} \
- \
- return esxVI_##_type##_Deserialize(anyType->node, ptrptr); \
- }
+ }, /* nothing */)
+
+
+
+#define ESX_VI__TEMPLATE__CAST_VALUE_FROM_ANY_TYPE(_type, _value_type) \
+ ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE_EXTRA(_type, _value_type, \
+ { \
+ if (anyType->type != esxVI_Type_##_type) { \
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
+ _("Call to %s for unexpected type '%s'"), \
+ __FUNCTION__, anyType->other); \
+ return -1; \
+ } \
+ }, Value)
@@ -591,6 +612,13 @@
+#define ESX_VI__TEMPLATE__DYNAMIC_CAST_FROM_ANY_TYPE(__type, _dispatch) \
+ ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE_EXTRA(__type, esxVI_##__type, \
+ ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, -1), \
+ /* nothing */)
+
+
+
#define ESX_VI__TEMPLATE__DYNAMIC_SERIALIZE(__type, _dispatch, _serialize) \
ESX_VI__TEMPLATE__SERIALIZE_EXTRA(__type, \
ESX_VI__TEMPLATE__DISPATCH(__type, _dispatch, -1), \
@@ -1111,6 +1139,12 @@ esxVI_String_DeepCopyValue(char **dest, const char *src)
return 0;
}
+/* esxVI_String_CastFromAnyType */
+ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(String)
+
+/* esxVI_String_CastValueFromAnyType */
+ESX_VI__TEMPLATE__CAST_VALUE_FROM_ANY_TYPE(String, char)
+
int
esxVI_String_Serialize(esxVI_String *string, const char *element,
virBufferPtr output)
@@ -1240,9 +1274,7 @@ ESX_VI__TEMPLATE__VALIDATE(Long,
ESX_VI__TEMPLATE__LIST__APPEND(Long)
/* esxVI_Long_CastFromAnyType */
-ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(Long,
-{
-})
+ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(Long)
/* esxVI_Long_Serialize */
ESX_VI__TEMPLATE__SERIALIZE(Long,
@@ -1522,9 +1554,7 @@ ESX_VI__TEMPLATE__DEEP_COPY(ManagedObjectReference,
ESX_VI__TEMPLATE__LIST__APPEND(ManagedObjectReference)
/* esxVI_ManagedObjectReference_CastFromAnyType */
-ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(ManagedObjectReference,
-{
-})
+ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(ManagedObjectReference)
/* esxVI_ManagedObjectReference_CastListFromAnyType */
ESX_VI__TEMPLATE__LIST__CAST_FROM_ANY_TYPE(ManagedObjectReference)
diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h
index 1ab39da..e53ccda 100644
--- a/src/esx/esx_vi_types.h
+++ b/src/esx/esx_vi_types.h
@@ -178,6 +178,8 @@ int esxVI_String_AppendValueListToList(esxVI_String **stringList,
int esxVI_String_DeepCopy(esxVI_String **dest, esxVI_String *src);
int esxVI_String_DeepCopyList(esxVI_String **destList, esxVI_String *srcList);
int esxVI_String_DeepCopyValue(char **dest, const char *src);
+int esxVI_String_CastFromAnyType(esxVI_AnyType *anyType, esxVI_String **string);
+int esxVI_String_CastValueFromAnyType(esxVI_AnyType *anyType, char **string);
int esxVI_String_Serialize(esxVI_String *string, const char *element,
virBufferPtr output);
int esxVI_String_SerializeList(esxVI_String *stringList, const char *element,
--
1.7.0.4
2
2
---
src/esx/esx_vi_generator.py | 177 +++++++++++++++++--------------------------
1 files changed, 71 insertions(+), 106 deletions(-)
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index 3d068f3..622a34a 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -41,6 +41,11 @@ valid_occurrences = [OCCURRENCE__REQUIRED_ITEM,
+def aligned(left, right):
+ while len(left) < 59:
+ left += " "
+
+ return left + right
@@ -64,9 +69,6 @@ class Parameter:
def is_enum(self):
- global predefined_enums
- global enums_by_name
-
return self.type in predefined_enums or self.type in enums_by_name
@@ -88,10 +90,7 @@ class Parameter:
else:
string += ", "
- while len(string) < 59:
- string += " "
-
- return string + self.get_occurrence_comment() + "\n"
+ return aligned(string, self.get_occurrence_comment() + "\n")
def generate_return(self, offset = 0, end_of_line = ";"):
@@ -102,10 +101,7 @@ class Parameter:
string += " " * offset
string += "%s%s)%s" % (self.get_type_string(True), self.name, end_of_line)
- while len(string) < 59:
- string += " "
-
- return string + self.get_occurrence_comment() + "\n"
+ return aligned(string, self.get_occurrence_comment() + "\n")
def generate_require_code(self):
@@ -274,9 +270,6 @@ class Property:
def is_enum(self):
- global predefined_enums
- global enums_by_name
-
return self.type in predefined_enums or self.type in enums_by_name
@@ -286,10 +279,7 @@ class Property:
else:
string = " %s%s; " % (self.get_type_string(), self.name)
- while len(string) < 59:
- string += " "
-
- return string + self.get_occurrence_comment() + "\n"
+ return aligned(string, self.get_occurrence_comment() + "\n")
def generate_free_code(self):
@@ -380,7 +370,37 @@ class Property:
-class Object:
+class Base:
+ def __init__(self, kind, name):
+ self.kind = kind
+ self.name = name
+
+
+ def generate_typedef(self):
+ return "typedef %s _esxVI_%s esxVI_%s;\n" % (self.kind, self.name, self.name)
+
+
+ def generate_typeenum(self):
+ return " esxVI_Type_%s,\n" % self.name
+
+
+ def generate_typetostring(self):
+ string = " case esxVI_Type_%s:\n" % self.name
+ string += " return \"%s\";\n\n" % self.name
+
+ return string
+
+
+ def generate_typefromstring(self):
+ string = " else if (STREQ(type, \"%s\")) {\n" % self.name
+ string += " return esxVI_Type_%s;\n" % self.name
+ string += " }\n"
+
+ return string
+
+
+
+class Object(Base):
FEATURE__DYNAMIC_CAST = (1 << 1)
FEATURE__LIST = (1 << 2)
FEATURE__DEEP_COPY = (1 << 3)
@@ -390,34 +410,24 @@ class Object:
def __init__(self, name, extends, properties, features = 0, extended_by = None):
- self.name = name
+ Base.__init__(self, "struct", name)
self.extends = extends
self.features = features | Object.FEATURE__SERIALIZE | Object.FEATURE__DESERIALIZE
self.properties = properties
self.extended_by = extended_by
if self.extended_by is not None:
- self.extended_by.sort();
+ self.extended_by.sort()
- def generate_struct_members(self, add_banner = False, struct_gap = False):
- global objects_by_name
+ def generate_struct_members(self, add_banner=False, struct_gap=False):
members = ""
- if self.extends is None:
- struct_gap = True
- string = " esxVI_Type _type; "
-
- while len(string) < 59:
- string += " "
-
- members += string + "/* required */\n"
-
- if struct_gap and self.extends is None:
+ if struct_gap:
members += "\n"
if self.extends is not None:
- members += objects_by_name[self.extends].generate_struct_members(add_banner = True, struct_gap = False) + "\n"
+ members += objects_by_name[self.extends].generate_struct_members(add_banner=True, struct_gap=False) + "\n"
if self.extends is not None or add_banner:
members += " /* %s */\n" % self.name
@@ -431,12 +441,11 @@ class Object:
return members
- def generate_free_code(self, add_banner = False):
- global objects_by_name
+ def generate_free_code(self, add_banner=False):
source = ""
if self.extends is not None:
- source += objects_by_name[self.extends].generate_free_code(add_banner = True) + "\n"
+ source += 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
@@ -457,12 +466,11 @@ class Object:
return source
- def generate_validate_code(self, add_banner = False):
- global objects_by_name
+ def generate_validate_code(self, add_banner=False):
source = ""
if self.extends is not None:
- source += objects_by_name[self.extends].generate_validate_code(add_banner = True) + "\n"
+ source += 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
@@ -484,7 +492,6 @@ class Object:
def generate_dynamic_cast_code(self, is_first = True):
- global objects_by_name
source = ""
if self.extended_by is not None:
@@ -503,7 +510,6 @@ class Object:
def generate_deep_copy_code(self, add_banner = False):
- global objects_by_name
source = ""
if self.extends is not None:
@@ -529,7 +535,6 @@ class Object:
def generate_serialize_code(self, add_banner = False):
- global objects_by_name
source = ""
if self.extends is not None:
@@ -548,11 +553,10 @@ class Object:
def generate_deserialize_code(self, add_banner = False):
- global objects_by_name
source = ""
if self.extends is not None:
- source += objects_by_name[self.extends].generate_deserialize_code(add_banner = True) + "\n"
+ source += objects_by_name[self.extends].generate_deserialize_code(add_banner=True) + "\n"
if self.extends is not None or add_banner:
source += " /* %s */\n" % self.name
@@ -566,29 +570,6 @@ class Object:
return source
- def generate_typedef(self):
- return "typedef struct _esxVI_%s esxVI_%s;\n" % (self.name, self.name)
-
-
- def generate_typeenum(self):
- return " esxVI_Type_%s,\n" % self.name
-
-
- def generate_typetostring(self):
- string = " case esxVI_Type_%s:\n" % self.name
- string += " return \"%s\";\n\n" % self.name
-
- return string
-
-
- def generate_typefromstring(self):
- string = " else if (STREQ(type, \"%s\")) {\n" % self.name
- string += " return esxVI_Type_%s;\n" % self.name
- string += " }\n"
-
- return string
-
-
def generate_header(self):
header = "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
header += " * VI Type: %s\n" % self.name
@@ -612,17 +593,12 @@ class Object:
header += "struct _esxVI_%s {\n" % self.name
if self.features & Object.FEATURE__LIST:
- string = " esxVI_%s *_next; " % self.name
+ header += aligned(" esxVI_%s *_next; " % self.name, "/* optional */\n")
else:
- string = " esxVI_%s *_unused; " % self.name
-
- while len(string) < 59:
- string += " "
-
- header += string + "/* optional */\n"
-
- header += self.generate_struct_members(struct_gap = True)
+ header += aligned(" esxVI_%s *_unused; " % self.name, "/* optional */\n")
+ header += aligned(" esxVI_Type _type; ", "/* required */\n")
+ header += self.generate_struct_members(struct_gap=True)
header += "};\n\n"
# functions
@@ -888,39 +864,28 @@ class Object:
-class Enum:
- FEATURE__ANY_TYPE = (1 << 1)
- FEATURE__SERIALIZE = (1 << 2)
- FEATURE__DESERIALIZE = (1 << 3)
- def __init__(self, name, values, features = 0):
- self.name = name
- self.values = values
- self.features = features | Enum.FEATURE__SERIALIZE | Enum.FEATURE__DESERIALIZE
- def generate_typedef(self):
- return "typedef enum _esxVI_%s esxVI_%s;\n" % (self.name, self.name)
- def generate_typeenum(self):
- return " esxVI_Type_%s,\n" % self.name
- def generate_typetostring(self):
- string = " case esxVI_Type_%s:\n" % self.name
- string += " return \"%s\";\n\n" % self.name
- return string
- def generate_typefromstring(self):
- string = " else if (STREQ(type, \"%s\")) {\n" % self.name
- string += " return esxVI_Type_%s;\n" % self.name
- string += " }\n"
- return string
+class Enum(Base):
+ FEATURE__ANY_TYPE = (1 << 1)
+ FEATURE__SERIALIZE = (1 << 2)
+ FEATURE__DESERIALIZE = (1 << 3)
+
+
+ def __init__(self, name, values, features=0):
+ Base.__init__(self, "enum", name)
+ self.values = values
+ self.features = features | Enum.FEATURE__SERIALIZE | Enum.FEATURE__DESERIALIZE
def generate_header(self):
@@ -1027,8 +992,8 @@ def parse_object(block):
if items[2] not in valid_occurrences:
report_error("line %d: invalid occurrence" % line[0])
- properties.append(Property(type = items[0], name = items[1],
- occurrence = items[2]))
+ properties.append(Property(type=items[0], name=items[1],
+ occurrence=items[2]))
return Object(name = name, extends = extends, properties = properties)
@@ -1051,7 +1016,7 @@ def parse_enum(block):
# expected format: <value>
values.append(line[1])
- return Enum(name = name, values = values)
+ return Enum(name=name, values=values)
@@ -1071,8 +1036,8 @@ def parse_method(block):
if header_items[2] != "returns":
report_error("line %d: invalid block header" % (number))
else:
- returns = Parameter(type = header_items[3], name = "output",
- occurrence = header_items[4])
+ returns = Parameter(type=header_items[3], name="output",
+ occurrence=header_items[4])
parameters = []
@@ -1086,10 +1051,10 @@ def parse_method(block):
if items[2] not in valid_occurrences:
report_error("line %d: invalid occurrence" % line[0])
- parameters.append(Parameter(type = items[0], name = items[1],
- occurrence = items[2]))
+ parameters.append(Parameter(type=items[0], name=items[1],
+ occurrence=items[2]))
- return Method(name = name, parameters = parameters, returns = returns)
+ return Method(name=name, parameters=parameters, returns=returns)
--
1.7.0.4
2
2
If brSetForwardDelay() fails, we go to err1 where we want to access
macTapIfName variable which was just VIR_FREE'd a few lines above.
---
src/network/bridge_driver.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index ea2bfd4..97d8ce0 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1616,7 +1616,7 @@ networkStartNetworkDaemon(struct network_driver *driver,
bool v4present = false, v6present = false;
virErrorPtr save_err = NULL;
virNetworkIpDefPtr ipdef;
- char *macTapIfName;
+ char *macTapIfName = NULL;
if (virNetworkObjIsActive(network)) {
networkReportError(VIR_ERR_OPERATION_INVALID,
@@ -1657,7 +1657,6 @@ networkStartNetworkDaemon(struct network_driver *driver,
VIR_FREE(macTapIfName);
goto err0;
}
- VIR_FREE(macTapIfName);
}
/* Set bridge options */
@@ -1731,6 +1730,7 @@ networkStartNetworkDaemon(struct network_driver *driver,
goto err5;
}
+ VIR_FREE(macTapIfName);
VIR_INFO(_("Starting up network '%s'"), network->def->name);
network->active = 1;
@@ -1778,6 +1778,7 @@ networkStartNetworkDaemon(struct network_driver *driver,
macTapIfName, network->def->bridge,
virStrerror(err, ebuf, sizeof ebuf));
}
+ VIR_FREE(macTapIfName);
err0:
if (!save_err)
--
1.7.4.2
2
2

[libvirt] [PATCH] docs: Serial and parallel device target ports actually start from 0
by Matthias Bolte 14 Apr '11
by Matthias Bolte 14 Apr '11
14 Apr '11
Reported by Igor Galić
---
docs/formatdomain.html.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 574fee5..ea021e8 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1807,7 +1807,7 @@ qemu-kvm -net nic,model=? /dev/null
<p>
<code>target</code> can have a <code>port</code> attribute, which
- specifies the port number. Ports are numbered starting from 1. There are
+ specifies the port number. Ports are numbered starting from 0. There are
usually 0, 1 or 2 parallel ports.
</p>
@@ -1825,7 +1825,7 @@ qemu-kvm -net nic,model=? /dev/null
<p>
<code>target</code> can have a <code>port</code> attribute, which
- specifies the port number. Ports are numbered starting from 1. There are
+ specifies the port number. Ports are numbered starting from 0. There are
usually 0, 1 or 2 serial ports.
</p>
--
1.7.0.4
2
2
Hi
For some reason recent libvirt code (0.8.3 and even before) the 'virsh
shutdown <domain> ' is not effective .
It issues an ok message by the domians remains in a runnning state . Only
th e destroy works fine.
Any idea ?
Zvi Dubitzky
Email:dubi@il.ibm.com
3
2
If brSetForwardDelay() fails, we go to err1 where we want to access
macTapIfName variable which was just VIR_FREE'd a few lines above.
---
src/network/bridge_driver.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index ea2bfd4..abde150 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1616,7 +1616,7 @@ networkStartNetworkDaemon(struct network_driver *driver,
bool v4present = false, v6present = false;
virErrorPtr save_err = NULL;
virNetworkIpDefPtr ipdef;
- char *macTapIfName;
+ char *macTapIfName = NULL;
if (virNetworkObjIsActive(network)) {
networkReportError(VIR_ERR_OPERATION_INVALID,
@@ -1657,7 +1657,6 @@ networkStartNetworkDaemon(struct network_driver *driver,
VIR_FREE(macTapIfName);
goto err0;
}
- VIR_FREE(macTapIfName);
}
/* Set bridge options */
@@ -1687,6 +1686,8 @@ networkStartNetworkDaemon(struct network_driver *driver,
if (networkAddIptablesRules(driver, network) < 0)
goto err1;
+ VIR_FREE(macTapIfName);
+
for (ii = 0;
(ipdef = virNetworkDefGetIpByIndex(network->def, AF_UNSPEC, ii));
ii++) {
--
1.7.4.2
2
1