[libvirt] [PATCH] esx: Generate method mappings via macros

Matthias Bolte matthias.bolte at googlemail.com
Mon Mar 22 00:53:50 UTC 2010


This is actually a consequence of the reworked required parameter
checking: Unify the required parameter check into a Validate function
instead of doing it separately im the (de)serialization part.

The required parameter checking for the mapped methods parameter was
done in the (de)serialize functions before. Now it's explicitly done
in the mapped method itself.
---

git produces a somwhat confusing diff for esx_vi_methods.c, basically
the whole file is rewritten.

 src/esx/esx_driver.c     |    5 +-
 src/esx/esx_vi.c         |  181 +-----
 src/esx/esx_vi.h         |   23 +-
 src/esx/esx_vi_methods.c | 1713 +++++++++++++++++-----------------------------
 src/esx/esx_vi_methods.h |   29 +-
 src/esx/esx_vi_types.c   |  568 ++++++++++------
 src/esx/esx_vi_types.h   |  120 ++--
 7 files changed, 1085 insertions(+), 1554 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 19e9c02..20977b6 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3128,7 +3128,10 @@ esxDomainMigratePerform(virDomainPtr domain,
 
     /* Perform the purposed migration */
     if (esxVI_MigrateVM_Task(priv->vCenter, virtualMachine->obj, resourcePool,
-                             hostSystem->obj, &task) < 0 ||
+                             hostSystem->obj,
+                             esxVI_VirtualMachineMovePriority_DefaultPriority,
+                             esxVI_VirtualMachinePowerState_Undefined,
+                             &task) < 0 ||
         esxVI_WaitForTaskCompletion(priv->vCenter, task, domain->uuid,
                                     priv->autoAnswer, &taskInfoState) < 0) {
         goto failure;
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 8c8f1bc..aa46532 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -844,8 +844,7 @@ esxVI_Enumeration_CastFromAnyType(const esxVI_Enumeration *enumeration,
 
 int
 esxVI_Enumeration_Serialize(const esxVI_Enumeration *enumeration,
-                            int value, const char *element,
-                            virBufferPtr output, esxVI_Boolean required)
+                            int value, const char *element, virBufferPtr output)
 {
     int i;
     const char *name = NULL;
@@ -856,7 +855,7 @@ esxVI_Enumeration_Serialize(const esxVI_Enumeration *enumeration,
     }
 
     if (value == 0) { /* undefined */
-        return esxVI_CheckSerializationNecessity(element, required);
+        return 0;
     }
 
     for (i = 0; enumeration->values[i].name != NULL; ++i) {
@@ -1045,7 +1044,7 @@ esxVI_List_CastFromAnyType(esxVI_AnyType *anyType, esxVI_List **list,
 
 int
 esxVI_List_Serialize(esxVI_List *list, const char *element,
-                     virBufferPtr output, esxVI_Boolean required,
+                     virBufferPtr output,
                      esxVI_List_SerializeFunc serializeFunc)
 {
     esxVI_List *item = NULL;
@@ -1056,11 +1055,11 @@ esxVI_List_Serialize(esxVI_List *list, const char *element,
     }
 
     if (list == NULL) {
-        return esxVI_CheckSerializationNecessity(element, required);
+        return 0;
     }
 
     for (item = list; item != NULL; item = item->_next) {
-        if (serializeFunc(item, element, output, esxVI_Boolean_True) < 0) {
+        if (serializeFunc(item, element, output) < 0) {
             return -1;
         }
     }
@@ -1138,27 +1137,6 @@ esxVI_Alloc(void **ptrptr, size_t size)
 
 
 int
-esxVI_CheckSerializationNecessity(const char *element,
-                                  esxVI_Boolean required)
-{
-    if (element == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
-    }
-
-    if (required == esxVI_Boolean_True) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
-                     "Required property missing while trying to serialize "
-                     "'%s'", element);
-        return -1;
-    } else {
-        return 0;
-    }
-}
-
-
-
-int
 esxVI_BuildFullTraversalSpecItem(esxVI_SelectionSpec **fullTraversalSpecList,
                                  const char *name, const char *type,
                                  const char *path, const char *selectSetNames)
@@ -1861,7 +1839,9 @@ esxVI_LookupVirtualMachineByUuid(esxVI_Context *ctx, const unsigned char *uuid,
         return -1;
     }
 
-    if (esxVI_FindByUuid(ctx, ctx->datacenter, uuid, esxVI_Boolean_True,
+    virUUIDFormat(uuid, uuid_string);
+
+    if (esxVI_FindByUuid(ctx, ctx->datacenter, uuid_string, esxVI_Boolean_True,
                          &managedObjectReference) < 0) {
         goto failure;
     }
@@ -1870,8 +1850,6 @@ esxVI_LookupVirtualMachineByUuid(esxVI_Context *ctx, const unsigned char *uuid,
         if (occurrence == esxVI_Occurrence_OptionalItem) {
             return 0;
         } else {
-            virUUIDFormat(uuid, uuid_string);
-
             ESX_VI_ERROR(VIR_ERR_NO_DOMAIN,
                          "Could not find domain with UUID '%s'", uuid_string);
             goto failure;
@@ -2268,149 +2246,6 @@ esxVI_LookupAndHandleVirtualMachineQuestion(esxVI_Context *ctx,
 
 
 int
-esxVI_StartVirtualMachineTask(esxVI_Context *ctx, const char *name,
-                              const char *request,
-                              esxVI_ManagedObjectReference **task)
-{
-    int result = 0;
-    char *methodName = NULL;
-    esxVI_Response *response = NULL;
-
-    if (virAsprintf(&methodName, "%s_Task", name) < 0) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    if (esxVI_Context_Execute(ctx, methodName, request, &response,
-                              esxVI_Occurrence_RequiredItem) < 0 ||
-        esxVI_ManagedObjectReference_Deserialize(response->node, task,
-                                                 "Task") < 0) {
-        goto failure;
-    }
-
-  cleanup:
-    VIR_FREE(methodName);
-    esxVI_Response_Free(&response);
-
-    return result;
-
-  failure:
-    result = -1;
-
-    goto cleanup;
-}
-
-
-
-int
-esxVI_StartSimpleVirtualMachineTask
-  (esxVI_Context *ctx, const char *name,
-   esxVI_ManagedObjectReference *virtualMachine,
-   esxVI_ManagedObjectReference **task)
-{
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<");
-    virBufferAdd(&buffer, name, -1);
-    virBufferAddLit(&buffer, "_Task xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(virtualMachine, "_this", &buffer,
-                                               esxVI_Boolean_True) < 0) {
-        goto failure;
-    }
-
-    virBufferAddLit(&buffer, "</");
-    virBufferAdd(&buffer, name, -1);
-    virBufferAddLit(&buffer, "_Task>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_StartVirtualMachineTask(ctx, name, request, task) < 0) {
-        goto failure;
-    }
-
-  cleanup:
-    VIR_FREE(request);
-
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
-
-
-
-int
-esxVI_SimpleVirtualMachineMethod(esxVI_Context *ctx, const char *name,
-                                 esxVI_ManagedObjectReference *virtualMachine)
-{
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
-    }
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<");
-    virBufferAdd(&buffer, name, -1);
-    virBufferAddLit(&buffer, " xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(virtualMachine, "_this", &buffer,
-                                               esxVI_Boolean_True) < 0) {
-        goto failure;
-    }
-
-    virBufferAddLit(&buffer, "</");
-    virBufferAdd(&buffer, name, -1);
-    virBufferAddLit(&buffer, ">");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_Context_Execute(ctx, name, request, &response,
-                              esxVI_Occurrence_None) < 0) {
-        goto failure;
-    }
-
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
-
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
-
-
-
-int
 esxVI_HandleVirtualMachineQuestion
   (esxVI_Context *ctx, esxVI_ManagedObjectReference *virtualMachine,
    esxVI_VirtualMachineQuestionInfo *questionInfo,
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index c45b91d..a57406c 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -140,7 +140,7 @@ int esxVI_Enumeration_CastFromAnyType(const esxVI_Enumeration *enumeration,
                                       esxVI_AnyType *anyType, int *value);
 int esxVI_Enumeration_Serialize(const esxVI_Enumeration *enumeration,
                                 int value, const char *element,
-                                virBufferPtr output, esxVI_Boolean required);
+                                virBufferPtr output);
 int esxVI_Enumeration_Deserialize(const esxVI_Enumeration *enumeration,
                                   xmlNodePtr node, int *value);
 
@@ -159,8 +159,7 @@ typedef int (*esxVI_List_DeepCopyFunc) (esxVI_List **dest, esxVI_List *src);
 typedef int (*esxVI_List_CastFromAnyTypeFunc) (esxVI_AnyType *anyType,
                                                esxVI_List **item);
 typedef int (*esxVI_List_SerializeFunc) (esxVI_List *item, const char *element,
-                                         virBufferPtr output,
-                                         esxVI_Boolean required);
+                                         virBufferPtr output);
 typedef int (*esxVI_List_DeserializeFunc) (xmlNodePtr node, esxVI_List **item);
 
 int esxVI_List_Append(esxVI_List **list, esxVI_List *item);
@@ -171,7 +170,7 @@ int esxVI_List_CastFromAnyType(esxVI_AnyType *anyType, esxVI_List **list,
                                esxVI_List_CastFromAnyTypeFunc castFromAnyTypeFunc,
                                esxVI_List_FreeFunc freeFunc);
 int esxVI_List_Serialize(esxVI_List *list, const char *element,
-                         virBufferPtr output, esxVI_Boolean required,
+                         virBufferPtr output,
                          esxVI_List_SerializeFunc serializeFunc);
 int esxVI_List_Deserialize(xmlNodePtr node, esxVI_List **list,
                            esxVI_List_DeserializeFunc deserializeFunc,
@@ -189,9 +188,6 @@ int esxVI_List_Deserialize(xmlNodePtr node, esxVI_List **list,
 
 int esxVI_Alloc(void **ptrptr, size_t size);
 
-int esxVI_CheckSerializationNecessity(const char *element,
-                                      esxVI_Boolean required);
-
 int esxVI_BuildFullTraversalSpecItem
       (esxVI_SelectionSpec **fullTraversalSpecList, const char *name,
        const char *type, const char *path, const char *selectSetNames);
@@ -263,19 +259,6 @@ int esxVI_LookupAndHandleVirtualMachineQuestion(esxVI_Context *ctx,
                                                 const unsigned char *uuid,
                                                 esxVI_Boolean autoAnswer);
 
-int esxVI_StartVirtualMachineTask(esxVI_Context *ctx, const char *name,
-                                  const char *request,
-                                  esxVI_ManagedObjectReference **task);
-
-int esxVI_StartSimpleVirtualMachineTask
-      (esxVI_Context *ctx, const char *name,
-       esxVI_ManagedObjectReference *virtualMachine,
-       esxVI_ManagedObjectReference **task);
-
-int esxVI_SimpleVirtualMachineMethod
-      (esxVI_Context *ctx, const char *name,
-       esxVI_ManagedObjectReference *virtualMachine);
-
 int esxVI_HandleVirtualMachineQuestion
       (esxVI_Context *ctx,
        esxVI_ManagedObjectReference *virtualMachine,
diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c
index 05c7b42..07cd82a 100644
--- a/src/esx/esx_vi_methods.c
+++ b/src/esx/esx_vi_methods.c
@@ -3,7 +3,7 @@
  * esx_vi_methods.c: client for the VMware VI API 2.5 to manage ESX hosts
  *
  * Copyright (C) 2010 Red Hat, Inc.
- * Copyright (C) 2009 Matthias Bolte <matthias.bolte at googlemail.com>
+ * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte at googlemail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -52,289 +52,168 @@
 
 
 
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * VI Methods
- */
-
-int
-esxVI_RetrieveServiceContent(esxVI_Context *ctx,
-                             esxVI_ServiceContent **serviceContent)
-{
-    int result = 0;
-    const char *request = ESX_VI__SOAP__REQUEST_HEADER
-                            "<RetrieveServiceContent xmlns=\"urn:vim25\">"
-                              "<_this xmlns=\"urn:vim25\" "
-                                     "xsi:type=\"ManagedObjectReference\" "
-                                     "type=\"ServiceInstance\">"
-                                "ServiceInstance"
-                              "</_this>"
-                            "</RetrieveServiceContent>"
-                          ESX_VI__SOAP__REQUEST_FOOTER;
-    esxVI_Response *response = NULL;
-
-    if (serviceContent == NULL || *serviceContent != NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
+#define ESX_VI__METHOD(_name, _parameters, _occurrence, _prolog, _validate,   \
+                       _serialize, _deserialize)                              \
+    int                                                                       \
+    esxVI_##_name _parameters                                                 \
+    {                                                                         \
+        int result = 0;                                                       \
+        const char* method_name = #_name;                                     \
+        virBuffer buffer = VIR_BUFFER_INITIALIZER;                            \
+        char *request = NULL;                                                 \
+        esxVI_Response *response = NULL;                                      \
+                                                                              \
+        _prolog                                                               \
+                                                                              \
+        _validate                                                             \
+                                                                              \
+        virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);               \
+        virBufferAddLit(&buffer, "<"#_name" xmlns=\"urn:vim25\">");           \
+                                                                              \
+        _serialize                                                            \
+                                                                              \
+        virBufferAddLit(&buffer, "</"#_name">");                              \
+        virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);               \
+                                                                              \
+        if (virBufferError(&buffer)) {                                        \
+            virReportOOMError();                                              \
+            goto failure;                                                     \
+        }                                                                     \
+                                                                              \
+        request = virBufferContentAndReset(&buffer);                          \
+                                                                              \
+        if (esxVI_Context_Execute(ctx, #_name, request, &response,            \
+                                  esxVI_Occurrence_##_occurrence) < 0) {      \
+            goto failure;                                                     \
+        }                                                                     \
+                                                                              \
+        if (response->node != NULL) {                                         \
+            _deserialize                                                      \
+        }                                                                     \
+                                                                              \
+      cleanup:                                                                \
+        VIR_FREE(request);                                                    \
+        esxVI_Response_Free(&response);                                       \
+                                                                              \
+        return result;                                                        \
+                                                                              \
+      failure:                                                                \
+        virBufferFreeAndReset(&buffer);                                       \
+                                                                              \
+        result = -1;                                                          \
+                                                                              \
+        goto cleanup;                                                         \
+    }
+
+
+
+#define ESX_VI__METHOD__CHECK_SERVICE()                                       \
+    if (ctx->service == NULL) {                                               \
+        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");                 \
+        return -1;                                                            \
+    }
+
+
+
+#define ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(_name)                        \
+    if (_name == NULL || *_name != NULL) {                                    \
+        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");             \
+        return -1;                                                            \
     }
 
-    if (esxVI_Context_Execute(ctx, "RetrieveServiceContent", request,
-                              &response, esxVI_Occurrence_RequiredItem) < 0 ||
-        esxVI_ServiceContent_Deserialize(response->node, serviceContent) < 0) {
-        goto failure;
-    }
 
-  cleanup:
-    esxVI_Response_Free(&response);
 
-    return result;
-
-  failure:
-    result = -1;
-
-    goto cleanup;
-}
-
-
-
-int
-esxVI_Login(esxVI_Context *ctx, const char *userName, const char *password,
-            esxVI_UserSession **userSession)
-{
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
+/*
+ * A required parameter must be != 0 (NULL for pointers, "undefined" == 0 for
+ * enumeration values).
+ *
+ * To be used as part of ESX_VI__METHOD.
+ */
+#define ESX_VI__METHOD__PARAMETER__REQUIRE(_name)                             \
+    if (_name == 0) {                                                         \
+        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,                                  \
+                     "Required parameter '%s' is missing for call to %s",     \
+                     #_name, method_name);                                    \
+        return -1;                                                            \
     }
 
-    if (userSession == NULL || *userSession != NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
-    }
 
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<Login xmlns=\"urn:vim25\">");
 
-    if (esxVI_ManagedObjectReference_Serialize(ctx->service->sessionManager,
-                                               "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_String_SerializeValue(userName, "userName", &buffer,
-                                    esxVI_Boolean_True) < 0 ||
-        esxVI_String_SerializeValue(password, "password", &buffer,
-                                    esxVI_Boolean_True) < 0) {
-        goto failure;
+#define ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(_name)                        \
+    if (_name == 0) {                                                         \
+        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,                                  \
+                     "Required parameter '_this' is missing for call to %s",  \
+                     method_name);                                            \
+        return -1;                                                            \
     }
 
-    virBufferAddLit(&buffer, "</Login>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
 
-    if (esxVI_Context_Execute(ctx, "Login", request, &response,
-                              esxVI_Occurrence_RequiredItem) < 0 ||
-        esxVI_UserSession_Deserialize(response->node, userSession) < 0) {
-        goto failure;
+#define ESX_VI__METHOD__PARAMETER__SERIALIZE(_type, _name)                    \
+    if (esxVI_##_type##_Serialize(_name, #_name, &buffer) < 0) {              \
+        goto failure;                                                         \
     }
 
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
-
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
-
 
 
-int
-esxVI_Logout(esxVI_Context *ctx)
-{
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
+#define ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(_type, _name)               \
+    if (esxVI_##_type##_SerializeList(_name, #_name, &buffer) < 0) {          \
+        goto failure;                                                         \
     }
 
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<Logout xmlns=\"urn:vim25\">");
 
-    if (esxVI_ManagedObjectReference_Serialize(ctx->service->sessionManager,
-                                               "_this", &buffer,
-                                               esxVI_Boolean_True) < 0) {
-        goto failure;
-    }
-
-    virBufferAddLit(&buffer, "</Logout>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
+#define ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(_type, _name)              \
+    if (esxVI_##_type##_SerializeValue(_name, #_name, &buffer) < 0) {         \
+        goto failure;                                                         \
     }
 
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_Context_Execute(ctx, "Logout", request, &response,
-                              esxVI_Occurrence_None) < 0) {
-        goto failure;
-    }
 
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
 
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
-
-
-
-int
-esxVI_SessionIsActive(esxVI_Context *ctx, const char *sessionID,
-                      const char *userName, esxVI_Boolean *active)
-{
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
-    }
-
-    if (active == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
+#define ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(_type, _name)               \
+    if (esxVI_##_type##_Serialize(_name, "_this", &buffer) < 0) {             \
+        goto failure;                                                         \
     }
 
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<SessionIsActive xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(ctx->service->sessionManager,
-                                               "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_String_SerializeValue(sessionID, "sessionID", &buffer,
-                                    esxVI_Boolean_True) < 0 ||
-        esxVI_String_SerializeValue(userName, "userName", &buffer,
-                                    esxVI_Boolean_True) < 0) {
-        goto failure;
-    }
-
-    virBufferAddLit(&buffer, "</SessionIsActive>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_Context_Execute(ctx, "SessionIsActive", request, &response,
-                              esxVI_Occurrence_RequiredItem) < 0 ||
-        esxVI_Boolean_Deserialize(response->node, active) < 0) {
-        goto failure;
-    }
-
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
-
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
 
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * VI Methods
+ */
 
 int
-esxVI_RetrieveProperties(esxVI_Context *ctx,
-                         esxVI_PropertyFilterSpec *propertyFilterSpecList,
-                         esxVI_ObjectContent **objectContentList)
+esxVI_RetrieveServiceContent(esxVI_Context *ctx,
+                             esxVI_ServiceContent **serviceContent)
 {
     int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
+    const char *request = ESX_VI__SOAP__REQUEST_HEADER
+                            "<RetrieveServiceContent xmlns=\"urn:vim25\">"
+                              "<_this xmlns=\"urn:vim25\" "
+                                     "xsi:type=\"ManagedObjectReference\" "
+                                     "type=\"ServiceInstance\">"
+                                "ServiceInstance"
+                              "</_this>"
+                            "</RetrieveServiceContent>"
+                          ESX_VI__SOAP__REQUEST_FOOTER;
     esxVI_Response *response = NULL;
 
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
-    }
-
-    if (objectContentList == NULL || *objectContentList != NULL) {
+    if (serviceContent == NULL || *serviceContent != NULL) {
         ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
         return -1;
     }
 
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<RetrieveProperties xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(ctx->service->propertyCollector,
-                                               "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_PropertyFilterSpec_SerializeList(propertyFilterSpecList,
-                                               "specSet", &buffer,
-                                               esxVI_Boolean_True) < 0) {
-        goto failure;
-    }
-
-    virBufferAddLit(&buffer, "</RetrieveProperties>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_Context_Execute(ctx, "RetrieveProperties", request, &response,
-                              esxVI_Occurrence_List) < 0 ||
-        esxVI_ObjectContent_DeserializeList(response->node,
-                                            objectContentList) < 0) {
+    if (esxVI_Context_Execute(ctx, "RetrieveServiceContent", request,
+                              &response, esxVI_Occurrence_RequiredItem) < 0 ||
+        esxVI_ServiceContent_Deserialize(response->node, serviceContent) < 0) {
         goto failure;
     }
 
   cleanup:
-    VIR_FREE(request);
     esxVI_Response_Free(&response);
 
     return result;
 
   failure:
-    virBufferFreeAndReset(&buffer);
-
     result = -1;
 
     goto cleanup;
@@ -342,1000 +221,650 @@ esxVI_RetrieveProperties(esxVI_Context *ctx,
 
 
 
-int
-esxVI_PowerOnVM_Task(esxVI_Context *ctx,
-                     esxVI_ManagedObjectReference *virtualMachine,
-                     esxVI_ManagedObjectReference **task)
+/* esxVI_Login */
+ESX_VI__METHOD(Login,
+               (esxVI_Context *ctx,
+                const char *userName, const char *password,
+                esxVI_UserSession **userSession),
+               RequiredItem,
 {
-    return esxVI_StartSimpleVirtualMachineTask(ctx, "PowerOnVM",
-                                               virtualMachine, task);
-}
-
-
-
-int
-esxVI_PowerOffVM_Task(esxVI_Context *ctx,
-                      esxVI_ManagedObjectReference *virtualMachine,
-                      esxVI_ManagedObjectReference **task)
+    ESX_VI__METHOD__CHECK_SERVICE()
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(userSession)
+},
 {
-    return esxVI_StartSimpleVirtualMachineTask(ctx, "PowerOffVM",
-                                               virtualMachine, task);
-}
-
-
-
-int
-esxVI_SuspendVM_Task(esxVI_Context *ctx,
-                     esxVI_ManagedObjectReference *virtualMachine,
-                     esxVI_ManagedObjectReference **task)
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->sessionManager)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(userName)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(password)
+},
 {
-    return esxVI_StartSimpleVirtualMachineTask(ctx, "SuspendVM",
-                                               virtualMachine, task);
-}
-
-
-
-int
-esxVI_MigrateVM_Task(esxVI_Context *ctx,
-                     esxVI_ManagedObjectReference *virtualMachine,
-                     esxVI_ManagedObjectReference *resourcePool,
-                     esxVI_ManagedObjectReference *hostSystem,
-                     esxVI_ManagedObjectReference **task)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              ctx->service->sessionManager)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, userName)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, password)
+},
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-
-    if (task == NULL || *task != NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
-    }
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<MigrateVM_Task xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(virtualMachine, "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_ManagedObjectReference_Serialize(resourcePool, "pool", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_ManagedObjectReference_Serialize(hostSystem, "host", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_VirtualMachineMovePriority_Serialize
-          (esxVI_VirtualMachineMovePriority_DefaultPriority, "priority",
-           &buffer, esxVI_Boolean_True) < 0) {
+    if (esxVI_UserSession_Deserialize(response->node, userSession) < 0) {
         goto failure;
     }
+})
 
-    virBufferAddLit(&buffer, "</MigrateVM_Task>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
 
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_StartVirtualMachineTask(ctx, "MigrateVM", request, task) < 0) {
-        goto failure;
-    }
-
-  cleanup:
-    VIR_FREE(request);
 
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
-
-
-
-int
-esxVI_ReconfigVM_Task(esxVI_Context *ctx,
-                      esxVI_ManagedObjectReference *virtualMachine,
-                      esxVI_VirtualMachineConfigSpec *spec,
-                      esxVI_ManagedObjectReference **task)
+/* esxVI_Logout */
+ESX_VI__METHOD(Logout, (esxVI_Context *ctx), None,
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-
-    if (task == NULL || *task != NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
-    }
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<ReconfigVM_Task xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(virtualMachine, "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_VirtualMachineConfigSpec_Serialize(spec, "spec", &buffer,
-                                                 esxVI_Boolean_True) < 0) {
-        goto failure;
-    }
-
-    virBufferAddLit(&buffer, "</ReconfigVM_Task>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_StartVirtualMachineTask(ctx, "ReconfigVM", request, task) < 0) {
-        goto failure;
-    }
-
-  cleanup:
-    VIR_FREE(request);
-
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
+    ESX_VI__METHOD__CHECK_SERVICE()
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->sessionManager)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              ctx->service->sessionManager)
+},
+{
+})
 
 
 
-int
-esxVI_RegisterVM_Task(esxVI_Context *ctx,
-                      esxVI_ManagedObjectReference *folder,
-                      const char *path, const char *name,
-                      esxVI_Boolean asTemplate,
-                      esxVI_ManagedObjectReference *resourcePool,
-                      esxVI_ManagedObjectReference *hostSystem,
-                      esxVI_ManagedObjectReference **task)
+/* esxVI_SessionIsActive */
+ESX_VI__METHOD(SessionIsActive,
+               (esxVI_Context *ctx, const char *sessionID,
+                const char *userName, esxVI_Boolean *active),
+               RequiredItem,
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
+    ESX_VI__METHOD__CHECK_SERVICE()
 
-    if (task == NULL || *task != NULL) {
+    if (active == NULL) {
         ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
         return -1;
     }
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<RegisterVM_Task xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(folder, "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_String_SerializeValue(path, "path", &buffer,
-                                    esxVI_Boolean_True) < 0 ||
-        esxVI_String_SerializeValue(name, "name", &buffer,
-                                    esxVI_Boolean_False) < 0 ||
-        esxVI_Boolean_Serialize(asTemplate, "asTemplate", &buffer,
-                                esxVI_Boolean_False) < 0 ||
-        esxVI_ManagedObjectReference_Serialize(resourcePool, "pool", &buffer,
-                                               esxVI_Boolean_False) < 0 ||
-        esxVI_ManagedObjectReference_Serialize(hostSystem, "host", &buffer,
-                                               esxVI_Boolean_False) < 0) {
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->sessionManager)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(sessionID)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(userName)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              ctx->service->sessionManager)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, sessionID)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, userName)
+},
+{
+    if (esxVI_Boolean_Deserialize(response->node, active) < 0) {
         goto failure;
     }
+})
 
