提交 c84c2cb3 编写于 作者: P Peter Krempa

util: Extract and rename qemuDomainDelCgroupForThread to virCgroupDelThread

上级 133be0a9
...@@ -1269,6 +1269,7 @@ virCgroupBindMount; ...@@ -1269,6 +1269,7 @@ virCgroupBindMount;
virCgroupControllerAvailable; virCgroupControllerAvailable;
virCgroupControllerTypeFromString; virCgroupControllerTypeFromString;
virCgroupControllerTypeToString; virCgroupControllerTypeToString;
virCgroupDelThread;
virCgroupDenyAllDevices; virCgroupDenyAllDevices;
virCgroupDenyDevice; virCgroupDenyDevice;
virCgroupDenyDevicePath; virCgroupDenyDevicePath;
......
...@@ -4589,25 +4589,6 @@ static void qemuProcessEventHandler(void *data, void *opaque) ...@@ -4589,25 +4589,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 static int
qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver, qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
...@@ -4701,8 +4682,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, ...@@ -4701,8 +4682,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
virDomainAuditVcpu(vm, oldvcpus, oldvcpus - 1, "update", true); virDomainAuditVcpu(vm, oldvcpus, oldvcpus - 1, "update", true);
if (qemuDomainDelCgroupForThread(priv->cgroup, if (virCgroupDelThread(priv->cgroup, VIR_CGROUP_THREAD_VCPU, vcpu) < 0)
VIR_CGROUP_THREAD_VCPU, vcpu) < 0)
goto cleanup; goto cleanup;
ret = 0; ret = 0;
...@@ -5904,9 +5884,8 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver, ...@@ -5904,9 +5884,8 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver,
virDomainIOThreadIDDel(vm->def, iothread_id); virDomainIOThreadIDDel(vm->def, iothread_id);
if (qemuDomainDelCgroupForThread(priv->cgroup, if (virCgroupDelThread(priv->cgroup, VIR_CGROUP_THREAD_IOTHREAD,
VIR_CGROUP_THREAD_IOTHREAD, iothread_id) < 0)
iothread_id) < 0)
goto cleanup; goto cleanup;
ret = 0; ret = 0;
......
...@@ -4821,3 +4821,23 @@ virCgroupControllerAvailable(int controller ATTRIBUTE_UNUSED) ...@@ -4821,3 +4821,23 @@ virCgroupControllerAvailable(int controller ATTRIBUTE_UNUSED)
return false; return false;
} }
#endif /* !VIR_CGROUP_SUPPORTED */ #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;
}
...@@ -86,6 +86,10 @@ int virCgroupNewThread(virCgroupPtr domain, ...@@ -86,6 +86,10 @@ int virCgroupNewThread(virCgroupPtr domain,
virCgroupPtr *group) virCgroupPtr *group)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(5); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(5);
int virCgroupDelThread(virCgroupPtr cgroup,
virCgroupThreadName nameval,
int idx);
int virCgroupNewDetect(pid_t pid, int virCgroupNewDetect(pid_t pid,
int controllers, int controllers,
virCgroupPtr *group); virCgroupPtr *group);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册