[PATCH 4/7] hyperv: remove hypervWmiClassInfoList, hypervWmiClassInfoListPtr, and _hypervWmiClassInfoList

Matt Coleman mcoleman at datto.com
Mon Nov 9 08:43:10 UTC 2020


Signed-off-by: Matt Coleman <matt at datto.com>
---
 scripts/hyperv_wmi_generator.py | 21 ++++++-----------
 src/hyperv/hyperv_wmi.c         | 41 ++++++---------------------------
 src/hyperv/hyperv_wmi.h         | 13 ++++++-----
 src/hyperv/hyperv_wmi_classes.h |  8 -------
 4 files changed, 21 insertions(+), 62 deletions(-)

diff --git a/scripts/hyperv_wmi_generator.py b/scripts/hyperv_wmi_generator.py
index 03cac2992e..a6f5c6aeab 100755
--- a/scripts/hyperv_wmi_generator.py
+++ b/scripts/hyperv_wmi_generator.py
@@ -57,7 +57,7 @@ class WmiClass:
         header += "#define %s_WQL_SELECT \\\n" % name_upper
         header += "    \"SELECT * FROM %s \"\n" % self.name
         header += "\n"
-        header += "extern hypervWmiClassInfoListPtr %s_WmiInfo;\n\n" % self.name
+        header += "extern hypervWmiClassInfoPtr %s_WmiInfo;\n\n" % self.name
 
         header += self._declare_data_structs()
         header += self._declare_hypervObject_struct()
