提交 7f3aedac 编写于 作者: P Pavel Hrdina

vircgroup: extract virCgroupV1(Set|Get)CpusetMemoryMigrate

Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 41510b1b
...@@ -1738,10 +1738,7 @@ virCgroupGetCpusetMems(virCgroupPtr group, char **mems) ...@@ -1738,10 +1738,7 @@ virCgroupGetCpusetMems(virCgroupPtr group, char **mems)
int int
virCgroupSetCpusetMemoryMigrate(virCgroupPtr group, bool migrate) virCgroupSetCpusetMemoryMigrate(virCgroupPtr group, bool migrate)
{ {
return virCgroupSetValueStr(group, VIR_CGROUP_BACKEND_CALL(group, setCpusetMemoryMigrate, -1, migrate);
VIR_CGROUP_CONTROLLER_CPUSET,
"cpuset.memory_migrate",
migrate ? "1" : "0");
} }
...@@ -1756,13 +1753,7 @@ virCgroupSetCpusetMemoryMigrate(virCgroupPtr group, bool migrate) ...@@ -1756,13 +1753,7 @@ virCgroupSetCpusetMemoryMigrate(virCgroupPtr group, bool migrate)
int int
virCgroupGetCpusetMemoryMigrate(virCgroupPtr group, bool *migrate) virCgroupGetCpusetMemoryMigrate(virCgroupPtr group, bool *migrate)
{ {
unsigned long long value = 0; VIR_CGROUP_BACKEND_CALL(group, getCpusetMemoryMigrate, -1, migrate);
int ret = virCgroupGetValueU64(group,
VIR_CGROUP_CONTROLLER_CPUSET,
"cpuset.memory_migrate",
&value);
*migrate = !!value;
return ret;
} }
......
...@@ -332,6 +332,14 @@ typedef int ...@@ -332,6 +332,14 @@ typedef int
(*virCgroupGetCpusetMemsCB)(virCgroupPtr group, (*virCgroupGetCpusetMemsCB)(virCgroupPtr group,
char **mems); char **mems);
typedef int
(*virCgroupSetCpusetMemoryMigrateCB)(virCgroupPtr group,
bool migrate);
typedef int
(*virCgroupGetCpusetMemoryMigrateCB)(virCgroupPtr group,
bool *migrate);
struct _virCgroupBackend { struct _virCgroupBackend {
virCgroupBackendType type; virCgroupBackendType type;
...@@ -404,6 +412,8 @@ struct _virCgroupBackend { ...@@ -404,6 +412,8 @@ struct _virCgroupBackend {
virCgroupSetCpusetMemsCB setCpusetMems; virCgroupSetCpusetMemsCB setCpusetMems;
virCgroupGetCpusetMemsCB getCpusetMems; virCgroupGetCpusetMemsCB getCpusetMems;
virCgroupSetCpusetMemoryMigrateCB setCpusetMemoryMigrate;
virCgroupGetCpusetMemoryMigrateCB getCpusetMemoryMigrate;
}; };
typedef struct _virCgroupBackend virCgroupBackend; typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr; typedef virCgroupBackend *virCgroupBackendPtr;
......
...@@ -1970,6 +1970,31 @@ virCgroupV1GetCpusetMems(virCgroupPtr group, ...@@ -1970,6 +1970,31 @@ virCgroupV1GetCpusetMems(virCgroupPtr group,
} }
static int
virCgroupV1SetCpusetMemoryMigrate(virCgroupPtr group,
bool migrate)
{
return virCgroupSetValueStr(group,
VIR_CGROUP_CONTROLLER_CPUSET,
"cpuset.memory_migrate",
migrate ? "1" : "0");
}
static int
virCgroupV1GetCpusetMemoryMigrate(virCgroupPtr group,
bool *migrate)
{
unsigned long long value = 0;
int ret = virCgroupGetValueU64(group,
VIR_CGROUP_CONTROLLER_CPUSET,
"cpuset.memory_migrate",
&value);
*migrate = !!value;
return ret;
}
virCgroupBackend virCgroupV1Backend = { virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1, .type = VIR_CGROUP_BACKEND_TYPE_V1,
...@@ -2040,6 +2065,8 @@ virCgroupBackend virCgroupV1Backend = { ...@@ -2040,6 +2065,8 @@ virCgroupBackend virCgroupV1Backend = {
.setCpusetMems = virCgroupV1SetCpusetMems, .setCpusetMems = virCgroupV1SetCpusetMems,
.getCpusetMems = virCgroupV1GetCpusetMems, .getCpusetMems = virCgroupV1GetCpusetMems,
.setCpusetMemoryMigrate = virCgroupV1SetCpusetMemoryMigrate,
.getCpusetMemoryMigrate = virCgroupV1GetCpusetMemoryMigrate,
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册