Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
88f09b75
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
88f09b75
编写于
3月 01, 2016
作者:
N
Nikolay Shirokovskiy
提交者:
Daniel P. Berrange
3月 01, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
close callback: move it to driver
Signed-off-by:
N
Nikolay Shirokovskiy
<
nshirokovskiy@virtuozzo.com
>
上级
bb582795
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
90 addition
and
41 deletion
+90
-41
src/datatypes.c
src/datatypes.c
+10
-21
src/datatypes.h
src/datatypes.h
+1
-3
src/driver-hypervisor.h
src/driver-hypervisor.h
+12
-0
src/libvirt-host.c
src/libvirt-host.c
+4
-13
src/remote/remote_driver.c
src/remote/remote_driver.c
+63
-4
未找到文件。
src/datatypes.c
浏览文件 @
88f09b75
...
...
@@ -118,22 +118,10 @@ VIR_ONCE_GLOBAL_INIT(virDataTypes)
virConnectPtr
virGetConnect
(
void
)
{
virConnectPtr
ret
;
if
(
virDataTypesInitialize
()
<
0
)
return
NULL
;
if
(
!
(
ret
=
virObjectLockableNew
(
virConnectClass
)))
return
NULL
;
if
(
!
(
ret
->
closeCallback
=
virObjectLockableNew
(
virConnectCloseCallbackDataClass
)))
goto
error
;
return
ret
;
error:
virObjectUnref
(
ret
);
return
NULL
;
return
virObjectLockableNew
(
virConnectClass
);
}
/**
...
...
@@ -154,14 +142,6 @@ virConnectDispose(void *obj)
virResetError
(
&
conn
->
err
);
virURIFree
(
conn
->
uri
);
if
(
conn
->
closeCallback
)
{
virObjectLock
(
conn
->
closeCallback
);
conn
->
closeCallback
->
callback
=
NULL
;
virObjectUnlock
(
conn
->
closeCallback
);
virObjectUnref
(
conn
->
closeCallback
);
}
}
...
...
@@ -189,6 +169,15 @@ virConnectCloseCallbackDataDispose(void *obj)
virConnectCloseCallbackDataReset
(
obj
);
}
virConnectCloseCallbackDataPtr
virNewConnectCloseCallbackData
(
void
)
{
if
(
virDataTypesInitialize
()
<
0
)
return
NULL
;
return
virObjectLockableNew
(
virConnectCloseCallbackDataClass
);
}
void
virConnectCloseCallbackDataRegister
(
virConnectCloseCallbackDataPtr
close
,
virConnectPtr
conn
,
virConnectCloseFunc
cb
,
...
...
src/datatypes.h
浏览文件 @
88f09b75
...
...
@@ -421,9 +421,6 @@ struct _virConnect {
virError
err
;
/* the last error */
virErrorFunc
handler
;
/* associated handler */
void
*
userData
;
/* the user data */
/* Per-connection close callback */
virConnectCloseCallbackDataPtr
closeCallback
;
};
/**
...
...
@@ -640,6 +637,7 @@ virAdmConnectPtr virAdmConnectNew(void);
virAdmServerPtr
virAdmGetServer
(
virAdmConnectPtr
conn
,
const
char
*
name
);
virConnectCloseCallbackDataPtr
virNewConnectCloseCallbackData
(
void
);
void
virConnectCloseCallbackDataRegister
(
virConnectCloseCallbackDataPtr
close
,
virConnectPtr
conn
,
virConnectCloseFunc
cb
,
...
...
src/driver-hypervisor.h
浏览文件 @
88f09b75
...
...
@@ -1212,6 +1212,16 @@ typedef int
const
char
*
password
,
unsigned
int
flags
);
typedef
int
(
*
virDrvConnectRegisterCloseCallback
)(
virConnectPtr
conn
,
virConnectCloseFunc
cb
,
void
*
opaque
,
virFreeCallback
freecb
);
typedef
int
(
*
virDrvConnectUnregisterCloseCallback
)(
virConnectPtr
conn
,
virConnectCloseFunc
cb
);
typedef
struct
_virHypervisorDriver
virHypervisorDriver
;
typedef
virHypervisorDriver
*
virHypervisorDriverPtr
;
...
...
@@ -1443,6 +1453,8 @@ struct _virHypervisorDriver {
virDrvDomainGetFSInfo
domainGetFSInfo
;
virDrvDomainInterfaceAddresses
domainInterfaceAddresses
;
virDrvDomainSetUserPassword
domainSetUserPassword
;
virDrvConnectRegisterCloseCallback
connectRegisterCloseCallback
;
virDrvConnectUnregisterCloseCallback
connectUnregisterCloseCallback
;
};
...
...
src/libvirt-host.c
浏览文件 @
88f09b75
...
...
@@ -1217,14 +1217,9 @@ virConnectRegisterCloseCallback(virConnectPtr conn,
virCheckConnectReturn
(
conn
,
-
1
);
virCheckNonNullArgGoto
(
cb
,
error
);
if
(
virConnectCloseCallbackDataGetCallback
(
conn
->
closeCallback
)
!=
NULL
)
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"A close callback is already registered"
));
if
(
conn
->
driver
->
connectRegisterCloseCallback
&&
conn
->
driver
->
connectRegisterCloseCallback
(
conn
,
cb
,
opaque
,
freecb
)
<
0
)
goto
error
;
}
virConnectCloseCallbackDataRegister
(
conn
->
closeCallback
,
conn
,
cb
,
opaque
,
freecb
);
return
0
;
...
...
@@ -1257,13 +1252,9 @@ virConnectUnregisterCloseCallback(virConnectPtr conn,
virCheckConnectReturn
(
conn
,
-
1
);
virCheckNonNullArgGoto
(
cb
,
error
);
if
(
virConnectCloseCallbackDataGetCallback
(
conn
->
closeCallback
)
!=
cb
)
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"A different callback was requested"
));
if
(
conn
->
driver
->
connectUnregisterCloseCallback
&&
conn
->
driver
->
connectUnregisterCloseCallback
(
conn
,
cb
)
<
0
)
goto
error
;
}
virConnectCloseCallbackDataUnregister
(
conn
->
closeCallback
,
cb
);
return
0
;
...
...
src/remote/remote_driver.c
浏览文件 @
88f09b75
...
...
@@ -96,6 +96,7 @@ struct private_data {
bool
serverEventFilter
;
/* Does server support modern event filtering */
virObjectEventStatePtr
eventState
;
virConnectCloseCallbackDataPtr
closeCallback
;
};
enum
{
...
...
@@ -963,11 +964,13 @@ doRemoteOpen(virConnectPtr conn,
goto
failed
;
}
virObjectRef
(
conn
->
closeCallback
);
if
(
!
(
priv
->
closeCallback
=
virNewConnectCloseCallbackData
()))
goto
failed
;
// ref on behalf of netclient
virObjectRef
(
priv
->
closeCallback
);
virNetClientSetCloseCallback
(
priv
->
client
,
remoteClientCloseFunc
,
conn
->
closeCallback
,
virObjectFreeCallback
);
priv
->
closeCallback
,
virObjectFreeCallback
);
if
(
!
(
priv
->
remoteProgram
=
virNetClientProgramNew
(
REMOTE_PROGRAM
,
REMOTE_PROTOCOL_VERSION
,
...
...
@@ -1097,6 +1100,8 @@ doRemoteOpen(virConnectPtr conn,
virNetClientClose
(
priv
->
client
);
virObjectUnref
(
priv
->
client
);
priv
->
client
=
NULL
;
virObjectUnref
(
priv
->
closeCallback
);
priv
->
closeCallback
=
NULL
;
#ifdef WITH_GNUTLS
virObjectUnref
(
priv
->
tls
);
priv
->
tls
=
NULL
;
...
...
@@ -1229,11 +1234,13 @@ doRemoteClose(virConnectPtr conn, struct private_data *priv)
virNetClientSetCloseCallback
(
priv
->
client
,
NULL
,
conn
->
closeCallback
,
virObjectFreeCallback
);
priv
->
closeCallback
,
virObjectFreeCallback
);
virNetClientClose
(
priv
->
client
);
virObjectUnref
(
priv
->
client
);
priv
->
client
=
NULL
;
virObjectUnref
(
priv
->
closeCallback
);
priv
->
closeCallback
=
NULL
;
virObjectUnref
(
priv
->
remoteProgram
);
virObjectUnref
(
priv
->
lxcProgram
);
virObjectUnref
(
priv
->
qemuProgram
);
...
...
@@ -7887,6 +7894,56 @@ remoteDomainInterfaceAddresses(virDomainPtr dom,
return
rv
;
}
static
int
remoteConnectRegisterCloseCallback
(
virConnectPtr
conn
,
virConnectCloseFunc
cb
,
void
*
opaque
,
virFreeCallback
freecb
)
{
struct
private_data
*
priv
=
conn
->
privateData
;
int
ret
=
-
1
;
remoteDriverLock
(
priv
);
if
(
virConnectCloseCallbackDataGetCallback
(
priv
->
closeCallback
)
!=
NULL
)
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"A close callback is already registered"
));
goto
cleanup
;
}
virConnectCloseCallbackDataRegister
(
priv
->
closeCallback
,
conn
,
cb
,
opaque
,
freecb
);
ret
=
0
;
cleanup:
remoteDriverUnlock
(
priv
);
return
ret
;
}
static
int
remoteConnectUnregisterCloseCallback
(
virConnectPtr
conn
,
virConnectCloseFunc
cb
)
{
struct
private_data
*
priv
=
conn
->
privateData
;
int
ret
=
-
1
;
remoteDriverLock
(
priv
);
if
(
virConnectCloseCallbackDataGetCallback
(
priv
->
closeCallback
)
!=
cb
)
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"A different callback was requested"
));
goto
cleanup
;
}
virConnectCloseCallbackDataUnregister
(
priv
->
closeCallback
,
cb
);
ret
=
0
;
cleanup:
remoteDriverUnlock
(
priv
);
return
ret
;
}
static
int
remoteDomainRename
(
virDomainPtr
dom
,
const
char
*
new_name
,
unsigned
int
flags
)
...
...
@@ -8279,6 +8336,8 @@ static virHypervisorDriver hypervisor_driver = {
.
domainInterfaceAddresses
=
remoteDomainInterfaceAddresses
,
/* 1.2.14 */
.
domainSetUserPassword
=
remoteDomainSetUserPassword
,
/* 1.2.16 */
.
domainRename
=
remoteDomainRename
,
/* 1.2.19 */
.
connectRegisterCloseCallback
=
remoteConnectRegisterCloseCallback
,
/* 1.3.2 */
.
connectUnregisterCloseCallback
=
remoteConnectUnregisterCloseCallback
,
/* 1.3.2 */
};
static
virNetworkDriver
network_driver
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录