-    virBufferAddLit(&buffer, "</RegisterVM_Task>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
 
-    request = virBufferContentAndReset(&buffer);
 
-    if (esxVI_StartVirtualMachineTask(ctx, "RegisterVM", request, task) < 0) {
+/* esxVI_RetrieveProperties */
+ESX_VI__METHOD(RetrieveProperties,
+               (esxVI_Context *ctx,
+                esxVI_PropertyFilterSpec *specSet, /* list */
+                esxVI_ObjectContent **objectContentList),
+               List,
+{
+    ESX_VI__METHOD__CHECK_SERVICE()
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(objectContentList)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->propertyCollector)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(specSet)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              ctx->service->propertyCollector)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(PropertyFilterSpec, specSet)
+},
+{
+    if (esxVI_ObjectContent_DeserializeList(response->node,
+                                            objectContentList) < 0) {
         goto failure;
     }
+})
 
-  cleanup:
-    VIR_FREE(request);
 
-    return result;
 
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
-
-
-
-int
-esxVI_CancelTask(esxVI_Context *ctx, esxVI_ManagedObjectReference *task)
+/* esxVI_PowerOnVM_Task */
+ESX_VI__METHOD(PowerOnVM_Task,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *virtualMachine,
+                esxVI_ManagedObjectReference **task),
+               RequiredItem,
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
-    }
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<CancelTask xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(task, "_this", &buffer,
-                                               esxVI_Boolean_True) < 0) {
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              virtualMachine)
+},
+{
+    if (esxVI_ManagedObjectReference_Deserialize(response->node, task,
+                                                 "Task") < 0) {
         goto failure;
     }
+})
 
-    virBufferAddLit(&buffer, "</CancelTask>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
 
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_Context_Execute(ctx, "CancelTask", request, &response,
-                              esxVI_Occurrence_None) < 0) {
+/* esxVI_PowerOffVM_Task */
+ESX_VI__METHOD(PowerOffVM_Task,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *virtualMachine,
+                esxVI_ManagedObjectReference **task),
+               RequiredItem,
+{
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              virtualMachine)
+},
+{
+    if (esxVI_ManagedObjectReference_Deserialize(response->node, task,
+                                                 "Task") < 0) {
         goto failure;
     }
+})
 
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
 
-    return result;
-
-  failure:
-    if (request == NULL) {
-        request = virBufferContentAndReset(&buffer);
-    }
-
-    result = -1;
 
-    goto cleanup;
-}
-
-
-
-int
-esxVI_UnregisterVM(esxVI_Context *ctx,
-                   esxVI_ManagedObjectReference *virtualMachine)
+/* esxVI_SuspendVM_Task */
+ESX_VI__METHOD(SuspendVM_Task,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *virtualMachine,
+                esxVI_ManagedObjectReference **task),
+               RequiredItem,
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<UnregisterVM xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(virtualMachine, "_this", &buffer,
-                                               esxVI_Boolean_True) < 0) {
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              virtualMachine)
+},
+{
+    if (esxVI_ManagedObjectReference_Deserialize(response->node, task,
+                                                 "Task") < 0) {
         goto failure;
     }
+})
 
