Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
6efe591e
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看板
提交
6efe591e
编写于
2月 13, 2009
作者:
G
Guido Günther
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
usleep to wait for domain logfile to fill up
上级
e9c920ba
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
66 addition
and
8 deletion
+66
-8
ChangeLog
ChangeLog
+9
-0
src/qemu_driver.c
src/qemu_driver.c
+57
-8
未找到文件。
ChangeLog
浏览文件 @
6efe591e
Fri Feb 13 12:31:03 CET 2009 Guido Günther <agx@sigxcpu.org>
usleep to wait for domain logfile to fill up
* src/qemu_driver.c (qemudReadLogOutput): New function to read from
domain log file.
(qemudWaitForMonitor): Use it.
(qemudOpenMonitor): Pass timout in seconds.
(qemudReadMonitorOutput): Convert timout to milliseconds.
Wed Feb 11 21:30:47 CET 2009 Guido Günther <agx@sigxcpu.org>
Wed Feb 11 21:30:47 CET 2009 Guido Günther <agx@sigxcpu.org>
* src/qemu_driver.c (qemudStartVMDaemon): fix return status when
* src/qemu_driver.c (qemudStartVMDaemon): fix return status when
...
...
src/qemu_driver.c
浏览文件 @
6efe591e
...
@@ -601,6 +601,7 @@ qemudReadMonitorOutput(virConnectPtr conn,
...
@@ -601,6 +601,7 @@ qemudReadMonitorOutput(virConnectPtr conn,
{
{
int
got
=
0
;
int
got
=
0
;
buf
[
0
]
=
'\0'
;
buf
[
0
]
=
'\0'
;
timeout
*=
1000
;
/* poll wants milli seconds */
/* Consume & discard the initial greeting */
/* Consume & discard the initial greeting */
while
(
got
<
(
buflen
-
1
))
{
while
(
got
<
(
buflen
-
1
))
{
...
@@ -662,6 +663,56 @@ qemudReadMonitorOutput(virConnectPtr conn,
...
@@ -662,6 +663,56 @@ qemudReadMonitorOutput(virConnectPtr conn,
}
}
/*
* Returns -1 for error, 0 on success
*/
static
int
qemudReadLogOutput
(
virConnectPtr
conn
,
virDomainObjPtr
vm
,
int
fd
,
char
*
buf
,
int
buflen
,
qemudHandlerMonitorOutput
func
,
const
char
*
what
,
int
timeout
)
{
int
got
=
0
;
int
ret
;
int
retries
=
timeout
*
10
;
buf
[
0
]
=
'\0'
;
while
(
retries
)
{
while
((
ret
=
read
(
fd
,
buf
+
got
,
buflen
-
got
-
1
))
>
0
)
{
got
+=
ret
;
buf
[
got
]
=
'\0'
;
if
((
buflen
-
got
-
1
)
==
0
)
{
qemudReportError
(
conn
,
NULL
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Out of space while reading %s log output"
),
what
);
return
-
1
;
}
}
if
(
ret
<
0
&&
errno
!=
EINTR
)
{
virReportSystemError
(
conn
,
errno
,
_
(
"Failure while reading %s log output"
),
what
);
return
-
1
;
}
ret
=
func
(
conn
,
vm
,
buf
,
fd
);
if
(
ret
<=
0
)
return
ret
;
usleep
(
100
*
1000
);
retries
--
;
}
if
(
retries
==
0
)
qemudReportError
(
conn
,
NULL
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Timed out while reading %s log output"
),
what
);
return
-
1
;
}
static
int
static
int
qemudCheckMonitorPrompt
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
qemudCheckMonitorPrompt
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virDomainObjPtr
vm
,
virDomainObjPtr
vm
,
...
@@ -706,7 +757,7 @@ static int qemudOpenMonitor(virConnectPtr conn,
...
@@ -706,7 +757,7 @@ static int qemudOpenMonitor(virConnectPtr conn,
vm
,
monfd
,
vm
,
monfd
,
buf
,
sizeof
(
buf
),
buf
,
sizeof
(
buf
),
qemudCheckMonitorPrompt
,
qemudCheckMonitorPrompt
,
"monitor"
,
10
000
)
<=
0
)
"monitor"
,
10
)
<=
0
)
ret
=
-
1
;
ret
=
-
1
;
else
else
ret
=
0
;
ret
=
0
;
...
@@ -738,6 +789,7 @@ static int qemudOpenMonitor(virConnectPtr conn,
...
@@ -738,6 +789,7 @@ static int qemudOpenMonitor(virConnectPtr conn,
return
ret
;
return
ret
;
}
}
/* Returns -1 for error, 0 success, 1 continue reading */
static
int
qemudExtractMonitorPath
(
virConnectPtr
conn
,
static
int
qemudExtractMonitorPath
(
virConnectPtr
conn
,
const
char
*
haystack
,
const
char
*
haystack
,
size_t
*
offset
,
size_t
*
offset
,
...
@@ -841,21 +893,18 @@ static int qemudWaitForMonitor(virConnectPtr conn,
...
@@ -841,21 +893,18 @@ static int qemudWaitForMonitor(virConnectPtr conn,
<
0
)
<
0
)
return
-
1
;
return
-
1
;
ret
=
qemudRead
Monitor
Output
(
conn
,
vm
,
logfd
,
buf
,
sizeof
(
buf
),
ret
=
qemudRead
Log
Output
(
conn
,
vm
,
logfd
,
buf
,
sizeof
(
buf
),
qemudFindCharDevicePTYs
,
qemudFindCharDevicePTYs
,
"console"
,
3000
);
"console"
,
3
);
if
(
close
(
logfd
)
<
0
)
{
if
(
close
(
logfd
)
<
0
)
{
char
ebuf
[
1024
];
char
ebuf
[
1024
];
qemudLog
(
QEMUD_WARN
,
_
(
"Unable to close logfile: %s
\n
"
),
qemudLog
(
QEMUD_WARN
,
_
(
"Unable to close logfile: %s
\n
"
),
virStrerror
(
errno
,
ebuf
,
sizeof
ebuf
));
virStrerror
(
errno
,
ebuf
,
sizeof
ebuf
));
}
}
if
(
ret
==
1
)
/* S
uccess */
if
(
ret
==
0
)
/* s
uccess */
return
0
;
return
0
;
if
(
ret
==
-
1
)
return
-
1
;
/* Unexpected end of file - inform user of QEMU log data */
/* Unexpected end of file - inform user of QEMU log data */
qemudReportError
(
conn
,
NULL
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
qemudReportError
(
conn
,
NULL
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"unable to start guest: %s"
),
buf
);
_
(
"unable to start guest: %s"
),
buf
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录