Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
70da0494
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看板
提交
70da0494
编写于
6月 26, 2007
作者:
D
Daniel P. Berrange
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add driver API for global startup/shutdown/reload hooks
上级
25905a78
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
183 addition
and
9 deletion
+183
-9
ChangeLog
ChangeLog
+7
-0
qemud/driver.c
qemud/driver.c
+25
-3
qemud/driver.h
qemud/driver.h
+3
-2
qemud/internal.h
qemud/internal.h
+1
-0
qemud/qemud.c
qemud/qemud.c
+43
-4
src/driver.h
src/driver.h
+15
-0
src/internal.h
src/internal.h
+9
-0
src/libvirt.c
src/libvirt.c
+75
-0
src/libvirt_sym.version
src/libvirt_sym.version
+5
-0
未找到文件。
ChangeLog
浏览文件 @
70da0494
Tue Jun 26 18:53:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/internal.h, src/libvirt.c, src/driver.h, src/libvirt_sym.version
Added internal driver API hooks for global shutdown/startup/reload
* qemud/driver.c, qemud/driver.h, qemud/internal.h, qemud/qemud.c
Adapt to make use of new driver API for startup/shutdown
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:
...
...
qemud/driver.c
浏览文件 @
70da0494
...
...
@@ -205,7 +205,7 @@ int qemudStartup(void) {
return
-
1
;
}
void
qemudReload
(
void
)
{
int
qemudReload
(
void
)
{
qemudScanConfigs
(
qemu_driver
);
if
(
qemu_driver
->
iptables
)
{
...
...
@@ -214,14 +214,28 @@ void qemudReload(void) {
}
qemudAutostartConfigs
(
qemu_driver
);
return
0
;
}
void
qemudShutdown
()
{
int
qemudActive
(
void
)
{
/* If we've any active networks or guests, then we
* mark this driver as active
*/
if
(
qemu_driver
->
nactivenetworks
&&
qemu_driver
->
nactivevms
)
return
1
;
/* Otherwise we're happy to deal with a shutdown */
return
0
;
}
int
qemudShutdown
()
{
struct
qemud_vm
*
vm
;
struct
qemud_network
*
network
;
if
(
!
qemu_driver
)
return
;
return
-
1
;
/* shutdown active VMs */
vm
=
qemu_driver
->
vms
;
...
...
@@ -279,6 +293,8 @@ void qemudShutdown() {
free
(
qemu_driver
);
qemu_driver
=
NULL
;
return
0
;
}
static
int
...
...
@@ -2516,6 +2532,12 @@ static virNetworkDriver qemuNetworkDriver = {
qemudNetworkSetAutostart
,
/* networkSetAutostart */
};
static
virStateDriver
qemuStateDriver
=
{
qemudStartup
,
qemudShutdown
,
qemudReload
,
qemudActive
,
};
/*
* Local variables:
...
...
qemud/driver.h
浏览文件 @
70da0494
...
...
@@ -29,8 +29,9 @@
#include "../src/internal.h"
int
qemudStartup
(
void
);
void
qemudReload
(
void
);
void
qemudShutdown
(
void
);
int
qemudReload
(
void
);
int
qemudShutdown
(
void
);
int
qemudActive
(
void
);
virDrvOpenStatus
qemudOpen
(
virConnectPtr
conn
,
...
...
qemud/internal.h
浏览文件 @
70da0494
...
...
@@ -34,6 +34,7 @@
#include "remote_protocol.h"
#include "bridge.h"
#include "iptables.h"
#include "../config.h"
#ifdef __GNUC__
#ifdef HAVE_ANSIDECL_H
...
...
qemud/qemud.c
浏览文件 @
70da0494
...
...
@@ -54,6 +54,7 @@
#include <libvirt/virterror.h>
#include "internal.h"
#include "../src/internal.h"
#include "../src/remote_internal.h"
#include "../src/conf.h"
#include "dispatch.h"
...
...
@@ -206,6 +207,9 @@ static void qemudDispatchSignalEvent(int fd ATTRIBUTE_UNUSED,
switch
(
sigc
)
{
case
SIGHUP
:
qemudLog
(
QEMUD_INFO
,
"Reloading configuration on SIGHUP"
);
if
(
virStateReload
()
<
0
)
qemudLog
(
QEMUD_WARN
,
"Error while reloading drivers"
);
if
(
!
remote
)
{
qemudReload
();
}
...
...
@@ -704,6 +708,8 @@ static struct qemud_server *qemudInitialize(int sigread) {
if
(
roSockname
[
0
]
!=
'\0'
&&
qemudListenUnix
(
server
,
roSockname
,
1
)
<
0
)
goto
cleanup
;
virStateInitialize
();
if
(
!
remote
)
/* qemud only */
{
if
(
qemudStartup
()
<
0
)
{
goto
cleanup
;
...
...
@@ -1478,13 +1484,45 @@ static int qemudOneLoop(void) {
return
0
;
}
static
void
qemudInactiveTimer
(
int
timer
ATTRIBUTE_UNUSED
,
void
*
data
)
{
struct
qemud_server
*
server
=
(
struct
qemud_server
*
)
data
;
qemudDebug
(
"Got inactive timer expiry"
);
if
(
!
virStateActive
())
{
qemudDebug
(
"No state active, shutting down"
);
server
->
shutdown
=
1
;
}
}
static
int
qemudRunLoop
(
struct
qemud_server
*
server
)
{
int
ret
;
int
timerid
=
-
1
;
for
(;;)
{
/* A shutdown timeout is specified, so check
* if any drivers have active state, if not
* shutdown after timeout seconds
*/
if
(
timeout
>
0
&&
!
virStateActive
()
&&
!
server
->
clients
)
{
timerid
=
virEventAddTimeoutImpl
(
timeout
*
1000
,
qemudInactiveTimer
,
server
);
qemudDebug
(
"Scheduling shutdown timer %d"
,
timerid
);
}
if
(
qemudOneLoop
()
<
0
)
break
;
while
((
ret
=
qemudOneLoop
())
==
0
&&
!
server
->
shutdown
)
;
/* Unregister any timeout that's active, since we
* just had an event processed
*/
if
(
timerid
!=
-
1
)
{
qemudDebug
(
"Removing shutdown timer %d"
,
timerid
);
virEventRemoveTimeoutImpl
(
timerid
);
timerid
=
-
1
;
}
return
ret
==
-
1
?
-
1
:
0
;
if
(
server
->
shutdown
)
return
0
;
}
return
-
1
;
}
static
void
qemudCleanup
(
struct
qemud_server
*
server
)
{
...
...
@@ -1502,6 +1540,7 @@ static void qemudCleanup(struct qemud_server *server) {
qemudShutdown
();
virStateCleanup
();
free
(
server
);
}
...
...
src/driver.h
浏览文件 @
70da0494
...
...
@@ -322,6 +322,20 @@ struct _virNetworkDriver {
virDrvNetworkSetAutostart
networkSetAutostart
;
};
typedef
int
(
*
virDrvStateInitialize
)
(
void
);
typedef
int
(
*
virDrvStateCleanup
)
(
void
);
typedef
int
(
*
virDrvStateReload
)
(
void
);
typedef
int
(
*
virDrvStateActive
)
(
void
);
typedef
struct
_virStateDriver
virStateDriver
;
typedef
virStateDriver
*
virStateDriverPtr
;
struct
_virStateDriver
{
virDrvStateInitialize
initialize
;
virDrvStateCleanup
cleanup
;
virDrvStateReload
reload
;
virDrvStateActive
active
;
};
/*
* Registration
...
...
@@ -330,6 +344,7 @@ struct _virNetworkDriver {
*/
int
virRegisterDriver
(
virDriverPtr
);
int
virRegisterNetworkDriver
(
virNetworkDriverPtr
);
int
virRegisterStateDriver
(
virStateDriverPtr
);
#ifdef __cplusplus
}
...
...
src/internal.h
浏览文件 @
70da0494
...
...
@@ -220,6 +220,15 @@ int virFreeNetwork (virConnectPtr conn,
#define virGetDomain(c,n,u) __virGetDomain((c),(n),(u))
#define virGetNetwork(c,n,u) __virGetNetwork((c),(n),(u))
int
__virStateInitialize
(
void
);
int
__virStateCleanup
(
void
);
int
__virStateReload
(
void
);
int
__virStateActive
(
void
);
#define virStateInitialize() __virStateInitialize()
#define virStateCleanup() __virStateCleanup()
#define virStateReload() __virStateReload()
#define virStateActive() __virStateActive()
#ifdef __cplusplus
}
#endif
/* __cplusplus */
...
...
src/libvirt.c
浏览文件 @
70da0494
...
...
@@ -40,6 +40,8 @@ static virDriverPtr virDriverTab[MAX_DRIVERS];
static
int
virDriverTabCount
=
0
;
static
virNetworkDriverPtr
virNetworkDriverTab
[
MAX_DRIVERS
];
static
int
virNetworkDriverTabCount
=
0
;
static
virStateDriverPtr
virStateDriverTab
[
MAX_DRIVERS
];
static
int
virStateDriverTabCount
=
0
;
static
int
initialized
=
0
;
/**
...
...
@@ -240,6 +242,79 @@ virRegisterDriver(virDriverPtr driver)
return
virDriverTabCount
++
;
}
/**
* virRegisterStateDriver:
* @driver: pointer to a driver block
*
* Register a virtualization driver
*
* Returns the driver priority or -1 in case of error.
*/
int
virRegisterStateDriver
(
virStateDriverPtr
driver
)
{
if
(
virInitialize
()
<
0
)
return
-
1
;
if
(
driver
==
NULL
)
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
if
(
virStateDriverTabCount
>=
MAX_DRIVERS
)
{
virLibConnError
(
NULL
,
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
return
(
-
1
);
}
virStateDriverTab
[
virStateDriverTabCount
]
=
driver
;
return
virStateDriverTabCount
++
;
}
int
__virStateInitialize
(
void
)
{
int
i
,
ret
=
0
;
if
(
virInitialize
()
<
0
)
return
-
1
;
for
(
i
=
0
;
i
<
virStateDriverTabCount
;
i
++
)
{
if
(
virStateDriverTab
[
i
]
->
initialize
()
<
0
)
ret
=
-
1
;
}
return
ret
;
}
int
__virStateCleanup
(
void
)
{
int
i
,
ret
=
0
;
for
(
i
=
0
;
i
<
virStateDriverTabCount
;
i
++
)
{
if
(
virStateDriverTab
[
i
]
->
cleanup
()
<
0
)
ret
=
-
1
;
}
return
ret
;
}
int
__virStateReload
(
void
)
{
int
i
,
ret
=
0
;
for
(
i
=
0
;
i
<
virStateDriverTabCount
;
i
++
)
{
if
(
virStateDriverTab
[
i
]
->
reload
()
<
0
)
ret
=
-
1
;
}
return
ret
;
}
int
__virStateActive
(
void
)
{
int
i
,
ret
=
0
;
for
(
i
=
0
;
i
<
virStateDriverTabCount
;
i
++
)
{
if
(
virStateDriverTab
[
i
]
->
active
())
ret
=
1
;
}
return
ret
;
}
/**
* virGetVersion:
* @libVer: return value for the library version (OUT)
...
...
src/libvirt_sym.version
浏览文件 @
70da0494
...
...
@@ -111,5 +111,10 @@
__virEventRegisterImpl;
__virStateInitialize;
__virStateCleanup;
__virStateReload;
__virStateActive;
local: *;
};
tester丶
🤺
@ssszwink
mentioned in commit
ca1701e3
·
9月 10, 2020
mentioned in commit
ca1701e3
mentioned in commit ca1701e3c2dc4647d5e67b168b32ddbf626e1bc7
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录