Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
dcc85c60
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看板
提交
dcc85c60
编写于
2月 14, 2014
作者:
T
Thorsten Behrens
提交者:
Michal Privoznik
2月 20, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement lxcDomainBlockStats* for lxc driver
Adds lxcDomainBlockStatsFlags and lxcDomainBlockStats functions.
上级
4b3b2f6c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
195 addition
and
0 deletion
+195
-0
src/lxc/lxc_driver.c
src/lxc/lxc_driver.c
+195
-0
未找到文件。
src/lxc/lxc_driver.c
浏览文件 @
dcc85c60
...
...
@@ -76,6 +76,7 @@
#define LXC_NB_MEM_PARAM 3
#define LXC_NB_DOMAIN_BLOCK_STAT_PARAM 4
static
int
lxcStateInitialize
(
bool
privileged
,
...
...
@@ -2229,6 +2230,198 @@ lxcDomainMergeBlkioDevice(virBlkioDevicePtr *dest_array,
}
static
int
lxcDomainBlockStats
(
virDomainPtr
dom
,
const
char
*
path
,
struct
_virDomainBlockStats
*
stats
)
{
int
ret
=
-
1
,
idx
;
virDomainObjPtr
vm
;
virDomainDiskDefPtr
disk
=
NULL
;
virLXCDomainObjPrivatePtr
priv
;
if
(
!
(
vm
=
lxcDomObjFromDomain
(
dom
)))
return
ret
;
priv
=
vm
->
privateData
;
if
(
virDomainBlockStatsEnsureACL
(
dom
->
conn
,
vm
->
def
)
<
0
)
goto
cleanup
;
if
(
!
virDomainObjIsActive
(
vm
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"domain is not running"
));
goto
cleanup
;
}
if
(
!
virCgroupHasController
(
priv
->
cgroup
,
VIR_CGROUP_CONTROLLER_BLKIO
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"blkio cgroup isn't mounted"
));
goto
cleanup
;
}
if
(
!*
path
)
{
/* empty path - return entire domain blkstats instead */
ret
=
virCgroupGetBlkioIoServiced
(
priv
->
cgroup
,
&
stats
->
rd_bytes
,
&
stats
->
wr_bytes
,
&
stats
->
rd_req
,
&
stats
->
wr_req
);
goto
cleanup
;
}
if
((
idx
=
virDomainDiskIndexByName
(
vm
->
def
,
path
,
false
))
<
0
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"invalid path: %s"
),
path
);
goto
cleanup
;
}
disk
=
vm
->
def
->
disks
[
idx
];
if
(
!
disk
->
info
.
alias
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"missing disk device alias name for %s"
),
disk
->
dst
);
goto
cleanup
;
}
ret
=
virCgroupGetBlkioIoDeviceServiced
(
priv
->
cgroup
,
disk
->
info
.
alias
,
&
stats
->
rd_bytes
,
&
stats
->
wr_bytes
,
&
stats
->
rd_req
,
&
stats
->
wr_req
);
cleanup:
if
(
vm
)
virObjectUnlock
(
vm
);
return
ret
;
}
static
int
lxcDomainBlockStatsFlags
(
virDomainPtr
dom
,
const
char
*
path
,
virTypedParameterPtr
params
,
int
*
nparams
,
unsigned
int
flags
)
{
int
tmp
,
ret
=
-
1
,
idx
;
virDomainObjPtr
vm
;
virDomainDiskDefPtr
disk
=
NULL
;
virLXCDomainObjPrivatePtr
priv
;
long
long
rd_req
,
rd_bytes
,
wr_req
,
wr_bytes
;
virTypedParameterPtr
param
;
virCheckFlags
(
VIR_TYPED_PARAM_STRING_OKAY
,
-
1
);
/* We don't return strings, and thus trivially support this flag. */
flags
&=
~
VIR_TYPED_PARAM_STRING_OKAY
;
if
(
!
params
&&
!*
nparams
)
{
*
nparams
=
LXC_NB_DOMAIN_BLOCK_STAT_PARAM
;
return
0
;
}
if
(
!
(
vm
=
lxcDomObjFromDomain
(
dom
)))
return
ret
;
priv
=
vm
->
privateData
;
if
(
virDomainBlockStatsFlagsEnsureACL
(
dom
->
conn
,
vm
->
def
)
<
0
)
goto
cleanup
;
if
(
!
virDomainObjIsActive
(
vm
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"domain is not running"
));
goto
cleanup
;
}
if
(
!
virCgroupHasController
(
priv
->
cgroup
,
VIR_CGROUP_CONTROLLER_BLKIO
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"blkio cgroup isn't mounted"
));
goto
cleanup
;
}
if
(
!*
path
)
{
/* empty path - return entire domain blkstats instead */
if
(
virCgroupGetBlkioIoServiced
(
priv
->
cgroup
,
&
rd_bytes
,
&
wr_bytes
,
&
rd_req
,
&
wr_req
)
<
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"domain stats query failed"
));
goto
cleanup
;
}
}
else
{
if
((
idx
=
virDomainDiskIndexByName
(
vm
->
def
,
path
,
false
))
<
0
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"invalid path: %s"
),
path
);
goto
cleanup
;
}
disk
=
vm
->
def
->
disks
[
idx
];
if
(
!
disk
->
info
.
alias
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"missing disk device alias name for %s"
),
disk
->
dst
);
goto
cleanup
;
}
if
(
virCgroupGetBlkioIoDeviceServiced
(
priv
->
cgroup
,
disk
->
info
.
alias
,
&
rd_bytes
,
&
wr_bytes
,
&
rd_req
,
&
wr_req
)
<
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"domain stats query failed"
));
goto
cleanup
;
}
}
tmp
=
0
;
ret
=
-
1
;
if
(
tmp
<
*
nparams
&&
wr_bytes
!=
-
1
)
{
param
=
&
params
[
tmp
];
if
(
virTypedParameterAssign
(
param
,
VIR_DOMAIN_BLOCK_STATS_WRITE_BYTES
,
VIR_TYPED_PARAM_LLONG
,
wr_bytes
)
<
0
)
goto
cleanup
;
tmp
++
;
}
if
(
tmp
<
*
nparams
&&
wr_req
!=
-
1
)
{
param
=
&
params
[
tmp
];
if
(
virTypedParameterAssign
(
param
,
VIR_DOMAIN_BLOCK_STATS_WRITE_REQ
,
VIR_TYPED_PARAM_LLONG
,
wr_req
)
<
0
)
goto
cleanup
;
tmp
++
;
}
if
(
tmp
<
*
nparams
&&
rd_bytes
!=
-
1
)
{
param
=
&
params
[
tmp
];
if
(
virTypedParameterAssign
(
param
,
VIR_DOMAIN_BLOCK_STATS_READ_BYTES
,
VIR_TYPED_PARAM_LLONG
,
rd_bytes
)
<
0
)
goto
cleanup
;
tmp
++
;
}
if
(
tmp
<
*
nparams
&&
rd_req
!=
-
1
)
{
param
=
&
params
[
tmp
];
if
(
virTypedParameterAssign
(
param
,
VIR_DOMAIN_BLOCK_STATS_READ_REQ
,
VIR_TYPED_PARAM_LLONG
,
rd_req
)
<
0
)
goto
cleanup
;
tmp
++
;
}
ret
=
0
;
*
nparams
=
tmp
;
cleanup:
if
(
vm
)
virObjectUnlock
(
vm
);
return
ret
;
}
static
int
lxcDomainSetBlkioParameters
(
virDomainPtr
dom
,
virTypedParameterPtr
params
,
...
...
@@ -5526,6 +5719,8 @@ static virDriver lxcDriver = {
.
domainGetSchedulerParametersFlags
=
lxcDomainGetSchedulerParametersFlags
,
/* 0.9.2 */
.
domainSetSchedulerParameters
=
lxcDomainSetSchedulerParameters
,
/* 0.5.0 */
.
domainSetSchedulerParametersFlags
=
lxcDomainSetSchedulerParametersFlags
,
/* 0.9.2 */
.
domainBlockStats
=
lxcDomainBlockStats
,
/* 1.2.2 */
.
domainBlockStatsFlags
=
lxcDomainBlockStatsFlags
,
/* 1.2.2 */
.
domainInterfaceStats
=
lxcDomainInterfaceStats
,
/* 0.7.3 */
.
domainMemoryStats
=
lxcDomainMemoryStats
,
/* 1.2.2 */
.
nodeGetCPUStats
=
lxcNodeGetCPUStats
,
/* 0.9.3 */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录