[PATCH 6/6] virDomain{Get,Set}PerfEvents: Grab job

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 56120ff..7fef901 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10069,9 +10069,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 = &params[i];
@@ -10079,16 +10082,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) {
@@ -10102,11 +10105,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);
@@ -10146,9 +10152,12 @@ qemuDomainGetPerfEvents(virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;
 
+    if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
+        goto cleanup;
+
     if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags,
                                         &persistentDef) < 0)
-        goto cleanup;
+        goto endjob;
 
     priv = vm->privateData;
 
@@ -10164,7 +10173,7 @@ qemuDomainGetPerfEvents(virDomainPtr dom,
                                      virPerfEventTypeToString(i),
                                      perf_enabled) < 0) {
             virTypedParamsFree(par, npar);
-            goto cleanup;
+            goto endjob;
         }
     }
 
@@ -10172,6 +10181,9 @@ qemuDomainGetPerfEvents(virDomainPtr dom,
     *nparams = npar;
     ret = 0;
 
+ endjob:
+    qemuDomainObjEndJob(driver, vm);
+
  cleanup:
     virDomainObjEndAPI(&vm);
     virObjectUnref(caps);
-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]