-    virBufferAddLit(&buffer, "</UnregisterVM>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
 
-    request = virBufferContentAndReset(&buffer);
 
-    if (esxVI_Context_Execute(ctx, "UnregisterVM", request, &response,
-                              esxVI_Occurrence_None) < 0) {
+/* esxVI_MigrateVM_Task */
+ESX_VI__METHOD(MigrateVM_Task,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *virtualMachine,
+                esxVI_ManagedObjectReference *pool,
+                esxVI_ManagedObjectReference *host,
+                esxVI_VirtualMachineMovePriority priority,
+                esxVI_VirtualMachinePowerState state,
+                esxVI_ManagedObjectReference **task),
+               RequiredItem,
+{
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(priority)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              virtualMachine)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, pool)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, host)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(VirtualMachineMovePriority, priority)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(VirtualMachinePowerState, state)
+},
+{
+    if (esxVI_ManagedObjectReference_Deserialize(response->node, task,
+                                                 "Task") < 0) {
         goto failure;
     }
-
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
-
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
+})
 
 
 
-int
-esxVI_AnswerVM(esxVI_Context *ctx,
-               esxVI_ManagedObjectReference *virtualMachine,
-               const char *questionId, const char *answerChoice)
+/* esxVI_ReconfigVM_Task */
+ESX_VI__METHOD(ReconfigVM_Task,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *virtualMachine,
+                esxVI_VirtualMachineConfigSpec *spec,
+                esxVI_ManagedObjectReference **task),
+               RequiredItem,
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<AnswerVM xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(virtualMachine, "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_String_SerializeValue(questionId, "questionId", &buffer,
-                                    esxVI_Boolean_True) < 0 ||
-        esxVI_String_SerializeValue(answerChoice, "answerChoice", &buffer,
-                                    esxVI_Boolean_True) < 0) {
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(spec)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              virtualMachine)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(VirtualMachineConfigSpec, spec)
+},
+{
+    if (esxVI_ManagedObjectReference_Deserialize(response->node, task,
+                                                 "Task") < 0) {
         goto failure;
     }
+})
 
-    virBufferAddLit(&buffer, "</AnswerVM>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
 
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_Context_Execute(ctx, request, NULL, &response,
-                              esxVI_Boolean_False) < 0) {
+/* esxVI_RegisterVM_Task */
+ESX_VI__METHOD(RegisterVM_Task,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *folder,
+                const char *path, const char *name,
+                esxVI_Boolean asTemplate,
+                esxVI_ManagedObjectReference *pool,
+                esxVI_ManagedObjectReference *host,
+                esxVI_ManagedObjectReference **task),
+               RequiredItem,
+{
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(folder)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(path)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference, folder)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, path)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, name)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, asTemplate)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, pool)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, host)
+},
+{
+    if (esxVI_ManagedObjectReference_Deserialize(response->node, task,
+                                                 "Task") < 0) {
         goto failure;
     }
+})
 
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
-
-    return result;
-
-  failure:
-    if (request == NULL) {
-        request = virBufferContentAndReset(&buffer);
-    }
 
-    result = -1;
 
-    goto cleanup;
-}
+/* esxVI_CancelTask */
+ESX_VI__METHOD(CancelTask,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *task),
+               None,
+{
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(task)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference, task)
+},
+{
+})
 
 
 
-int
-esxVI_CreateFilter(esxVI_Context *ctx,
-                   esxVI_PropertyFilterSpec *propertyFilterSpec,
-                   esxVI_Boolean partialUpdates,
-                   esxVI_ManagedObjectReference **propertyFilter)
+/* esxVI_UnregisterVM */
+ESX_VI__METHOD(UnregisterVM,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *virtualMachine),
+               None,
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
-    }
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              virtualMachine)
+},
+{
+})
 
-    if (propertyFilter == NULL || *propertyFilter != NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
-    }
 
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<CreateFilter xmlns=\"urn:vim25\">");
 
-    if (esxVI_ManagedObjectReference_Serialize(ctx->service->propertyCollector,
-                                               "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_PropertyFilterSpec_Serialize(propertyFilterSpec, "spec", &buffer,
-                                           esxVI_Boolean_True) < 0 ||
-        esxVI_Boolean_Serialize(partialUpdates, "partialUpdates", &buffer,
-                                esxVI_Boolean_True) < 0) {
-        goto failure;
-    }
+/* esxVI_AnswerVM */
+ESX_VI__METHOD(AnswerVM,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *virtualMachine,
+                const char *questionId,
+                const char *answerChoice),
+               None,
+{
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(questionId)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(answerChoice)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              virtualMachine)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, questionId)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, answerChoice)
+},
+{
+})
 
-    virBufferAddLit(&buffer, "</CreateFilter>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
 
-    if (esxVI_Context_Execute(ctx, "CreateFilter", request, &response,
-                              esxVI_Occurrence_RequiredItem) < 0 ||
-        esxVI_ManagedObjectReference_Deserialize(response->node, propertyFilter,
+/* esxVI_CreateFilter */
+ESX_VI__METHOD(CreateFilter,
+               (esxVI_Context *ctx,
+                esxVI_PropertyFilterSpec *spec,
+                esxVI_Boolean partialUpdates,
+                esxVI_ManagedObjectReference **propertyFilter),
+               RequiredItem,
+{
+    ESX_VI__METHOD__CHECK_SERVICE()
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(propertyFilter)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->propertyCollector)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(spec)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(partialUpdates)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              ctx->service->propertyCollector)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(PropertyFilterSpec, spec)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, partialUpdates)
+},
+{
+    if (esxVI_ManagedObjectReference_Deserialize(response->node, propertyFilter,
                                                  "PropertyFilter") < 0) {
         goto failure;
     }
+})
 
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
-
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
 
-    result = -1;
 
-    goto cleanup;
-}
-
-
-
-int
-esxVI_DestroyPropertyFilter(esxVI_Context *ctx,
-                            esxVI_ManagedObjectReference *propertyFilter)
+/* esxVI_DestroyPropertyFilter */
+ESX_VI__METHOD(DestroyPropertyFilter,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *propertyFilter),
+               None,
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
-    }
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<DestroyPropertyFilter xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(propertyFilter, "_this", &buffer,
-                                               esxVI_Boolean_True) < 0) {
-        goto failure;
-    }
-
-    virBufferAddLit(&buffer, "</DestroyPropertyFilter>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_Context_Execute(ctx, "DestroyPropertyFilter", request,
-                              &response, esxVI_Occurrence_None) < 0) {
-        goto failure;
-    }
-
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
-
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
-
-
-
-int
-esxVI_WaitForUpdates(esxVI_Context *ctx, const char *version,
-                     esxVI_UpdateSet **updateSet)
+},
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
-    }
-
-    if (updateSet == NULL || *updateSet != NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
-    }
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<WaitForUpdates xmlns=\"urn:vim25\">");
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(propertyFilter)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              propertyFilter)
+},
+{
+})
 
-    if (esxVI_ManagedObjectReference_Serialize(ctx->service->propertyCollector,
-                                               "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_String_SerializeValue(version, "version", &buffer,
-                                    esxVI_Boolean_True) < 0) {
-        goto failure;
-    }
 
-    virBufferAddLit(&buffer, "</WaitForUpdates>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_Context_Execute(ctx, "WaitForUpdates", request,
-                              &response, esxVI_Occurrence_RequiredItem) < 0 ||
-        esxVI_UpdateSet_Deserialize(response->node, updateSet) < 0) {
+/* esxVI_WaitForUpdates */
+ESX_VI__METHOD(WaitForUpdates,
+               (esxVI_Context *ctx,
+                const char *version,
+                esxVI_UpdateSet **updateSet),
+               RequiredItem,
+{
+    ESX_VI__METHOD__CHECK_SERVICE()
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(updateSet)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->propertyCollector)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(version)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              ctx->service->propertyCollector)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, version)
+},
+{
+    if (esxVI_UpdateSet_Deserialize(response->node, updateSet) < 0) {
         goto failure;
     }
+})
 
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
-
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
 
-    result = -1;
 
-    goto cleanup;
-}
-
-
-
-int
-esxVI_RebootGuest(esxVI_Context *ctx,
-                  esxVI_ManagedObjectReference *virtualMachine)
+/* esxVI_RebootGuest */
+ESX_VI__METHOD(RebootGuest,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *virtualMachine),
+               None,
 {
-    return esxVI_SimpleVirtualMachineMethod(ctx, "RebootGuest", virtualMachine);
-}
-
-
-
-int
-esxVI_ShutdownGuest(esxVI_Context *ctx,
-                    esxVI_ManagedObjectReference *virtualMachine)
+},
 {
-    return esxVI_SimpleVirtualMachineMethod(ctx, "ShutdownGuest",
-                                            virtualMachine);
-}
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              virtualMachine)
+},
+{
+})
 
 
 
-int
-esxVI_ValidateMigration(esxVI_Context *ctx,
-                        esxVI_ManagedObjectReference *virtualMachineList,
-                        esxVI_VirtualMachinePowerState powerState,
-                        esxVI_String *testTypeList,
-                        esxVI_ManagedObjectReference *resourcePool,
-                        esxVI_ManagedObjectReference *hostSystem,
-                        esxVI_Event **eventList)
+/* esxVI_ShutdownGuest */
+ESX_VI__METHOD(ShutdownGuest,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *virtualMachine),
+               None,
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              virtualMachine)
+},
+{
+})
 
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
-    }
 
-    if (eventList == NULL || *eventList != NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
-    }
 
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<ValidateMigration xmlns=\"urn:vim25\">"
-                             "<_this xmlns=\"urn:vim25\" "
+/* esxVI_ValidateMigration */
+ESX_VI__METHOD(ValidateMigration,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *vm, /* list */
+                esxVI_VirtualMachinePowerState state,
+                esxVI_String *testType, /* list */
+                esxVI_ManagedObjectReference *pool,
+                esxVI_ManagedObjectReference *host,
+                esxVI_Event **eventList),
+               List,
+{
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(eventList)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE(vm)
+},
+{
+    virBufferAddLit(&buffer, "<_this xmlns=\"urn:vim25\" "
                                     "xsi:type=\"ManagedObjectReference\" "
                                     "type=\"ServiceInstance\">"
                                "ServiceInstance"
                              "</_this>");
-
-    if (esxVI_ManagedObjectReference_SerializeList(virtualMachineList, "vm",
-                                                   &buffer,
-                                                   esxVI_Boolean_True) < 0 ||
-        esxVI_VirtualMachinePowerState_Serialize(powerState, "state", &buffer,
-                                                 esxVI_Boolean_False) < 0 ||
-        esxVI_String_SerializeList(testTypeList, "testType", &buffer,
-                                   esxVI_Boolean_False) < 0 ||
-        esxVI_ManagedObjectReference_Serialize(resourcePool, "pool", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_ManagedObjectReference_Serialize(hostSystem, "host", &buffer,
-                                               esxVI_Boolean_True) < 0) {
-        goto failure;
-    }
-
-    virBufferAddLit(&buffer, "</ValidateMigration>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_Context_Execute(ctx, "ValidateMigration", request, &response,
-                              esxVI_Occurrence_List) < 0 ||
-        esxVI_Event_DeserializeList(response->node, eventList) < 0) {
-        goto failure;
-    }
-
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
-
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
-
-
-
-int
-esxVI_FindByIp(esxVI_Context *ctx,
-                 esxVI_ManagedObjectReference *datacenter,
-                 const char *ip, esxVI_Boolean vmSearch,
-                 esxVI_ManagedObjectReference **managedObjectReference)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(ManagedObjectReference, vm)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(VirtualMachinePowerState, state)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(String, testType)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, pool)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, host)
+},
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
-    }
-
-    if (managedObjectReference == NULL || *managedObjectReference != NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
-    }
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<FindByIp xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(ctx->service->searchIndex,
-                                               "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_ManagedObjectReference_Serialize(datacenter, "datacenter",
-                                               &buffer,
-                                               esxVI_Boolean_False) < 0 ||
-        esxVI_String_SerializeValue(ip, "ip", &buffer,
-                                    esxVI_Boolean_True) < 0 ||
-        esxVI_Boolean_Serialize(vmSearch, "vmSearch", &buffer,
-                                esxVI_Boolean_True) < 0) {
+    if (esxVI_Event_DeserializeList(response->node, eventList) < 0) {
         goto failure;
     }
+})
 
-    virBufferAddLit(&buffer, "</FindByIp>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
 
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
 
-    if (esxVI_Context_Execute(ctx, "FindByIp", request, &response,
-                              esxVI_Occurrence_OptionalItem) < 0 ||
-        esxVI_ManagedObjectReference_Deserialize
+/* esxVI_FindByIp */
+ESX_VI__METHOD(FindByIp,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *datacenter,
+                const char *ip,
+                esxVI_Boolean vmSearch,
+                esxVI_ManagedObjectReference **managedObjectReference),
+               OptionalItem,
+{
+    ESX_VI__METHOD__CHECK_SERVICE()
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(managedObjectReference)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->searchIndex)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(ip)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(vmSearch)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              ctx->service->searchIndex)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, datacenter)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, ip)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, vmSearch)
+},
+{
+    if (esxVI_ManagedObjectReference_Deserialize
           (response->node, managedObjectReference,
            vmSearch == esxVI_Boolean_True ? "VirtualMachine"
                                           : "HostSystem") < 0) {
         goto failure;
     }
+})
 
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
 
-    return result;
 
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
-
-
-
-int
-esxVI_FindByUuid(esxVI_Context *ctx,
-                 esxVI_ManagedObjectReference *datacenter,
-                 const unsigned char *uuid, esxVI_Boolean vmSearch,
-                 esxVI_ManagedObjectReference **managedObjectReference)
+/* esxVI_FindByUuid */
+ESX_VI__METHOD(FindByUuid,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *datacenter,
+                const char *uuid, /* string */
+                esxVI_Boolean vmSearch,
+                esxVI_ManagedObjectReference **managedObjectReference),
+               OptionalItem,
+{
+    ESX_VI__METHOD__CHECK_SERVICE()
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(managedObjectReference)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->searchIndex)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(uuid)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(vmSearch)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              ctx->service->searchIndex)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, datacenter)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, uuid)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, vmSearch)
+},
 {
-    int result = 0;
-    char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
-    }
-
-    if (managedObjectReference == NULL || *managedObjectReference != NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
-    }
-
-    virUUIDFormat(uuid, uuid_string);
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<FindByUuid xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(ctx->service->searchIndex,
-                                               "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_ManagedObjectReference_Serialize(datacenter, "datacenter",
-                                               &buffer,
-                                               esxVI_Boolean_False) < 0 ||
-        esxVI_String_SerializeValue(uuid_string, "uuid", &buffer,
-                                    esxVI_Boolean_True) < 0 ||
-        esxVI_Boolean_Serialize(vmSearch, "vmSearch", &buffer,
-                                esxVI_Boolean_True) < 0) {
-        goto failure;
-    }
-
-    virBufferAddLit(&buffer, "</FindByUuid>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_Context_Execute(ctx, "FindByUuid", request, &response,
-                              esxVI_Occurrence_OptionalItem) < 0) {
-        goto failure;
-    }
-
-    if (response->node == NULL) {
-        goto cleanup;
-    }
-
     if (esxVI_ManagedObjectReference_Deserialize
           (response->node, managedObjectReference,
            vmSearch == esxVI_Boolean_True ? "VirtualMachine"
                                           : "HostSystem") < 0) {
         goto failure;
     }
