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

[libvirt] [PATCH 33/35] qemu: Refactor qemuDomainPinEmulator by reusing virDomainObjGetDefs



---
 src/qemu/qemu_driver.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1dfba58..9c0f7d3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5268,13 +5268,13 @@ qemuDomainPinEmulator(virDomainPtr dom,
     virQEMUDriverPtr driver = dom->conn->privateData;
     virDomainObjPtr vm;
     virCgroupPtr cgroup_emulator = NULL;
-    virDomainDefPtr persistentDef = NULL;
+    virDomainDefPtr def;
+    virDomainDefPtr persistentDef;
     int ret = -1;
     qemuDomainObjPrivatePtr priv;
     bool doReset = false;
     virBitmapPtr pcpumap = NULL;
     virQEMUDriverConfigPtr cfg = NULL;
-    virCapsPtr caps = NULL;
     virObjectEventPtr event = NULL;
     char *str = NULL;
     virTypedParameterPtr eventParams = NULL;
@@ -5292,9 +5292,6 @@ qemuDomainPinEmulator(virDomainPtr dom,
     if (virDomainPinEmulatorEnsureACL(dom->conn, vm->def, flags) < 0)
         goto cleanup;

-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
-        goto cleanup;
-
     if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
         virReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("Changing affinity for emulator thread dynamically "
@@ -5305,8 +5302,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
     if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
         goto cleanup;

-    if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags,
-                                        &persistentDef) < 0)
+    if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
         goto endjob;

     priv = vm->privateData;
@@ -5326,7 +5322,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
     if (virBitmapIsAllSet(pcpumap))
         doReset = true;

-    if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+    if (def) {
         if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
             if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_EMULATOR,
                                    0, false, &cgroup_emulator) < 0)
@@ -5347,11 +5343,11 @@ qemuDomainPinEmulator(virDomainPtr dom,
             }
         }

-        virBitmapFree(vm->def->cputune.emulatorpin);
-        vm->def->cputune.emulatorpin = NULL;
+        virBitmapFree(def->cputune.emulatorpin);
+        def->cputune.emulatorpin = NULL;

         if (!doReset &&
-            !(vm->def->cputune.emulatorpin = virBitmapNewCopy(pcpumap)))
+            !(def->cputune.emulatorpin = virBitmapNewCopy(pcpumap)))
             goto endjob;

         if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
@@ -5367,7 +5363,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
         event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams);
     }

-    if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+    if (persistentDef) {
         virBitmapFree(persistentDef->cputune.emulatorpin);
         persistentDef->cputune.emulatorpin = NULL;

@@ -5391,7 +5387,6 @@ qemuDomainPinEmulator(virDomainPtr dom,
         qemuDomainEventQueue(driver, event);
     VIR_FREE(str);
     virBitmapFree(pcpumap);
-    virObjectUnref(caps);
     virDomainObjEndAPI(&vm);
     virObjectUnref(cfg);
     return ret;
-- 
2.4.1


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