Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
2b15f2a1
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看板
提交
2b15f2a1
编写于
2月 16, 2016
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: cgroup: Split up qemuSetImageCgroupInternal
Separate the Teardown and Setup code paths into separate helpers.
上级
5dd610d0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
24 deletion
+36
-24
src/qemu/qemu_cgroup.c
src/qemu/qemu_cgroup.c
+36
-24
未找到文件。
src/qemu/qemu_cgroup.c
浏览文件 @
2b15f2a1
...
...
@@ -53,10 +53,9 @@ static const char *const defaultDeviceACL[] = {
#define DEVICE_SND_MAJOR 116
static
int
qemuSetImageCgroupInternal
(
virDomainObjPtr
vm
,
virStorageSourcePtr
src
,
bool
deny
,
bool
forceReadonly
)
qemuSetupImageCgroupInternal
(
virDomainObjPtr
vm
,
virStorageSourcePtr
src
,
bool
forceReadonly
)
{
qemuDomainObjPrivatePtr
priv
=
vm
->
privateData
;
int
perms
=
VIR_CGROUP_DEVICE_READ
;
...
...
@@ -72,25 +71,15 @@ qemuSetImageCgroupInternal(virDomainObjPtr vm,
return
0
;
}
if
(
deny
)
{
perms
|=
VIR_CGROUP_DEVICE_WRITE
|
VIR_CGROUP_DEVICE_MKNOD
;
if
(
!
src
->
readonly
&&
!
forceReadonly
)
perms
|=
VIR_CGROUP_DEVICE_WRITE
;
VIR_DEBUG
(
"Deny path %s"
,
src
->
path
);
VIR_DEBUG
(
"Allow path %s, perms: %s"
,
src
->
path
,
virCgroupGetDevicePermsString
(
perms
));
ret
=
virCgroupDenyDevicePath
(
priv
->
cgroup
,
src
->
path
,
perms
,
true
);
}
else
{
if
(
!
src
->
readonly
&&
!
forceReadonly
)
perms
|=
VIR_CGROUP_DEVICE_WRITE
;
ret
=
virCgroupAllowDevicePath
(
priv
->
cgroup
,
src
->
path
,
perms
,
true
);
VIR_DEBUG
(
"Allow path %s, perms: %s"
,
src
->
path
,
virCgroupGetDevicePermsString
(
perms
));
ret
=
virCgroupAllowDevicePath
(
priv
->
cgroup
,
src
->
path
,
perms
,
true
);
}
virDomainAuditCgroupPath
(
vm
,
priv
->
cgroup
,
deny
?
"deny"
:
"allow"
,
src
->
path
,
virDomainAuditCgroupPath
(
vm
,
priv
->
cgroup
,
"allow"
,
src
->
path
,
virCgroupGetDevicePermsString
(
perms
),
ret
==
0
);
...
...
@@ -102,7 +91,7 @@ int
qemuSetupImageCgroup
(
virDomainObjPtr
vm
,
virStorageSourcePtr
src
)
{
return
qemuSet
ImageCgroupInternal
(
vm
,
src
,
false
,
false
);
return
qemuSet
upImageCgroupInternal
(
vm
,
src
,
false
);
}
...
...
@@ -110,7 +99,30 @@ int
qemuTeardownImageCgroup
(
virDomainObjPtr
vm
,
virStorageSourcePtr
src
)
{
return
qemuSetImageCgroupInternal
(
vm
,
src
,
true
,
false
);
qemuDomainObjPrivatePtr
priv
=
vm
->
privateData
;
int
perms
=
VIR_CGROUP_DEVICE_READ
|
VIR_CGROUP_DEVICE_WRITE
|
VIR_CGROUP_DEVICE_MKNOD
;
int
ret
;
if
(
!
virCgroupHasController
(
priv
->
cgroup
,
VIR_CGROUP_CONTROLLER_DEVICES
))
return
0
;
if
(
!
src
->
path
||
!
virStorageSourceIsLocalStorage
(
src
))
{
VIR_DEBUG
(
"Not updating cgroups for disk path '%s', type: %s"
,
NULLSTR
(
src
->
path
),
virStorageTypeToString
(
src
->
type
));
return
0
;
}
VIR_DEBUG
(
"Deny path %s"
,
src
->
path
);
ret
=
virCgroupDenyDevicePath
(
priv
->
cgroup
,
src
->
path
,
perms
,
true
);
virDomainAuditCgroupPath
(
vm
,
priv
->
cgroup
,
"deny"
,
src
->
path
,
virCgroupGetDevicePermsString
(
perms
),
ret
==
0
);
return
ret
;
}
...
...
@@ -122,7 +134,7 @@ qemuSetupDiskCgroup(virDomainObjPtr vm,
bool
forceReadonly
=
false
;
for
(
next
=
disk
->
src
;
next
;
next
=
next
->
backingStore
)
{
if
(
qemuSet
ImageCgroupInternal
(
vm
,
next
,
false
,
forceReadonly
)
<
0
)
if
(
qemuSet
upImageCgroupInternal
(
vm
,
next
,
forceReadonly
)
<
0
)
return
-
1
;
/* setup only the top level image for read-write */
...
...
@@ -140,7 +152,7 @@ qemuTeardownDiskCgroup(virDomainObjPtr vm,
virStorageSourcePtr
next
;
for
(
next
=
disk
->
src
;
next
;
next
=
next
->
backingStore
)
{
if
(
qemu
SetImageCgroupInternal
(
vm
,
next
,
true
,
false
)
<
0
)
if
(
qemu
TeardownImageCgroup
(
vm
,
next
)
<
0
)
return
-
1
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录