From 4349e24d5411ee1fe19cedfe8e7a070ba4fd003a Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 31 Mar 2016 07:21:11 +0200 Subject: [PATCH] virDomain{Get,Set}PerfEvents: Grab job Even though we have the machine locked throughout whole APIs we are querying/modifying domain internal state. We should grab a job whilst doing that. Signed-off-by: Michal Privoznik --- src/qemu/qemu_driver.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c80f1dae36..4aa162590f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10071,9 +10071,12 @@ qemuDomainSetPerfEvents(virDomainPtr dom, if (virDomainSetPerfEventsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; + if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) + goto endjob; + if (def) { for (i = 0; i < nparams; i++) { virTypedParameterPtr param = ¶ms[i]; @@ -10081,16 +10084,16 @@ qemuDomainSetPerfEvents(virDomainPtr dom, type = virPerfEventTypeFromString(param->field); if (!enabled && virPerfEventDisable(priv->perf, type)) - goto cleanup; + goto endjob; if (enabled && virPerfEventEnable(priv->perf, type, vm->pid)) - goto cleanup; + goto endjob; def->perf->events[type] = enabled ? VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO; } if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) - goto cleanup; + goto endjob; } if (persistentDef) { @@ -10104,11 +10107,14 @@ qemuDomainSetPerfEvents(virDomainPtr dom, } if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0) - goto cleanup; + goto endjob; } ret = 0; + endjob: + qemuDomainObjEndJob(driver, vm); + cleanup: virDomainObjEndAPI(&vm); virObjectUnref(cfg); @@ -10121,6 +10127,7 @@ qemuDomainGetPerfEvents(virDomainPtr dom, int *nparams, unsigned int flags) { + virQEMUDriverPtr driver = dom->conn->privateData; virDomainObjPtr vm = NULL; qemuDomainObjPrivatePtr priv; virDomainDefPtr def; @@ -10140,9 +10147,12 @@ qemuDomainGetPerfEvents(virDomainPtr dom, if (virDomainGetPerfEventsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (!(def = virDomainObjGetOneDef(vm, flags))) + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; + if (!(def = virDomainObjGetOneDef(vm, flags))) + goto endjob; + priv = vm->privateData; for (i = 0; i < VIR_PERF_EVENT_LAST; i++) { @@ -10156,7 +10166,7 @@ qemuDomainGetPerfEvents(virDomainPtr dom, if (virTypedParamsAddBoolean(&par, &npar, &maxpar, virPerfEventTypeToString(i), perf_enabled) < 0) - goto cleanup; + goto endjob; } *params = par; @@ -10165,6 +10175,9 @@ qemuDomainGetPerfEvents(virDomainPtr dom, npar = 0; ret = 0; + endjob: + qemuDomainObjEndJob(driver, vm); + cleanup: virDomainObjEndAPI(&vm); virTypedParamsFree(par, npar);