-
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
-
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
+})
 
 
 
-int
-esxVI_QueryAvailablePerfMetric(esxVI_Context *ctx,
-                               esxVI_ManagedObjectReference *entity,
-                               esxVI_DateTime *beginTime,
-                               esxVI_DateTime *endTime, esxVI_Int *intervalId,
-                               esxVI_PerfMetricId **perfMetricIdList)
+/* esxVI_QueryAvailablePerfMetric */
+ESX_VI__METHOD(QueryAvailablePerfMetric,
+               (esxVI_Context *ctx,
+                esxVI_ManagedObjectReference *entity,
+                esxVI_DateTime *beginTime,
+                esxVI_DateTime *endTime,
+                esxVI_Int *intervalId,
+                esxVI_PerfMetricId **perfMetricIdList),
+               List,
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
-    }
-
-    if (perfMetricIdList == NULL || *perfMetricIdList != NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
-    }
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<QueryAvailablePerfMetric xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(ctx->service->perfManager,
-                                               "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_ManagedObjectReference_Serialize(entity, "entity", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_DateTime_Serialize(beginTime, "beginTime", &buffer,
-                                 esxVI_Boolean_False) < 0 ||
-        esxVI_DateTime_Serialize(endTime, "endTime", &buffer,
-                                 esxVI_Boolean_False) < 0 ||
-        esxVI_Int_Serialize(intervalId, "intervalId", &buffer,
-                            esxVI_Boolean_False) < 0) {
-        goto failure;
-    }
-
-    virBufferAddLit(&buffer, "</QueryAvailablePerfMetric>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_Context_Execute(ctx, "QueryAvailablePerfMetric", request,
-                              &response, esxVI_Occurrence_List) < 0 ||
-        esxVI_PerfMetricId_DeserializeList(response->node,
+    ESX_VI__METHOD__CHECK_SERVICE()
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(perfMetricIdList)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->perfManager)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(entity)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              ctx->service->perfManager)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, entity)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(DateTime, beginTime)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(DateTime, endTime)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE(Int, intervalId)
+},
+{
+    if (esxVI_PerfMetricId_DeserializeList(response->node,
                                            perfMetricIdList) < 0) {
         goto failure;
     }
+})
 
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
 
-    return result;
 
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
-
-
-
-int
-esxVI_QueryPerfCounter(esxVI_Context *ctx, esxVI_Int *counterIdList,
-                       esxVI_PerfCounterInfo **perfCounterInfoList)
+/* esxVI_QueryPerfCounter */
+ESX_VI__METHOD(QueryPerfCounter,
+               (esxVI_Context *ctx,
+                esxVI_Int *counterId, /* list */
+                esxVI_PerfCounterInfo **perfCounterInfoList),
+               List,
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
-    }
-
-    if (perfCounterInfoList == NULL || *perfCounterInfoList != NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
-    }
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<QueryPerfCounter xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(ctx->service->perfManager,
-                                               "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_Int_SerializeList(counterIdList, "counterId", &buffer,
-                                esxVI_Boolean_True) < 0) {
-        goto failure;
-    }
-
-    virBufferAddLit(&buffer, "</QueryPerfCounter>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_Context_Execute(ctx, "QueryPerfCounter", request, &response,
-                              esxVI_Occurrence_List) < 0 ||
-        esxVI_PerfCounterInfo_DeserializeList(response->node,
+    ESX_VI__METHOD__CHECK_SERVICE()
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(perfCounterInfoList)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->perfManager)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(counterId)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              ctx->service->perfManager)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(Int, counterId)
+},
+{
+    if (esxVI_PerfCounterInfo_DeserializeList(response->node,
                                               perfCounterInfoList) < 0) {
         goto failure;
     }
+})
 
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
-
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
 
 
-
-int
-esxVI_QueryPerf(esxVI_Context *ctx, esxVI_PerfQuerySpec *querySpecList,
-                esxVI_PerfEntityMetric **perfEntityMetricList)
+/* esxVI_QueryPerf */
+ESX_VI__METHOD(QueryPerf,
+               (esxVI_Context *ctx,
+                esxVI_PerfQuerySpec *querySpec, /* list */
+                esxVI_PerfEntityMetric **perfEntityMetricList),
+               List,
 {
-    int result = 0;
-    virBuffer buffer = VIR_BUFFER_INITIALIZER;
-    char *request = NULL;
-    esxVI_Response *response = NULL;
-
-    if (ctx->service == NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");
-        return -1;
-    }
-
-    if (perfEntityMetricList == NULL || *perfEntityMetricList != NULL) {
-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
-        return -1;
-    }
-
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
-    virBufferAddLit(&buffer, "<QueryPerf xmlns=\"urn:vim25\">");
-
-    if (esxVI_ManagedObjectReference_Serialize(ctx->service->perfManager,
-                                               "_this", &buffer,
-                                               esxVI_Boolean_True) < 0 ||
-        esxVI_PerfQuerySpec_SerializeList(querySpecList, "querySpec", &buffer,
-                                          esxVI_Boolean_True) < 0) {
-        goto failure;
-    }
-
-    virBufferAddLit(&buffer, "</QueryPerf>");
-    virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);
-
-    if (virBufferError(&buffer)) {
-        virReportOOMError();
-        goto failure;
-    }
-
-    request = virBufferContentAndReset(&buffer);
-
-    if (esxVI_Context_Execute(ctx, "QueryPerf", request, &response,
-                              esxVI_Occurrence_List) < 0 ||
-        esxVI_PerfEntityMetric_DeserializeList(response->node,
+    ESX_VI__METHOD__CHECK_SERVICE()
+    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(perfEntityMetricList)
+},
+{
+    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->perfManager)
+    ESX_VI__METHOD__PARAMETER__REQUIRE(querySpec)
+},
+{
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
+                                              ctx->service->perfManager)
+    ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(PerfQuerySpec, querySpec)
+},
+{
+    if (esxVI_PerfEntityMetric_DeserializeList(response->node,
                                                perfEntityMetricList) < 0) {
         goto failure;
     }
-
-  cleanup:
-    VIR_FREE(request);
-    esxVI_Response_Free(&response);
-
-    return result;
-
-  failure:
-    virBufferFreeAndReset(&buffer);
-
-    result = -1;
-
-    goto cleanup;
-}
+})
diff --git a/src/esx/esx_vi_methods.h b/src/esx/esx_vi_methods.h
index 54b0417..40bff51 100644
--- a/src/esx/esx_vi_methods.h
+++ b/src/esx/esx_vi_methods.h
@@ -44,7 +44,7 @@ int esxVI_SessionIsActive(esxVI_Context *ctx, const char *sessionID,
                           const char *userName, esxVI_Boolean *active);
 
 int esxVI_RetrieveProperties(esxVI_Context *ctx,
-                             esxVI_PropertyFilterSpec *propertyFilterSpecList,
+                             esxVI_PropertyFilterSpec *specSet, /* list */
                              esxVI_ObjectContent **objectContentList);
 
 int esxVI_PowerOnVM_Task(esxVI_Context *ctx,
@@ -61,8 +61,10 @@ int esxVI_SuspendVM_Task(esxVI_Context *ctx,
 
 int esxVI_MigrateVM_Task(esxVI_Context *ctx,
                          esxVI_ManagedObjectReference *virtualMachine,
-                         esxVI_ManagedObjectReference *resourcePool,
-                         esxVI_ManagedObjectReference *hostSystem,
+                         esxVI_ManagedObjectReference *pool,
+                         esxVI_ManagedObjectReference *host,
+                         esxVI_VirtualMachineMovePriority priority,
+                         esxVI_VirtualMachinePowerState state,
                          esxVI_ManagedObjectReference **task);
 
 int esxVI_ReconfigVM_Task(esxVI_Context *ctx,
@@ -74,8 +76,8 @@ int esxVI_RegisterVM_Task(esxVI_Context *ctx,
                           esxVI_ManagedObjectReference *folder,
                           const char *path, const char *name,
                           esxVI_Boolean asTemplate,
-                          esxVI_ManagedObjectReference *resourcePool,
-                          esxVI_ManagedObjectReference *hostSystem,
+                          esxVI_ManagedObjectReference *pool,
+                          esxVI_ManagedObjectReference *host,
                           esxVI_ManagedObjectReference **task);
 
 int esxVI_CancelTask(esxVI_Context *ctx, esxVI_ManagedObjectReference *task);
@@ -88,7 +90,7 @@ int esxVI_AnswerVM(esxVI_Context *ctx,
                    const char *questionId, const char *answerChoice);
 
 int esxVI_CreateFilter(esxVI_Context *ctx,
-                       esxVI_PropertyFilterSpec *propertyFilterSpec,
+                       esxVI_PropertyFilterSpec *spec,
                        esxVI_Boolean partialUpdates,
                        esxVI_ManagedObjectReference **propertyFilter);
 
@@ -105,11 +107,11 @@ int esxVI_ShutdownGuest(esxVI_Context *ctx,
                         esxVI_ManagedObjectReference *virtualMachine);
 
 int esxVI_ValidateMigration(esxVI_Context *ctx,
-                            esxVI_ManagedObjectReference *virtualMachineList,
-                            esxVI_VirtualMachinePowerState powerState,
-                            esxVI_String *testTypeList, // FIXME: see ValidateMigrationTestType
-                            esxVI_ManagedObjectReference *resourcePool,
-                            esxVI_ManagedObjectReference *hostSystem,
+                            esxVI_ManagedObjectReference *vm, /* list */
+                            esxVI_VirtualMachinePowerState state,
+                            esxVI_String *testType, /* list */ // FIXME: see ValidateMigrationTestType
+                            esxVI_ManagedObjectReference *pool,
+                            esxVI_ManagedObjectReference *host,
                             esxVI_Event **eventList);
 
 int esxVI_FindByIp(esxVI_Context *ctx, esxVI_ManagedObjectReference *datacenter,
@@ -118,7 +120,8 @@ int esxVI_FindByIp(esxVI_Context *ctx, esxVI_ManagedObjectReference *datacenter,
 
 int esxVI_FindByUuid(esxVI_Context *ctx,
                      esxVI_ManagedObjectReference *datacenter,
-                     const unsigned char *uuid, esxVI_Boolean vmSearch,
+                     const char *uuid, /* string */
+                     esxVI_Boolean vmSearch,
                      esxVI_ManagedObjectReference **managedObjectReference);
 
 int esxVI_QueryAvailablePerfMetric(esxVI_Context *ctx,
@@ -128,7 +131,7 @@ int esxVI_QueryAvailablePerfMetric(esxVI_Context *ctx,
                                    esxVI_Int *intervalId,
                                    esxVI_PerfMetricId **perfMetricIdList);
 
-int esxVI_QueryPerfCounter(esxVI_Context *ctx, esxVI_Int *counterIdList,
+int esxVI_QueryPerfCounter(esxVI_Context *ctx, esxVI_Int *counterId, /* list */
                            esxVI_PerfCounterInfo **perfCounterInfoList);
 
 int esxVI_QueryPerf(esxVI_Context *ctx, esxVI_PerfQuerySpec *querySpecList,
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index dd0b763..87a13cb 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 Matthias Bolte <matthias.bolte at googlemail.com>
+ * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte at googlemail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -92,6 +92,28 @@
 
 
 
+#define ESX_VI__TEMPLATE__VALIDATE(_type, _require)                           \
+    int                                                                       \
+    esxVI_##_type##_Validate(esxVI_##_type *item)                             \
+    {                                                                         \
+        const char *type_name = #_type;                                       \
+                                                                              \
+        _require                                                              \
+                                                                              \
+        return 0;                                                             \
+    }
+
+
+
+#define ESX_VI__TEMPLATE__VALIDATE_NOOP(_type)                                \
+    int                                                                       \
+    esxVI_##_type##_Validate(esxVI_##_type *item ATTRIBUTE_UNUSED)            \
+    {                                                                         \
+        return 0;                                                             \
+    }
+
+
+
 #define ESX_VI__TEMPLATE__LIST__APPEND(_type)                                 \
     int                                                                       \
     esxVI_##_type##_AppendToList(esxVI_##_type **list,  esxVI_##_type *item)  \
@@ -131,11 +153,9 @@
 #define ESX_VI__TEMPLATE__LIST__SERIALIZE(_type)                              \
     int                                                                       \
     esxVI_##_type##_SerializeList(esxVI_##_type *list, const char *element,   \
-                                  virBufferPtr output,                        \
-                                  esxVI_Boolean required)                     \
+                                  virBufferPtr output)                        \
     {                                                                         \
-        return esxVI_List_Serialize((esxVI_List *)list, element,              \
-                                    output, required,                         \
+        return esxVI_List_Serialize((esxVI_List *)list, element, output,      \
                                     (esxVI_List_SerializeFunc)                \
                                       esxVI_##_type##_Serialize);             \
     }
@@ -179,8 +199,7 @@
 #define ESX_VI__TEMPLATE__SERIALIZE_EXTRA(_type, _type_string, _serialize)    \
     int                                                                       \
     esxVI_##_type##_Serialize(esxVI_##_type *item,                            \
-                              const char *element, virBufferPtr output,       \
-                              esxVI_Boolean required)                         \
+                              const char *element, virBufferPtr output)       \
     {                                                                         \
         if (element == NULL || output == NULL ) {                             \
             ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");         \
@@ -188,7 +207,11 @@
         }                                                                     \
                                                                               \
         if (item == NULL) {                                                   \
-            return esxVI_CheckSerializationNecessity(element, required);      \
+            return 0;                                                         \
+        }                                                                     \
+                                                                              \
+        if (esxVI_##_type##_Validate(item) < 0) {                             \
+            return -1;                                                        \
         }                                                                     \
                                                                               \
         ESV_VI__XML_TAG__OPEN(output, element, _type_string);                 \
@@ -207,7 +230,7 @@
 
 
 
-#define ESX_VI__TEMPLATE__DESERIALIZE(_type, _deserialize, _require)          \
+#define ESX_VI__TEMPLATE__DESERIALIZE(_type, _deserialize)                    \
     int                                                                       \
     esxVI_##_type##_Deserialize(xmlNodePtr node, esxVI_##_type **ptrptr)      \
     {                                                                         \
@@ -235,7 +258,9 @@
             VIR_WARN("Unexpected '%s' property", childNode->name);            \
         }                                                                     \
                                                                               \
-        _require                                                              \
+        if (esxVI_##_type##_Validate(*ptrptr) < 0) {                          \
+            goto failure;                                                     \
+        }                                                                     \
                                                                               \
         return 0;                                                             \
                                                                               \
@@ -303,25 +328,22 @@
 
 
 
-#define ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(_type, _name, _required)        \
-    if (esxVI_##_type##_Serialize(item->_name, #_name, output,                \
-                                  esxVI_Boolean_##_required) < 0) {           \
+#define ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(_type, _name)                   \
+    if (esxVI_##_type##_Serialize(item->_name, #_name, output) < 0) {         \
         return -1;                                                            \
     }
 
 
 
-#define ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(_type, _name, _required)  \
-    if (esxVI_##_type##_SerializeValue(item->_name, #_name, output,           \
-                                       esxVI_Boolean_##_required) < 0) {      \
+#define ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(_type, _name)             \
+    if (esxVI_##_type##_SerializeValue(item->_name, #_name, output) < 0) {    \
         return -1;                                                            \
     }
 
 
 
-#define ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(_type, _name, _required)   \
-    if (esxVI_##_type##_SerializeList(item->_name, #_name, output,            \
-                                      esxVI_Boolean_##_required) < 0) {       \
+#define ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(_type, _name)              \
+    if (esxVI_##_type##_SerializeList(item->_name, #_name, output) < 0) {     \
         return -1;                                                            \
     }
 
@@ -392,12 +414,15 @@
 /*
  * A required property must be != 0 (NULL for pointers, "undefined" == 0 for
  * enumeration values).
+ *
+ * To be used as part of ESX_VI__TEMPLATE__VALIDATE.
  */
-#define ESX_VI__TEMPLATE__PROPERTY__REQUIRED(_name)                           \
-    if ((*ptrptr)->_name == 0) {                                              \
+#define ESX_VI__TEMPLATE__PROPERTY__REQUIRE(_name)                            \
+    if (item->_name == 0) {                                                   \
         ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,                                  \
-                     "Missing required '%s' property", #_name);               \
-        goto failure;                                                         \
+                     "%s object is missing the required '%s' property",       \
+                     type_name, #_name);                                      \
+        return -1;                                                            \
     }
 
 
@@ -416,10 +441,10 @@
 #define ESX_VI__TEMPLATE__ENUMERATION__SERIALIZE(_type)                       \
     int                                                                       \
     esxVI_##_type##_Serialize(esxVI_##_type value, const char *element,       \
-                              virBufferPtr output, esxVI_Boolean required)    \
+                              virBufferPtr output)                            \
     {                                                                         \
         return esxVI_Enumeration_Serialize(&_esxVI_##_type##_Enumeration,     \
-                                           value, element, output, required); \
+                                           value, element, output);           \
     }
 
 
@@ -809,10 +834,10 @@ esxVI_String_DeepCopyValue(char **dest, const char *src)
 
 int
 esxVI_String_Serialize(esxVI_String *string, const char *element,
-                       virBufferPtr output, esxVI_Boolean required)
+                       virBufferPtr output)
 {
     return esxVI_String_SerializeValue(string != NULL ? string->value : NULL,
-                                       element, output, required);
+                                       element, output);
 }
 
 /* esxVI_String_SerializeList */
@@ -820,7 +845,7 @@ ESX_VI__TEMPLATE__LIST__SERIALIZE(String);
 
 int
 esxVI_String_SerializeValue(const char *value, const char *element,
-                            virBufferPtr output, esxVI_Boolean required)
+                            virBufferPtr output)
 {
     if (element == NULL || output == NULL) {
         ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
@@ -828,7 +853,7 @@ esxVI_String_SerializeValue(const char *value, const char *element,
     }
 
     if (value == NULL) {
-        return esxVI_CheckSerializationNecessity(element, required);
+        return 0;
     }
 
     ESV_VI__XML_TAG__OPEN(output, element, "xsd:string");
@@ -912,6 +937,9 @@ ESX_VI__TEMPLATE__FREE(Int,
     esxVI_Int_Free(&item->_next);
 });
 
+/* esxVI_Int_Validate */
+ESX_VI__TEMPLATE__VALIDATE_NOOP(Int);
+
 /* esxVI_Int_AppendToList */
 ESX_VI__TEMPLATE__LIST__APPEND(Int);
 
@@ -968,6 +996,9 @@ ESX_VI__TEMPLATE__FREE(Long,
     esxVI_Long_Free(&item->_next);
 });
 
+/* esxVI_Long_Validate */
+ESX_VI__TEMPLATE__VALIDATE_NOOP(Long);
+
 /* esxVI_Long_AppendToList */
 ESX_VI__TEMPLATE__LIST__APPEND(Long);
 
@@ -998,6 +1029,12 @@ ESX_VI__TEMPLATE__FREE(DateTime,
     VIR_FREE(item->value);
 });
 
+/* esxVI_DateTime_Validate */
+ESX_VI__TEMPLATE__VALIDATE(DateTime,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(value);
+});
+
 /* esxVI_DateTime_Serialize */
 ESX_VI__TEMPLATE__SERIALIZE_EXTRA(DateTime, "xsd:dateTime",
 {
@@ -1228,16 +1265,19 @@ ESX_VI__TEMPLATE__FREE(Fault,
     VIR_FREE(item->faultstring);
 });
 
+/* esxVI_Fault_Validate */
+ESX_VI__TEMPLATE__VALIDATE(Fault,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(faultcode);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(faultstring);
+});
+
 /* esxVI_Fault_Deserialize */
 ESX_VI__TEMPLATE__DESERIALIZE(Fault,
 {
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, faultcode);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, faultstring);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(detail); /* FIXME */
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(faultcode);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(faultstring);
 });
 
 
@@ -1384,7 +1424,7 @@ esxVI_ManagedObjectReference_CastListFromAnyType
 int
 esxVI_ManagedObjectReference_Serialize
   (esxVI_ManagedObjectReference *managedObjectReference,
-   const char *element, virBufferPtr output, esxVI_Boolean required)
+   const char *element, virBufferPtr output)
 {
     if (element == NULL || output == NULL) {
         ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
@@ -1392,7 +1432,7 @@ esxVI_ManagedObjectReference_Serialize
     }
 
     if (managedObjectReference == NULL) {
-        return esxVI_CheckSerializationNecessity(element, required);
+        return 0;
     }
 
     virBufferAddLit(output, "<");
@@ -1474,6 +1514,13 @@ ESX_VI__TEMPLATE__FREE(DynamicProperty,
     esxVI_AnyType_Free(&item->val);
 });
 
