Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
4275be68
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看板
提交
4275be68
编写于
1月 11, 2009
作者:
G
Guido Günther
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
split out opening of the qemu logfile
上级
261c3a8f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
53 addition
and
36 deletion
+53
-36
ChangeLog
ChangeLog
+6
-0
src/qemu_driver.c
src/qemu_driver.c
+47
-36
未找到文件。
ChangeLog
浏览文件 @
4275be68
Sun Jan 11 12:16:44 CET 2009 Guido Günther <agx@sigxcpu.org>
split out opening of the qemu logfile
* src/qemu_driver.c (qemudLogFD): new function
(qemudStartVMDaemon): call qemudLogFD
Fri Jan 9 18:29:11 GMT 2009 John Levon <levon@movementarian.org>
* src/logging.h: fix non-debug compile
...
...
src/qemu_driver.c
浏览文件 @
4275be68
...
...
@@ -143,6 +143,52 @@ static int qemudMonitorCommand (const virDomainObjPtr vm,
static
struct
qemud_driver
*
qemu_driver
=
NULL
;
static
int
qemudLogFD
(
virConnectPtr
conn
,
const
char
*
logDir
,
const
char
*
name
)
{
char
logfile
[
PATH_MAX
];
mode_t
logmode
;
uid_t
uid
=
geteuid
();
int
fd
=
-
1
;
if
((
strlen
(
logDir
)
+
/* path */
1
+
/* Separator */
strlen
(
name
)
+
/* basename */
4
+
/* suffix .log */
1
/* NULL */
)
>
PATH_MAX
)
{
qemudReportError
(
conn
,
NULL
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"config file path too long: %s/%s.log"
),
logDir
,
name
);
return
-
1
;
}
strcpy
(
logfile
,
logDir
);
strcat
(
logfile
,
"/"
);
strcat
(
logfile
,
name
);
strcat
(
logfile
,
".log"
);
logmode
=
O_CREAT
|
O_WRONLY
;
if
(
uid
!=
0
)
logmode
|=
O_TRUNC
;
else
logmode
|=
O_APPEND
;
if
((
fd
=
open
(
logfile
,
logmode
,
S_IRUSR
|
S_IWUSR
))
<
0
)
{
qemudReportError
(
conn
,
NULL
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"failed to create logfile %s: %s"
),
logfile
,
strerror
(
errno
));
return
-
1
;
}
if
(
qemudSetCloseExec
(
fd
)
<
0
)
{
qemudReportError
(
conn
,
NULL
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Unable to set VM logfile close-on-exec flag %s"
),
strerror
(
errno
));
close
(
fd
);
return
-
1
;
}
return
fd
;
}
static
void
qemudAutostartConfigs
(
struct
qemud_driver
*
driver
)
{
unsigned
int
i
;
...
...
@@ -892,15 +938,12 @@ static int qemudStartVMDaemon(virConnectPtr conn,
const
char
**
argv
=
NULL
,
**
tmp
;
const
char
**
progenv
=
NULL
;
int
i
,
ret
;
char
logfile
[
PATH_MAX
];
struct
stat
sb
;
int
*
tapfds
=
NULL
;
int
ntapfds
=
0
;
unsigned
int
qemuCmdFlags
;
fd_set
keepfd
;
const
char
*
emulator
;
uid_t
uid
=
geteuid
();
mode_t
logmode
;
FD_ZERO
(
&
keepfd
);
...
...
@@ -922,21 +965,6 @@ static int qemudStartVMDaemon(virConnectPtr conn,
vm
->
def
->
graphics
->
data
.
vnc
.
port
=
port
;
}
if
((
strlen
(
driver
->
logDir
)
+
/* path */
1
+
/* Separator */
strlen
(
vm
->
def
->
name
)
+
/* basename */
4
+
/* suffix .log */
1
/* NULL */
)
>
PATH_MAX
)
{
qemudReportError
(
conn
,
NULL
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"config file path too long: %s/%s.log"
),
driver
->
logDir
,
vm
->
def
->
name
);
return
-
1
;
}
strcpy
(
logfile
,
driver
->
logDir
);
strcat
(
logfile
,
"/"
);
strcat
(
logfile
,
vm
->
def
->
name
);
strcat
(
logfile
,
".log"
);
if
(
virFileMakePath
(
driver
->
logDir
)
<
0
)
{
qemudReportError
(
conn
,
NULL
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"cannot create log directory %s: %s"
),
...
...
@@ -944,25 +972,8 @@ static int qemudStartVMDaemon(virConnectPtr conn,
return
-
1
;
}
logmode
=
O_CREAT
|
O_WRONLY
;
if
(
uid
!=
0
)
logmode
|=
O_TRUNC
;
else
logmode
|=
O_APPEND
;
if
((
vm
->
logfile
=
open
(
logfile
,
logmode
,
S_IRUSR
|
S_IWUSR
))
<
0
)
{
qemudReportError
(
conn
,
NULL
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"failed to create logfile %s: %s"
),
logfile
,
strerror
(
errno
));
if
((
vm
->
logfile
=
qemudLogFD
(
conn
,
driver
->
logDir
,
vm
->
def
->
name
))
<
0
)
return
-
1
;
}
if
(
qemudSetCloseExec
(
vm
->
logfile
)
<
0
)
{
qemudReportError
(
conn
,
NULL
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Unable to set VM logfile close-on-exec flag %s"
),
strerror
(
errno
));
close
(
vm
->
logfile
);
vm
->
logfile
=
-
1
;
return
-
1
;
}
emulator
=
vm
->
def
->
emulator
;
if
(
!
emulator
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录