[PATCH v2 15/23] util: Extract and rename qemuDomainDelCgroupForThread to virCgroupDelThread

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

 



---
 src/libvirt_private.syms |  1 +
 src/qemu/qemu_driver.c   | 27 +++------------------------
 src/util/vircgroup.c     | 20 ++++++++++++++++++++
 src/util/vircgroup.h     |  4 ++++
 4 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a32ce1c..77df0c0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1269,6 +1269,7 @@ virCgroupBindMount;
 virCgroupControllerAvailable;
 virCgroupControllerTypeFromString;
 virCgroupControllerTypeToString;
+virCgroupDelThread;
 virCgroupDenyAllDevices;
 virCgroupDenyDevice;
 virCgroupDenyDevicePath;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8ff95f6..d083e46 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4590,25 +4590,6 @@ static void qemuProcessEventHandler(void *data, void *opaque)


 static int
-qemuDomainDelCgroupForThread(virCgroupPtr cgroup,
-                             virCgroupThreadName nameval,
-                             int idx)
-{
-    virCgroupPtr new_cgroup = NULL;
-
-    if (cgroup) {
-        if (virCgroupNewThread(cgroup, nameval, idx, false, &new_cgroup) < 0)
-            return -1;
-
-        /* Remove the offlined cgroup */
-        virCgroupRemove(new_cgroup);
-        virCgroupFree(&new_cgroup);
-    }
-
-    return 0;
-}
-
-static int
 qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
                          virDomainObjPtr vm,
                          unsigned int vcpu)
@@ -4701,8 +4682,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,

     virDomainAuditVcpu(vm, oldvcpus, oldvcpus - 1, "update", true);

-    if (qemuDomainDelCgroupForThread(priv->cgroup,
-                                     VIR_CGROUP_THREAD_VCPU, vcpu) < 0)
+    if (virCgroupDelThread(priv->cgroup, VIR_CGROUP_THREAD_VCPU, vcpu) < 0)
         goto cleanup;

     ret = 0;
@@ -5904,9 +5884,8 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver,

     virDomainIOThreadIDDel(vm->def, iothread_id);

-    if (qemuDomainDelCgroupForThread(priv->cgroup,
-                                     VIR_CGROUP_THREAD_IOTHREAD,
-                                     iothread_id) < 0)
+    if (virCgroupDelThread(priv->cgroup, VIR_CGROUP_THREAD_IOTHREAD,
+                           iothread_id) < 0)
         goto cleanup;

     ret = 0;
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 07cd7f6..f2477d5 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -4821,3 +4821,23 @@ virCgroupControllerAvailable(int controller ATTRIBUTE_UNUSED)
     return false;
 }
 #endif /* !VIR_CGROUP_SUPPORTED */
+
+
+int
+virCgroupDelThread(virCgroupPtr cgroup,
+                   virCgroupThreadName nameval,
+                   int idx)
+{
+    virCgroupPtr new_cgroup = NULL;
+
+    if (cgroup) {
+        if (virCgroupNewThread(cgroup, nameval, idx, false, &new_cgroup) < 0)
+            return -1;
+
+        /* Remove the offlined cgroup */
+        virCgroupRemove(new_cgroup);
+        virCgroupFree(&new_cgroup);
+    }
+
+    return 0;
+}
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index 2ddbb35..4b8f3ff 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -86,6 +86,10 @@ int virCgroupNewThread(virCgroupPtr domain,
                        virCgroupPtr *group)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(5);

+int virCgroupDelThread(virCgroupPtr cgroup,
+                       virCgroupThreadName nameval,
+                       int idx);
+
 int virCgroupNewDetect(pid_t pid,
                        int controllers,
                        virCgroupPtr *group);
-- 
2.8.2

--
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]