+/* esxVI_DynamicProperty_Validate */
+ESX_VI__TEMPLATE__VALIDATE(DynamicProperty,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(name);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(val);
+});
+
 int
 esxVI_DynamicProperty_DeepCopy(esxVI_DynamicProperty **dest,
                                esxVI_DynamicProperty *src)
@@ -1512,10 +1559,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(DynamicProperty,
 {
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, name);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(AnyType, val);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(name);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(val);
 });
 
 /* esxVI_DynamicProperty_DeserializeList */
@@ -1544,6 +1587,12 @@ ESX_VI__TEMPLATE__FREE(HostCpuIdInfo,
     VIR_FREE(item->edx);
 });
 
+/* esxVI_HostCpuIdInfo_Validate */
+ESX_VI__TEMPLATE__VALIDATE(HostCpuIdInfo,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(level);
+});
+
 /* esxVI_HostCpuIdInfo_CastFromAnyType */
 ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(HostCpuIdInfo);
 
@@ -1559,9 +1608,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(HostCpuIdInfo,
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, ebx);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, ecx);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, edx);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(level);
 });
 
 /* esxVI_HostCpuIdInfo_DeserializeList */
@@ -1608,13 +1654,23 @@ esxVI_SelectionSpec_Free(esxVI_SelectionSpec **selectionSpec)
     }
 }
 
+/* esxVI_SelectionSpec_Validate */
+ESX_VI__TEMPLATE__VALIDATE(SelectionSpec,
+{
+    if (item->_super != NULL) {
+        return esxVI_TraversalSpec_Validate(item->_super);
+    }
+
+    /* All properties are optional */
+    (void)type_name;
+});
+
 /* esxVI_SelectionSpec_AppendToList */
 ESX_VI__TEMPLATE__LIST__APPEND(SelectionSpec);
 
 int
 esxVI_SelectionSpec_Serialize(esxVI_SelectionSpec *selectionSpec,
-                              const char *element, virBufferPtr output,
-                              esxVI_Boolean required)
+                              const char *element, virBufferPtr output)
 {
     if (element == NULL || output == NULL) {
         ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
@@ -1622,18 +1678,21 @@ esxVI_SelectionSpec_Serialize(esxVI_SelectionSpec *selectionSpec,
     }
 
     if (selectionSpec == NULL) {
-        return esxVI_CheckSerializationNecessity(element, required);
+        return 0;
     }
 
     if (selectionSpec->_super != NULL) {
         return esxVI_TraversalSpec_Serialize(selectionSpec->_super, element,
-                                             output, required);
+                                             output);
+    }
+
+    if (esxVI_SelectionSpec_Validate(selectionSpec) < 0) {
+        return -1;
     }
 
     ESV_VI__XML_TAG__OPEN(output, element, "SelectionSpec");
 
-    if (esxVI_String_SerializeValue(selectionSpec->name, "name", output,
-                                    esxVI_Boolean_False) < 0) {
+    if (esxVI_String_SerializeValue(selectionSpec->name, "name", output) < 0) {
         return -1;
     }
 
@@ -1708,18 +1767,24 @@ esxVI_TraversalSpec_Free(esxVI_TraversalSpec **traversalSpec)
     VIR_FREE(local);
 }
 
+/* esxVI_TraversalSpec_Validate */
+ESX_VI__TEMPLATE__VALIDATE(TraversalSpec,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(type);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(path);
+});
+
 /* esxVI_TraversalSpec_Serialize */
 ESX_VI__TEMPLATE__SERIALIZE(TraversalSpec,
 {
-    if (esxVI_String_SerializeValue(item->_base->name, "name", output,
-                                    esxVI_Boolean_False) < 0) {
+    if (esxVI_String_SerializeValue(item->_base->name, "name", output) < 0) {
         return -1;
     }
 
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, type, True);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, path, True);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Boolean, skip, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(SelectionSpec, selectSet, False);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, type);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, path);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Boolean, skip);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(SelectionSpec, selectSet);
 });
 
 
@@ -1740,15 +1805,21 @@ ESX_VI__TEMPLATE__FREE(ObjectSpec,
     esxVI_SelectionSpec_Free(&item->selectSet);
 });
 
+/* esxVI_ObjectSpec_Validate */
+ESX_VI__TEMPLATE__VALIDATE(ObjectSpec,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(obj);
+});
+
 /* esxVI_ObjectSpec_AppendToList */
 ESX_VI__TEMPLATE__LIST__APPEND(ObjectSpec);
 
 /* esxVI_ObjectSpec_Serialize */
 ESX_VI__TEMPLATE__SERIALIZE(ObjectSpec,
 {
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(ManagedObjectReference, obj, True);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Boolean, skip, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(SelectionSpec, selectSet, False);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(ManagedObjectReference, obj);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Boolean, skip);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(SelectionSpec, selectSet);
 });
 
 /* esxVI_ObjectSpec_SerializeList */
@@ -1772,6 +1843,13 @@ ESX_VI__TEMPLATE__FREE(PropertyChange,
     esxVI_AnyType_Free(&item->val);
 });
 
+/* esxVI_PropertyChange_Validate */
+ESX_VI__TEMPLATE__VALIDATE(PropertyChange,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(name);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(op);
+});
+
 /* esxVI_PropertyChange_AppendToList */
 ESX_VI__TEMPLATE__LIST__APPEND(PropertyChange);
 
@@ -1781,10 +1859,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(PropertyChange,
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, name);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(PropertyChangeOp, op);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(AnyType, val);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(name);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(op);
 });
 
 /* esxVI_PropertyChange_DeserializeList */
@@ -1808,15 +1882,21 @@ ESX_VI__TEMPLATE__FREE(PropertySpec,
     esxVI_String_Free(&item->pathSet);
 });
 
+/* esxVI_PropertySpec_Validate */
+ESX_VI__TEMPLATE__VALIDATE(PropertySpec,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(type);
+});
+
 /* esxVI_PropertySpec_AppendToList */
 ESX_VI__TEMPLATE__LIST__APPEND(PropertySpec);
 
 /* esxVI_PropertySpec_Serialize */
 ESX_VI__TEMPLATE__SERIALIZE(PropertySpec,
 {
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, type, True);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Boolean, all, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(String, pathSet, False);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, type);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Boolean, all);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(String, pathSet);
 });
 
 /* esxVI_PropertySpec_SerializeList */
@@ -1840,14 +1920,21 @@ ESX_VI__TEMPLATE__FREE(PropertyFilterSpec,
     esxVI_ObjectSpec_Free(&item->objectSet);
 });
 
+/* esxVI_PropertyFilterSpec_Validate */
+ESX_VI__TEMPLATE__VALIDATE(PropertyFilterSpec,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(propSet);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(objectSet);
+});
+
 /* esxVI_PropertyFilterSpec_AppendToList */
 ESX_VI__TEMPLATE__LIST__APPEND(PropertyFilterSpec);
 
 /* esxVI_PropertyFilterSpec_Serialize */
 ESX_VI__TEMPLATE__SERIALIZE(PropertyFilterSpec,
 {
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(PropertySpec, propSet, True);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(ObjectSpec, objectSet, True);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(PropertySpec, propSet);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(ObjectSpec, objectSet);
 });
 
 /* esxVI_PropertyFilterSpec_SerializeList */
@@ -1872,6 +1959,12 @@ ESX_VI__TEMPLATE__FREE(ObjectContent,
     /*esxVI_MissingProperty_Free(&item->missingSet);*//* FIXME */
 });
 
+/* esxVI_ObjectContent_Validate */
+ESX_VI__TEMPLATE__VALIDATE(ObjectContent,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(obj);
+});
+
 /* esxVI_ObjectContent_AppendToList */
 ESX_VI__TEMPLATE__LIST__APPEND(ObjectContent);
 
@@ -1917,9 +2010,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(ObjectContent,
                                                      NULL, obj);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(DynamicProperty, propSet);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(missingSet); /* FIXME */
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(obj);
 });
 
 /* esxVI_ObjectContent_DeserializeList */
@@ -1944,6 +2034,13 @@ ESX_VI__TEMPLATE__FREE(ObjectUpdate,
     /*esxVI_MissingProperty_Free(&item->missingSet);*//* FIXME */
 });
 
+/* esxVI_ObjectUpdate_Validate */
+ESX_VI__TEMPLATE__VALIDATE(ObjectUpdate,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(kind);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(obj);
+});
+
 /* esxVI_ObjectUpdate_AppendToList */
 ESX_VI__TEMPLATE__LIST__APPEND(ObjectUpdate);
 
