mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
hyperv: Make it obvious that hypervInvokeMethod() consumes an argument
Upon invocation, hypervInvokeMethod() consumes passed @params (the second argument) regardless whether success or failure is released. However, it takes only simple pointer (which hides this ownership transfer) and because of that it doesn't clear it. Switch to double pointer and tweak the documentation. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Matt Coleman <matt@datto.com>
This commit is contained in:
parent
2508d10f67
commit
f978e2e6ef
@ -1677,7 +1677,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (hypervInvokeMethod(priv, params, NULL) < 0) {
|
||||
if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not press key %d"),
|
||||
translatedKeycodes[i]);
|
||||
goto cleanup;
|
||||
@ -1704,7 +1704,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (hypervInvokeMethod(priv, params, NULL) < 0) {
|
||||
if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not release key %s"),
|
||||
keycodeStr);
|
||||
goto cleanup;
|
||||
@ -1807,7 +1807,7 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory,
|
||||
}
|
||||
}
|
||||
|
||||
if (hypervInvokeMethod(priv, params, NULL) < 0) {
|
||||
if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not set memory"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -753,17 +753,24 @@ hypervSerializeEmbeddedParam(hypervParamPtr p, const char *resourceUri,
|
||||
/*
|
||||
* hypervInvokeMethod:
|
||||
* @priv: hypervPrivate object associated with the connection
|
||||
* @params: object containing the all necessary information for method
|
||||
* invocation
|
||||
* @paramsPtr: pointer to object containing the all necessary information for
|
||||
* method invocation (consumed on invocation)
|
||||
* @res: Optional out parameter to contain the response XML.
|
||||
*
|
||||
* Performs an invocation described by @params, and optionally returns the
|
||||
* XML containing the result. Returns -1 on failure, 0 on success.
|
||||
* Performs an invocation described by object at @paramsPtr, and optionally
|
||||
* returns the XML containing the result.
|
||||
*
|
||||
* Please note that, object at @paramsPtr is consumed by this function and the
|
||||
* pointer is cleared out, regardless of returning success or failure.
|
||||
*
|
||||
* Returns -1 on failure, 0 on success.
|
||||
*/
|
||||
int
|
||||
hypervInvokeMethod(hypervPrivate *priv, hypervInvokeParamsListPtr params,
|
||||
WsXmlDocH *res)
|
||||
hypervInvokeMethod(hypervPrivate *priv,
|
||||
hypervInvokeParamsListPtr *paramsPtr,
|
||||
WsXmlDocH *res)
|
||||
{
|
||||
hypervInvokeParamsListPtr params = *paramsPtr;
|
||||
int result = -1;
|
||||
size_t i = 0;
|
||||
int returnCode;
|
||||
@ -939,6 +946,7 @@ hypervInvokeMethod(hypervPrivate *priv, hypervInvokeParamsListPtr params,
|
||||
VIR_FREE(instanceID);
|
||||
hypervFreeObject(priv, (hypervObject *)job);
|
||||
hypervFreeInvokeParams(params);
|
||||
*paramsPtr = NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -154,8 +154,9 @@ int hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, hypervPrivate *priv
|
||||
|
||||
void hypervFreeEmbeddedParam(virHashTablePtr p);
|
||||
|
||||
int hypervInvokeMethod(hypervPrivate *priv, hypervInvokeParamsListPtr params,
|
||||
WsXmlDocH *res);
|
||||
int hypervInvokeMethod(hypervPrivate *priv,
|
||||
hypervInvokeParamsListPtr *paramsPtr,
|
||||
WsXmlDocH *res);
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* CIM/Msvm_ReturnCode
|
||||
|
Loading…
Reference in New Issue
Block a user