Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
0ed4aa44
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,发现更多精彩内容 >>
提交
0ed4aa44
编写于
5月 06, 2011
作者:
C
Cole Robinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lxc: container: Build init cmd before we close stdout
That way we can log the 'init' argv for debugging.
上级
0719c3d6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
16 deletion
+25
-16
src/lxc/lxc_container.c
src/lxc/lxc_container.c
+25
-16
未找到文件。
src/lxc/lxc_container.c
浏览文件 @
0ed4aa44
...
@@ -94,15 +94,14 @@ struct __lxc_child_argv {
...
@@ -94,15 +94,14 @@ struct __lxc_child_argv {
/**
/**
* lxcContainer
ExecInit
:
* lxcContainer
BuildInitCmd
:
* @vmDef: pointer to vm definition structure
* @vmDef: pointer to vm definition structure
*
*
* Exec the container init string. The container init will replace then
* Build a virCommandPtr for launching the container 'init' process
* be running in the current process
*
*
*
Does not return
*
Returns a virCommandPtr
*/
*/
static
int
lxcContainerExecInit
(
virDomainDefPtr
vmDef
)
static
virCommandPtr
lxcContainerBuildInitCmd
(
virDomainDefPtr
vmDef
)
{
{
char
uuidstr
[
VIR_UUID_STRING_BUFLEN
];
char
uuidstr
[
VIR_UUID_STRING_BUFLEN
];
virCommandPtr
cmd
;
virCommandPtr
cmd
;
...
@@ -116,7 +115,7 @@ static int lxcContainerExecInit(virDomainDefPtr vmDef)
...
@@ -116,7 +115,7 @@ static int lxcContainerExecInit(virDomainDefPtr vmDef)
virCommandAddEnvPair
(
cmd
,
"LIBVIRT_LXC_UUID"
,
uuidstr
);
virCommandAddEnvPair
(
cmd
,
"LIBVIRT_LXC_UUID"
,
uuidstr
);
virCommandAddEnvPair
(
cmd
,
"LIBVIRT_LXC_NAME"
,
vmDef
->
name
);
virCommandAddEnvPair
(
cmd
,
"LIBVIRT_LXC_NAME"
,
vmDef
->
name
);
return
virCommandExec
(
cmd
)
;
return
cmd
;
}
}
/**
/**
...
@@ -753,28 +752,34 @@ static int lxcContainerChild( void *data )
...
@@ -753,28 +752,34 @@ static int lxcContainerChild( void *data )
lxc_child_argv_t
*
argv
=
data
;
lxc_child_argv_t
*
argv
=
data
;
virDomainDefPtr
vmDef
=
argv
->
config
;
virDomainDefPtr
vmDef
=
argv
->
config
;
int
ttyfd
;
int
ttyfd
;
int
ret
=
-
1
;
char
*
ttyPath
;
char
*
ttyPath
;
virDomainFSDefPtr
root
;
virDomainFSDefPtr
root
;
virCommandPtr
cmd
=
NULL
;
if
(
NULL
==
vmDef
)
{
if
(
NULL
==
vmDef
)
{
lxcError
(
VIR_ERR_INTERNAL_ERROR
,
lxcError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"lxcChild() passed invalid vm definition"
));
"%s"
,
_
(
"lxcChild() passed invalid vm definition"
));
return
-
1
;
goto
cleanup
;
}
}
cmd
=
lxcContainerBuildInitCmd
(
vmDef
);
virCommandWriteArgLog
(
cmd
,
1
);
root
=
virDomainGetRootFilesystem
(
vmDef
);
root
=
virDomainGetRootFilesystem
(
vmDef
);
if
(
root
)
{
if
(
root
)
{
if
(
virAsprintf
(
&
ttyPath
,
"%s%s"
,
root
->
src
,
argv
->
ttyPath
)
<
0
)
{
if
(
virAsprintf
(
&
ttyPath
,
"%s%s"
,
root
->
src
,
argv
->
ttyPath
)
<
0
)
{
virReportOOMError
();
virReportOOMError
();
return
-
1
;
goto
cleanup
;
}
}
}
else
{
}
else
{
if
(
!
(
ttyPath
=
strdup
(
argv
->
ttyPath
)))
{
if
(
!
(
ttyPath
=
strdup
(
argv
->
ttyPath
)))
{
virReportOOMError
();
virReportOOMError
();
return
-
1
;
goto
cleanup
;
}
}
}
}
VIR_DEBUG
(
"Container TTY path: %s"
,
ttyPath
);
ttyfd
=
open
(
ttyPath
,
O_RDWR
|
O_NOCTTY
);
ttyfd
=
open
(
ttyPath
,
O_RDWR
|
O_NOCTTY
);
if
(
ttyfd
<
0
)
{
if
(
ttyfd
<
0
)
{
...
@@ -782,34 +787,38 @@ static int lxcContainerChild( void *data )
...
@@ -782,34 +787,38 @@ static int lxcContainerChild( void *data )
_
(
"Failed to open tty %s"
),
_
(
"Failed to open tty %s"
),
ttyPath
);
ttyPath
);
VIR_FREE
(
ttyPath
);
VIR_FREE
(
ttyPath
);
return
-
1
;
goto
cleanup
;
}
}
VIR_FREE
(
ttyPath
);
VIR_FREE
(
ttyPath
);
if
(
lxcContainerSetStdio
(
argv
->
monitor
,
ttyfd
)
<
0
)
{
if
(
lxcContainerSetStdio
(
argv
->
monitor
,
ttyfd
)
<
0
)
{
VIR_FORCE_CLOSE
(
ttyfd
);
VIR_FORCE_CLOSE
(
ttyfd
);
return
-
1
;
goto
cleanup
;
}
}
VIR_FORCE_CLOSE
(
ttyfd
);
VIR_FORCE_CLOSE
(
ttyfd
);
if
(
lxcContainerSetupMounts
(
vmDef
,
root
)
<
0
)
if
(
lxcContainerSetupMounts
(
vmDef
,
root
)
<
0
)
return
-
1
;
goto
cleanup
;
/* Wait for interface devices to show up */
/* Wait for interface devices to show up */
if
(
lxcContainerWaitForContinue
(
argv
->
monitor
)
<
0
)
if
(
lxcContainerWaitForContinue
(
argv
->
monitor
)
<
0
)
return
-
1
;
goto
cleanup
;
/* rename and enable interfaces */
/* rename and enable interfaces */
if
(
lxcContainerRenameAndEnableInterfaces
(
argv
->
nveths
,
if
(
lxcContainerRenameAndEnableInterfaces
(
argv
->
nveths
,
argv
->
veths
)
<
0
)
argv
->
veths
)
<
0
)
return
-
1
;
goto
cleanup
;
/* drop a set of root capabilities */
/* drop a set of root capabilities */
if
(
lxcContainerDropCapabilities
()
<
0
)
if
(
lxcContainerDropCapabilities
()
<
0
)
return
-
1
;
goto
cleanup
;
/* this function will only return if an error occured */
/* this function will only return if an error occured */
return
lxcContainerExecInit
(
vmDef
);
ret
=
virCommandExec
(
cmd
);
cleanup:
virCommandFree
(
cmd
);
return
ret
;
}
}
static
int
userns_supported
(
void
)
static
int
userns_supported
(
void
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录