@@ -1955,10 +2052,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(ObjectUpdate,
                                                      NULL, obj);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(PropertyChange, changeSet);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(missingSet); /* FIXME */
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(kind);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(obj);
 });
 
 /* esxVI_ObjectUpdate_DeserializeList */
@@ -1983,6 +2076,12 @@ ESX_VI__TEMPLATE__FREE(PropertyFilterUpdate,
     /*esxVI_MissingProperty_Free(&item->missingSet);*//* FIXME */
 });
 
+/* esxVI_PropertyFilterUpdate_Validate */
+ESX_VI__TEMPLATE__VALIDATE(PropertyFilterUpdate,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(filter);
+});
+
 /* esxVI_PropertyFilterUpdate_AppendToList */
 ESX_VI__TEMPLATE__LIST__APPEND(PropertyFilterUpdate);
 
@@ -1993,9 +2092,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(PropertyFilterUpdate,
                                                      NULL, filter);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(ObjectUpdate, objectSet);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(missingSet); /* FIXME */
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(filter);
 });
 
 /* esxVI_PropertyFilterUpdate_DeserializeList */
@@ -2026,6 +2122,22 @@ ESX_VI__TEMPLATE__FREE(AboutInfo,
     VIR_FREE(item->apiVersion);
 });
 
+/* esxVI_AboutInfo_Validate */
+ESX_VI__TEMPLATE__VALIDATE(AboutInfo,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(name);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(fullName);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(vendor);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(version);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(build);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(localeVersion);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(localeBuild);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(osType);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(productLineId);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(apiType);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(apiVersion);
+});
+
 /* esxVI_AboutInfo_Deserialize */
 ESX_VI__TEMPLATE__DESERIALIZE(AboutInfo,
 {
@@ -2040,19 +2152,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(AboutInfo,
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, productLineId);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, apiType);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, apiVersion);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(name);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(fullName);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(vendor);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(version);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(build);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(localeVersion);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(localeBuild);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(osType);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(productLineId);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(apiType);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(apiVersion);
 });
 
 
@@ -2092,6 +2191,14 @@ ESX_VI__TEMPLATE__FREE(ServiceContent,
     esxVI_ManagedObjectReference_Free(&item->virtualizationManager);
 });
 
+/* esxVI_ServiceContent_Validate */
+ESX_VI__TEMPLATE__VALIDATE(ServiceContent,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(rootFolder);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(propertyCollector);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(about);
+});
+
 /* esxVI_ServiceContent_Deserialize */
 ESX_VI__TEMPLATE__DESERIALIZE(ServiceContent,
 {
@@ -2160,11 +2267,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(ServiceContent,
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_EXPECTED(ManagedObjectReference,
                                                      "VirtualizationManager",
                                                      virtualizationManager);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(rootFolder);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(propertyCollector);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(about);
 });
 
 
@@ -2183,15 +2285,18 @@ ESX_VI__TEMPLATE__FREE(UpdateSet,
     esxVI_PropertyFilterUpdate_Free(&item->filterSet);
 });
 
+/* esxVI_UpdateSet_Validate */
+ESX_VI__TEMPLATE__VALIDATE(UpdateSet,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(version);
+});
+
 /* esxVI_UpdateSet_Deserialize */
 ESX_VI__TEMPLATE__DESERIALIZE(UpdateSet,
 {
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, version);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(PropertyFilterUpdate,
                                                  filterSet);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(version);
 });
 
 
@@ -2209,6 +2314,13 @@ ESX_VI__TEMPLATE__FREE(SharesInfo,
     esxVI_Int_Free(&item->shares);
 });
 
+/* esxVI_SharesInfo_Validate */
+ESX_VI__TEMPLATE__VALIDATE(SharesInfo,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(shares);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(level);
+});
+
 /* esxVI_SharesInfo_CastFromAnyType */
 ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(SharesInfo);
 
@@ -2217,17 +2329,13 @@ ESX_VI__TEMPLATE__DESERIALIZE(SharesInfo,
 {
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, shares);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(SharesLevel, level);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(shares);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(level);
 });
 
 /* esxVI_SharesInfo_Serialize */
 ESX_VI__TEMPLATE__SERIALIZE(SharesInfo,
 {
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, shares, True);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(SharesLevel, level, True);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, shares);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(SharesLevel, level);
 });
 
 
@@ -2248,15 +2356,17 @@ ESX_VI__TEMPLATE__FREE(ResourceAllocationInfo,
     esxVI_Long_Free(&item->overheadLimit);
 });
 
+/* esxVI_ResourceAllocationInfo_Validate */
+ESX_VI__TEMPLATE__VALIDATE_NOOP(ResourceAllocationInfo);
+
 /* esxVI_ResourceAllocationInfo_Serialize */
 ESX_VI__TEMPLATE__SERIALIZE(ResourceAllocationInfo,
 {
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Long, reservation, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Boolean, expandableReservation,
-                                          False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Long, limit, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(SharesInfo, shares, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Long, overheadLimit, False);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Long, reservation);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Boolean, expandableReservation);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Long, limit);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(SharesInfo, shares);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Long, overheadLimit);
 });
 
 
@@ -2279,6 +2389,17 @@ ESX_VI__TEMPLATE__FREE(ResourcePoolResourceUsage,
     esxVI_Long_Free(&item->maxUsage);
 });
 
+/* esxVI_ResourcePoolResourceUsage_Validate */
+ESX_VI__TEMPLATE__VALIDATE(ResourcePoolResourceUsage,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(reservationUsed);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(reservationUsedForVm);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(unreservedForPool);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(unreservedForVm);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(overallUsage);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(maxUsage);
+});
+
 /* esxVI_ResourcePoolResourceUsage_CastFromAnyType */
 ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(ResourcePoolResourceUsage);
 
@@ -2291,14 +2412,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(ResourcePoolResourceUsage,
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Long, unreservedForVm);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Long, overallUsage);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Long, maxUsage);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(reservationUsed);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(reservationUsedForVm);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(unreservedForPool);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(unreservedForVm);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(overallUsage);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(maxUsage);
 });
 
 
@@ -2336,36 +2449,34 @@ ESX_VI__TEMPLATE__FREE(VirtualMachineConfigSpec,
     /* FIXME: implement missing */
 });
 
+/* esxVI_VirtualMachineConfigSpec_Validate */
+ESX_VI__TEMPLATE__VALIDATE_NOOP(VirtualMachineConfigSpec);
+
 /* esxVI_VirtualMachineConfigSpec_Serialize */
 ESX_VI__TEMPLATE__SERIALIZE(VirtualMachineConfigSpec,
 {
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, changeVersion, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, name, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, version, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, uuid, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(Long, npivNodeWorldWideName,
-                                               False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(Long, npivPortWorldWideName,
-                                               False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, npivWorldWideNameType,
-                                                False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, npivWorldWideNameOp,
-                                                False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, locationId, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, guestId, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, alternateGuestName,
-                                                False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, annotation, False);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, changeVersion);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, name);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, version);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, uuid);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(Long, npivNodeWorldWideName);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(Long, npivPortWorldWideName);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, npivWorldWideNameType);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, npivWorldWideNameOp);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, locationId);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, guestId);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, alternateGuestName);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, annotation);
     /* FIXME: implement missing */
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, numCPUs, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Long, memoryMB, False);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, numCPUs);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Long, memoryMB);
     /* FIXME: implement missing */
     ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(ResourceAllocationInfo,
-                                          cpuAllocation, False);
+                                          cpuAllocation);
     ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(ResourceAllocationInfo,
-                                          memoryAllocation, False);
+                                          memoryAllocation);
     /* FIXME: implement missing */
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, swapPlacement, False);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, swapPlacement);
     /* FIXME: implement missing */
 });
 
@@ -2391,6 +2502,15 @@ ESX_VI__TEMPLATE__FREE(Event,
     VIR_FREE(item->fullFormattedMessage);
 });
 
+/* esxVI_Event_Validate */
+ESX_VI__TEMPLATE__VALIDATE(Event,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(key);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(chainId);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(createdTime);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(userName);
+});
+
 /* esxVI_Event_Deserialize */
 ESX_VI__TEMPLATE__DESERIALIZE(Event,
 {
@@ -2403,12 +2523,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(Event,
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(host); /* FIXME */
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(vm); /* FIXME */
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, fullFormattedMessage);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(key);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(chainId);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(createdTime);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(userName);
 });
 
 /* esxVI_Event_DeserializeList */
@@ -2435,6 +2549,18 @@ ESX_VI__TEMPLATE__FREE(UserSession,
     VIR_FREE(item->messageLocale);
 });
 
+/* esxVI_UserSession_Validate */
+ESX_VI__TEMPLATE__VALIDATE(UserSession,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(key);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(userName);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(fullName);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(loginTime);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(lastActiveTime);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(locale);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(messageLocale);
+});
+
 /* esxVI_UserSession_CastFromAnyType */
 ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(UserSession);
 
@@ -2448,15 +2574,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(UserSession,
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(DateTime, lastActiveTime);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, locale);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, messageLocale);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(key);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(userName);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(fullName);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(loginTime);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(lastActiveTime);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(locale);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(messageLocale);
 });
 
 
@@ -2477,6 +2594,14 @@ ESX_VI__TEMPLATE__FREE(VirtualMachineQuestionInfo,
     /*esxVI_VirtualMachineMessage_Free(&item->message);*//* FIXME */
 });
 
+/* esxVI_VirtualMachineQuestionInfo_Validate */
+ESX_VI__TEMPLATE__VALIDATE(VirtualMachineQuestionInfo,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(id);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(text);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(choice);
+});
+
 /* esxVI_VirtualMachineQuestionInfo_CastFromAnyType */
 ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(VirtualMachineQuestionInfo);
 
@@ -2487,11 +2612,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(VirtualMachineQuestionInfo,
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, text);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(ChoiceOption, choice);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_NOOP(message); /* FIXME */
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(id);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(text);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(choice);
 });
 
 
@@ -2517,6 +2637,14 @@ ESX_VI__TEMPLATE__FREE(ElementDescription,
     VIR_FREE(item->key);
 });
 
+/* esxVI_ElementDescription_Validate */
+ESX_VI__TEMPLATE__VALIDATE(ElementDescription,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(label);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(summary);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(key);
+});
+
 /* esxVI_ElementDescription_AppendToList */
 ESX_VI__TEMPLATE__LIST__APPEND(ElementDescription);
 
@@ -2526,11 +2654,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(ElementDescription,
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, label);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, summary);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, key);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(label);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(summary);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(key);
 });
 
 
@@ -2553,15 +2676,18 @@ ESX_VI__TEMPLATE__FREE(ChoiceOption,
     esxVI_Int_Free(&item->defaultIndex);
 });
 
+/* esxVI_ChoiceOption_Validate */
+ESX_VI__TEMPLATE__VALIDATE(ChoiceOption,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(choiceInfo);
+});
+
 /* esxVI_ChoiceOption_Deserialize */
 ESX_VI__TEMPLATE__DESERIALIZE(ChoiceOption,
 {
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Boolean, valueIsReadonly);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(ElementDescription, choiceInfo);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, defaultIndex);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(choiceInfo);
 });
 
 
@@ -2582,11 +2708,18 @@ ESX_VI__TEMPLATE__FREE(PerfMetricId,
     VIR_FREE(item->instance);
 });
 
+/* esxVI_PerfMetricId_Validate */
+ESX_VI__TEMPLATE__VALIDATE(PerfMetricId,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(counterId);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(instance);
+});
+
 /* esxVI_PerfMetricId_Serialize */
 ESX_VI__TEMPLATE__SERIALIZE(PerfMetricId,
 {
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, counterId, True);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, instance, True);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, counterId);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, instance);
 });
 
 /* esxVI_PerfMetricId_SerializeList */
@@ -2597,10 +2730,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(PerfMetricId,
 {
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, counterId);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, instance);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(counterId);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(instance);
 });
 
 /* esxVI_PerfMetricId_DeserializeList */
@@ -2628,6 +2757,17 @@ ESX_VI__TEMPLATE__FREE(PerfCounterInfo,
     esxVI_Int_Free(&item->associatedCounterId);
 });
 
+/* esxVI_PerfCounterInfo_Validate */
+ESX_VI__TEMPLATE__VALIDATE(PerfCounterInfo,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(key);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(nameInfo);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(groupInfo);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(unitInfo);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(rollupType);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(statsType);
+});
+
 /* esxVI_PerfCounterInfo_Deserialize */
 ESX_VI__TEMPLATE__DESERIALIZE(PerfCounterInfo,
 {
@@ -2639,14 +2779,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(PerfCounterInfo,
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(PerfStatsType, statsType);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, level);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(Int, associatedCounterId);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(key);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(nameInfo);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(groupInfo);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(unitInfo);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(rollupType);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(statsType);
 });
 
 /* esxVI_PerfCounterInfo_DeserializeList */
@@ -2675,16 +2807,22 @@ ESX_VI__TEMPLATE__FREE(PerfQuerySpec,
     VIR_FREE(item->format);
 });
 
+/* esxVI_PerfQuerySpec_Validate */
+ESX_VI__TEMPLATE__VALIDATE(PerfQuerySpec,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(entity);
+});
+
 /* esxVI_PerfQuerySpec_Serialize */
 ESX_VI__TEMPLATE__SERIALIZE(PerfQuerySpec,
 {
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(ManagedObjectReference, entity, True);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(DateTime, startTime, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(DateTime, endTime, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, maxSample, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(PerfMetricId, metricId, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, intervalId, False);
-    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, format, False);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(ManagedObjectReference, entity);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(DateTime, startTime);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(DateTime, endTime);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, maxSample);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_LIST(PerfMetricId, metricId);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE(Int, intervalId);
+    ESX_VI__TEMPLATE__PROPERTY__SERIALIZE_VALUE(String, format);
 });
 
 /* esxVI_PerfQuerySpec_SerializeList */
@@ -2708,6 +2846,13 @@ ESX_VI__TEMPLATE__FREE(PerfSampleInfo,
     esxVI_Int_Free(&item->interval);
 });
 
+/* esxVI_PerfSampleInfo_Validate */
+ESX_VI__TEMPLATE__VALIDATE(PerfSampleInfo,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(timestamp);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(interval);
+});
+
 /* esxVI_PerfSampleInfo_AppendToList */
 ESX_VI__TEMPLATE__LIST__APPEND(PerfSampleInfo);
 
@@ -2716,10 +2861,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(PerfSampleInfo,
 {
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(DateTime, timestamp);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, interval);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(timestamp);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(interval);
 });
 
 /* esxVI_PerfSampleInfo_DeserializeList */
@@ -2748,6 +2889,12 @@ ESX_VI__TEMPLATE__FREE(PerfMetricIntSeries,
     esxVI_Long_Free(&item->value);
 });
 
