Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
f484310a
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看板
提交
f484310a
编写于
2月 17, 2016
作者:
N
Nikolay Shirokovskiy
提交者:
Daniel P. Berrange
3月 01, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
daemon: add connection close rpc
Signed-off-by:
N
Nikolay Shirokovskiy
<
nshirokovskiy@virtuozzo.com
>
上级
ec4ef72c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
160 addition
and
1 deletion
+160
-1
daemon/libvirtd.h
daemon/libvirtd.h
+1
-0
daemon/remote.c
daemon/remote.c
+85
-0
src/libvirt_internal.h
src/libvirt_internal.h
+5
-0
src/remote/remote_driver.c
src/remote/remote_driver.c
+40
-0
src/remote/remote_protocol.x
src/remote/remote_protocol.x
+23
-1
src/remote_protocol-structs
src/remote_protocol-structs
+6
-0
未找到文件。
daemon/libvirtd.h
浏览文件 @
f484310a
...
...
@@ -60,6 +60,7 @@ struct daemonClientPrivate {
size_t
nnetworkEventCallbacks
;
daemonClientEventCallbackPtr
*
qemuEventCallbacks
;
size_t
nqemuEventCallbacks
;
bool
closeRegistered
;
# if WITH_SASL
virNetSASLSessionPtr
sasl
;
...
...
daemon/remote.c
浏览文件 @
f484310a
...
...
@@ -1208,6 +1208,20 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr conn,
VIR_FREE
(
details_p
);
}
static
void
remoteRelayConnectionClosedEvent
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
int
reason
,
void
*
opaque
)
{
virNetServerClientPtr
client
=
opaque
;
VIR_DEBUG
(
"Relaying connection closed event, reason %d"
,
reason
);
remote_connect_event_connection_closed_msg
msg
=
{
reason
};
remoteDispatchObjectEventSend
(
client
,
remoteProgram
,
REMOTE_PROC_CONNECT_EVENT_CONNECTION_CLOSED
,
(
xdrproc_t
)
xdr_remote_connect_event_connection_closed_msg
,
&
msg
);
}
/*
* You must hold lock for at least the client
* We don't free stuff here, merely disconnect the client's
...
...
@@ -1270,6 +1284,12 @@ void remoteClientFreeFunc(void *data)
}
VIR_FREE
(
priv
->
qemuEventCallbacks
);
if
(
priv
->
closeRegistered
)
{
if
(
virConnectUnregisterCloseCallback
(
priv
->
conn
,
remoteRelayConnectionClosedEvent
)
<
0
)
VIR_WARN
(
"unexpected close callback event deregister failure"
);
}
virConnectClose
(
priv
->
conn
);
virIdentitySetCurrent
(
NULL
);
...
...
@@ -3345,6 +3365,70 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr server ATTRIBUTE_UNUSED,
return
rv
;
}
static
int
remoteDispatchConnectCloseCallbackRegister
(
virNetServerPtr
server
ATTRIBUTE_UNUSED
,
virNetServerClientPtr
client
,
virNetMessagePtr
msg
ATTRIBUTE_UNUSED
,
virNetMessageErrorPtr
rerr
)
{
int
rv
=
-
1
;
struct
daemonClientPrivate
*
priv
=
virNetServerClientGetPrivateData
(
client
);
virMutexLock
(
&
priv
->
lock
);
if
(
!
priv
->
conn
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"connection not open"
));
goto
cleanup
;
}
// on behalf of close callback
virObjectRef
(
client
);
if
(
virConnectRegisterCloseCallback
(
priv
->
conn
,
remoteRelayConnectionClosedEvent
,
client
,
virObjectFreeCallback
)
<
0
)
goto
cleanup
;
priv
->
closeRegistered
=
true
;
rv
=
0
;
cleanup:
virMutexUnlock
(
&
priv
->
lock
);
if
(
rv
<
0
)
virNetMessageSaveError
(
rerr
);
return
rv
;
}
static
int
remoteDispatchConnectCloseCallbackUnregister
(
virNetServerPtr
server
ATTRIBUTE_UNUSED
,
virNetServerClientPtr
client
,
virNetMessagePtr
msg
ATTRIBUTE_UNUSED
,
virNetMessageErrorPtr
rerr
)
{
int
rv
=
-
1
;
struct
daemonClientPrivate
*
priv
=
virNetServerClientGetPrivateData
(
client
);
virMutexLock
(
&
priv
->
lock
);
if
(
!
priv
->
conn
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"connection not open"
));
goto
cleanup
;
}
if
(
virConnectUnregisterCloseCallback
(
priv
->
conn
,
remoteRelayConnectionClosedEvent
)
<
0
)
goto
cleanup
;
priv
->
closeRegistered
=
false
;
rv
=
0
;
cleanup:
virMutexUnlock
(
&
priv
->
lock
);
if
(
rv
<
0
)
virNetMessageSaveError
(
rerr
);
return
rv
;
}
/***************************
* Register / deregister events
...
...
@@ -4145,6 +4229,7 @@ static int remoteDispatchConnectSupportsFeature(virNetServerPtr server ATTRIBUTE
switch
(
args
->
feature
)
{
case
VIR_DRV_FEATURE_FD_PASSING
:
case
VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK
:
case
VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK
:
supported
=
1
;
break
;
...
...
src/libvirt_internal.h
浏览文件 @
f484310a
...
...
@@ -118,6 +118,11 @@ enum {
* Support for server-side event filtering via callback ids in events.
*/
VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK
=
14
,
/*
* Support for driver close callback rpc
*/
VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK
=
15
,
};
...
...
src/remote/remote_driver.c
浏览文件 @
f484310a
...
...
@@ -94,6 +94,7 @@ struct private_data {
char
*
hostname
;
/* Original hostname */
bool
serverKeepAlive
;
/* Does server support keepalive protocol? */
bool
serverEventFilter
;
/* Does server support modern event filtering */
bool
serverCloseCallback
;
/* Does server support driver close callback */
virObjectEventStatePtr
eventState
;
virConnectCloseCallbackDataPtr
closeCallback
;
...
...
@@ -347,6 +348,11 @@ remoteNetworkBuildEventLifecycle(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
virNetClientPtr
client
ATTRIBUTE_UNUSED
,
void
*
evdata
,
void
*
opaque
);
static
void
remoteConnectNotifyEventConnectionClosed
(
virNetClientProgramPtr
prog
ATTRIBUTE_UNUSED
,
virNetClientPtr
client
ATTRIBUTE_UNUSED
,
void
*
evdata
,
void
*
opaque
);
static
virNetClientProgramEvent
remoteEvents
[]
=
{
{
REMOTE_PROC_DOMAIN_EVENT_LIFECYCLE
,
remoteDomainBuildEventLifecycle
,
...
...
@@ -509,8 +515,23 @@ static virNetClientProgramEvent remoteEvents[] = {
remoteDomainBuildEventCallbackMigrationIteration
,
sizeof
(
remote_domain_event_callback_migration_iteration_msg
),
(
xdrproc_t
)
xdr_remote_domain_event_callback_migration_iteration_msg
},
{
REMOTE_PROC_CONNECT_EVENT_CONNECTION_CLOSED
,
remoteConnectNotifyEventConnectionClosed
,
sizeof
(
remote_connect_event_connection_closed_msg
),
(
xdrproc_t
)
xdr_remote_connect_event_connection_closed_msg
},
};
static
void
remoteConnectNotifyEventConnectionClosed
(
virNetClientProgramPtr
prog
ATTRIBUTE_UNUSED
,
virNetClientPtr
client
ATTRIBUTE_UNUSED
,
void
*
evdata
,
void
*
opaque
)
{
virConnectPtr
conn
=
opaque
;
struct
private_data
*
priv
=
conn
->
privateData
;
remote_connect_event_connection_closed_msg
*
msg
=
evdata
;
virConnectCloseCallbackDataCall
(
priv
->
closeCallback
,
msg
->
reason
);
}
static
void
remoteDomainBuildQemuMonitorEvent
(
virNetClientProgramPtr
prog
ATTRIBUTE_UNUSED
,
...
...
@@ -1067,6 +1088,13 @@ doRemoteOpen(virConnectPtr conn,
"supported by the server"
);
}
priv
->
serverCloseCallback
=
remoteConnectSupportsFeatureUnlocked
(
conn
,
priv
,
VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK
);
if
(
!
priv
->
serverCloseCallback
)
{
VIR_INFO
(
"Close callback registering isn't supported "
"by the remote side."
);
}
/* Successful. */
retcode
=
VIR_DRV_OPEN_SUCCESS
;
...
...
@@ -7908,6 +7936,12 @@ remoteConnectRegisterCloseCallback(virConnectPtr conn,
goto
cleanup
;
}
if
(
priv
->
serverCloseCallback
&&
call
(
conn
,
priv
,
0
,
REMOTE_PROC_CONNECT_CLOSE_CALLBACK_REGISTER
,
(
xdrproc_t
)
xdr_void
,
(
char
*
)
NULL
,
(
xdrproc_t
)
xdr_void
,
(
char
*
)
NULL
)
==
-
1
)
goto
cleanup
;
virConnectCloseCallbackDataRegister
(
priv
->
closeCallback
,
conn
,
cb
,
opaque
,
freecb
);
ret
=
0
;
...
...
@@ -7933,6 +7967,12 @@ remoteConnectUnregisterCloseCallback(virConnectPtr conn,
goto
cleanup
;
}
if
(
priv
->
serverCloseCallback
&&
call
(
conn
,
priv
,
0
,
REMOTE_PROC_CONNECT_CLOSE_CALLBACK_UNREGISTER
,
(
xdrproc_t
)
xdr_void
,
(
char
*
)
NULL
,
(
xdrproc_t
)
xdr_void
,
(
char
*
)
NULL
)
==
-
1
)
goto
cleanup
;
virConnectCloseCallbackDataUnregister
(
priv
->
closeCallback
,
cb
);
ret
=
0
;
...
...
src/remote/remote_protocol.x
浏览文件 @
f484310a
...
...
@@ -3045,6 +3045,10 @@ struct remote_domain_event_callback_device_added_msg {
remote_nonnull_string
devAlias
;
};
struct
remote_connect_event_connection_closed_msg
{
int
reason
;
};
struct
remote_connect_get_cpu_model_names_args
{
remote_nonnull_string
arch
;
int
need_results
;
...
...
@@ -5706,5 +5710,23 @@ enum remote_procedure {
* @generate: both
* @acl: none
*/
REMOTE_PROC_DOMAIN_EVENT_CALLBACK_MIGRATION_ITERATION
=
359
REMOTE_PROC_DOMAIN_EVENT_CALLBACK_MIGRATION_ITERATION
=
359
,
/**
* @generate: none
* @acl: none
*/
REMOTE_PROC_CONNECT_CLOSE_CALLBACK_REGISTER
=
360
,
/**
* @generate: none
* @acl: none
*/
REMOTE_PROC_CONNECT_CLOSE_CALLBACK_UNREGISTER
=
361
,
/**
* @generate: none
* @acl: none
*/
REMOTE_PROC_CONNECT_EVENT_CONNECTION_CLOSED
=
362
};
src/remote_protocol-structs
浏览文件 @
f484310a
...
...
@@ -2502,6 +2502,9 @@ struct remote_domain_event_callback_device_added_msg {
remote_nonnull_domain
dom
;
remote_nonnull_string
devAlias
;
};
struct
remote_connect_event_connection_closed_msg
{
int
reason
;
};
struct
remote_connect_get_cpu_model_names_args
{
remote_nonnull_string
arch
;
int
need_results
;
...
...
@@ -3057,4 +3060,7 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_SET_USER_PASSWORD
=
357
,
REMOTE_PROC_DOMAIN_RENAME
=
358
,
REMOTE_PROC_DOMAIN_EVENT_CALLBACK_MIGRATION_ITERATION
=
359
,
REMOTE_PROC_CONNECT_CLOSE_CALLBACK_REGISTER
=
360
,
REMOTE_PROC_CONNECT_CLOSE_CALLBACK_UNREGISTER
=
361
,
REMOTE_PROC_CONNECT_EVENT_CONNECTION_CLOSED
=
362
,
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录