Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
4b4fbfe4
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看板
提交
4b4fbfe4
编写于
2月 17, 2016
作者:
N
Nikolay Shirokovskiy
提交者:
Daniel P. Berrange
3月 01, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vz: implement connection close notification
Signed-off-by:
N
Nikolay Shirokovskiy
<
nshirokovskiy@virtuozzo.com
>
上级
f484310a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
66 addition
and
0 deletion
+66
-0
src/vz/vz_driver.c
src/vz/vz_driver.c
+59
-0
src/vz/vz_sdk.c
src/vz/vz_sdk.c
+4
-0
src/vz/vz_utils.h
src/vz/vz_utils.h
+3
-0
未找到文件。
src/vz/vz_driver.c
浏览文件 @
4b4fbfe4
...
...
@@ -254,6 +254,9 @@ vzOpenDefault(virConnectPtr conn)
if
(
prlsdkSubscribeToPCSEvents
(
privconn
))
goto
error
;
if
(
!
(
privconn
->
closeCallback
=
virNewConnectCloseCallbackData
()))
goto
error
;
conn
->
privateData
=
privconn
;
if
(
prlsdkLoadDomains
(
privconn
))
...
...
@@ -262,6 +265,8 @@ vzOpenDefault(virConnectPtr conn)
return
VIR_DRV_OPEN_SUCCESS
;
error:
virObjectUnref
(
privconn
->
closeCallback
);
privconn
->
closeCallback
=
NULL
;
virObjectUnref
(
privconn
->
domains
);
virObjectUnref
(
privconn
->
caps
);
virObjectEventStateFree
(
privconn
->
domainEventState
);
...
...
@@ -329,6 +334,8 @@ vzConnectClose(virConnectPtr conn)
virObjectUnref
(
privconn
->
caps
);
virObjectUnref
(
privconn
->
xmlopt
);
virObjectUnref
(
privconn
->
domains
);
virObjectUnref
(
privconn
->
closeCallback
);
privconn
->
closeCallback
=
NULL
;
virObjectEventStateFree
(
privconn
->
domainEventState
);
prlsdkDisconnect
(
privconn
);
conn
->
privateData
=
NULL
;
...
...
@@ -1470,6 +1477,56 @@ vzNodeGetFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED)
return
freeMem
;
}
static
int
vzConnectRegisterCloseCallback
(
virConnectPtr
conn
,
virConnectCloseFunc
cb
,
void
*
opaque
,
virFreeCallback
freecb
)
{
vzConnPtr
privconn
=
conn
->
privateData
;
int
ret
=
-
1
;
vzDriverLock
(
privconn
);
if
(
virConnectCloseCallbackDataGetCallback
(
privconn
->
closeCallback
)
!=
NULL
)
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"A close callback is already registered"
));
goto
cleanup
;
}
virConnectCloseCallbackDataRegister
(
privconn
->
closeCallback
,
conn
,
cb
,
opaque
,
freecb
);
ret
=
0
;
cleanup:
vzDriverUnlock
(
privconn
);
return
ret
;
}
static
int
vzConnectUnregisterCloseCallback
(
virConnectPtr
conn
,
virConnectCloseFunc
cb
)
{
vzConnPtr
privconn
=
conn
->
privateData
;
int
ret
=
-
1
;
vzDriverLock
(
privconn
);
if
(
virConnectCloseCallbackDataGetCallback
(
privconn
->
closeCallback
)
!=
cb
)
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"A different callback was requested"
));
goto
cleanup
;
}
virConnectCloseCallbackDataUnregister
(
privconn
->
closeCallback
,
cb
);
ret
=
0
;
cleanup:
vzDriverUnlock
(
privconn
);
return
ret
;
}
static
virHypervisorDriver
vzDriver
=
{
.
name
=
"vz"
,
.
connectOpen
=
vzConnectOpen
,
/* 0.10.0 */
...
...
@@ -1532,6 +1589,8 @@ static virHypervisorDriver vzDriver = {
.
domainBlockStatsFlags
=
vzDomainBlockStatsFlags
,
/* 1.2.17 */
.
domainInterfaceStats
=
vzDomainInterfaceStats
,
/* 1.2.17 */
.
domainMemoryStats
=
vzDomainMemoryStats
,
/* 1.2.17 */
.
connectRegisterCloseCallback
=
vzConnectRegisterCloseCallback
,
/* 1.3.2 */
.
connectUnregisterCloseCallback
=
vzConnectUnregisterCloseCallback
,
/* 1.3.2 */
};
static
virConnectDriver
vzConnectDriver
=
{
...
...
src/vz/vz_sdk.c
浏览文件 @
4b4fbfe4
...
...
@@ -1710,6 +1710,10 @@ prlsdkEventsHandler(PRL_HANDLE prlEvent, PRL_VOID_PTR opaque)
/* above function takes own of event */
prlEvent
=
PRL_INVALID_HANDLE
;
break
;
case
PET_DSP_EVT_DISP_CONNECTION_CLOSED
:
virConnectCloseCallbackDataCall
(
privconn
->
closeCallback
,
VIR_CONNECT_CLOSE_REASON_EOF
);
break
;
default:
VIR_DEBUG
(
"Skipping event of type %d"
,
prlEventType
);
}
...
...
src/vz/vz_utils.h
浏览文件 @
4b4fbfe4
...
...
@@ -30,6 +30,7 @@
# include "conf/virdomainobjlist.h"
# include "conf/domain_event.h"
# include "virthread.h"
# include "datatypes.h"
# define vzParseError() \
virReportErrorHelper(VIR_FROM_TEST, VIR_ERR_OPERATION_FAILED, __FILE__, \
...
...
@@ -59,6 +60,8 @@ struct _vzConn {
virDomainXMLOptionPtr
xmlopt
;
virObjectEventStatePtr
domainEventState
;
const
char
*
drivername
;
/* Immutable pointer, self-locking APIs */
virConnectCloseCallbackDataPtr
closeCallback
;
};
typedef
struct
_vzConn
vzConn
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录