Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
809ba20e
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
809ba20e
编写于
6月 15, 2015
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: Refactor qemuDomainSetNumaParameters
Use virDomainObjGetDefs and sanitize the control flow.
上级
caa6cd39
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
36 deletion
+28
-36
src/qemu/qemu_driver.c
src/qemu/qemu_driver.c
+28
-36
未找到文件。
src/qemu/qemu_driver.c
浏览文件 @
809ba20e
...
@@ -10131,11 +10131,11 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
...
@@ -10131,11 +10131,11 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
{
{
virQEMUDriverPtr driver = dom->conn->privateData;
virQEMUDriverPtr driver = dom->conn->privateData;
size_t i;
size_t i;
virDomainDefPtr persistentDef = NULL;
virDomainDefPtr def;
virDomainDefPtr persistentDef;
virDomainObjPtr vm = NULL;
virDomainObjPtr vm = NULL;
int ret = -1;
int ret = -1;
virQEMUDriverConfigPtr cfg = NULL;
virQEMUDriverConfigPtr cfg = NULL;
virCapsPtr caps = NULL;
qemuDomainObjPrivatePtr priv;
qemuDomainObjPrivatePtr priv;
virBitmapPtr nodeset = NULL;
virBitmapPtr nodeset = NULL;
virDomainNumatuneMemMode config_mode;
virDomainNumatuneMemMode config_mode;
...
@@ -10161,31 +10161,6 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
...
@@ -10161,31 +10161,6 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
if (virDomainSetNumaParametersEnsureACL(dom->conn, vm->def, flags) < 0)
if (virDomainSetNumaParametersEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
goto cleanup;
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags,
&persistentDef) < 0)
goto endjob;
if (!cfg->privileged &&
flags & VIR_DOMAIN_AFFECT_LIVE) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("NUMA tuning is not available in session mode"));
goto endjob;
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cgroup cpuset controller is not mounted"));
goto endjob;
}
}
for (i = 0; i < nparams; i++) {
for (i = 0; i < nparams; i++) {
virTypedParameterPtr param = ¶ms[i];
virTypedParameterPtr param = ¶ms[i];
...
@@ -10195,26 +10170,44 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
...
@@ -10195,26 +10170,44 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
if (mode < 0 || mode >= VIR_DOMAIN_NUMATUNE_MEM_LAST) {
if (mode < 0 || mode >= VIR_DOMAIN_NUMATUNE_MEM_LAST) {
virReportError(VIR_ERR_INVALID_ARG,
virReportError(VIR_ERR_INVALID_ARG,
_("unsupported numatune mode: '%d'"), mode);
_("unsupported numatune mode: '%d'"), mode);
goto
endjob
;
goto
cleanup
;
}
}
} else if (STREQ(param->field, VIR_DOMAIN_NUMA_NODESET)) {
} else if (STREQ(param->field, VIR_DOMAIN_NUMA_NODESET)) {
if (virBitmapParse(param->value.s, 0, &nodeset,
if (virBitmapParse(param->value.s, 0, &nodeset,
VIR_DOMAIN_CPUMASK_LEN) < 0)
VIR_DOMAIN_CPUMASK_LEN) < 0)
goto
endjob
;
goto
cleanup
;
if (virBitmapIsAllClear(nodeset)) {
if (virBitmapIsAllClear(nodeset)) {
virReportError(VIR_ERR_OPERATION_INVALID,
virReportError(VIR_ERR_OPERATION_INVALID,
_("Invalid nodeset of 'numatune': %s"),
_("Invalid nodeset of 'numatune': %s"),
param->value.s);
param->value.s);
goto
endjob
;
goto
cleanup
;
}
}
}
}
}
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
goto endjob;
if (def) {
if (!cfg->privileged) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("NUMA tuning is not available in session mode"));
goto endjob;
}
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cgroup cpuset controller is not mounted"));
goto endjob;
}
if (mode != -1 &&
if (mode != -1 &&
virDomainNumatuneGetMode(
vm->
def->numa, -1, &config_mode) == 0 &&
virDomainNumatuneGetMode(def->numa, -1, &config_mode) == 0 &&
config_mode != mode) {
config_mode != mode) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("can't change numatune mode for running domain"));
_("can't change numatune mode for running domain"));
...
@@ -10225,8 +10218,8 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
...
@@ -10225,8 +10218,8 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
qemuDomainSetNumaParamsLive(vm, nodeset) < 0)
qemuDomainSetNumaParamsLive(vm, nodeset) < 0)
goto endjob;
goto endjob;
if (virDomainNumatuneSet(
vm->
def->numa,
if (virDomainNumatuneSet(def->numa,
vm->
def->placement_mode ==
def->placement_mode ==
VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
-1, mode, nodeset) < 0)
-1, mode, nodeset) < 0)
goto endjob;
goto endjob;
...
@@ -10235,7 +10228,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
...
@@ -10235,7 +10228,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
goto endjob;
goto endjob;
}
}
if (
flags & VIR_DOMAIN_AFFECT_CONFIG
) {
if (
persistentDef
) {
if (virDomainNumatuneSet(persistentDef->numa,
if (virDomainNumatuneSet(persistentDef->numa,
persistentDef->placement_mode ==
persistentDef->placement_mode ==
VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
...
@@ -10254,7 +10247,6 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
...
@@ -10254,7 +10247,6 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
cleanup:
cleanup:
virBitmapFree(nodeset);
virBitmapFree(nodeset);
virDomainObjEndAPI(&vm);
virDomainObjEndAPI(&vm);
virObjectUnref(caps);
virObjectUnref(cfg);
virObjectUnref(cfg);
return ret;
return ret;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录