Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
a231016b
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看板
提交
a231016b
编写于
6月 01, 2011
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use virTimeMs when appropriate
上级
ef6e99dc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
78 deletion
+36
-78
src/qemu/qemu_domain.c
src/qemu/qemu_domain.c
+8
-16
src/qemu/qemu_driver.c
src/qemu/qemu_driver.c
+2
-9
src/qemu/qemu_migration.c
src/qemu/qemu_migration.c
+10
-24
src/util/event_poll.c
src/util/event_poll.c
+16
-29
未找到文件。
src/qemu/qemu_domain.c
浏览文件 @
a231016b
...
...
@@ -45,8 +45,6 @@
#define QEMU_NAMESPACE_HREF "http://libvirt.org/schemas/domain/qemu/1.0"
#define timeval_to_ms(tv) (((tv).tv_sec * 1000ull) + ((tv).tv_usec / 1000))
static
void
qemuDomainEventDispatchFunc
(
virConnectPtr
conn
,
virDomainEventPtr
event
,
...
...
@@ -492,15 +490,12 @@ void qemuDomainSetNamespaceHooks(virCapsPtr caps)
int
qemuDomainObjBeginJob
(
virDomainObjPtr
obj
)
{
qemuDomainObjPrivatePtr
priv
=
obj
->
privateData
;
struct
timeval
now
;
unsigned
long
long
now
;
unsigned
long
long
then
;
if
(
gettimeofday
(
&
now
,
NULL
)
<
0
)
{
virReportSystemError
(
errno
,
"%s"
,
_
(
"cannot get time of day"
));
if
(
virTimeMs
(
&
now
)
<
0
)
return
-
1
;
}
then
=
timeval_to_ms
(
now
)
+
QEMU_JOB_WAIT_TIME
;
then
=
now
+
QEMU_JOB_WAIT_TIME
;
virDomainObjRef
(
obj
);
...
...
@@ -520,7 +515,7 @@ int qemuDomainObjBeginJob(virDomainObjPtr obj)
priv
->
jobActive
=
QEMU_JOB_UNSPECIFIED
;
priv
->
jobSignals
=
0
;
memset
(
&
priv
->
jobSignalsData
,
0
,
sizeof
(
priv
->
jobSignalsData
));
priv
->
jobStart
=
timeval_to_ms
(
now
)
;
priv
->
jobStart
=
now
;
memset
(
&
priv
->
jobInfo
,
0
,
sizeof
(
priv
->
jobInfo
));
return
0
;
...
...
@@ -536,15 +531,12 @@ int qemuDomainObjBeginJobWithDriver(struct qemud_driver *driver,
virDomainObjPtr
obj
)
{
qemuDomainObjPrivatePtr
priv
=
obj
->
privateData
;
struct
timeval
now
;
unsigned
long
long
now
;
unsigned
long
long
then
;
if
(
gettimeofday
(
&
now
,
NULL
)
<
0
)
{
virReportSystemError
(
errno
,
"%s"
,
_
(
"cannot get time of day"
));
if
(
virTimeMs
(
&
now
)
<
0
)
return
-
1
;
}
then
=
timeval_to_ms
(
now
)
+
QEMU_JOB_WAIT_TIME
;
then
=
now
+
QEMU_JOB_WAIT_TIME
;
virDomainObjRef
(
obj
);
qemuDriverUnlock
(
driver
);
...
...
@@ -568,7 +560,7 @@ int qemuDomainObjBeginJobWithDriver(struct qemud_driver *driver,
priv
->
jobActive
=
QEMU_JOB_UNSPECIFIED
;
priv
->
jobSignals
=
0
;
memset
(
&
priv
->
jobSignalsData
,
0
,
sizeof
(
priv
->
jobSignalsData
));
priv
->
jobStart
=
timeval_to_ms
(
now
)
;
priv
->
jobStart
=
now
;
memset
(
&
priv
->
jobInfo
,
0
,
sizeof
(
priv
->
jobInfo
));
virDomainObjUnlock
(
obj
);
...
...
src/qemu/qemu_driver.c
浏览文件 @
a231016b
...
...
@@ -113,8 +113,6 @@
#define QEMU_NB_BLKIO_PARAM 1
#define timeval_to_ms(tv) (((tv).tv_sec * 1000ull) + ((tv).tv_usec / 1000))
static
void
processWatchdogEvent
(
void
*
data
,
void
*
opaque
);
static
int
qemudShutdown
(
void
);
...
...
@@ -6841,8 +6839,6 @@ static int qemuDomainGetJobInfo(virDomainPtr dom,
if
(
virDomainObjIsActive
(
vm
))
{
if
(
priv
->
jobActive
)
{
struct
timeval
now
;
memcpy
(
info
,
&
priv
->
jobInfo
,
sizeof
(
*
info
));
/* Refresh elapsed time again just to ensure it
...
...
@@ -6850,12 +6846,9 @@ static int qemuDomainGetJobInfo(virDomainPtr dom,
* of incoming migration which we don't currently
* monitor actively in the background thread
*/
if
(
gettimeofday
(
&
now
,
NULL
)
<
0
)
{
virReportSystemError
(
errno
,
"%s"
,
_
(
"cannot get time of day"
));
if
(
virTimeMs
(
&
info
->
timeElapsed
)
<
0
)
goto
cleanup
;
}
info
->
timeElapsed
=
timeval_to_ms
(
now
)
-
priv
->
jobStart
;
info
->
timeElapsed
-=
priv
->
jobStart
;
}
else
{
memset
(
info
,
0
,
sizeof
(
*
info
));
info
->
type
=
VIR_DOMAIN_JOB_NONE
;
...
...
src/qemu/qemu_migration.c
浏览文件 @
a231016b
...
...
@@ -46,8 +46,6 @@
#define VIR_FROM_THIS VIR_FROM_QEMU
#define timeval_to_ms(tv) (((tv).tv_sec * 1000ull) + ((tv).tv_usec / 1000))
enum
qemuMigrationCookieFlags
{
QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS
,
QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE
,
...
...
@@ -831,7 +829,6 @@ qemuMigrationUpdateJobStatus(struct qemud_driver *driver,
unsigned
long
long
memProcessed
;
unsigned
long
long
memRemaining
;
unsigned
long
long
memTotal
;
struct
timeval
now
;
if
(
!
virDomainObjIsActive
(
vm
))
{
qemuReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"%s: %s"
),
...
...
@@ -847,18 +844,11 @@ qemuMigrationUpdateJobStatus(struct qemud_driver *driver,
&
memTotal
);
qemuDomainObjExitMonitorWithDriver
(
driver
,
vm
);
if
(
ret
<
0
)
{
if
(
ret
<
0
||
virTimeMs
(
&
priv
->
jobInfo
.
timeElapsed
)
<
0
)
{
priv
->
jobInfo
.
type
=
VIR_DOMAIN_JOB_FAILED
;
return
-
1
;
}
if
(
gettimeofday
(
&
now
,
NULL
)
<
0
)
{
priv
->
jobInfo
.
type
=
VIR_DOMAIN_JOB_FAILED
;
virReportSystemError
(
errno
,
"%s"
,
_
(
"cannot get time of day"
));
return
-
1
;
}
priv
->
jobInfo
.
timeElapsed
=
timeval_to_ms
(
now
)
-
priv
->
jobStart
;
priv
->
jobInfo
.
timeElapsed
-=
priv
->
jobStart
;
switch
(
status
)
{
case
QEMU_MONITOR_MIGRATION_STATUS_INACTIVE
:
...
...
@@ -1069,18 +1059,16 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
int
internalret
;
int
dataFD
[
2
]
=
{
-
1
,
-
1
};
qemuDomainObjPrivatePtr
priv
=
NULL
;
struct
timeval
now
;
unsigned
long
long
now
;
qemuMigrationCookiePtr
mig
=
NULL
;
VIR_DEBUG
(
"driver=%p, dconn=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, st=%p, dname=%s, dom_xml=%s"
,
driver
,
dconn
,
NULLSTR
(
cookiein
),
cookieinlen
,
cookieout
,
cookieoutlen
,
st
,
NULLSTR
(
dname
),
dom_xml
);
if
(
gettimeofday
(
&
now
,
NULL
)
<
0
)
{
virReportSystemError
(
errno
,
"%s"
,
_
(
"cannot get time of day"
));
if
(
virTimeMs
(
&
now
)
<
0
)
return
-
1
;
}
/* Parse the domain XML. */
if
(
!
(
def
=
virDomainDefParseString
(
driver
->
caps
,
dom_xml
,
...
...
@@ -1190,7 +1178,7 @@ endjob:
virDomainObjIsActive
(
vm
))
{
priv
->
jobActive
=
QEMU_JOB_MIGRATION_IN
;
priv
->
jobInfo
.
type
=
VIR_DOMAIN_JOB_UNBOUNDED
;
priv
->
jobStart
=
timeval_to_ms
(
now
)
;
priv
->
jobStart
=
now
;
}
cleanup:
...
...
@@ -1229,8 +1217,9 @@ qemuMigrationPrepareDirect(struct qemud_driver *driver,
int
ret
=
-
1
;
int
internalret
;
qemuDomainObjPrivatePtr
priv
=
NULL
;
struct
timeval
now
;
unsigned
long
long
now
;
qemuMigrationCookiePtr
mig
=
NULL
;
VIR_DEBUG
(
"driver=%p, dconn=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, uri_in=%s, uri_out=%p, "
"dname=%s, dom_xml=%s"
,
...
...
@@ -1238,11 +1227,8 @@ qemuMigrationPrepareDirect(struct qemud_driver *driver,
cookieout
,
cookieoutlen
,
NULLSTR
(
uri_in
),
uri_out
,
NULLSTR
(
dname
),
dom_xml
);
if
(
gettimeofday
(
&
now
,
NULL
)
<
0
)
{
virReportSystemError
(
errno
,
"%s"
,
_
(
"cannot get time of day"
));
if
(
virTimeMs
(
&
now
)
<
0
)
return
-
1
;
}
/* The URI passed in may be NULL or a string "tcp://somehostname:port".
*
...
...
@@ -1413,7 +1399,7 @@ endjob:
virDomainObjIsActive
(
vm
))
{
priv
->
jobActive
=
QEMU_JOB_MIGRATION_IN
;
priv
->
jobInfo
.
type
=
VIR_DOMAIN_JOB_UNBOUNDED
;
priv
->
jobStart
=
timeval_to_ms
(
now
)
;
priv
->
jobStart
=
now
;
}
cleanup:
...
...
src/util/event_poll.c
浏览文件 @
a231016b
...
...
@@ -201,11 +201,12 @@ int virEventPollRemoveHandle(int watch) {
int
virEventPollAddTimeout
(
int
frequency
,
virEventTimeoutCallback
cb
,
void
*
opaque
,
virFreeCallback
ff
)
{
struct
timeval
now
;
virFreeCallback
ff
)
{
unsigned
long
long
now
;
int
ret
;
EVENT_DEBUG
(
"Adding timer %d with %d ms freq"
,
nextTimer
,
frequency
);
if
(
gettimeofday
(
&
now
,
NULL
)
<
0
)
{
if
(
virTimeMs
(
&
now
)
<
0
)
{
return
-
1
;
}
...
...
@@ -227,9 +228,7 @@ int virEventPollAddTimeout(int frequency,
eventLoop
.
timeouts
[
eventLoop
.
timeoutsCount
].
opaque
=
opaque
;
eventLoop
.
timeouts
[
eventLoop
.
timeoutsCount
].
deleted
=
0
;
eventLoop
.
timeouts
[
eventLoop
.
timeoutsCount
].
expiresAt
=
frequency
>=
0
?
frequency
+
(((
unsigned
long
long
)
now
.
tv_sec
)
*
1000
)
+
(((
unsigned
long
long
)
now
.
tv_usec
)
/
1000
)
:
0
;
frequency
>=
0
?
frequency
+
now
:
0
;
eventLoop
.
timeoutsCount
++
;
ret
=
nextTimer
-
1
;
...
...
@@ -238,8 +237,9 @@ int virEventPollAddTimeout(int frequency,
return
ret
;
}
void
virEventPollUpdateTimeout
(
int
timer
,
int
frequency
)
{
struct
timeval
tv
;
void
virEventPollUpdateTimeout
(
int
timer
,
int
frequency
)
{
unsigned
long
long
now
;
int
i
;
EVENT_DEBUG
(
"Updating timer %d timeout with %d ms freq"
,
timer
,
frequency
);
...
...
@@ -248,7 +248,7 @@ void virEventPollUpdateTimeout(int timer, int frequency) {
return
;
}
if
(
gettimeofday
(
&
tv
,
NULL
)
<
0
)
{
if
(
virTimeMs
(
&
now
)
<
0
)
{
return
;
}
...
...
@@ -257,9 +257,7 @@ void virEventPollUpdateTimeout(int timer, int frequency) {
if
(
eventLoop
.
timeouts
[
i
].
timer
==
timer
)
{
eventLoop
.
timeouts
[
i
].
frequency
=
frequency
;
eventLoop
.
timeouts
[
i
].
expiresAt
=
frequency
>=
0
?
frequency
+
(((
unsigned
long
long
)
tv
.
tv_sec
)
*
1000
)
+
(((
unsigned
long
long
)
tv
.
tv_usec
)
/
1000
)
:
0
;
frequency
>=
0
?
frequency
+
now
:
0
;
virEventPollInterruptLocked
();
break
;
}
...
...
@@ -321,18 +319,12 @@ static int virEventPollCalculateTimeout(int *timeout) {
/* Calculate how long we should wait for a timeout if needed */
if
(
then
>
0
)
{
struct
timeval
tv
;
unsigned
long
long
now
;
if
(
gettimeofday
(
&
tv
,
NULL
)
<
0
)
{
virReportSystemError
(
errno
,
"%s"
,
_
(
"Unable to get current time"
));
if
(
virTimeMs
(
&
now
)
<
0
)
return
-
1
;
}
*
timeout
=
then
-
((((
unsigned
long
long
)
tv
.
tv_sec
)
*
1000
)
+
(((
unsigned
long
long
)
tv
.
tv_usec
)
/
1000
));
*
timeout
=
then
-
now
;
if
(
*
timeout
<
0
)
*
timeout
=
0
;
}
else
{
...
...
@@ -397,21 +389,16 @@ static struct pollfd *virEventPollMakePollFDs(int *nfds) {
*
* Returns 0 upon success, -1 if an error occurred
*/
static
int
virEventPollDispatchTimeouts
(
void
)
{
struct
timeval
tv
;
static
int
virEventPollDispatchTimeouts
(
void
)
{
unsigned
long
long
now
;
int
i
;
/* Save this now - it may be changed during dispatch */
int
ntimeouts
=
eventLoop
.
timeoutsCount
;
VIR_DEBUG
(
"Dispatch %d"
,
ntimeouts
);
if
(
gettimeofday
(
&
tv
,
NULL
)
<
0
)
{
virReportSystemError
(
errno
,
"%s"
,
_
(
"Unable to get current time"
));
if
(
virTimeMs
(
&
now
)
<
0
)
return
-
1
;
}
now
=
(((
unsigned
long
long
)
tv
.
tv_sec
)
*
1000
)
+
(((
unsigned
long
long
)
tv
.
tv_usec
)
/
1000
);
for
(
i
=
0
;
i
<
ntimeouts
;
i
++
)
{
if
(
eventLoop
.
timeouts
[
i
].
deleted
||
eventLoop
.
timeouts
[
i
].
frequency
<
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录