+/* esxVI_PerfMetricIntSeries_Validate */
+ESX_VI__TEMPLATE__VALIDATE(PerfMetricIntSeries,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(id);
+});
+
 /* esxVI_PerfMetricIntSeries_AppendToList */
 ESX_VI__TEMPLATE__LIST__APPEND(PerfMetricIntSeries);
 
@@ -2756,9 +2903,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(PerfMetricIntSeries,
 {
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(PerfMetricId, id);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(Long, value);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(id);
 });
 
 
@@ -2789,6 +2933,12 @@ ESX_VI__TEMPLATE__FREE(PerfEntityMetric,
     esxVI_PerfMetricIntSeries_Free(&item->value);
 });
 
+/* esxVI_PerfEntityMetric_Validate */
+ESX_VI__TEMPLATE__VALIDATE(PerfEntityMetric,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(entity);
+});
+
 /* esxVI_PerfEntityMetric_Deserialize */
 ESX_VI__TEMPLATE__DESERIALIZE(PerfEntityMetric,
 {
@@ -2796,9 +2946,6 @@ ESX_VI__TEMPLATE__DESERIALIZE(PerfEntityMetric,
                                                      NULL, entity);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(PerfSampleInfo, sampleInfo);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(PerfMetricIntSeries, value);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(entity);
 });
 
 /* esxVI_PerfEntityMetric_DeserializeList */
@@ -2835,6 +2982,20 @@ ESX_VI__TEMPLATE__FREE(TaskInfo,
     esxVI_Int_Free(&item->eventChainId);
 });
 
+/* esxVI_TaskInfo_Validate */
+ESX_VI__TEMPLATE__VALIDATE(TaskInfo,
+{
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(key);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(task);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(descriptionId);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(state);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(cancelled);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(cancelable);
+    /*ESX_VI__TEMPLATE__PROPERTY__REQUIRE(reason);*//* FIXME */
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(queueTime);
+    ESX_VI__TEMPLATE__PROPERTY__REQUIRE(eventChainId);
+});
+
 /* esxVI_TaskInfo_CastFromAnyType */
 ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(TaskInfo);
 
@@ -2864,15 +3025,4 @@ ESX_VI__TEMPLATE__DESERIALIZE(TaskInfo,
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(DateTime, startTime);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(DateTime, completeTime);
     ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, eventChainId);
-},
-{
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(key);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(task);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(descriptionId);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(state);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(cancelled);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(cancelable);
-    /*ESX_VI__TEMPLATE__PROPERTY__REQUIRED(reason);*//* FIXME */
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(queueTime);
-    ESX_VI__TEMPLATE__PROPERTY__REQUIRED(eventChainId);
 });
diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h
index 9a43241..e5451e9 100644
--- a/src/esx/esx_vi_types.h
+++ b/src/esx/esx_vi_types.h
@@ -2,7 +2,7 @@
 /*
  * esx_vi_types.h: client for the VMware VI API 2.5 to manage ESX hosts
  *
- * Copyright (C) 2009 Matthias Bolte <matthias.bolte at googlemail.com>
+ * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte at googlemail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -132,7 +132,7 @@ enum _esxVI_Boolean {
 };
 
 int esxVI_Boolean_Serialize(esxVI_Boolean boolean_, const char *element,
-                            virBufferPtr output, esxVI_Boolean required);
+                            virBufferPtr output);
 int esxVI_Boolean_Deserialize(xmlNodePtr node, esxVI_Boolean *boolean_);
 
 
@@ -185,11 +185,11 @@ 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_Serialize(esxVI_String *string, const char *element,
-                           virBufferPtr output, esxVI_Boolean required);
+                           virBufferPtr output);
 int esxVI_String_SerializeList(esxVI_String *stringList, const char *element,
-                               virBufferPtr output, esxVI_Boolean required);
+                               virBufferPtr output);
 int esxVI_String_SerializeValue(const char *value, const char *element,
-                                virBufferPtr output, esxVI_Boolean required);
+                                virBufferPtr output);
 int esxVI_String_Deserialize(xmlNodePtr node, esxVI_String **string);
 int esxVI_String_DeserializeList(xmlNodePtr node, esxVI_String **stringList);
 int esxVI_String_DeserializeValue(xmlNodePtr node, char **value);
@@ -208,12 +208,13 @@ struct _esxVI_Int {
 
 int esxVI_Int_Alloc(esxVI_Int **number);
 void esxVI_Int_Free(esxVI_Int **numberList);
+int esxVI_Int_Validate(esxVI_Int *number);
 int esxVI_Int_AppendToList(esxVI_Int **numberList, esxVI_Int *number);
 int esxVI_Int_DeepCopy(esxVI_Int **dest, esxVI_Int *src);
 int esxVI_Int_Serialize(esxVI_Int *number, const char *element,
-                        virBufferPtr output, esxVI_Boolean required);
+                        virBufferPtr output);
 int esxVI_Int_SerializeList(esxVI_Int *numberList, const char *element,
-                            virBufferPtr output, esxVI_Boolean required);
+                            virBufferPtr output);
 int esxVI_Int_Deserialize(xmlNodePtr node, esxVI_Int **number);
 
 
@@ -230,11 +231,12 @@ struct _esxVI_Long {
 
 int esxVI_Long_Alloc(esxVI_Long **number);
 void esxVI_Long_Free(esxVI_Long **numberList);
+int esxVI_Long_Validate(esxVI_Long *number);
 int esxVI_Long_AppendToList(esxVI_Long **numberList, esxVI_Long *number);
 int esxVI_Long_Serialize(esxVI_Long *number, const char *element,
-                         virBufferPtr output, esxVI_Boolean required);
+                         virBufferPtr output);
 int esxVI_Long_SerializeList(esxVI_Long *numberList, const char *element,
-                             virBufferPtr output,esxVI_Boolean required);
+                             virBufferPtr output);
 int esxVI_Long_Deserialize(xmlNodePtr node, esxVI_Long **number);
 
 
@@ -249,8 +251,9 @@ struct _esxVI_DateTime {
 
 int esxVI_DateTime_Alloc(esxVI_DateTime **dateTime);
 void esxVI_DateTime_Free(esxVI_DateTime **dateTime);
+int esxVI_DateTime_Validate(esxVI_DateTime *dateTime);
 int esxVI_DateTime_Serialize(esxVI_DateTime *dateTime, const char *element,
-                             virBufferPtr output, esxVI_Boolean required);
+                             virBufferPtr output);
 int esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime);
 
 
@@ -353,8 +356,7 @@ enum _esxVI_SharesLevel {
 };
 
 int esxVI_SharesLevel_Serialize(esxVI_SharesLevel sharesLevel,
-                                const char *element, virBufferPtr output,
-                                esxVI_Boolean required);
+                                const char *element, virBufferPtr output);
 int esxVI_SharesLevel_Deserialize(xmlNodePtr node,
                                   esxVI_SharesLevel *sharesLevel);
 
@@ -392,7 +394,7 @@ enum _esxVI_VirtualMachineMovePriority {
 
 int esxVI_VirtualMachineMovePriority_Serialize
       (esxVI_VirtualMachineMovePriority virtualMachineMovePriority,
-       const char *element, virBufferPtr output, esxVI_Boolean required);
+       const char *element, virBufferPtr output);
 
 
 
@@ -412,7 +414,7 @@ int esxVI_VirtualMachinePowerState_CastFromAnyType
        esxVI_VirtualMachinePowerState *virtualMachinePowerState);
 int esxVI_VirtualMachinePowerState_Serialize
       (esxVI_VirtualMachinePowerState virtualMachinePowerState,
-       const char *element, virBufferPtr output, esxVI_Boolean required);
+       const char *element, virBufferPtr output);
 
 
 
@@ -427,6 +429,7 @@ struct _esxVI_Fault {
 
 int esxVI_Fault_Alloc(esxVI_Fault **fault);
 void esxVI_Fault_Free(esxVI_Fault **fault);
+int esxVI_Fault_Validate(esxVI_Fault *fault);
 int esxVI_Fault_Deserialize(xmlNodePtr node, esxVI_Fault **fault);
 
 
@@ -461,10 +464,10 @@ int esxVI_ManagedObjectReference_CastListFromAnyType
        const char *expectedType);
 int esxVI_ManagedObjectReference_Serialize
       (esxVI_ManagedObjectReference *managedObjectReference,
-       const char *element, virBufferPtr output, esxVI_Boolean required);
+       const char *element, virBufferPtr output);
 int esxVI_ManagedObjectReference_SerializeList
       (esxVI_ManagedObjectReference *managedObjectReference,
-       const char *element, virBufferPtr output, esxVI_Boolean required);
+       const char *element, virBufferPtr output);
 int esxVI_ManagedObjectReference_Deserialize
       (xmlNodePtr node, esxVI_ManagedObjectReference **managedObjectReference,
        const char *expectedType);
@@ -485,6 +488,7 @@ struct _esxVI_DynamicProperty {
 int esxVI_DynamicProperty_Alloc(esxVI_DynamicProperty **dynamicProperty);
 void esxVI_DynamicProperty_Free
        (esxVI_DynamicProperty **dynamicPropertyList);
+int esxVI_DynamicProperty_Validate(esxVI_DynamicProperty *dynamicProperty);
 int esxVI_DynamicProperty_DeepCopy(esxVI_DynamicProperty **dest,
                                    esxVI_DynamicProperty *src);
 int esxVI_DynamicProperty_DeepCopyList(esxVI_DynamicProperty **destList,
@@ -516,6 +520,7 @@ struct _esxVI_HostCpuIdInfo {
 
 int esxVI_HostCpuIdInfo_Alloc(esxVI_HostCpuIdInfo **hostCpuIdInfo);
 void esxVI_HostCpuIdInfo_Free(esxVI_HostCpuIdInfo **hostCpuIdInfoList);
+int esxVI_HostCpuIdInfo_Validate(esxVI_HostCpuIdInfo *hostCpuIdInfo);
 int esxVI_HostCpuIdInfo_CastFromAnyType(esxVI_AnyType *anyType,
                                         esxVI_HostCpuIdInfo **hostCpuIdInfo);
 int esxVI_HostCpuIdInfo_CastListFromAnyType
@@ -540,14 +545,13 @@ struct _esxVI_SelectionSpec {
 
 int esxVI_SelectionSpec_Alloc(esxVI_SelectionSpec **selectionSpec);
 void esxVI_SelectionSpec_Free(esxVI_SelectionSpec **selectionSpecList);
+int esxVI_SelectionSpec_Validate(esxVI_SelectionSpec *selectionSpec);
 int esxVI_SelectionSpec_AppendToList(esxVI_SelectionSpec **selectionSpecList,
                                      esxVI_SelectionSpec *selectionSpec);
 int esxVI_SelectionSpec_Serialize(esxVI_SelectionSpec *selectionSpec,
-                                  const char *element, virBufferPtr output,
-                                  esxVI_Boolean required);
+                                  const char *element, virBufferPtr output);
 int esxVI_SelectionSpec_SerializeList(esxVI_SelectionSpec *selectionSpecList,
-                                      const char *element, virBufferPtr output,
-                                      esxVI_Boolean required);
+                                      const char *element, virBufferPtr output);
 
 
 
@@ -566,9 +570,9 @@ struct _esxVI_TraversalSpec {
 
 int esxVI_TraversalSpec_Alloc(esxVI_TraversalSpec **traversalSpec);
 void esxVI_TraversalSpec_Free(esxVI_TraversalSpec **traversalSpec);
+int esxVI_TraversalSpec_Validate(esxVI_TraversalSpec *traversalSpec);
 int esxVI_TraversalSpec_Serialize(esxVI_TraversalSpec *traversalSpec,
-                                  const char *element, virBufferPtr output,
-                                  esxVI_Boolean required);
+                                  const char *element, virBufferPtr output);
 
 
 
@@ -586,14 +590,13 @@ struct _esxVI_ObjectSpec {
 
 int esxVI_ObjectSpec_Alloc(esxVI_ObjectSpec **objectSpec);
 void esxVI_ObjectSpec_Free(esxVI_ObjectSpec **objectSpecList);
+int esxVI_ObjectSpec_Validate(esxVI_ObjectSpec *objectSpec);
 int esxVI_ObjectSpec_AppendToList(esxVI_ObjectSpec **objectSpecList,
                                   esxVI_ObjectSpec *objectSpec);
 int esxVI_ObjectSpec_Serialize(esxVI_ObjectSpec *objectSpec,
-                               const char *element, virBufferPtr output,
-                               esxVI_Boolean required);
+                               const char *element, virBufferPtr output);
 int esxVI_ObjectSpec_SerializeList(esxVI_ObjectSpec *objectSpecList,
-                                   const char *element, virBufferPtr output,
-                                   esxVI_Boolean required);
+                                   const char *element, virBufferPtr output);
 
 
 
@@ -611,6 +614,7 @@ struct _esxVI_PropertyChange {
 
 int esxVI_PropertyChange_Alloc(esxVI_PropertyChange **propertyChange);
 void esxVI_PropertyChange_Free(esxVI_PropertyChange **propertyChangeList);
+int esxVI_PropertyChange_Validate(esxVI_PropertyChange *propertyChange);
 int esxVI_PropertyChange_AppendToList
       (esxVI_PropertyChange **propertyChangeList,
        esxVI_PropertyChange *propertyChange);
@@ -635,14 +639,13 @@ struct _esxVI_PropertySpec {
 
 int esxVI_PropertySpec_Alloc(esxVI_PropertySpec **propertySpec);
 void esxVI_PropertySpec_Free(esxVI_PropertySpec **propertySpecList);
+int esxVI_PropertySpec_Validate(esxVI_PropertySpec *propertySpec);
 int esxVI_PropertySpec_AppendToList(esxVI_PropertySpec **propertySpecList,
                                     esxVI_PropertySpec *propertySpec);
 int esxVI_PropertySpec_Serialize(esxVI_PropertySpec *propertySpec,
-                                 const char *element, virBufferPtr output,
-                                 esxVI_Boolean required);
+                                 const char *element, virBufferPtr output);
 int esxVI_PropertySpec_SerializeList(esxVI_PropertySpec *propertySpecList,
-                                     const char *element, virBufferPtr output,
-                                     esxVI_Boolean required);
+                                     const char *element, virBufferPtr output);
 
 
 
@@ -661,15 +664,17 @@ int esxVI_PropertyFilterSpec_Alloc
       (esxVI_PropertyFilterSpec **propertyFilterSpec);
 void esxVI_PropertyFilterSpec_Free
        (esxVI_PropertyFilterSpec **propertyFilterSpecList);
+int esxVI_PropertyFilterSpec_Validate
+      (esxVI_PropertyFilterSpec *propertyFilterSpec);
 int esxVI_PropertyFilterSpec_AppendToList
       (esxVI_PropertyFilterSpec **propertyFilterSpecList,
        esxVI_PropertyFilterSpec *propertyFilterSpec);
 int esxVI_PropertyFilterSpec_Serialize
       (esxVI_PropertyFilterSpec *propertyFilterSpec, const char *element,
-       virBufferPtr output, esxVI_Boolean required);
+       virBufferPtr output);
 int esxVI_PropertyFilterSpec_SerializeList
       (esxVI_PropertyFilterSpec *propertyFilterSpecList, const char *element,
-       virBufferPtr output, esxVI_Boolean required);
+       virBufferPtr output);
 
 
 
@@ -687,6 +692,7 @@ struct _esxVI_ObjectContent {
 
 int esxVI_ObjectContent_Alloc(esxVI_ObjectContent **objectContent);
 void esxVI_ObjectContent_Free(esxVI_ObjectContent **objectContentList);
+int esxVI_ObjectContent_Validate(esxVI_ObjectContent *objectContent);
 int esxVI_ObjectContent_AppendToList(esxVI_ObjectContent **objectContentList,
                                      esxVI_ObjectContent *objectContent);
 int esxVI_ObjectContent_DeepCopy(esxVI_ObjectContent **dest,
@@ -713,6 +719,7 @@ struct _esxVI_ObjectUpdate {
 
 int esxVI_ObjectUpdate_Alloc(esxVI_ObjectUpdate **objectUpdate);
 void esxVI_ObjectUpdate_Free(esxVI_ObjectUpdate **objectUpdateList);
+int esxVI_ObjectUpdate_Validate(esxVI_ObjectUpdate *objectUpdate);
 int esxVI_ObjectUpdate_AppendToList(esxVI_ObjectUpdate **objectUpdateList,
                                     esxVI_ObjectUpdate *objectUpdate);
 int esxVI_ObjectUpdate_Deserialize(xmlNodePtr node,
@@ -738,6 +745,8 @@ int esxVI_PropertyFilterUpdate_Alloc
       (esxVI_PropertyFilterUpdate **propertyFilterUpdate);
 void esxVI_PropertyFilterUpdate_Free
        (esxVI_PropertyFilterUpdate **propertyFilterUpdateList);
+int esxVI_PropertyFilterUpdate_Validate
+      (esxVI_PropertyFilterUpdate *propertyFilterUpdate);
 int esxVI_PropertyFilterUpdate_AppendToList
       (esxVI_PropertyFilterUpdate **propertyFilterUpdateList,
        esxVI_PropertyFilterUpdate *propertyFilterUpdate);
@@ -768,6 +777,7 @@ struct _esxVI_AboutInfo {
 
 int esxVI_AboutInfo_Alloc(esxVI_AboutInfo **aboutInfo);
 void esxVI_AboutInfo_Free(esxVI_AboutInfo **aboutInfo);
+int esxVI_AboutInfo_Validate(esxVI_AboutInfo *aboutInfo);
 int esxVI_AboutInfo_Deserialize(xmlNodePtr node, esxVI_AboutInfo **aboutInfo);
 
 
@@ -804,6 +814,7 @@ struct _esxVI_ServiceContent {
 
 int esxVI_ServiceContent_Alloc(esxVI_ServiceContent **serviceContent);
 void esxVI_ServiceContent_Free(esxVI_ServiceContent **serviceContent);
+int esxVI_ServiceContent_Validate(esxVI_ServiceContent *serviceContent);
 int esxVI_ServiceContent_Deserialize(xmlNodePtr node,
                                      esxVI_ServiceContent **serviceContent);
 
@@ -820,6 +831,7 @@ struct _esxVI_UpdateSet {
 
 int esxVI_UpdateSet_Alloc(esxVI_UpdateSet **updateSet);
 void esxVI_UpdateSet_Free(esxVI_UpdateSet **updateSet);
+int esxVI_UpdateSet_Validate(esxVI_UpdateSet *updateSet);
 int esxVI_UpdateSet_Deserialize(xmlNodePtr node, esxVI_UpdateSet **updateSet);
 
 
@@ -835,13 +847,13 @@ struct _esxVI_SharesInfo {
 
 int esxVI_SharesInfo_Alloc(esxVI_SharesInfo **sharesInfo);
 void esxVI_SharesInfo_Free(esxVI_SharesInfo **sharesInfo);
+int esxVI_SharesInfo_Validate(esxVI_SharesInfo *sharesInfo);
 int esxVI_SharesInfo_CastFromAnyType(esxVI_AnyType *anyType,
                                      esxVI_SharesInfo **sharesInfo);
 int esxVI_SharesInfo_Deserialize(xmlNodePtr node,
                                  esxVI_SharesInfo **sharesInfo);
 int esxVI_SharesInfo_Serialize(esxVI_SharesInfo *sharesInfo,
-                               const char *element, virBufferPtr output,
-                               esxVI_Boolean required);
+                               const char *element, virBufferPtr output);
 
 
 
@@ -861,9 +873,11 @@ int esxVI_ResourceAllocationInfo_Alloc
       (esxVI_ResourceAllocationInfo **resourceAllocationInfo);
 void esxVI_ResourceAllocationInfo_Free
        (esxVI_ResourceAllocationInfo **resourceAllocationInfo);
+int esxVI_ResourceAllocationInfo_Validate
+      (esxVI_ResourceAllocationInfo *resourceAllocationInfo);
 int esxVI_ResourceAllocationInfo_Serialize
       (esxVI_ResourceAllocationInfo *resourceAllocationInfo,
-       const char *element, virBufferPtr output, esxVI_Boolean required);
+       const char *element, virBufferPtr output);
 
 
 
@@ -884,6 +898,8 @@ int esxVI_ResourcePoolResourceUsage_Alloc
       (esxVI_ResourcePoolResourceUsage **resourcePoolResourceUsage);
 void esxVI_ResourcePoolResourceUsage_Free
        (esxVI_ResourcePoolResourceUsage **resourcePoolResourceUsage);
+int esxVI_ResourcePoolResourceUsage_Validate
+      (esxVI_ResourcePoolResourceUsage *resourcePoolResourceUsage);
 int esxVI_ResourcePoolResourceUsage_CastFromAnyType
       (esxVI_AnyType *anyType,
        esxVI_ResourcePoolResourceUsage **resourcePoolResourceUsage);
@@ -934,9 +950,11 @@ int esxVI_VirtualMachineConfigSpec_Alloc
       (esxVI_VirtualMachineConfigSpec **virtualMachineConfigSpec);
 void esxVI_VirtualMachineConfigSpec_Free
        (esxVI_VirtualMachineConfigSpec **virtualMachineConfigSpec);
+int esxVI_VirtualMachineConfigSpec_Validate
+      (esxVI_VirtualMachineConfigSpec *virtualMachineConfigSpec);
 int esxVI_VirtualMachineConfigSpec_Serialize
       (esxVI_VirtualMachineConfigSpec *virtualMachineConfigSpec,
-       const char *element, virBufferPtr output, esxVI_Boolean required);
+       const char *element, virBufferPtr output);
 
 
 
@@ -961,6 +979,7 @@ struct _esxVI_Event {
 
 int esxVI_Event_Alloc(esxVI_Event **event);
 void esxVI_Event_Free(esxVI_Event **eventList);
+int esxVI_Event_Validate(esxVI_Event *event);
 int esxVI_Event_Deserialize(xmlNodePtr node, esxVI_Event **event);
 int esxVI_Event_DeserializeList(xmlNodePtr node, esxVI_Event **eventList);
 
@@ -982,6 +1001,7 @@ struct _esxVI_UserSession {
 
 int esxVI_UserSession_Alloc(esxVI_UserSession **userSession);
 void esxVI_UserSession_Free(esxVI_UserSession **userSession);
+int esxVI_UserSession_Validate(esxVI_UserSession *userSession);
 int esxVI_UserSession_CastFromAnyType(esxVI_AnyType *anyType,
                                       esxVI_UserSession **userSession);
 int esxVI_UserSession_Deserialize(xmlNodePtr node,
@@ -1005,6 +1025,8 @@ int esxVI_VirtualMachineQuestionInfo_Alloc
       (esxVI_VirtualMachineQuestionInfo **virtualMachineQuestionInfo);
 void esxVI_VirtualMachineQuestionInfo_Free
        (esxVI_VirtualMachineQuestionInfo **virtualMachineQuestionInfo);
+int esxVI_VirtualMachineQuestionInfo_Validate
+      (esxVI_VirtualMachineQuestionInfo *virtualMachineQuestionInfo);
 int esxVI_VirtualMachineQuestionInfo_CastFromAnyType
       (esxVI_AnyType *anyType,
        esxVI_VirtualMachineQuestionInfo **virtualMachineQuestionInfo);
@@ -1037,6 +1059,8 @@ int esxVI_ElementDescription_Alloc
       (esxVI_ElementDescription **elementDescription);
 void esxVI_ElementDescription_Free
        (esxVI_ElementDescription **elementDescription);
+int esxVI_ElementDescription_Validate
+      (esxVI_ElementDescription *elementDescription);
 int esxVI_ElementDescription_AppendToList
       (esxVI_ElementDescription **elementDescriptionList,
        esxVI_ElementDescription *elementDescription);
@@ -1064,6 +1088,7 @@ struct _esxVI_ChoiceOption {
 
 int esxVI_ChoiceOption_Alloc(esxVI_ChoiceOption **choiceOption);
 void esxVI_ChoiceOption_Free(esxVI_ChoiceOption **choiceOption);
+int esxVI_ChoiceOption_Validate(esxVI_ChoiceOption *choiceOption);
 int esxVI_ChoiceOption_Deserialize(xmlNodePtr node,
                                    esxVI_ChoiceOption **choiceOption);
 
@@ -1082,12 +1107,11 @@ struct _esxVI_PerfMetricId {
 
 int esxVI_PerfMetricId_Alloc(esxVI_PerfMetricId **perfMetricId);
 void esxVI_PerfMetricId_Free(esxVI_PerfMetricId **perfMetricId);
+int esxVI_PerfMetricId_Validate(esxVI_PerfMetricId *perfMetricId);
 int esxVI_PerfMetricId_Serialize(esxVI_PerfMetricId *perfMetricId,
-                                 const char *element, virBufferPtr output,
-                                 esxVI_Boolean required);
+                                 const char *element, virBufferPtr output);
 int esxVI_PerfMetricId_SerializeList(esxVI_PerfMetricId *perfMetricIdList,
-                                     const char *element, virBufferPtr output,
-                                     esxVI_Boolean required);
+                                     const char *element, virBufferPtr output);
 int esxVI_PerfMetricId_Deserialize(xmlNodePtr node,
                                    esxVI_PerfMetricId **perfMetricId);
 int esxVI_PerfMetricId_DeserializeList(xmlNodePtr node,
@@ -1114,6 +1138,7 @@ struct _esxVI_PerfCounterInfo {
 
 int esxVI_PerfCounterInfo_Alloc(esxVI_PerfCounterInfo **perfCounterInfo);
 void esxVI_PerfCounterInfo_Free(esxVI_PerfCounterInfo **perfCounterInfo);
+int esxVI_PerfCounterInfo_Validate(esxVI_PerfCounterInfo *perfCounterInfo);
 int esxVI_PerfCounterInfo_Deserialize(xmlNodePtr node,
                                       esxVI_PerfCounterInfo **perfCounterInfo);
 int esxVI_PerfCounterInfo_DeserializeList
@@ -1139,12 +1164,11 @@ struct _esxVI_PerfQuerySpec {
 
 int esxVI_PerfQuerySpec_Alloc(esxVI_PerfQuerySpec **perfQuerySpec);
 void esxVI_PerfQuerySpec_Free(esxVI_PerfQuerySpec **perfQuerySpec);
+int esxVI_PerfQuerySpec_Validate(esxVI_PerfQuerySpec *perfQuerySpec);
 int esxVI_PerfQuerySpec_Serialize(esxVI_PerfQuerySpec *perfQuerySpec,
-                                  const char *element, virBufferPtr output,
-                                  esxVI_Boolean required);
+                                  const char *element, virBufferPtr output);
 int esxVI_PerfQuerySpec_SerializeList(esxVI_PerfQuerySpec *perfQuerySpecList,
-                                      const char *element, virBufferPtr output,
-                                      esxVI_Boolean required);
+                                      const char *element, virBufferPtr output);
 
 
 
@@ -1161,6 +1185,7 @@ struct _esxVI_PerfSampleInfo {
 
 int esxVI_PerfSampleInfo_Alloc(esxVI_PerfSampleInfo **perfSampleInfo);
 void esxVI_PerfSampleInfo_Free(esxVI_PerfSampleInfo **perfSampleInfo);
+int esxVI_PerfSampleInfo_Validate(esxVI_PerfSampleInfo *perfSampleInfo);
 int esxVI_PerfSampleInfo_AppendToList(esxVI_PerfSampleInfo **perfSampleInfoList,
                                       esxVI_PerfSampleInfo *perfSampleInfo);
 int esxVI_PerfSampleInfo_Deserialize(xmlNodePtr node,
@@ -1193,6 +1218,8 @@ int esxVI_PerfMetricIntSeries_Alloc
       (esxVI_PerfMetricIntSeries **perfMetricIntSeries);
 void esxVI_PerfMetricIntSeries_Free
        (esxVI_PerfMetricIntSeries **perfMetricIntSeries);
+int esxVI_PerfMetricIntSeries_Validate
+      (esxVI_PerfMetricIntSeries *perfMetricIntSeries);
 int esxVI_PerfMetricIntSeries_AppendToList
       (esxVI_PerfMetricIntSeries **perfMetricIntSeriesList,
        esxVI_PerfMetricIntSeries *perfMetricIntSeries);
@@ -1226,8 +1253,8 @@ struct _esxVI_PerfEntityMetric {
 };
 
 int esxVI_PerfEntityMetric_Alloc(esxVI_PerfEntityMetric **perfEntityMetric);
-void esxVI_PerfEntityMetric_Free
-       (esxVI_PerfEntityMetric **perfEntityMetric);
+void esxVI_PerfEntityMetric_Free(esxVI_PerfEntityMetric **perfEntityMetric);
+int esxVI_PerfEntityMetric_Validate(esxVI_PerfEntityMetric *perfEntityMetric);
 int esxVI_PerfEntityMetric_Deserialize
       (xmlNodePtr node, esxVI_PerfEntityMetric **perfEntityMetric);
 int esxVI_PerfEntityMetric_DeserializeList
@@ -1264,6 +1291,7 @@ struct _esxVI_TaskInfo {
 
 int esxVI_TaskInfo_Alloc(esxVI_TaskInfo **taskInfo);
 void esxVI_TaskInfo_Free(esxVI_TaskInfo **taskInfoList);
+int esxVI_TaskInfo_Validate(esxVI_TaskInfo *taskInfo);
 int esxVI_TaskInfo_CastFromAnyType(esxVI_AnyType *anyType,
                                    esxVI_TaskInfo **taskInfo);
 int esxVI_TaskInfo_AppendToList(esxVI_TaskInfo **taskInfoList,
-- 
1.6.3.3




More information about the libvir-list mailing list