Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
ec3e5064
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看板
提交
ec3e5064
编写于
1月 16, 2013
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virsh: Use virTypedParams* APIs in numatune
上级
77862330
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
53 deletion
+35
-53
tools/virsh-domain.c
tools/virsh-domain.c
+35
-53
未找到文件。
tools/virsh-domain.c
浏览文件 @
ec3e5064
...
...
@@ -7308,8 +7308,9 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd)
{
virDomainPtr
dom
;
int
nparams
=
0
;
int
maxparams
=
0
;
unsigned
int
i
=
0
;
virTypedParameterPtr
params
=
NULL
,
temp
=
NULL
;
virTypedParameterPtr
params
=
NULL
;
const
char
*
nodeset
=
NULL
;
bool
ret
=
false
;
unsigned
int
flags
=
0
;
...
...
@@ -7336,18 +7337,32 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd)
if
(
vshCommandOptString
(
cmd
,
"nodeset"
,
&
nodeset
)
<
0
)
{
vshError
(
ctl
,
"%s"
,
_
(
"Unable to parse nodeset."
));
virDomainFree
(
dom
);
return
false
;
goto
cleanup
;
}
if
(
nodeset
)
nparams
++
;
if
(
nodeset
&&
virTypedParamsAddString
(
&
params
,
&
nparams
,
&
maxparams
,
VIR_DOMAIN_NUMA_NODESET
,
nodeset
)
<
0
)
goto
save_error
;
if
(
vshCommandOptString
(
cmd
,
"mode"
,
&
mode
)
<
0
)
{
vshError
(
ctl
,
"%s"
,
_
(
"Unable to parse mode."
));
virDomainFree
(
dom
);
return
false
;
goto
cleanup
;
}
if
(
mode
)
{
int
m
;
/* Accept string or integer, in case server understands newer
* integer than what strings we were compiled with
*/
if
((
m
=
virDomainNumatuneMemModeTypeFromString
(
mode
))
<
0
&&
virStrToLong_i
(
mode
,
NULL
,
0
,
&
m
)
<
0
)
{
vshError
(
ctl
,
_
(
"Invalid mode: %s"
),
mode
);
goto
cleanup
;
}
if
(
virTypedParamsAddInt
(
&
params
,
&
nparams
,
&
maxparams
,
VIR_DOMAIN_NUMA_MODE
,
m
)
<
0
)
goto
save_error
;
}
if
(
mode
)
nparams
++
;
if
(
nparams
==
0
)
{
/* get the number of numa parameters */
...
...
@@ -7381,56 +7396,23 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd)
VIR_FREE
(
str
);
}
}
ret
=
true
;
}
else
{
/* set the numa parameters */
params
=
vshCalloc
(
ctl
,
nparams
,
sizeof
(
*
params
));
for
(
i
=
0
;
i
<
nparams
;
i
++
)
{
temp
=
&
params
[
i
];
/*
* Some magic here, this is used to fill the params structure with
* the valid arguments passed, after filling the particular
* argument we purposely make them 0, so on the next pass it goes
* to the next valid argument and so on.
*/
if
(
mode
)
{
/* Accept string or integer, in case server
* understands newer integer than what strings we were
* compiled with */
if
((
temp
->
value
.
i
=
virDomainNumatuneMemModeTypeFromString
(
mode
))
<
0
&&
virStrToLong_i
(
mode
,
NULL
,
0
,
&
temp
->
value
.
i
)
<
0
)
{
vshError
(
ctl
,
_
(
"Invalid mode: %s"
),
mode
);
goto
cleanup
;
}
if
(
!
virStrcpy
(
temp
->
field
,
VIR_DOMAIN_NUMA_MODE
,
sizeof
(
temp
->
field
)))
goto
cleanup
;
temp
->
type
=
VIR_TYPED_PARAM_INT
;
mode
=
NULL
;
}
else
if
(
nodeset
)
{
temp
->
value
.
s
=
vshStrdup
(
ctl
,
nodeset
);
temp
->
type
=
VIR_TYPED_PARAM_STRING
;
if
(
!
virStrcpy
(
temp
->
field
,
VIR_DOMAIN_NUMA_NODESET
,
sizeof
(
temp
->
field
)))
goto
cleanup
;
nodeset
=
NULL
;
}
}
if
(
virDomainSetNumaParameters
(
dom
,
params
,
nparams
,
flags
)
!=
0
)
vshError
(
ctl
,
"%s"
,
_
(
"Unable to change numa parameters"
));
else
ret
=
true
;
goto
error
;
}
cleanup:
virTypedParameterArrayClear
(
params
,
nparams
);
VIR_FREE
(
params
);
ret
=
true
;
cleanup:
virTypedParamsFree
(
params
,
nparams
);
virDomainFree
(
dom
);
return
ret
;
save_error:
vshSaveLibvirtError
();
error:
vshError
(
ctl
,
"%s"
,
_
(
"Unable to change numa parameters"
));
goto
cleanup
;
}
/*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录