From: lu zhipeng <luzhipeng(a)cestc.cn>
For prevent memory leak and easier to use, So change
virDomainEventTunableNew to get virTypedParameterPtr *params
and set it = NULL.
Signed-off-by: lu zhipeng <luzhipeng(a)cestc.cn>
---
v1:
https://patchew.org/Libvirt/20220922130038.1616-1-luzhipeng@cestc.cn/
src/conf/domain_event.c | 12 ++++++------
src/conf/domain_event.h | 4 ++--
src/qemu/qemu_driver.c | 22 ++++++++++------------
src/remote/remote_driver.c | 2 +-
4 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index ff8ea2c389..97d58c2521 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -1495,7 +1495,7 @@ static virObjectEvent *
virDomainEventTunableNew(int id,
const char *name,
unsigned char *uuid,
- virTypedParameterPtr params,
+ virTypedParameterPtr *params,
int nparams)
{
virDomainEventTunable *ev;
@@ -1508,19 +1508,19 @@ virDomainEventTunableNew(int id,
id, name, uuid)))
goto error;
- ev->params = params;
+ ev->params = *params;
ev->nparams = nparams;
-
+ *params = NULL;
return (virObjectEvent *)ev;
error:
- virTypedParamsFree(params, nparams);
+ virTypedParamsFree(*params, nparams);
return NULL;
}
virObjectEvent *
virDomainEventTunableNewFromObj(virDomainObj *obj,
- virTypedParameterPtr params,
+ virTypedParameterPtr *params,
int nparams)
{
return virDomainEventTunableNew(obj->def->id,
@@ -1532,7 +1532,7 @@ virDomainEventTunableNewFromObj(virDomainObj *obj,
virObjectEvent *
virDomainEventTunableNewFromDom(virDomainPtr dom,
- virTypedParameterPtr params,
+ virTypedParameterPtr *params,
int nparams)
{
return virDomainEventTunableNew(dom->id,
diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h
index 4a9f6b988b..f4016dc1e9 100644
--- a/src/conf/domain_event.h
+++ b/src/conf/domain_event.h
@@ -195,11 +195,11 @@ virDomainEventDeviceRemovalFailedNewFromDom(virDomainPtr dom,
virObjectEvent *
virDomainEventTunableNewFromObj(virDomainObj *obj,
- virTypedParameterPtr params,
+ virTypedParameterPtr *params,
int nparams);
virObjectEvent *
virDomainEventTunableNewFromDom(virDomainPtr dom,
- virTypedParameterPtr params,
+ virTypedParameterPtr *params,
int nparams);
virObjectEvent *
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 94b70872d4..3db4592945 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4472,12 +4472,12 @@ qemuDomainPinVcpuLive(virDomainObj *vm,
&eventMaxparams, paramField, str) < 0)
goto cleanup;
- event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams);
+ event = virDomainEventTunableNewFromObj(vm, &eventParams, eventNparams);
ret = 0;
cleanup:
virObjectEventStateQueue(driver->domainEventState, event);
+ virTypedParamsFree(eventParams, eventNparams);
return ret;
}
The patch cannot be applied as it is reported as corrupted here. And
indeed, the header of this hunk says "-4472,12 +4472,12" while the new
version has more lines than the original one. Anyway, this is suspicious
and it looks like the patch was edited before sending or something.
Could you please resend it to make sure we really get the correct patch
you created?
Jirka