Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
25905a78
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看板
提交
25905a78
编写于
6月 26, 2007
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Switch to using internal event API for QEMU driver
上级
133fdfe9
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
239 addition
and
54 deletion
+239
-54
ChangeLog
ChangeLog
+8
-0
docs/apibuild.py
docs/apibuild.py
+2
-0
qemud/driver.c
qemud/driver.c
+3
-0
qemud/event.c
qemud/event.c
+4
-4
qemud/event.h
qemud/event.h
+9
-26
qemud/qemud.c
qemud/qemud.c
+24
-24
src/Makefile.am
src/Makefile.am
+1
-0
src/event.c
src/event.c
+80
-0
src/event.h
src/event.h
+100
-0
src/libvirt_sym.version
src/libvirt_sym.version
+8
-0
未找到文件。
ChangeLog
浏览文件 @
25905a78
Tue Jun 26 18:47:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/event.h, src/event.c, src/Makefile.am, src/libvirt_sym.version:
Provide an internal API for drivers to register callbacks for
monitoring file handles & generating timer notifications.
* qemud/driver.c, qemud/event.c, qemud/event.h, qemud/qemud.c:
Adapt to make use of internal driver API for events.
Tue Jun 26 18:41:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* qemud/conf.c, qemud/conf.h, qemud/dispatch.c, qemud/driver.c,
...
...
docs/apibuild.py
浏览文件 @
25905a78
...
...
@@ -49,6 +49,8 @@ ignored_files = {
"conf.c"
:
"internal code"
,
"console.h"
:
"internal code"
,
"console.c"
:
"internal code"
,
"event.h"
:
"internal code"
,
"event.c"
:
"internal code"
,
}
ignored_words
=
{
...
...
qemud/driver.c
浏览文件 @
25905a78
...
...
@@ -81,6 +81,9 @@ static int qemudSetNonBlock(int fd) {
}
#define virEventAddHandle(fd, events, cb, opaque) virEventAddHandleImpl(fd, events, cb, opaque)
#define virEventRemoveHandle(fd) virEventRemoveHandleImpl(fd)
static
void
qemudDispatchVMEvent
(
int
fd
,
int
events
,
void
*
opaque
);
int
qemudStartVMDaemon
(
struct
qemud_driver
*
driver
,
...
...
qemud/event.c
浏览文件 @
25905a78
...
...
@@ -76,7 +76,7 @@ static int nextTimer = 0;
* NB, it *must* be safe to call this from within a callback
* For this reason we only ever append to existing list.
*/
int
virEventAddHandle
(
int
fd
,
int
events
,
virEventHandleCallback
cb
,
void
*
opaque
)
{
int
virEventAddHandle
Impl
(
int
fd
,
int
events
,
virEventHandleCallback
cb
,
void
*
opaque
)
{
qemudDebug
(
"Add handle %d %d %p %p
\n
"
,
fd
,
events
,
cb
,
opaque
);
if
(
eventLoop
.
handlesCount
==
eventLoop
.
handlesAlloc
)
{
struct
virEventHandle
*
tmp
;
...
...
@@ -109,7 +109,7 @@ int virEventAddHandle(int fd, int events, virEventHandleCallback cb, void *opaqu
* For this reason we only ever set a flag in the existing list.
* Actual deletion will be done out-of-band
*/
int
virEventRemoveHandle
(
int
fd
)
{
int
virEventRemoveHandle
Impl
(
int
fd
)
{
int
i
;
qemudDebug
(
"Remove handle %d
\n
"
,
fd
);
for
(
i
=
0
;
i
<
eventLoop
.
handlesCount
;
i
++
)
{
...
...
@@ -131,7 +131,7 @@ int virEventRemoveHandle(int fd) {
* NB, it *must* be safe to call this from within a callback
* For this reason we only ever append to existing list.
*/
int
virEventAddTimeout
(
int
timeout
,
virEventTimeoutCallback
cb
,
void
*
opaque
)
{
int
virEventAddTimeout
Impl
(
int
timeout
,
virEventTimeoutCallback
cb
,
void
*
opaque
)
{
struct
timeval
tv
;
qemudDebug
(
"Adding timeout with %d ms period"
,
timeout
);
if
(
gettimeofday
(
&
tv
,
NULL
)
<
0
)
{
...
...
@@ -173,7 +173,7 @@ int virEventAddTimeout(int timeout, virEventTimeoutCallback cb, void *opaque) {
* For this reason we only ever set a flag in the existing list.
* Actual deletion will be done out-of-band
*/
int
virEventRemoveTimeout
(
int
timer
)
{
int
virEventRemoveTimeout
Impl
(
int
timer
)
{
int
i
;
for
(
i
=
0
;
i
<
eventLoop
.
timeoutsCount
;
i
++
)
{
if
(
eventLoop
.
timeouts
[
i
].
deleted
)
...
...
qemud/event.h
浏览文件 @
25905a78
...
...
@@ -24,18 +24,10 @@
#ifndef __VIRTD_EVENT_H__
#define __VIRTD_EVENT_H__
#include "../src/event.h"
/**
* virEventHandleCallback: callback for receiving file handle events
*
* @fd: file handle on which the event occured
* @events: bitset of events from POLLnnn constants
* @opaque: user data registered with handle
*/
typedef
void
(
*
virEventHandleCallback
)(
int
fd
,
int
events
,
void
*
opaque
);
/**
* virEventAddHandle: register a callback for monitoring file handle events
* virEventAddHandleImpl: register a callback for monitoring file handle events
*
* @fd: file handle to monitor for events
* @events: bitset of events to wach from POLLnnn constants
...
...
@@ -44,27 +36,19 @@ typedef void (*virEventHandleCallback)(int fd, int events, void *opaque);
*
* returns -1 if the file handle cannot be registered, 0 upon success
*/
int
virEventAddHandle
(
int
fd
,
int
events
,
virEventHandleCallback
cb
,
void
*
opaque
);
int
virEventAddHandle
Impl
(
int
fd
,
int
events
,
virEventHandleCallback
cb
,
void
*
opaque
);
/**
* virEventRemoveHandle: unregister a callback from a file handle
* virEventRemoveHandle
Impl
: unregister a callback from a file handle
*
* @fd: file handle to stop monitoring for events
*
* returns -1 if the file handle was not registered, 0 upon success
*/
int
virEventRemoveHandle
(
int
fd
);
int
virEventRemoveHandle
Impl
(
int
fd
);
/**
* virEventTimeoutCallback: callback for receiving timer events
*
* @timer: timer id emitting the event
* @opaque: user data registered with handle
*/
typedef
void
(
*
virEventTimeoutCallback
)(
int
timer
,
void
*
opaque
);
/**
* virEventAddTimeout: register a callback for a timer event
* virEventAddTimeoutImpl: register a callback for a timer event
*
* @timeout: timeout between events in milliseconds
* @cb: callback to invoke when an event occurrs
...
...
@@ -73,17 +57,16 @@ typedef void (*virEventTimeoutCallback)(int timer, void *opaque);
* returns -1 if the file handle cannot be registered, a positive
* integer timer id upon success
*/
int
virEventAddTimeout
(
int
timeout
,
virEventTimeoutCallback
cb
,
void
*
opaque
);
int
virEventAddTimeout
Impl
(
int
timeout
,
virEventTimeoutCallback
cb
,
void
*
opaque
);
/**
* virEventRemoveTimeout: unregister a callback for a timer
* virEventRemoveTimeout
Impl
: unregister a callback for a timer
*
* @timer: the timer id to remove
*
* returns -1 if the timer was not registered, 0 upon success
*/
int
virEventRemoveTimeout
(
int
timer
);
int
virEventRemoveTimeoutImpl
(
int
timer
);
/**
* virEventRunOnce: run a single iteration of the event loop.
...
...
qemud/qemud.c
浏览文件 @
25905a78
...
...
@@ -471,10 +471,10 @@ static int qemudListenUnix(struct qemud_server *server,
goto
cleanup
;
}
if
(
virEventAddHandle
(
sock
->
fd
,
POLLIN
|
POLLERR
|
POLLHUP
,
qemudDispatchServerEvent
,
server
)
<
0
)
{
if
(
virEventAddHandle
Impl
(
sock
->
fd
,
POLLIN
|
POLLERR
|
POLLHUP
,
qemudDispatchServerEvent
,
server
)
<
0
)
{
qemudLog
(
QEMUD_ERR
,
"Failed to add server event callback"
);
goto
cleanup
;
}
...
...
@@ -584,10 +584,10 @@ remoteListenTCP (struct qemud_server *server,
return
-
1
;
}
if
(
virEventAddHandle
(
sock
->
fd
,
POLLIN
|
POLLERR
|
POLLHUP
,
qemudDispatchServerEvent
,
server
)
<
0
)
{
if
(
virEventAddHandle
Impl
(
sock
->
fd
,
POLLIN
|
POLLERR
|
POLLHUP
,
qemudDispatchServerEvent
,
server
)
<
0
)
{
qemudLog
(
QEMUD_ERR
,
"Failed to add server event callback"
);
return
-
1
;
}
...
...
@@ -1056,7 +1056,7 @@ static void qemudDispatchClientFailure(struct qemud_server *server, struct qemud
tmp
=
tmp
->
next
;
}
virEventRemoveHandle
(
client
->
fd
);
virEventRemoveHandle
Impl
(
client
->
fd
);
if
(
client
->
tls
&&
client
->
session
)
gnutls_deinit
(
client
->
session
);
close
(
client
->
fd
);
...
...
@@ -1418,22 +1418,22 @@ static int qemudRegisterClientEvent(struct qemud_server *server,
struct
qemud_client
*
client
,
int
removeFirst
)
{
if
(
removeFirst
)
if
(
virEventRemoveHandle
(
client
->
fd
)
<
0
)
if
(
virEventRemoveHandle
Impl
(
client
->
fd
)
<
0
)
return
-
1
;
if
(
client
->
tls
)
{
if
(
virEventAddHandle
(
client
->
fd
,
(
client
->
direction
?
POLLOUT
:
POLLIN
)
|
POLLERR
|
POLLHUP
,
qemudDispatchClientEvent
,
server
)
<
0
)
if
(
virEventAddHandle
Impl
(
client
->
fd
,
(
client
->
direction
?
POLLOUT
:
POLLIN
)
|
POLLERR
|
POLLHUP
,
qemudDispatchClientEvent
,
server
)
<
0
)
return
-
1
;
}
else
{
if
(
virEventAddHandle
(
client
->
fd
,
(
client
->
mode
==
QEMUD_MODE_TX_PACKET
?
POLLOUT
:
POLLIN
)
|
POLLERR
|
POLLHUP
,
qemudDispatchClientEvent
,
server
)
<
0
)
if
(
virEventAddHandle
Impl
(
client
->
fd
,
(
client
->
mode
==
QEMUD_MODE_TX_PACKET
?
POLLOUT
:
POLLIN
)
|
POLLERR
|
POLLHUP
,
qemudDispatchClientEvent
,
server
)
<
0
)
return
-
1
;
}
...
...
@@ -1864,10 +1864,10 @@ int main(int argc, char **argv) {
goto
error2
;
}
if
(
virEventAddHandle
(
sigpipe
[
0
],
POLLIN
,
qemudDispatchSignalEvent
,
server
)
<
0
)
{
if
(
virEventAddHandle
Impl
(
sigpipe
[
0
],
POLLIN
,
qemudDispatchSignalEvent
,
server
)
<
0
)
{
qemudLog
(
QEMUD_ERR
,
"Failed to register callback for signal pipe"
);
ret
=
3
;
goto
error2
;
...
...
src/Makefile.am
浏览文件 @
25905a78
...
...
@@ -31,6 +31,7 @@ CLIENT_SOURCES = \
test.c test.h
\
buf.c buf.h
\
xml.c xml.h
\
event.c event.h
\
xen_unified.c xen_unified.h
\
xen_internal.c xen_internal.h
\
xs_internal.c xs_internal.h
\
...
...
src/event.c
0 → 100644
浏览文件 @
25905a78
/*
* event.h: event loop for monitoring file handles
*
* Copyright (C) 2007 Daniel P. Berrange
* Copyright (C) 2007 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#include "event.h"
#include <stdlib.h>
static
virEventAddHandleFunc
addHandleImpl
=
NULL
;
static
virEventRemoveHandleFunc
removeHandleImpl
=
NULL
;
static
virEventAddTimeoutFunc
addTimeoutImpl
=
NULL
;
static
virEventRemoveTimeoutFunc
removeTimeoutImpl
=
NULL
;
int
virEventAddHandle
(
int
fd
,
int
events
,
virEventHandleCallback
cb
,
void
*
opaque
)
{
if
(
!
addHandleImpl
)
return
-
1
;
return
addHandleImpl
(
fd
,
events
,
cb
,
opaque
);
}
int
virEventRemoveHandle
(
int
fd
)
{
if
(
!
removeHandleImpl
)
return
-
1
;
return
removeHandleImpl
(
fd
);
}
int
virEventAddTimeout
(
int
timeout
,
virEventTimeoutCallback
cb
,
void
*
opaque
)
{
if
(
!
addTimeoutImpl
)
return
-
1
;
return
addTimeoutImpl
(
timeout
,
cb
,
opaque
);
}
int
virEventRemoveTimeout
(
int
timer
)
{
if
(
!
removeTimeoutImpl
)
return
-
1
;
return
removeTimeoutImpl
(
timer
);
}
void
__virEventRegisterImpl
(
virEventAddHandleFunc
addHandle
,
virEventRemoveHandleFunc
removeHandle
,
virEventAddTimeoutFunc
addTimeout
,
virEventRemoveTimeoutFunc
removeTimeout
)
{
addHandleImpl
=
addHandle
;
removeHandleImpl
=
removeHandle
;
addTimeoutImpl
=
addTimeout
;
removeTimeoutImpl
=
removeTimeout
;
}
/*
* Local variables:
* indent-tabs-mode: nil
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
* End:
*/
src/event.h
0 → 100644
浏览文件 @
25905a78
/*
* event.h: event loop for monitoring file handles
*
* Copyright (C) 2007 Daniel P. Berrange
* Copyright (C) 2007 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#ifndef __VIR_EVENT_H__
#define __VIR_EVENT_H__
/**
* virEventHandleCallback: callback for receiving file handle events
*
* @fd: file handle on which the event occured
* @events: bitset of events from POLLnnn constants
* @opaque: user data registered with handle
*/
typedef
void
(
*
virEventHandleCallback
)(
int
fd
,
int
events
,
void
*
opaque
);
/**
* virEventAddHandle: register a callback for monitoring file handle events
*
* @fd: file handle to monitor for events
* @events: bitset of events to wach from POLLnnn constants
* @cb: callback to invoke when an event occurrs
* @opaque: user data to pass to callback
*
* returns -1 if the file handle cannot be registered, 0 upon success
*/
int
virEventAddHandle
(
int
fd
,
int
events
,
virEventHandleCallback
cb
,
void
*
opaque
);
/**
* virEventRemoveHandle: unregister a callback from a file handle
*
* @fd: file handle to stop monitoring for events
*
* returns -1 if the file handle was not registered, 0 upon success
*/
int
virEventRemoveHandle
(
int
fd
);
/**
* virEventTimeoutCallback: callback for receiving timer events
*
* @timer: timer id emitting the event
* @opaque: user data registered with handle
*/
typedef
void
(
*
virEventTimeoutCallback
)(
int
timer
,
void
*
opaque
);
/**
* virEventAddTimeout: register a callback for a timer event
*
* @timeout: timeout between events in milliseconds
* @cb: callback to invoke when an event occurrs
* @opaque: user data to pass to callback
*
* returns -1 if the file handle cannot be registered, a positive
* integer timer id upon success
*/
int
virEventAddTimeout
(
int
timeout
,
virEventTimeoutCallback
cb
,
void
*
opaque
);
/**
* virEventRemoveTimeout: unregister a callback for a timer
*
* @timer: the timer id to remove
*
* returns -1 if the timer was not registered, 0 upon success
*/
int
virEventRemoveTimeout
(
int
timer
);
typedef
int
(
*
virEventAddHandleFunc
)(
int
,
int
,
virEventHandleCallback
,
void
*
);
typedef
int
(
*
virEventRemoveHandleFunc
)(
int
);
typedef
int
(
*
virEventAddTimeoutFunc
)(
int
,
virEventTimeoutCallback
,
void
*
);
typedef
int
(
*
virEventRemoveTimeoutFunc
)(
int
);
void
__virEventRegisterImpl
(
virEventAddHandleFunc
addHandle
,
virEventRemoveHandleFunc
removeHandle
,
virEventAddTimeoutFunc
addTimeout
,
virEventRemoveTimeoutFunc
removeTimeout
);
#define virEventRegisterImpl(ah,rh,at,rt) __virEventRegisterImpl(ah,rh,at,rt)
#endif
/* __VIR_EVENT_H__ */
src/libvirt_sym.version
浏览文件 @
25905a78
...
...
@@ -91,6 +91,12 @@
virNetworkGetAutostart;
virNetworkSetAutostart;
/* Symbols with __ are private only
for use by the libvirtd daemon.
They are not part of stable ABI
guarentee provided for the public
symbols above */
__virConfNew;
__virConfReadFile;
__virConfReadMem;
...
...
@@ -103,5 +109,7 @@
__virGetDomain;
__virGetNetwork;
__virEventRegisterImpl;
local: *;
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录