mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
vircgroup.c: add virCgroupSetupCpusetCpus()
The code from qemuSetupCgroupCpusetCpus() and virLXCCgroupSetupCpusetTune() can be centralized in a new helper called virCgroupSetupCpusetCpus(). Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
ca4238ba73
commit
867c554e52
@ -1731,6 +1731,7 @@ virCgroupSetupBlkioDeviceReadIops;
|
||||
virCgroupSetupBlkioDeviceWeight;
|
||||
virCgroupSetupBlkioDeviceWriteBps;
|
||||
virCgroupSetupBlkioDeviceWriteIops;
|
||||
virCgroupSetupCpusetCpus;
|
||||
virCgroupSupportsCpuBW;
|
||||
virCgroupTerminateMachine;
|
||||
|
||||
|
@ -69,14 +69,9 @@ static int virLXCCgroupSetupCpusetTune(virDomainDefPtr def,
|
||||
virDomainNumatuneMemMode mode;
|
||||
|
||||
if (def->placement_mode != VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO &&
|
||||
def->cpumask) {
|
||||
if (!(mask = virBitmapFormat(def->cpumask)))
|
||||
def->cpumask &&
|
||||
virCgroupSetupCpusetCpus(cgroup, def->cpumask) < 0) {
|
||||
return -1;
|
||||
|
||||
if (virCgroupSetCpusetCpus(cgroup, mask) < 0)
|
||||
goto cleanup;
|
||||
/* free mask to make sure we won't use it in a wrong way later */
|
||||
VIR_FREE(mask);
|
||||
}
|
||||
|
||||
if (virDomainNumatuneGetMode(def->numa, -1, &mode) < 0 ||
|
||||
|
@ -1165,19 +1165,7 @@ int
|
||||
qemuSetupCgroupCpusetCpus(virCgroupPtr cgroup,
|
||||
virBitmapPtr cpumask)
|
||||
{
|
||||
int ret = -1;
|
||||
char *new_cpus = NULL;
|
||||
|
||||
if (!(new_cpus = virBitmapFormat(cpumask)))
|
||||
goto cleanup;
|
||||
|
||||
if (virCgroupSetCpusetCpus(cgroup, new_cpus) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(new_cpus);
|
||||
return ret;
|
||||
return virCgroupSetupCpusetCpus(cgroup, cpumask);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3666,3 +3666,18 @@ virCgroupSetupBlkioDeviceWriteBps(virCgroupPtr cgroup, const char *path,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virCgroupSetupCpusetCpus(virCgroupPtr cgroup, virBitmapPtr cpumask)
|
||||
{
|
||||
g_autofree char *new_cpus = NULL;
|
||||
|
||||
if (!(new_cpus = virBitmapFormat(cpumask)))
|
||||
return -1;
|
||||
|
||||
if (virCgroupSetCpusetCpus(cgroup, new_cpus) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -245,6 +245,7 @@ int virCgroupGetCpusetMemoryMigrate(virCgroupPtr group, bool *migrate);
|
||||
|
||||
int virCgroupSetCpusetCpus(virCgroupPtr group, const char *cpus);
|
||||
int virCgroupGetCpusetCpus(virCgroupPtr group, char **cpus);
|
||||
int virCgroupSetupCpusetCpus(virCgroupPtr cgroup, virBitmapPtr cpumask);
|
||||
|
||||
int virCgroupRemove(virCgroupPtr group);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user