@@ -143,19 +143,12 @@ class WmiClass:
         This struct holds info with meta-data needed to make wsman requests for the WMI class.
         """
 
-        source = "hypervWmiClassInfoListPtr %s_WmiInfo = &(hypervWmiClassInfoList) {\n" % self.name
-        source += "    .count = 1,\n"
-        source += "    .objs = (hypervWmiClassInfoPtr []) {\n"
-
-        source += "        &(hypervWmiClassInfo) {\n"
-        source += "            .name = %s_CLASSNAME,\n" % self.name.upper()
-        source += "            .rootUri = %s,\n" % self.uri_info.rootUri
-        source += "            .resourceUri = %s_RESOURCE_URI,\n" % self.name.upper()
-        source += "            .serializerInfo = %s_Data_TypeInfo,\n" % self.name
-        source += "            .propertyInfo = %s_Typemap\n" % self.name
-        source += "        },\n"
-
-        source += "    }\n"
+        source = "hypervWmiClassInfoPtr %s_WmiInfo = &(hypervWmiClassInfo) {\n" % self.name
+        source += "    .name = %s_CLASSNAME,\n" % self.name.upper()
+        source += "    .rootUri = %s,\n" % self.uri_info.rootUri
+        source += "    .resourceUri = %s_RESOURCE_URI,\n" % self.name.upper()
+        source += "    .serializerInfo = %s_Data_TypeInfo,\n" % self.name
+        source += "    .propertyInfo = %s_Typemap\n" % self.name
         source += "};\n"
 
         return source
diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index 2a3d6abc0b..72a68c0591 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -47,16 +47,8 @@
 
 VIR_LOG_INIT("hyperv.hyperv_wmi");
 
-static int
-hypervGetWmiClassInfo(hypervWmiClassInfoListPtr list, hypervWmiClassInfoPtr *info)
-{
-    *info = list->objs[0];
-    return 0;
-}
-
-
 int
-hypervGetWmiClassList(hypervPrivate *priv, hypervWmiClassInfoListPtr wmiInfo,
+hypervGetWmiClassList(hypervPrivate *priv, hypervWmiClassInfoPtr wmiInfo,
                       virBufferPtr query, hypervObject **wmiClass)
 {
     hypervWqlQuery wqlQuery = HYPERV_WQL_QUERY_INITIALIZER;
@@ -141,13 +133,9 @@ hypervVerifyResponse(WsManClient *client, WsXmlDocH response,
 hypervInvokeParamsListPtr
 hypervCreateInvokeParamsList(const char *method,
                              const char *selector,
-                             hypervWmiClassInfoListPtr obj)
+                             hypervWmiClassInfoPtr info)
 {
     hypervInvokeParamsListPtr params = NULL;
-    hypervWmiClassInfoPtr info = NULL;
-
-    if (hypervGetWmiClassInfo(obj, &info) < 0)
-        return NULL;
 
     params = g_new0(hypervInvokeParamsList, 1);
 
@@ -259,13 +247,11 @@ int
 hypervAddEprParam(hypervInvokeParamsListPtr params,
                   const char *name,
                   virBufferPtr query,
-                  hypervWmiClassInfoListPtr eprInfo)
+                  hypervWmiClassInfoPtr classInfo)
 {
     hypervParamPtr p = NULL;
-    hypervWmiClassInfoPtr classInfo = NULL;
 
-    if (hypervGetWmiClassInfo(eprInfo, &classInfo) < 0 ||
-        hypervCheckParams(params) < 0)
+    if (hypervCheckParams(params) < 0)
         return -1;
 
     p = &params->params[params->nbParams];
@@ -290,17 +276,12 @@ hypervAddEprParam(hypervInvokeParamsListPtr params,
  * Returns a pointer to the GHashTable on success, otherwise NULL.
  */
 GHashTable *
-hypervCreateEmbeddedParam(hypervWmiClassInfoListPtr info)
+hypervCreateEmbeddedParam(hypervWmiClassInfoPtr classInfo)
 {
     size_t i;
     size_t count;
     g_autoptr(GHashTable) table = NULL;
     XmlSerializerInfo *typeinfo = NULL;
-    hypervWmiClassInfoPtr classInfo = NULL;
-
-    /* Get the typeinfo out of the class info list */
-    if (hypervGetWmiClassInfo(info, &classInfo) < 0)
-        return NULL;
 
     typeinfo = classInfo->serializerInfo;
 
@@ -363,18 +344,13 @@ int
 hypervAddEmbeddedParam(hypervInvokeParamsListPtr params,
                        const char *name,
                        GHashTable **table,
-                       hypervWmiClassInfoListPtr info)
+                       hypervWmiClassInfoPtr classInfo)
 {
     hypervParamPtr p = NULL;
-    hypervWmiClassInfoPtr classInfo = NULL;
 
     if (hypervCheckParams(params) < 0)
         return -1;
 
-    /* Get the typeinfo out of the class info list */
-    if (hypervGetWmiClassInfo(info, &classInfo) < 0)
-        return -1;
-
     p = &params->params[params->nbParams];
     p->type = HYPERV_EMBEDDED_PARAM;
     p->embedded.name = name;
@@ -959,7 +935,7 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery,
     WsSerializerContextH serializerContext;
     client_opt_t *options = NULL;
     char *query_string = NULL;
-    hypervWmiClassInfoPtr wmiInfo = NULL;
+    hypervWmiClassInfoPtr wmiInfo = wqlQuery->info;
     filter_t *filter = NULL;
     WsXmlDocH response = NULL;
     char *enumContext = NULL;
@@ -977,9 +953,6 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery,
         return -1;
     }
 
-    if (hypervGetWmiClassInfo(wqlQuery->info, &wmiInfo) < 0)
-        goto cleanup;
-
     serializerContext = wsmc_get_serialization_context(priv->client);
 
     options = wsmc_options_init();
diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h
index a9fe5318e6..eb273ba7cf 100644
--- a/src/hyperv/hyperv_wmi.h
+++ b/src/hyperv/hyperv_wmi.h
@@ -56,7 +56,7 @@ typedef struct _hypervWqlQuery hypervWqlQuery;
 typedef hypervWqlQuery *hypervWqlQueryPtr;
 struct _hypervWqlQuery {
     virBufferPtr query;
-    hypervWmiClassInfoListPtr info;
+    hypervWmiClassInfoPtr info;
 };
 
 int hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery,
@@ -121,7 +121,7 @@ typedef hypervInvokeParamsList *hypervInvokeParamsListPtr;
 
 hypervInvokeParamsListPtr hypervCreateInvokeParamsList(const char *method,
                                                        const char *selector,
-                                                       hypervWmiClassInfoListPtr obj);
+                                                       hypervWmiClassInfoPtr obj);
 
 void hypervFreeInvokeParams(hypervInvokeParamsListPtr params);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(hypervInvokeParamsList, hypervFreeInvokeParams);
@@ -132,9 +132,9 @@ int hypervAddSimpleParam(hypervInvokeParamsListPtr params, const char *name,
 int hypervAddEprParam(hypervInvokeParamsListPtr params,
                       const char *name,
                       virBufferPtr query,
-                      hypervWmiClassInfoListPtr eprInfo);
+                      hypervWmiClassInfoPtr eprInfo);
 
-GHashTable *hypervCreateEmbeddedParam(hypervWmiClassInfoListPtr info);
+GHashTable *hypervCreateEmbeddedParam(hypervWmiClassInfoPtr info);
 
 int hypervSetEmbeddedProperty(GHashTable *table,
                               const char *name,
@@ -143,7 +143,7 @@ int hypervSetEmbeddedProperty(GHashTable *table,
 int hypervAddEmbeddedParam(hypervInvokeParamsListPtr params,
                            const char *name,
                            GHashTable **table,
-                           hypervWmiClassInfoListPtr info);
+                           hypervWmiClassInfoPtr info);
 
 void hypervFreeEmbeddedParam(GHashTable *p);
 
@@ -188,7 +188,8 @@ const char *hypervReturnCodeToString(int returnCode);
 
 
 int hypervGetWmiClassList(hypervPrivate *priv,
-                          hypervWmiClassInfoListPtr wmiInfo, virBufferPtr query,
+                          hypervWmiClassInfoPtr wmiInfo,
+                          virBufferPtr query,
                           hypervObject **wmiClass);
 
 /**
diff --git a/src/hyperv/hyperv_wmi_classes.h b/src/hyperv/hyperv_wmi_classes.h
index a00751013d..161e9be131 100644
--- a/src/hyperv/hyperv_wmi_classes.h
+++ b/src/hyperv/hyperv_wmi_classes.h
@@ -128,12 +128,4 @@ struct _hypervWmiClassInfo {
     hypervCimTypePtr propertyInfo;
 };
 
-
-typedef struct _hypervWmiClassInfoList hypervWmiClassInfoList;
-typedef hypervWmiClassInfoList *hypervWmiClassInfoListPtr;
-struct _hypervWmiClassInfoList {
-    size_t count;
-    hypervWmiClassInfoPtr *objs;
-};
-
 #include "hyperv_wmi_classes.generated.h"
-- 
2.27.0





More information about the libvir-list mailing list