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

[libvirt] [PATCH 28/35] qemu: Refactor qemuDomainPinIOThread by reusing virDomainObjGetDefs



---
 src/qemu/qemu_driver.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b799d6e..c1dca36 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5792,8 +5792,8 @@ qemuDomainPinIOThread(virDomainPtr dom,
     virQEMUDriverPtr driver = dom->conn->privateData;
     virQEMUDriverConfigPtr cfg = NULL;
     virDomainObjPtr vm;
-    virCapsPtr caps = NULL;
-    virDomainDefPtr persistentDef = NULL;
+    virDomainDefPtr def;
+    virDomainDefPtr persistentDef;
     virBitmapPtr pcpumap = NULL;
     qemuDomainObjPrivatePtr priv;
     virCgroupPtr cgroup_iothread = NULL;
@@ -5816,9 +5816,6 @@ qemuDomainPinIOThread(virDomainPtr dom,
     if (virDomainPinIOThreadEnsureACL(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 IOThread dynamically is "
@@ -5829,9 +5826,8 @@ qemuDomainPinIOThread(virDomainPtr dom,
     if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
         goto cleanup;

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

     if (!(pcpumap = virBitmapNewData(cpumap, maplen)))
         goto endjob;
@@ -5842,12 +5838,11 @@ qemuDomainPinIOThread(virDomainPtr dom,
         goto endjob;
     }

-    if (flags & VIR_DOMAIN_AFFECT_LIVE) {
-
+    if (def) {
         virDomainIOThreadIDDefPtr iothrid;
         virBitmapPtr cpumask;

-        if (!(iothrid = virDomainIOThreadIDFind(vm->def, iothread_id))) {
+        if (!(iothrid = virDomainIOThreadIDFind(def, iothread_id))) {
             virReportError(VIR_ERR_INVALID_ARG,
                            _("iothread %d not found"), iothread_id);
             goto endjob;
@@ -5897,13 +5892,10 @@ qemuDomainPinIOThread(virDomainPtr dom,
         event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams);
     }

-    if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+    if (persistentDef) {
         virDomainIOThreadIDDefPtr iothrid;
         virBitmapPtr cpumask;

-        /* Coverity didn't realize that targetDef must be set if we got here. */
-        sa_assert(persistentDef);
-
         if (!(iothrid = virDomainIOThreadIDFind(persistentDef, iothread_id))) {
             virReportError(VIR_ERR_INVALID_ARG,
                            _("iothreadid %d not found"), iothread_id);
@@ -5934,7 +5926,6 @@ qemuDomainPinIOThread(virDomainPtr dom,
     VIR_FREE(str);
     virBitmapFree(pcpumap);
     virDomainObjEndAPI(&vm);
-    virObjectUnref(caps);
     virObjectUnref(cfg);
     return ret;
 }
-- 
2.4.1


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