Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
773f3bd3
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看板
提交
773f3bd3
编写于
2月 12, 2016
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virsh: cpupin: Extract getter code into a separate function
上级
783584b5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
75 addition
and
54 deletion
+75
-54
tools/virsh-domain.c
tools/virsh-domain.c
+75
-54
未找到文件。
tools/virsh-domain.c
浏览文件 @
773f3bd3
...
...
@@ -6374,6 +6374,68 @@ virshPrintPinInfo(vshControl *ctl,
return
true
;
}
static
bool
virshVcpuPinQuery
(
vshControl
*
ctl
,
virDomainPtr
dom
,
unsigned
int
vcpu
,
bool
got_vcpu
,
int
maxcpu
,
unsigned
int
flags
)
{
unsigned
char
*
cpumap
=
NULL
;
int
cpumaplen
;
size_t
i
;
int
ncpus
;
bool
ret
=
false
;
if
((
ncpus
=
virshCPUCountCollect
(
ctl
,
dom
,
flags
,
true
))
<
0
)
{
if
(
ncpus
==
-
1
)
{
if
(
flags
&
VIR_DOMAIN_AFFECT_LIVE
)
vshError
(
ctl
,
"%s"
,
_
(
"cannot get vcpupin for offline domain"
));
else
vshError
(
ctl
,
"%s"
,
_
(
"cannot get vcpupin for transient domain"
));
}
return
false
;
}
if
(
got_vcpu
&&
vcpu
>=
ncpus
)
{
if
(
flags
&
VIR_DOMAIN_AFFECT_LIVE
||
(
!
(
flags
&
VIR_DOMAIN_AFFECT_CONFIG
)
&&
virDomainIsActive
(
dom
)
==
1
))
vshError
(
ctl
,
_
(
"vcpu %d is out of range of live cpu count %d"
),
vcpu
,
ncpus
);
else
vshError
(
ctl
,
_
(
"vcpu %d is out of range of persistent cpu count %d"
),
vcpu
,
ncpus
);
return
false
;
}
cpumaplen
=
VIR_CPU_MAPLEN
(
maxcpu
);
cpumap
=
vshMalloc
(
ctl
,
ncpus
*
cpumaplen
);
if
((
ncpus
=
virDomainGetVcpuPinInfo
(
dom
,
ncpus
,
cpumap
,
cpumaplen
,
flags
))
>=
0
)
{
vshPrintExtra
(
ctl
,
"%s %s
\n
"
,
_
(
"VCPU:"
),
_
(
"CPU Affinity"
));
vshPrintExtra
(
ctl
,
"----------------------------------
\n
"
);
for
(
i
=
0
;
i
<
ncpus
;
i
++
)
{
if
(
got_vcpu
&&
i
!=
vcpu
)
continue
;
vshPrint
(
ctl
,
"%4zu: "
,
i
);
ret
=
virshPrintPinInfo
(
ctl
,
VIR_GET_CPUMAP
(
cpumap
,
cpumaplen
,
i
),
cpumaplen
);
vshPrint
(
ctl
,
"
\n
"
);
if
(
!
ret
)
break
;
}
}
return
ret
;
}
static
unsigned
char
*
virshParseCPUList
(
vshControl
*
ctl
,
int
*
cpumaplen
,
const
char
*
cpulist
,
int
maxcpu
)
...
...
@@ -6416,8 +6478,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
bool
ret
=
false
;
unsigned
char
*
cpumap
=
NULL
;
int
cpumaplen
;
int
maxcpu
,
ncpus
;
size_t
i
;
int
maxcpu
;
bool
config
=
vshCommandOptBool
(
cmd
,
"config"
);
bool
live
=
vshCommandOptBool
(
cmd
,
"live"
);
bool
current
=
vshCommandOptBool
(
cmd
,
"current"
);
...
...
@@ -6456,63 +6517,23 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
/* Query mode: show CPU affinity information then exit.*/
if
(
!
cpulist
)
{
if
((
ncpus
=
virshCPUCountCollect
(
ctl
,
dom
,
flags
,
true
))
<
0
)
{
if
(
ncpus
==
-
1
)
{
if
(
flags
&
VIR_DOMAIN_AFFECT_LIVE
)
vshError
(
ctl
,
"%s"
,
_
(
"cannot get vcpupin for offline domain"
));
else
vshError
(
ctl
,
"%s"
,
_
(
"cannot get vcpupin for transient domain"
));
}
goto
cleanup
;
}
if
(
got_vcpu
&&
vcpu
>=
ncpus
)
{
if
(
flags
&
VIR_DOMAIN_AFFECT_LIVE
||
(
!
(
flags
&
VIR_DOMAIN_AFFECT_CONFIG
)
&&
virDomainIsActive
(
dom
)
==
1
))
vshError
(
ctl
,
_
(
"vcpu %d is out of range of live cpu count %d"
),
vcpu
,
ncpus
);
else
vshError
(
ctl
,
_
(
"vcpu %d is out of range of persistent cpu count %d"
),
vcpu
,
ncpus
);
goto
cleanup
;
}
ret
=
virshVcpuPinQuery
(
ctl
,
dom
,
vcpu
,
got_vcpu
,
maxcpu
,
flags
);
goto
cleanup
;
}
cpumaplen
=
VIR_CPU_MAPLEN
(
maxcpu
);
cpumap
=
vshMalloc
(
ctl
,
ncpus
*
cpumaplen
);
if
((
ncpus
=
virDomainGetVcpuPinInfo
(
dom
,
ncpus
,
cpumap
,
cpumaplen
,
flags
))
>=
0
)
{
vshPrintExtra
(
ctl
,
"%s %s
\n
"
,
_
(
"VCPU:"
),
_
(
"CPU Affinity"
));
vshPrintExtra
(
ctl
,
"----------------------------------
\n
"
);
for
(
i
=
0
;
i
<
ncpus
;
i
++
)
{
if
(
got_vcpu
&&
i
!=
vcpu
)
continue
;
/* Pin mode: pinning specified vcpu to specified physical cpus*/
if
(
!
(
cpumap
=
virshParseCPUList
(
ctl
,
&
cpumaplen
,
cpulist
,
maxcpu
)))
goto
cleanup
;
vshPrint
(
ctl
,
"%4zu: "
,
i
);
ret
=
virshPrintPinInfo
(
ctl
,
VIR_GET_CPUMAP
(
cpumap
,
cpumaplen
,
i
),
cpumaplen
);
vshPrint
(
ctl
,
"
\n
"
);
if
(
!
ret
)
break
;
}
}
/* use old API without any explicit flags */
if
(
flags
==
VIR_DOMAIN_AFFECT_CURRENT
&&
!
current
)
{
if
(
virDomainPinVcpu
(
dom
,
vcpu
,
cpumap
,
cpumaplen
)
!=
0
)
goto
cleanup
;
}
else
{
/* Pin mode: pinning specified vcpu to specified physical cpus*/
if
(
!
(
cpumap
=
virshParseCPUList
(
ctl
,
&
cpumaplen
,
cpulist
,
maxcpu
)))
if
(
virDomainPinVcpuFlags
(
dom
,
vcpu
,
cpumap
,
cpumaplen
,
flags
)
!=
0
)
goto
cleanup
;
/* use old API without any explicit flags */
if
(
flags
==
VIR_DOMAIN_AFFECT_CURRENT
&&
!
current
)
{
if
(
virDomainPinVcpu
(
dom
,
vcpu
,
cpumap
,
cpumaplen
)
!=
0
)
goto
cleanup
;
}
else
{
if
(
virDomainPinVcpuFlags
(
dom
,
vcpu
,
cpumap
,
cpumaplen
,
flags
)
!=
0
)
goto
cleanup
;
}
ret
=
true
;
}
ret
=
true
;
cleanup:
VIR_FREE
(
cpumap
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录