Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
8049357d
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看板
提交
8049357d
编写于
5月 20, 2008
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid initializing driver if pidfie is claimed. Always claim pidfile as root
上级
1290f502
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
48 deletion
+52
-48
ChangeLog
ChangeLog
+7
-0
qemud/qemud.c
qemud/qemud.c
+45
-48
未找到文件。
ChangeLog
浏览文件 @
8049357d
Tue May 20 12:15:29 EST 2008 Daniel P. Berrange <berrange@redhat.com>
* qemud/qemud.c: Re-factor daemon startup code to avoid
initializing the drivers if the pidfile is already claimed
by another daemon instance. Always claim pidfile when running
as root, even in non-daemon mode
Tue May 20 17:53:29 CEST 2008 Daniel Veillard <veillard@redhat.com>
Tue May 20 17:53:29 CEST 2008 Daniel Veillard <veillard@redhat.com>
* docs/remote.html docs/remote.html.in: patch from Kenneth Nagin
* docs/remote.html docs/remote.html.in: patch from Kenneth Nagin
...
...
qemud/qemud.c
浏览文件 @
8049357d
...
@@ -2143,6 +2143,26 @@ int main(int argc, char **argv) {
...
@@ -2143,6 +2143,26 @@ int main(int argc, char **argv) {
}
}
}
}
if
(
godaemon
)
{
openlog
(
"libvirtd"
,
0
,
0
);
if
(
qemudGoDaemon
()
<
0
)
{
qemudLog
(
QEMUD_ERR
,
_
(
"Failed to fork as daemon: %s"
),
strerror
(
errno
));
goto
error1
;
}
}
/* If running as root and no PID file is set, use the default */
if
(
pid_file
==
NULL
&&
getuid
()
==
0
&&
REMOTE_PID_FILE
[
0
]
!=
'\0'
)
pid_file
=
REMOTE_PID_FILE
;
/* If we have a pidfile set, claim it now, exiting if already taken */
if
(
pid_file
!=
NULL
&&
qemudWritePidFile
(
pid_file
)
<
0
)
goto
error1
;
if
(
pipe
(
sigpipe
)
<
0
||
if
(
pipe
(
sigpipe
)
<
0
||
qemudSetNonBlock
(
sigpipe
[
0
])
<
0
||
qemudSetNonBlock
(
sigpipe
[
0
])
<
0
||
qemudSetNonBlock
(
sigpipe
[
1
])
<
0
||
qemudSetNonBlock
(
sigpipe
[
1
])
<
0
||
...
@@ -2150,24 +2170,34 @@ int main(int argc, char **argv) {
...
@@ -2150,24 +2170,34 @@ int main(int argc, char **argv) {
qemudSetCloseExec
(
sigpipe
[
1
])
<
0
)
{
qemudSetCloseExec
(
sigpipe
[
1
])
<
0
)
{
qemudLog
(
QEMUD_ERR
,
_
(
"Failed to create pipe: %s"
),
qemudLog
(
QEMUD_ERR
,
_
(
"Failed to create pipe: %s"
),
strerror
(
errno
));
strerror
(
errno
));
goto
error
1
;
goto
error
2
;
}
}
sigwrite
=
sigpipe
[
1
];
sigwrite
=
sigpipe
[
1
];
sig_action
.
sa_sigaction
=
sig_handler
;
sig_action
.
sa_flags
=
SA_SIGINFO
;
sigemptyset
(
&
sig_action
.
sa_mask
);
sigaction
(
SIGHUP
,
&
sig_action
,
NULL
);
sigaction
(
SIGINT
,
&
sig_action
,
NULL
);
sigaction
(
SIGQUIT
,
&
sig_action
,
NULL
);
sigaction
(
SIGTERM
,
&
sig_action
,
NULL
);
sigaction
(
SIGCHLD
,
&
sig_action
,
NULL
);
sig_action
.
sa_handler
=
SIG_IGN
;
sigaction
(
SIGPIPE
,
&
sig_action
,
NULL
);
if
(
!
(
server
=
qemudInitialize
(
sigpipe
[
0
])))
{
if
(
!
(
server
=
qemudInitialize
(
sigpipe
[
0
])))
{
ret
=
2
;
ret
=
2
;
goto
error
1
;
goto
error
2
;
}
}
/* Read the config file (if it exists). */
/* Read the config file (if it exists). */
if
(
remoteReadConfigFile
(
server
,
remote_config_file
)
<
0
)
if
(
remoteReadConfigFile
(
server
,
remote_config_file
)
<
0
)
goto
error
1
;
goto
error
2
;
/* Change the group ownership of /var/run/libvirt to unix_sock_gid */
/* Change the group ownership of /var/run/libvirt to unix_sock_gid */
if
(
getuid
()
!=
0
)
{
if
(
getuid
()
==
0
)
{
qemudLog
(
QEMUD_WARN
,
"%s"
,
_
(
"Cannot set group ownership when not running as root"
));
}
else
{
const
char
*
sockdirname
=
LOCAL_STATE_DIR
"/run/libvirt"
;
const
char
*
sockdirname
=
LOCAL_STATE_DIR
"/run/libvirt"
;
if
(
chown
(
sockdirname
,
-
1
,
unix_sock_gid
)
<
0
)
if
(
chown
(
sockdirname
,
-
1
,
unix_sock_gid
)
<
0
)
...
@@ -2175,37 +2205,6 @@ int main(int argc, char **argv) {
...
@@ -2175,37 +2205,6 @@ int main(int argc, char **argv) {
sockdirname
);
sockdirname
);
}
}
if
(
godaemon
)
{
openlog
(
"libvirtd"
,
0
,
0
);
if
(
qemudGoDaemon
()
<
0
)
{
qemudLog
(
QEMUD_ERR
,
_
(
"Failed to fork as daemon: %s"
),
strerror
(
errno
));
goto
error1
;
}
/* Choose the name of the PID file. */
if
(
!
pid_file
)
{
if
(
REMOTE_PID_FILE
[
0
]
!=
'\0'
)
pid_file
=
REMOTE_PID_FILE
;
}
if
(
pid_file
&&
qemudWritePidFile
(
pid_file
)
<
0
)
goto
error1
;
}
sig_action
.
sa_sigaction
=
sig_handler
;
sig_action
.
sa_flags
=
SA_SIGINFO
;
sigemptyset
(
&
sig_action
.
sa_mask
);
sigaction
(
SIGHUP
,
&
sig_action
,
NULL
);
sigaction
(
SIGINT
,
&
sig_action
,
NULL
);
sigaction
(
SIGQUIT
,
&
sig_action
,
NULL
);
sigaction
(
SIGTERM
,
&
sig_action
,
NULL
);
sigaction
(
SIGCHLD
,
&
sig_action
,
NULL
);
sig_action
.
sa_handler
=
SIG_IGN
;
sigaction
(
SIGPIPE
,
&
sig_action
,
NULL
);
if
(
virEventAddHandleImpl
(
sigpipe
[
0
],
if
(
virEventAddHandleImpl
(
sigpipe
[
0
],
POLLIN
,
POLLIN
,
qemudDispatchSignalEvent
,
qemudDispatchSignalEvent
,
...
@@ -2223,19 +2222,17 @@ int main(int argc, char **argv) {
...
@@ -2223,19 +2222,17 @@ int main(int argc, char **argv) {
qemudRunLoop
(
server
);
qemudRunLoop
(
server
);
close
(
sigwrite
);
if
(
godaemon
)
closelog
();
ret
=
0
;
ret
=
0
;
error2:
error2:
if
(
godaemon
&&
pid_file
)
unlink
(
pid_file
);
error1:
if
(
server
)
if
(
server
)
qemudCleanup
(
server
);
qemudCleanup
(
server
);
if
(
pid_file
)
unlink
(
pid_file
);
close
(
sigwrite
);
error1:
if
(
godaemon
)
closelog
();
return
ret
;
return
ret
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录