Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
8921799a
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看板
提交
8921799a
编写于
4月 23, 2011
作者:
M
Matthias Bolte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remote: Refactor remote*Open and remote*Close functions
Add generic versions of the open and close functions and call them.
上级
58b6a5c4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
296 deletion
+51
-296
src/remote/remote_driver.c
src/remote/remote_driver.c
+51
-296
未找到文件。
src/remote/remote_driver.c
浏览文件 @
8921799a
...
...
@@ -3049,9 +3049,8 @@ done:
/*----------------------------------------------------------------------*/
static
virDrvOpenStatus
ATTRIBUTE_NONNULL
(
1
)
remoteNetworkOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
,
int
flags
)
remoteGenericOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
,
int
flags
,
void
**
genericPrivateData
)
{
if
(
inside_daemon
)
return
VIR_DRV_OPEN_DECLINED
;
...
...
@@ -3060,45 +3059,48 @@ remoteNetworkOpen (virConnectPtr conn,
STREQ
(
conn
->
driver
->
name
,
"remote"
))
{
struct
private_data
*
priv
;
/* If we're here, the remote driver is already
/* If we're here, the remote driver is already
* in use due to a) a QEMU uri, or b) a remote
* URI. So we can re-use existing connection
*/
* URI. So we can re-use existing connection */
priv
=
conn
->
privateData
;
remoteDriverLock
(
priv
);
priv
->
localUses
++
;
conn
->
networkPrivateData
=
priv
;
*
genericPrivateData
=
priv
;
remoteDriverUnlock
(
priv
);
return
VIR_DRV_OPEN_SUCCESS
;
}
else
if
(
conn
->
networkDriver
&&
STREQ
(
conn
->
networkDriver
->
name
,
"remote"
))
{
struct
private_data
*
priv
=
conn
->
networkPrivateData
;
remoteDriverLock
(
priv
);
*
genericPrivateData
=
priv
;
priv
->
localUses
++
;
remoteDriverUnlock
(
priv
);
return
VIR_DRV_OPEN_SUCCESS
;
}
else
{
/* Using a non-remote driver, so we need to open a
* new connection for network APIs, forcing it to
* use the UNIX transport. This handles Xen driver
* which doesn't have its own impl of the network APIs.
*/
* which doesn't have its own impl of the network APIs. */
struct
private_data
*
priv
;
int
ret
;
ret
=
remoteOpenSecondaryDriver
(
conn
,
auth
,
flags
,
&
priv
);
ret
=
remoteOpenSecondaryDriver
(
conn
,
auth
,
flags
,
&
priv
);
if
(
ret
==
VIR_DRV_OPEN_SUCCESS
)
conn
->
network
PrivateData
=
priv
;
*
generic
PrivateData
=
priv
;
return
ret
;
}
}
static
int
remote
NetworkClose
(
virConnectPtr
conn
)
remote
GenericClose
(
virConnectPtr
conn
,
void
**
genericPrivateData
)
{
int
rv
=
0
;
struct
private_data
*
priv
=
conn
->
network
PrivateData
;
struct
private_data
*
priv
=
*
generic
PrivateData
;
remoteDriverLock
(
priv
);
priv
->
localUses
--
;
if
(
!
priv
->
localUses
)
{
rv
=
doRemoteClose
(
conn
,
priv
);
conn
->
network
PrivateData
=
NULL
;
*
generic
PrivateData
=
NULL
;
remoteDriverUnlock
(
priv
);
virMutexDestroy
(
&
priv
->
lock
);
VIR_FREE
(
priv
);
...
...
@@ -3108,6 +3110,18 @@ remoteNetworkClose (virConnectPtr conn)
return
rv
;
}
static
virDrvOpenStatus
ATTRIBUTE_NONNULL
(
1
)
remoteNetworkOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
,
int
flags
)
{
return
remoteGenericOpen
(
conn
,
auth
,
flags
,
&
conn
->
networkPrivateData
);
}
static
int
remoteNetworkClose
(
virConnectPtr
conn
)
{
return
remoteGenericClose
(
conn
,
&
conn
->
networkPrivateData
);
}
static
int
remoteListNetworks
(
virConnectPtr
conn
,
char
**
const
names
,
int
maxnames
)
{
...
...
@@ -3230,63 +3244,15 @@ done:
/*----------------------------------------------------------------------*/
static
virDrvOpenStatus
ATTRIBUTE_NONNULL
(
1
)
remoteInterfaceOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
,
int
flags
)
remoteInterfaceOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
,
int
flags
)
{
if
(
inside_daemon
)
return
VIR_DRV_OPEN_DECLINED
;
if
(
conn
->
driver
&&
STREQ
(
conn
->
driver
->
name
,
"remote"
))
{
struct
private_data
*
priv
;
/* If we're here, the remote driver is already
* in use due to a) a QEMU uri, or b) a remote
* URI. So we can re-use existing connection
*/
priv
=
conn
->
privateData
;
remoteDriverLock
(
priv
);
priv
->
localUses
++
;
conn
->
interfacePrivateData
=
priv
;
remoteDriverUnlock
(
priv
);
return
VIR_DRV_OPEN_SUCCESS
;
}
else
{
/* Using a non-remote driver, so we need to open a
* new connection for interface APIs, forcing it to
* use the UNIX transport. This handles Xen driver
* which doesn't have its own impl of the interface APIs.
*/
struct
private_data
*
priv
;
int
ret
;
ret
=
remoteOpenSecondaryDriver
(
conn
,
auth
,
flags
,
&
priv
);
if
(
ret
==
VIR_DRV_OPEN_SUCCESS
)
conn
->
interfacePrivateData
=
priv
;
return
ret
;
}
return
remoteGenericOpen
(
conn
,
auth
,
flags
,
&
conn
->
interfacePrivateData
);
}
static
int
remoteInterfaceClose
(
virConnectPtr
conn
)
remoteInterfaceClose
(
virConnectPtr
conn
)
{
int
rv
=
0
;
struct
private_data
*
priv
=
conn
->
interfacePrivateData
;
remoteDriverLock
(
priv
);
priv
->
localUses
--
;
if
(
!
priv
->
localUses
)
{
rv
=
doRemoteClose
(
conn
,
priv
);
conn
->
interfacePrivateData
=
NULL
;
remoteDriverUnlock
(
priv
);
virMutexDestroy
(
&
priv
->
lock
);
VIR_FREE
(
priv
);
}
if
(
priv
)
remoteDriverUnlock
(
priv
);
return
rv
;
return
remoteGenericClose
(
conn
,
&
conn
->
interfacePrivateData
);
}
static
int
...
...
@@ -3410,70 +3376,15 @@ done:
/*----------------------------------------------------------------------*/
static
virDrvOpenStatus
ATTRIBUTE_NONNULL
(
1
)
remoteStorageOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
,
int
flags
)
remoteStorageOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
,
int
flags
)
{
if
(
inside_daemon
)
return
VIR_DRV_OPEN_DECLINED
;
if
(
conn
->
driver
&&
STREQ
(
conn
->
driver
->
name
,
"remote"
))
{
struct
private_data
*
priv
=
conn
->
privateData
;
/* If we're here, the remote driver is already
* in use due to a) a QEMU uri, or b) a remote
* URI. So we can re-use existing connection
*/
remoteDriverLock
(
priv
);
priv
->
localUses
++
;
conn
->
storagePrivateData
=
priv
;
remoteDriverUnlock
(
priv
);
return
VIR_DRV_OPEN_SUCCESS
;
}
else
if
(
conn
->
networkDriver
&&
STREQ
(
conn
->
networkDriver
->
name
,
"remote"
))
{
struct
private_data
*
priv
=
conn
->
networkPrivateData
;
remoteDriverLock
(
priv
);
conn
->
storagePrivateData
=
priv
;
priv
->
localUses
++
;
remoteDriverUnlock
(
priv
);
return
VIR_DRV_OPEN_SUCCESS
;
}
else
{
/* Using a non-remote driver, so we need to open a
* new connection for network APIs, forcing it to
* use the UNIX transport. This handles Xen driver
* which doesn't have its own impl of the network APIs.
*/
struct
private_data
*
priv
;
int
ret
;
ret
=
remoteOpenSecondaryDriver
(
conn
,
auth
,
flags
,
&
priv
);
if
(
ret
==
VIR_DRV_OPEN_SUCCESS
)
conn
->
storagePrivateData
=
priv
;
return
ret
;
}
return
remoteGenericOpen
(
conn
,
auth
,
flags
,
&
conn
->
storagePrivateData
);
}
static
int
remoteStorageClose
(
virConnectPtr
conn
)
remoteStorageClose
(
virConnectPtr
conn
)
{
int
ret
=
0
;
struct
private_data
*
priv
=
conn
->
storagePrivateData
;
remoteDriverLock
(
priv
);
priv
->
localUses
--
;
if
(
!
priv
->
localUses
)
{
ret
=
doRemoteClose
(
conn
,
priv
);
conn
->
storagePrivateData
=
NULL
;
remoteDriverUnlock
(
priv
);
virMutexDestroy
(
&
priv
->
lock
);
VIR_FREE
(
priv
);
}
if
(
priv
)
remoteDriverUnlock
(
priv
);
return
ret
;
return
remoteGenericClose
(
conn
,
&
conn
->
storagePrivateData
);
}
static
int
...
...
@@ -3691,68 +3602,15 @@ done:
/*----------------------------------------------------------------------*/
static
virDrvOpenStatus
ATTRIBUTE_NONNULL
(
1
)
remoteDevMonOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
ATTRIBUTE_UNUSED
,
int
flags
ATTRIBUTE_UNUSED
)
remoteDevMonOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
,
int
flags
)
{
if
(
inside_daemon
)
return
VIR_DRV_OPEN_DECLINED
;
if
(
conn
->
driver
&&
STREQ
(
conn
->
driver
->
name
,
"remote"
))
{
struct
private_data
*
priv
=
conn
->
privateData
;
/* If we're here, the remote driver is already
* in use due to a) a QEMU uri, or b) a remote
* URI. So we can re-use existing connection
*/
remoteDriverLock
(
priv
);
priv
->
localUses
++
;
conn
->
devMonPrivateData
=
priv
;
remoteDriverUnlock
(
priv
);
return
VIR_DRV_OPEN_SUCCESS
;
}
else
if
(
conn
->
networkDriver
&&
STREQ
(
conn
->
networkDriver
->
name
,
"remote"
))
{
struct
private_data
*
priv
=
conn
->
networkPrivateData
;
remoteDriverLock
(
priv
);
conn
->
devMonPrivateData
=
priv
;
priv
->
localUses
++
;
remoteDriverUnlock
(
priv
);
return
VIR_DRV_OPEN_SUCCESS
;
}
else
{
/* Using a non-remote driver, so we need to open a
* new connection for network APIs, forcing it to
* use the UNIX transport. This handles Xen driver
* which doesn't have its own impl of the network APIs.
*/
struct
private_data
*
priv
;
int
ret
;
ret
=
remoteOpenSecondaryDriver
(
conn
,
auth
,
flags
,
&
priv
);
if
(
ret
==
VIR_DRV_OPEN_SUCCESS
)
conn
->
devMonPrivateData
=
priv
;
return
ret
;
}
return
remoteGenericOpen
(
conn
,
auth
,
flags
,
&
conn
->
devMonPrivateData
);
}
static
int
remoteDevMonClose
(
virConnectPtr
conn
)
static
int
remoteDevMonClose
(
virConnectPtr
conn
)
{
int
ret
=
0
;
struct
private_data
*
priv
=
conn
->
devMonPrivateData
;
remoteDriverLock
(
priv
);
priv
->
localUses
--
;
if
(
!
priv
->
localUses
)
{
ret
=
doRemoteClose
(
conn
,
priv
);
conn
->
devMonPrivateData
=
NULL
;
remoteDriverUnlock
(
priv
);
virMutexDestroy
(
&
priv
->
lock
);
VIR_FREE
(
priv
);
}
if
(
priv
)
remoteDriverUnlock
(
priv
);
return
ret
;
return
remoteGenericClose
(
conn
,
&
conn
->
devMonPrivateData
);
}
static
int
remoteNodeListDevices
(
virConnectPtr
conn
,
...
...
@@ -3976,63 +3834,15 @@ done:
/* ------------------------------------------------------------- */
static
virDrvOpenStatus
ATTRIBUTE_NONNULL
(
1
)
remoteNWFilterOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
,
int
flags
)
remoteNWFilterOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
,
int
flags
)
{
if
(
inside_daemon
)
return
VIR_DRV_OPEN_DECLINED
;
if
(
conn
->
driver
&&
STREQ
(
conn
->
driver
->
name
,
"remote"
))
{
struct
private_data
*
priv
;
/* If we're here, the remote driver is already
* in use due to a) a QEMU uri, or b) a remote
* URI. So we can re-use existing connection
*/
priv
=
conn
->
privateData
;
remoteDriverLock
(
priv
);
priv
->
localUses
++
;
conn
->
nwfilterPrivateData
=
priv
;
remoteDriverUnlock
(
priv
);
return
VIR_DRV_OPEN_SUCCESS
;
}
else
{
/* Using a non-remote driver, so we need to open a
* new connection for network filtering APIs, forcing it to
* use the UNIX transport. This handles Xen driver
* which doesn't have its own impl of the network filtering APIs.
*/
struct
private_data
*
priv
;
int
ret
;
ret
=
remoteOpenSecondaryDriver
(
conn
,
auth
,
flags
,
&
priv
);
if
(
ret
==
VIR_DRV_OPEN_SUCCESS
)
conn
->
nwfilterPrivateData
=
priv
;
return
ret
;
}
return
remoteGenericOpen
(
conn
,
auth
,
flags
,
&
conn
->
nwfilterPrivateData
);
}
static
int
remoteNWFilterClose
(
virConnectPtr
conn
)
remoteNWFilterClose
(
virConnectPtr
conn
)
{
int
rv
=
0
;
struct
private_data
*
priv
=
conn
->
nwfilterPrivateData
;
remoteDriverLock
(
priv
);
priv
->
localUses
--
;
if
(
!
priv
->
localUses
)
{
rv
=
doRemoteClose
(
conn
,
priv
);
conn
->
nwfilterPrivateData
=
NULL
;
remoteDriverUnlock
(
priv
);
virMutexDestroy
(
&
priv
->
lock
);
VIR_FREE
(
priv
);
}
if
(
priv
)
remoteDriverUnlock
(
priv
);
return
rv
;
return
remoteGenericClose
(
conn
,
&
conn
->
nwfilterPrivateData
);
}
static
virNWFilterPtr
...
...
@@ -5116,70 +4926,15 @@ no_memory:
static
virDrvOpenStatus
ATTRIBUTE_NONNULL
(
1
)
remoteSecretOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
,
int
flags
)
remoteSecretOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
,
int
flags
)
{
if
(
inside_daemon
)
return
VIR_DRV_OPEN_DECLINED
;
if
(
conn
->
driver
&&
STREQ
(
conn
->
driver
->
name
,
"remote"
))
{
struct
private_data
*
priv
;
/* If we're here, the remote driver is already
* in use due to a) a QEMU uri, or b) a remote
* URI. So we can re-use existing connection
*/
priv
=
conn
->
privateData
;
remoteDriverLock
(
priv
);
priv
->
localUses
++
;
conn
->
secretPrivateData
=
priv
;
remoteDriverUnlock
(
priv
);
return
VIR_DRV_OPEN_SUCCESS
;
}
else
if
(
conn
->
networkDriver
&&
STREQ
(
conn
->
networkDriver
->
name
,
"remote"
))
{
struct
private_data
*
priv
=
conn
->
networkPrivateData
;
remoteDriverLock
(
priv
);
conn
->
secretPrivateData
=
priv
;
priv
->
localUses
++
;
remoteDriverUnlock
(
priv
);
return
VIR_DRV_OPEN_SUCCESS
;
}
else
{
/* Using a non-remote driver, so we need to open a
* new connection for secret APIs, forcing it to
* use the UNIX transport.
*/
struct
private_data
*
priv
;
int
ret
;
ret
=
remoteOpenSecondaryDriver
(
conn
,
auth
,
flags
,
&
priv
);
if
(
ret
==
VIR_DRV_OPEN_SUCCESS
)
conn
->
secretPrivateData
=
priv
;
return
ret
;
}
return
remoteGenericOpen
(
conn
,
auth
,
flags
,
&
conn
->
secretPrivateData
);
}
static
int
remoteSecretClose
(
virConnectPtr
conn
)
{
int
rv
=
0
;
struct
private_data
*
priv
=
conn
->
secretPrivateData
;
conn
->
secretPrivateData
=
NULL
;
remoteDriverLock
(
priv
);
priv
->
localUses
--
;
if
(
!
priv
->
localUses
)
{
rv
=
doRemoteClose
(
conn
,
priv
);
remoteDriverUnlock
(
priv
);
virMutexDestroy
(
&
priv
->
lock
);
VIR_FREE
(
priv
);
}
if
(
priv
)
remoteDriverUnlock
(
priv
);
return
rv
;
return
remoteGenericClose
(
conn
,
&
conn
->
secretPrivateData
);
}
static
int
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录