Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
ce1cef1c
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,发现更多精彩内容 >>
提交
ce1cef1c
编写于
10月 02, 2014
作者:
T
Taowei
提交者:
Michal Privoznik
10月 03, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vbox: Rewrite vboxConnectListNetworks
上级
a8b1b043
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
86 addition
and
45 deletion
+86
-45
src/vbox/vbox_network.c
src/vbox/vbox_network.c
+77
-0
src/vbox/vbox_tmpl.c
src/vbox/vbox_tmpl.c
+7
-45
src/vbox/vbox_uniformed_api.h
src/vbox/vbox_uniformed_api.h
+2
-0
未找到文件。
src/vbox/vbox_network.c
浏览文件 @
ce1cef1c
...
...
@@ -25,6 +25,7 @@
#include "domain_conf.h"
#include "domain_event.h"
#include "virlog.h"
#include "virstring.h"
#include "vbox_common.h"
#include "vbox_uniformed_api.h"
...
...
@@ -33,6 +34,25 @@
VIR_LOG_INIT
(
"vbox.vbox_network"
);
#define VBOX_UTF16_FREE(arg) \
do { \
if (arg) { \
gVBoxAPI.UPFN.Utf16Free(data->pFuncs, arg); \
(arg) = NULL; \
} \
} while (0)
#define VBOX_UTF8_FREE(arg) \
do { \
if (arg) { \
gVBoxAPI.UPFN.Utf8Free(data->pFuncs, arg); \
(arg) = NULL; \
} \
} while (0)
#define VBOX_UTF16_TO_UTF8(arg1, arg2) gVBoxAPI.UPFN.Utf16ToUtf8(data->pFuncs, arg1, arg2)
#define VBOX_UTF8_TO_UTF16(arg1, arg2) gVBoxAPI.UPFN.Utf8ToUtf16(data->pFuncs, arg1, arg2)
#define VBOX_RELEASE(arg) \
do { \
if (arg) { \
...
...
@@ -120,3 +140,60 @@ int vboxConnectNumOfNetworks(virConnectPtr conn)
VIR_DEBUG
(
"numActive: %d"
,
ret
);
return
ret
;
}
int
vboxConnectListNetworks
(
virConnectPtr
conn
,
char
**
const
names
,
int
nnames
)
{
vboxGlobalData
*
data
=
conn
->
privateData
;
vboxArray
networkInterfaces
=
VBOX_ARRAY_INITIALIZER
;
IHost
*
host
=
NULL
;
size_t
i
=
0
;
int
ret
=
-
1
;
if
(
!
data
->
vboxObj
)
return
ret
;
gVBoxAPI
.
UIVirtualBox
.
GetHost
(
data
->
vboxObj
,
&
host
);
if
(
!
host
)
return
ret
;
gVBoxAPI
.
UArray
.
vboxArrayGet
(
&
networkInterfaces
,
host
,
gVBoxAPI
.
UArray
.
handleHostGetNetworkInterfaces
(
host
));
ret
=
0
;
for
(
i
=
0
;
(
ret
<
nnames
)
&&
(
i
<
networkInterfaces
.
count
);
i
++
)
{
IHostNetworkInterface
*
networkInterface
=
networkInterfaces
.
items
[
i
];
char
*
nameUtf8
=
NULL
;
PRUnichar
*
nameUtf16
=
NULL
;
PRUint32
interfaceType
=
0
;
PRUint32
status
=
HostNetworkInterfaceStatus_Unknown
;
if
(
!
networkInterface
)
continue
;
gVBoxAPI
.
UIHNInterface
.
GetInterfaceType
(
networkInterface
,
&
interfaceType
);
if
(
interfaceType
!=
HostNetworkInterfaceType_HostOnly
)
continue
;
gVBoxAPI
.
UIHNInterface
.
GetStatus
(
networkInterface
,
&
status
);
if
(
status
!=
HostNetworkInterfaceStatus_Up
)
continue
;
gVBoxAPI
.
UIHNInterface
.
GetName
(
networkInterface
,
&
nameUtf16
);
VBOX_UTF16_TO_UTF8
(
nameUtf16
,
&
nameUtf8
);
VIR_DEBUG
(
"nnames[%d]: %s"
,
ret
,
nameUtf8
);
if
(
VIR_STRDUP
(
names
[
ret
],
nameUtf8
)
>=
0
)
ret
++
;
VBOX_UTF8_FREE
(
nameUtf8
);
VBOX_UTF16_FREE
(
nameUtf16
);
}
gVBoxAPI
.
UArray
.
vboxArrayRelease
(
&
networkInterfaces
);
VBOX_RELEASE
(
host
);
return
ret
;
}
src/vbox/vbox_tmpl.c
浏览文件 @
ce1cef1c
...
...
@@ -2060,51 +2060,6 @@ _registerDomainEvent(virDriverPtr driver)
* The Network Functions here on
*/
static
int
vboxConnectListNetworks
(
virConnectPtr
conn
,
char
**
const
names
,
int
nnames
)
{
VBOX_OBJECT_HOST_CHECK
(
conn
,
int
,
0
);
vboxArray
networkInterfaces
=
VBOX_ARRAY_INITIALIZER
;
size_t
i
=
0
;
vboxArrayGet
(
&
networkInterfaces
,
host
,
host
->
vtbl
->
GetNetworkInterfaces
);
for
(
i
=
0
;
(
ret
<
nnames
)
&&
(
i
<
networkInterfaces
.
count
);
i
++
)
{
IHostNetworkInterface
*
networkInterface
=
networkInterfaces
.
items
[
i
];
if
(
networkInterface
)
{
PRUint32
interfaceType
=
0
;
networkInterface
->
vtbl
->
GetInterfaceType
(
networkInterface
,
&
interfaceType
);
if
(
interfaceType
==
HostNetworkInterfaceType_HostOnly
)
{
PRUint32
status
=
HostNetworkInterfaceStatus_Unknown
;
networkInterface
->
vtbl
->
GetStatus
(
networkInterface
,
&
status
);
if
(
status
==
HostNetworkInterfaceStatus_Up
)
{
char
*
nameUtf8
=
NULL
;
PRUnichar
*
nameUtf16
=
NULL
;
networkInterface
->
vtbl
->
GetName
(
networkInterface
,
&
nameUtf16
);
VBOX_UTF16_TO_UTF8
(
nameUtf16
,
&
nameUtf8
);
VIR_DEBUG
(
"nnames[%d]: %s"
,
ret
,
nameUtf8
);
if
(
VIR_STRDUP
(
names
[
ret
],
nameUtf8
)
>=
0
)
ret
++
;
VBOX_UTF8_FREE
(
nameUtf8
);
VBOX_UTF16_FREE
(
nameUtf16
);
}
}
}
}
vboxArrayRelease
(
&
networkInterfaces
);
VBOX_RELEASE
(
host
);
return
ret
;
}
static
int
vboxConnectNumOfDefinedNetworks
(
virConnectPtr
conn
)
{
VBOX_OBJECT_HOST_CHECK
(
conn
,
int
,
0
);
...
...
@@ -6032,6 +5987,12 @@ _hnInterfaceGetStatus(IHostNetworkInterface *hni, PRUint32 *status)
return
hni
->
vtbl
->
GetStatus
(
hni
,
status
);
}
static
nsresult
_hnInterfaceGetName
(
IHostNetworkInterface
*
hni
,
PRUnichar
**
name
)
{
return
hni
->
vtbl
->
GetName
(
hni
,
name
);
}
static
bool
_machineStateOnline
(
PRUint32
state
)
{
return
((
state
>=
MachineState_FirstOnline
)
&&
...
...
@@ -6338,6 +6299,7 @@ static vboxUniformedIDisplay _UIDisplay = {
static
vboxUniformedIHNInterface
_UIHNInterface
=
{
.
GetInterfaceType
=
_hnInterfaceGetInterfaceType
,
.
GetStatus
=
_hnInterfaceGetStatus
,
.
GetName
=
_hnInterfaceGetName
,
};
static
uniformedMachineStateChecker
_machineStateChecker
=
{
...
...
src/vbox/vbox_uniformed_api.h
浏览文件 @
ce1cef1c
...
...
@@ -470,6 +470,7 @@ typedef struct {
typedef
struct
{
nsresult
(
*
GetInterfaceType
)(
IHostNetworkInterface
*
hni
,
PRUint32
*
interfaceType
);
nsresult
(
*
GetStatus
)(
IHostNetworkInterface
*
hni
,
PRUint32
*
status
);
nsresult
(
*
GetName
)(
IHostNetworkInterface
*
hni
,
PRUnichar
**
name
);
}
vboxUniformedIHNInterface
;
typedef
struct
{
...
...
@@ -548,6 +549,7 @@ virDrvOpenStatus vboxNetworkOpen(virConnectPtr conn,
unsigned
int
flags
);
int
vboxNetworkClose
(
virConnectPtr
conn
);
int
vboxConnectNumOfNetworks
(
virConnectPtr
conn
);
int
vboxConnectListNetworks
(
virConnectPtr
conn
,
char
**
const
names
,
int
nnames
);
/* 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录