From 717c8b3107df3cda89453bd2427c231bdad84357 Mon Sep 17 00:00:00 2001 Message-Id: <717c8b3107df3cda89453bd2427c231bdad84357@dist-git> From: Peter Krempa Date: Wed, 24 Aug 2016 16:11:32 -0400 Subject: [PATCH] util: Extract and rename qemuDomainDelCgroupForThread to virCgroupDelThread https://bugzilla.redhat.com/show_bug.cgi?id=1097930 https://bugzilla.redhat.com/show_bug.cgi?id=1224341 (cherry picked from commit c84c2cb389398d684a00066c421813e7908a84e7) --- 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 b7a1663..7535064 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1265,6 +1265,7 @@ virCgroupBindMount; virCgroupControllerAvailable; virCgroupControllerTypeFromString; virCgroupControllerTypeToString; +virCgroupDelThread; virCgroupDenyAllDevices; virCgroupDenyDevice; virCgroupDenyDevicePath; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 35ed8ec..43e00ff 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4596,25 +4596,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) @@ -4707,8 +4688,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; @@ -5910,9 +5890,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 04f3818..97cf246 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -4819,3 +4819,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.10.0