Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
0958334a
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看板
提交
0958334a
编写于
8月 11, 2014
作者:
T
Taowei
提交者:
Michal Privoznik
8月 15, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vbox: Rewrite vboxConnectListDomains
上级
30a95f30
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
105 addition
and
39 deletion
+105
-39
src/vbox/vbox_common.c
src/vbox/vbox_common.c
+42
-0
src/vbox/vbox_tmpl.c
src/vbox/vbox_tmpl.c
+41
-39
src/vbox/vbox_uniformed_api.h
src/vbox/vbox_uniformed_api.h
+22
-0
未找到文件。
src/vbox/vbox_common.c
浏览文件 @
0958334a
...
...
@@ -97,6 +97,10 @@ if (!data->vboxObj) {\
#define VBOX_IID_INITIALIZE(iid) gVBoxAPI.UIID.vboxIIDInitialize(iid)
#define ARRAY_GET_MACHINES \
(gVBoxAPI.UArray.handleGetMachines(data->vboxObj))
/* global vbox API, used for all common codes. */
static
vboxUniformedAPI
gVBoxAPI
;
...
...
@@ -474,3 +478,41 @@ char *vboxConnectGetCapabilities(virConnectPtr conn)
return
ret
;
}
int
vboxConnectListDomains
(
virConnectPtr
conn
,
int
*
ids
,
int
nids
)
{
VBOX_OBJECT_CHECK
(
conn
,
int
,
-
1
);
vboxArray
machines
=
VBOX_ARRAY_INITIALIZER
;
PRUint32
state
;
nsresult
rc
;
size_t
i
,
j
;
rc
=
gVBoxAPI
.
UArray
.
vboxArrayGet
(
&
machines
,
data
->
vboxObj
,
ARRAY_GET_MACHINES
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not get list of Domains, rc=%08x"
),
(
unsigned
)
rc
);
goto
cleanup
;
}
ret
=
0
;
for
(
i
=
0
,
j
=
0
;
(
i
<
machines
.
count
)
&&
(
j
<
nids
);
++
i
)
{
IMachine
*
machine
=
machines
.
items
[
i
];
if
(
machine
)
{
PRBool
isAccessible
=
PR_FALSE
;
gVBoxAPI
.
UIMachine
.
GetAccessible
(
machine
,
&
isAccessible
);
if
(
isAccessible
)
{
gVBoxAPI
.
UIMachine
.
GetState
(
machine
,
&
state
);
if
(
gVBoxAPI
.
machineStateChecker
.
Online
(
state
))
{
ret
++
;
ids
[
j
++
]
=
i
+
1
;
}
}
}
}
cleanup:
gVBoxAPI
.
UArray
.
vboxArrayRelease
(
&
machines
);
return
ret
;
}
src/vbox/vbox_tmpl.c
浏览文件 @
0958334a
...
...
@@ -921,45 +921,6 @@ vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16,
return
result
;
}
static
int
vboxConnectListDomains
(
virConnectPtr
conn
,
int
*
ids
,
int
nids
)
{
VBOX_OBJECT_CHECK
(
conn
,
int
,
-
1
);
vboxArray
machines
=
VBOX_ARRAY_INITIALIZER
;
PRUint32
state
;
nsresult
rc
;
size_t
i
,
j
;
rc
=
vboxArrayGet
(
&
machines
,
data
->
vboxObj
,
data
->
vboxObj
->
vtbl
->
GetMachines
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not get list of Domains, rc=%08x"
),
(
unsigned
)
rc
);
goto
cleanup
;
}
ret
=
0
;
for
(
i
=
0
,
j
=
0
;
(
i
<
machines
.
count
)
&&
(
j
<
nids
);
++
i
)
{
IMachine
*
machine
=
machines
.
items
[
i
];
if
(
machine
)
{
PRBool
isAccessible
=
PR_FALSE
;
machine
->
vtbl
->
GetAccessible
(
machine
,
&
isAccessible
);
if
(
isAccessible
)
{
machine
->
vtbl
->
GetState
(
machine
,
&
state
);
if
((
state
>=
MachineState_FirstOnline
)
&&
(
state
<=
MachineState_LastOnline
))
{
ret
++
;
ids
[
j
++
]
=
i
+
1
;
}
}
}
}
cleanup:
vboxArrayRelease
(
&
machines
);
return
ret
;
}
static
int
vboxConnectNumOfDomains
(
virConnectPtr
conn
)
{
VBOX_OBJECT_CHECK
(
conn
,
int
,
-
1
);
...
...
@@ -11290,6 +11251,11 @@ static void _DEBUGIID(const char *msg, vboxIIDUnion *iidu)
#endif
/* VBOX_API_VERSION != 2002000 */
static
void
*
_handleGetMachines
(
IVirtualBox
*
vboxObj
)
{
return
vboxObj
->
vtbl
->
GetMachines
;
}
static
nsresult
_nsisupportsRelease
(
nsISupports
*
nsi
)
{
return
nsi
->
vtbl
->
Release
(
nsi
);
...
...
@@ -11325,6 +11291,18 @@ _virtualboxGetSystemProperties(IVirtualBox *vboxObj, ISystemProperties **systemP
return
vboxObj
->
vtbl
->
GetSystemProperties
(
vboxObj
,
systemProperties
);
}
static
nsresult
_machineGetAccessible
(
IMachine
*
machine
,
PRBool
*
isAccessible
)
{
return
machine
->
vtbl
->
GetAccessible
(
machine
,
isAccessible
);
}
static
nsresult
_machineGetState
(
IMachine
*
machine
,
PRUint32
*
state
)
{
return
machine
->
vtbl
->
GetState
(
machine
,
state
);
}
#if VBOX_API_VERSION < 4000000
static
nsresult
...
...
@@ -11389,6 +11367,12 @@ _systemPropertiesGetMaxGuestCPUCount(ISystemProperties *systemProperties, PRUint
return
systemProperties
->
vtbl
->
GetMaxGuestCPUCount
(
systemProperties
,
maxCPUCount
);
}
static
bool
_machineStateOnline
(
PRUint32
state
)
{
return
((
state
>=
MachineState_FirstOnline
)
&&
(
state
<=
MachineState_LastOnline
));
}
static
vboxUniformedPFN
_UPFN
=
{
.
Initialize
=
_pfnInitialize
,
.
Uninitialize
=
_pfnUninitialize
,
...
...
@@ -11409,6 +11393,12 @@ static vboxUniformedIID _UIID = {
.
DEBUGIID
=
_DEBUGIID
,
};
static
vboxUniformedArray
_UArray
=
{
.
vboxArrayGet
=
vboxArrayGet
,
.
vboxArrayRelease
=
vboxArrayRelease
,
.
handleGetMachines
=
_handleGetMachines
,
};
static
vboxUniformednsISupports
_nsUISupports
=
{
.
Release
=
_nsisupportsRelease
,
};
...
...
@@ -11419,6 +11409,11 @@ static vboxUniformedIVirtualBox _UIVirtualBox = {
.
GetSystemProperties
=
_virtualboxGetSystemProperties
,
};
static
vboxUniformedIMachine
_UIMachine
=
{
.
GetAccessible
=
_machineGetAccessible
,
.
GetState
=
_machineGetState
,
};
static
vboxUniformedISession
_UISession
=
{
.
OpenExisting
=
_sessionOpenExisting
,
.
GetConsole
=
_sessionGetConsole
,
...
...
@@ -11438,6 +11433,10 @@ static vboxUniformedISystemProperties _UISystemProperties = {
.
GetMaxGuestCPUCount
=
_systemPropertiesGetMaxGuestCPUCount
,
};
static
uniformedMachineStateChecker
_machineStateChecker
=
{
.
Online
=
_machineStateOnline
,
};
void
NAME
(
InstallUniformedAPI
)(
vboxUniformedAPI
*
pVBoxAPI
)
{
pVBoxAPI
->
APIVersion
=
VBOX_API_VERSION
;
...
...
@@ -11446,12 +11445,15 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI)
pVBoxAPI
->
registerGlobalData
=
_registerGlobalData
;
pVBoxAPI
->
UPFN
=
_UPFN
;
pVBoxAPI
->
UIID
=
_UIID
;
pVBoxAPI
->
UArray
=
_UArray
;
pVBoxAPI
->
nsUISupports
=
_nsUISupports
;
pVBoxAPI
->
UIVirtualBox
=
_UIVirtualBox
;
pVBoxAPI
->
UIMachine
=
_UIMachine
;
pVBoxAPI
->
UISession
=
_UISession
;
pVBoxAPI
->
UIConsole
=
_UIConsole
;
pVBoxAPI
->
UIProgress
=
_UIProgress
;
pVBoxAPI
->
UISystemProperties
=
_UISystemProperties
;
pVBoxAPI
->
machineStateChecker
=
_machineStateChecker
;
#if VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000
pVBoxAPI
->
domainEventCallbacks
=
0
;
...
...
src/vbox/vbox_uniformed_api.h
浏览文件 @
0958334a
...
...
@@ -162,6 +162,14 @@ typedef struct {
void
(
*
DEBUGIID
)(
const
char
*
msg
,
vboxIIDUnion
*
iidu
);
}
vboxUniformedIID
;
/* Functions for vboxArray */
typedef
struct
{
nsresult
(
*
vboxArrayGet
)(
vboxArray
*
array
,
void
*
self
,
void
*
getter
);
void
(
*
vboxArrayRelease
)(
vboxArray
*
array
);
/* Generate function pointers for vboxArrayGet */
void
*
(
*
handleGetMachines
)(
IVirtualBox
*
vboxObj
);
}
vboxUniformedArray
;
/* Functions for nsISupports */
typedef
struct
{
nsresult
(
*
Release
)(
nsISupports
*
nsi
);
...
...
@@ -174,6 +182,12 @@ typedef struct {
nsresult
(
*
GetSystemProperties
)(
IVirtualBox
*
vboxObj
,
ISystemProperties
**
systemProperties
);
}
vboxUniformedIVirtualBox
;
/* Functions for IMachine */
typedef
struct
{
nsresult
(
*
GetAccessible
)(
IMachine
*
machine
,
PRBool
*
isAccessible
);
nsresult
(
*
GetState
)(
IMachine
*
machine
,
PRUint32
*
state
);
}
vboxUniformedIMachine
;
/* Functions for ISession */
typedef
struct
{
nsresult
(
*
OpenExisting
)(
vboxGlobalData
*
data
,
vboxIIDUnion
*
iidu
,
IMachine
*
machine
);
...
...
@@ -197,6 +211,10 @@ typedef struct {
nsresult
(
*
GetMaxGuestCPUCount
)(
ISystemProperties
*
systemProperties
,
PRUint32
*
maxCPUCount
);
}
vboxUniformedISystemProperties
;
typedef
struct
{
bool
(
*
Online
)(
PRUint32
state
);
}
uniformedMachineStateChecker
;
typedef
struct
{
/* vbox API version */
uint32_t
APIVersion
;
...
...
@@ -206,12 +224,15 @@ typedef struct {
void
(
*
registerGlobalData
)(
vboxGlobalData
*
data
);
vboxUniformedPFN
UPFN
;
vboxUniformedIID
UIID
;
vboxUniformedArray
UArray
;
vboxUniformednsISupports
nsUISupports
;
vboxUniformedIVirtualBox
UIVirtualBox
;
vboxUniformedIMachine
UIMachine
;
vboxUniformedISession
UISession
;
vboxUniformedIConsole
UIConsole
;
vboxUniformedIProgress
UIProgress
;
vboxUniformedISystemProperties
UISystemProperties
;
uniformedMachineStateChecker
machineStateChecker
;
/* vbox API features */
bool
domainEventCallbacks
;
bool
hasStaticGlobalData
;
...
...
@@ -234,6 +255,7 @@ int vboxConnectIsEncrypted(virConnectPtr conn);
int
vboxConnectIsAlive
(
virConnectPtr
conn
);
int
vboxConnectGetMaxVcpus
(
virConnectPtr
conn
,
const
char
*
type
);
char
*
vboxConnectGetCapabilities
(
virConnectPtr
conn
);
int
vboxConnectListDomains
(
virConnectPtr
conn
,
int
*
ids
,
int
nids
);
/* Version specified functions for installing uniformed API */
void
vbox22InstallUniformedAPI
(
vboxUniformedAPI
*
pVBoxAPI
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录