mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
hyperv: Make it obvious that hypervAddEmbeddedParam() consumes an argument
Upon successful return hypervAddEmbeddedParam() transfers ownership of @table argument to @params. But because it takes only simple pointer (which hides this ownership transfer) it doesn't clear the @table pointer. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Matt Coleman <matt@datto.com>
This commit is contained in:
parent
49562e92e8
commit
e0a09c243c
@ -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;
|
||||
}
|
||||
|
@ -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++;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user