diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index dd08e573c0..cae284db0b 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1794,14 +1794,14 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) { if (hypervAddEmbeddedParam(params, priv, "ResourceSettingData", - memResource, Msvm_MemorySettingData_WmiInfo) < 0) { + &memResource, Msvm_MemorySettingData_WmiInfo) < 0) { hypervFreeEmbeddedParam(memResource); goto cleanup; } } else if (priv->wmiVersion == HYPERV_WMI_VERSION_V2) { if (hypervAddEmbeddedParam(params, priv, "ResourceSettings", - memResource, Msvm_MemorySettingData_WmiInfo) < 0) { + &memResource, Msvm_MemorySettingData_WmiInfo) < 0) { hypervFreeEmbeddedParam(memResource); goto cleanup; } diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 779f4265b5..41579858de 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -362,15 +362,22 @@ hypervSetEmbeddedProperty(virHashTablePtr table, const char *name, char *value) * @params: Params list to add to * @priv: hypervPrivate object associated with the connection * @name: Name of the parameter - * @table: table of properties to add + * @table: pointer to table of properties to add * @info: WmiInfo of the object to serialize * * Add a virHashTable containing object properties as an embedded param to - * an invocation list. Returns -1 on failure, 0 on success. + * an invocation list. + * + * Upon successfull return the @table is consumed and the pointer is cleared out. + * + * Returns -1 on failure, 0 on success. */ int -hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, hypervPrivate *priv, - const char *name, virHashTablePtr table, hypervWmiClassInfoListPtr info) +hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, + hypervPrivate *priv, + const char *name, + virHashTablePtr *table, + hypervWmiClassInfoListPtr info) { hypervParamPtr p = NULL; hypervWmiClassInfoPtr classInfo = NULL; @@ -385,7 +392,7 @@ hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, hypervPrivate *priv, p = ¶ms->params[params->nbParams]; p->type = HYPERV_EMBEDDED_PARAM; p->embedded.name = name; - p->embedded.table = table; + p->embedded.table = g_steal_pointer(table); p->embedded.info = classInfo; params->nbParams++; diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index 20749f2a39..fb19a7f375 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -149,8 +149,11 @@ virHashTablePtr hypervCreateEmbeddedParam(hypervPrivate *priv, int hypervSetEmbeddedProperty(virHashTablePtr table, const char *name, char *value); -int hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, hypervPrivate *priv, - const char *name, virHashTablePtr table, hypervWmiClassInfoListPtr info); +int hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, + hypervPrivate *priv, + const char *name, + virHashTablePtr *table, + hypervWmiClassInfoListPtr info); void hypervFreeEmbeddedParam(virHashTablePtr p);