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

[libvirt] [PATCH] qemu_cgroup: Remove unnecessary virQEMUDriverPtr arguments



Since commit 2e6ecba1bcac, the pointer to the qemu driver is saved in
domain object's private data and hence does not have to be passed as
yet another parameter if domain object is already one of them.

This is a first (example) patch of this kind of clean up, others will
hopefully follow.

Signed-off-by: Martin Kletzander <mkletzan redhat com>
---
 src/qemu/qemu_cgroup.c  | 33 ++++++++++++++-------------------
 src/qemu/qemu_cgroup.h  |  6 ++----
 src/qemu/qemu_process.c |  4 ++--
 3 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 7355527c1cc5..6fc413098ae8 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -604,8 +604,7 @@ qemuTeardownChardevCgroup(virDomainObjPtr vm,
 
 
 static int
-qemuSetupDevicesCgroup(virQEMUDriverPtr driver,
-                       virDomainObjPtr vm)
+qemuSetupDevicesCgroup(virDomainObjPtr vm)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virQEMUDriverConfigPtr cfg = NULL;
@@ -644,7 +643,7 @@ qemuSetupDevicesCgroup(virQEMUDriverPtr driver,
     if (rv < 0)
         goto cleanup;
 
-    cfg = virQEMUDriverGetConfig(driver);
+    cfg = virQEMUDriverGetConfig(priv->driver);
     deviceACL = cfg->cgroupDeviceACL ?
                 (const char *const *)cfg->cgroupDeviceACL :
                 defaultDeviceACL;
@@ -769,8 +768,7 @@ qemuSetupCpusetCgroup(virDomainObjPtr vm)
 
 
 static int
-qemuSetupCpuCgroup(virQEMUDriverPtr driver,
-                   virDomainObjPtr vm)
+qemuSetupCpuCgroup(virDomainObjPtr vm)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virObjectEventPtr event = NULL;
@@ -806,7 +804,7 @@ qemuSetupCpuCgroup(virQEMUDriverPtr driver,
             event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams);
         }
 
-        qemuDomainEventQueue(driver, event);
+        qemuDomainEventQueue(priv->driver, event);
     }
 
     return 0;
@@ -814,16 +812,15 @@ qemuSetupCpuCgroup(virQEMUDriverPtr driver,
 
 
 static int
-qemuInitCgroup(virQEMUDriverPtr driver,
-               virDomainObjPtr vm,
+qemuInitCgroup(virDomainObjPtr vm,
                size_t nnicindexes,
                int *nicindexes)
 {
     int ret = -1;
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(priv->driver);
 
-    if (!virQEMUDriverIsPrivileged(driver))
+    if (!virQEMUDriverIsPrivileged(priv->driver))
         goto done;
 
     if (!virCgroupAvailable())
@@ -954,14 +951,13 @@ qemuRestoreCgroupState(virDomainObjPtr vm)
 }
 
 int
-qemuConnectCgroup(virQEMUDriverPtr driver,
-                  virDomainObjPtr vm)
+qemuConnectCgroup(virDomainObjPtr vm)
 {
-    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
     qemuDomainObjPrivatePtr priv = vm->privateData;
+    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(priv->driver);
     int ret = -1;
 
-    if (!virQEMUDriverIsPrivileged(driver))
+    if (!virQEMUDriverIsPrivileged(priv->driver))
         goto done;
 
     if (!virCgroupAvailable())
@@ -991,8 +987,7 @@ qemuConnectCgroup(virQEMUDriverPtr driver,
 }
 
 int
-qemuSetupCgroup(virQEMUDriverPtr driver,
-                virDomainObjPtr vm,
+qemuSetupCgroup(virDomainObjPtr vm,
                 size_t nnicindexes,
                 int *nicindexes)
 {
@@ -1005,13 +1000,13 @@ qemuSetupCgroup(virQEMUDriverPtr driver,
         return -1;
     }
 
-    if (qemuInitCgroup(driver, vm, nnicindexes, nicindexes) < 0)
+    if (qemuInitCgroup(vm, nnicindexes, nicindexes) < 0)
         return -1;
 
     if (!priv->cgroup)
         return 0;
 
-    if (qemuSetupDevicesCgroup(driver, vm) < 0)
+    if (qemuSetupDevicesCgroup(vm) < 0)
         goto cleanup;
 
     if (qemuSetupBlkioCgroup(vm) < 0)
@@ -1020,7 +1015,7 @@ qemuSetupCgroup(virQEMUDriverPtr driver,
     if (qemuSetupMemoryCgroup(vm) < 0)
         goto cleanup;
 
-    if (qemuSetupCpuCgroup(driver, vm) < 0)
+    if (qemuSetupCpuCgroup(vm) < 0)
         goto cleanup;
 
     if (qemuSetupCpusetCgroup(vm) < 0)
diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
index d016ce29d87e..3fc1583612e1 100644
--- a/src/qemu/qemu_cgroup.h
+++ b/src/qemu/qemu_cgroup.h
@@ -55,10 +55,8 @@ int qemuSetupChardevCgroup(virDomainObjPtr vm,
                            virDomainChrDefPtr dev);
 int qemuTeardownChardevCgroup(virDomainObjPtr vm,
                               virDomainChrDefPtr dev);
-int qemuConnectCgroup(virQEMUDriverPtr driver,
-                      virDomainObjPtr vm);
-int qemuSetupCgroup(virQEMUDriverPtr driver,
-                    virDomainObjPtr vm,
+int qemuConnectCgroup(virDomainObjPtr vm);
+int qemuSetupCgroup(virDomainObjPtr vm,
                     size_t nnicindexes,
                     int *nicindexes);
 int qemuSetupCpusetMems(virDomainObjPtr vm);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 87ab85fdb476..535c16b03705 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5595,7 +5595,7 @@ qemuProcessLaunch(virConnectPtr conn,
     }
 
     VIR_DEBUG("Setting up domain cgroup (if required)");
-    if (qemuSetupCgroup(driver, vm, nnicindexes, nicindexes) < 0)
+    if (qemuSetupCgroup(vm, nnicindexes, nicindexes) < 0)
         goto cleanup;
 
     if (!(priv->perf = virPerfNew()))
@@ -6821,7 +6821,7 @@ qemuProcessReconnect(void *opaque)
     if (qemuHostdevUpdateActiveDomainDevices(driver, obj->def) < 0)
         goto error;
 
-    if (qemuConnectCgroup(driver, obj) < 0)
+    if (qemuConnectCgroup(obj) < 0)
         goto error;
 
     if (qemuDomainPerfRestart(obj) < 0)
-- 
2.13.3


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