Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
f67ae174
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,发现更多精彩内容 >>
提交
f67ae174
编写于
10月 24, 2014
作者:
T
Taowei Luo
提交者:
Michal Privoznik
10月 29, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vbox: Rewrite vboxStorageVolLookupByKey
上级
8a8fa504
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
88 addition
and
70 deletion
+88
-70
src/vbox/vbox_storage.c
src/vbox/vbox_storage.c
+67
-0
src/vbox/vbox_tmpl.c
src/vbox/vbox_tmpl.c
+19
-69
src/vbox/vbox_uniformed_api.h
src/vbox/vbox_uniformed_api.h
+2
-1
未找到文件。
src/vbox/vbox_storage.c
浏览文件 @
f67ae174
...
@@ -276,3 +276,70 @@ virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *
...
@@ -276,3 +276,70 @@ virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *
return
ret
;
return
ret
;
}
}
virStorageVolPtr
vboxStorageVolLookupByKey
(
virConnectPtr
conn
,
const
char
*
key
)
{
vboxGlobalData
*
data
=
conn
->
privateData
;
vboxIIDUnion
hddIID
;
unsigned
char
uuid
[
VIR_UUID_BUFLEN
];
IHardDisk
*
hardDisk
=
NULL
;
PRUnichar
*
hddNameUtf16
=
NULL
;
char
*
hddNameUtf8
=
NULL
;
PRUint32
hddstate
;
nsresult
rc
;
virStorageVolPtr
ret
=
NULL
;
if
(
!
data
->
vboxObj
)
{
return
ret
;
}
VBOX_IID_INITIALIZE
(
&
hddIID
);
if
(
!
key
)
return
ret
;
if
(
virUUIDParse
(
key
,
uuid
)
<
0
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"Could not parse UUID from '%s'"
),
key
);
return
NULL
;
}
vboxIIDFromUUID
(
&
hddIID
,
uuid
);
rc
=
gVBoxAPI
.
UIVirtualBox
.
GetHardDiskByIID
(
data
->
vboxObj
,
&
hddIID
,
&
hardDisk
);
if
(
NS_FAILED
(
rc
))
goto
cleanup
;
gVBoxAPI
.
UIMedium
.
GetState
(
hardDisk
,
&
hddstate
);
if
(
hddstate
==
MediaState_Inaccessible
)
goto
cleanup
;
gVBoxAPI
.
UIMedium
.
GetName
(
hardDisk
,
&
hddNameUtf16
);
if
(
!
hddNameUtf16
)
goto
cleanup
;
VBOX_UTF16_TO_UTF8
(
hddNameUtf16
,
&
hddNameUtf8
);
if
(
!
hddNameUtf8
)
{
VBOX_UTF16_FREE
(
hddNameUtf16
);
goto
cleanup
;
}
if
(
vboxConnectNumOfStoragePools
(
conn
)
==
1
)
{
ret
=
virGetStorageVol
(
conn
,
"default-pool"
,
hddNameUtf8
,
key
,
NULL
,
NULL
);
VIR_DEBUG
(
"Storage Volume Pool: %s"
,
"default-pool"
);
}
else
{
/* TODO: currently only one default pool and thus
* nothing here, change it when pools are supported
*/
}
VIR_DEBUG
(
"Storage Volume Name: %s"
,
key
);
VIR_DEBUG
(
"Storage Volume key : %s"
,
hddNameUtf8
);
VBOX_UTF8_FREE
(
hddNameUtf8
);
VBOX_UTF16_FREE
(
hddNameUtf16
);
cleanup:
VBOX_MEDIUM_RELEASE
(
hardDisk
);
vboxIIDUnalloc
(
&
hddIID
);
return
ret
;
}
src/vbox/vbox_tmpl.c
浏览文件 @
f67ae174
...
@@ -104,7 +104,10 @@ typedef IUSBDeviceFilters IUSBCommon;
...
@@ -104,7 +104,10 @@ typedef IUSBDeviceFilters IUSBCommon;
#if VBOX_API_VERSION < 3001000
#if VBOX_API_VERSION < 3001000
typedef
IHardDiskAttachment
IMediumAttachment
;
typedef
IHardDiskAttachment
IMediumAttachment
;
#endif
/* VBOX_API_VERSION < 3001000 */
#else
/* VBOX_API_VERSION >= 3001000 */
typedef
IMedium
IHardDisk
;
typedef
IMediumAttachment
IHardDiskAttachment
;
#endif
/* VBOX_API_VERSION >= 3001000 */
#include "vbox_uniformed_api.h"
#include "vbox_uniformed_api.h"
...
@@ -171,8 +174,6 @@ if (arg)\
...
@@ -171,8 +174,6 @@ if (arg)\
#else
/* VBOX_API_VERSION >= 3001000 */
#else
/* VBOX_API_VERSION >= 3001000 */
typedef
IMedium
IHardDisk
;
typedef
IMediumAttachment
IHardDiskAttachment
;
# define MediaState_Inaccessible MediumState_Inaccessible
# define MediaState_Inaccessible MediumState_Inaccessible
# define HardDiskVariant_Standard MediumVariant_Standard
# define HardDiskVariant_Standard MediumVariant_Standard
# define HardDiskVariant_Fixed MediumVariant_Fixed
# define HardDiskVariant_Fixed MediumVariant_Fixed
...
@@ -2033,72 +2034,6 @@ _registerDomainEvent(virHypervisorDriverPtr driver)
...
@@ -2033,72 +2034,6 @@ _registerDomainEvent(virHypervisorDriverPtr driver)
* The Storage Functions here on
* The Storage Functions here on
*/
*/
static
virStorageVolPtr
vboxStorageVolLookupByKey
(
virConnectPtr
conn
,
const
char
*
key
)
{
VBOX_OBJECT_CHECK
(
conn
,
virStorageVolPtr
,
NULL
);
vboxIID
hddIID
=
VBOX_IID_INITIALIZER
;
unsigned
char
uuid
[
VIR_UUID_BUFLEN
];
IHardDisk
*
hardDisk
=
NULL
;
nsresult
rc
;
if
(
!
key
)
return
ret
;
if
(
virUUIDParse
(
key
,
uuid
)
<
0
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"Could not parse UUID from '%s'"
),
key
);
return
NULL
;
}
vboxIIDFromUUID
(
&
hddIID
,
uuid
);
#if VBOX_API_VERSION < 4000000
rc
=
data
->
vboxObj
->
vtbl
->
GetHardDisk
(
data
->
vboxObj
,
hddIID
.
value
,
&
hardDisk
);
#elif VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 4002000
rc
=
data
->
vboxObj
->
vtbl
->
FindMedium
(
data
->
vboxObj
,
hddIID
.
value
,
DeviceType_HardDisk
,
&
hardDisk
);
#else
rc
=
data
->
vboxObj
->
vtbl
->
OpenMedium
(
data
->
vboxObj
,
hddIID
.
value
,
DeviceType_HardDisk
,
AccessMode_ReadWrite
,
PR_FALSE
,
&
hardDisk
);
#endif
/* VBOX_API_VERSION >= 4000000 */
if
(
NS_SUCCEEDED
(
rc
))
{
PRUint32
hddstate
;
VBOX_MEDIUM_FUNC_ARG1
(
hardDisk
,
GetState
,
&
hddstate
);
if
(
hddstate
!=
MediaState_Inaccessible
)
{
PRUnichar
*
hddNameUtf16
=
NULL
;
char
*
hddNameUtf8
=
NULL
;
VBOX_MEDIUM_FUNC_ARG1
(
hardDisk
,
GetName
,
&
hddNameUtf16
);
VBOX_UTF16_TO_UTF8
(
hddNameUtf16
,
&
hddNameUtf8
);
if
(
hddNameUtf8
)
{
if
(
vboxConnectNumOfStoragePools
(
conn
)
==
1
)
{
ret
=
virGetStorageVol
(
conn
,
"default-pool"
,
hddNameUtf8
,
key
,
NULL
,
NULL
);
VIR_DEBUG
(
"Storage Volume Pool: %s"
,
"default-pool"
);
}
else
{
/* TODO: currently only one default pool and thus
* nothing here, change it when pools are supported
*/
}
VIR_DEBUG
(
"Storage Volume Name: %s"
,
key
);
VIR_DEBUG
(
"Storage Volume key : %s"
,
hddNameUtf8
);
VBOX_UTF8_FREE
(
hddNameUtf8
);
VBOX_UTF16_FREE
(
hddNameUtf16
);
}
}
VBOX_MEDIUM_RELEASE
(
hardDisk
);
}
vboxIIDUnalloc
(
&
hddIID
);
return
ret
;
}
static
virStorageVolPtr
static
virStorageVolPtr
vboxStorageVolLookupByPath
(
virConnectPtr
conn
,
const
char
*
path
)
vboxStorageVolLookupByPath
(
virConnectPtr
conn
,
const
char
*
path
)
{
{
...
@@ -3660,6 +3595,20 @@ _virtualboxOpenMedium(IVirtualBox *vboxObj ATTRIBUTE_UNUSED,
...
@@ -3660,6 +3595,20 @@ _virtualboxOpenMedium(IVirtualBox *vboxObj ATTRIBUTE_UNUSED,
#endif
#endif
}
}
static
nsresult
_virtualboxGetHardDiskByIID
(
IVirtualBox
*
vboxObj
,
vboxIIDUnion
*
iidu
,
IHardDisk
**
hardDisk
)
{
#if VBOX_API_VERSION < 4000000
return
vboxObj
->
vtbl
->
GetHardDisk
(
vboxObj
,
IID_MEMBER
(
value
),
hardDisk
);
#elif VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 4002000
return
vboxObj
->
vtbl
->
FindMedium
(
vboxObj
,
IID_MEMBER
(
value
),
DeviceType_HardDisk
,
hardDisk
);
#else
/* VBOX_API_VERSION >= 4002000 */
return
vboxObj
->
vtbl
->
OpenMedium
(
vboxObj
,
IID_MEMBER
(
value
),
DeviceType_HardDisk
,
AccessMode_ReadWrite
,
PR_FALSE
,
hardDisk
);
#endif
/* VBOX_API_VERSION >= 4002000 */
}
static
nsresult
static
nsresult
_virtualboxFindDHCPServerByNetworkName
(
IVirtualBox
*
vboxObj
,
PRUnichar
*
name
,
IDHCPServer
**
server
)
_virtualboxFindDHCPServerByNetworkName
(
IVirtualBox
*
vboxObj
,
PRUnichar
*
name
,
IDHCPServer
**
server
)
{
{
...
@@ -5340,6 +5289,7 @@ static vboxUniformedIVirtualBox _UIVirtualBox = {
...
@@ -5340,6 +5289,7 @@ static vboxUniformedIVirtualBox _UIVirtualBox = {
.
RegisterMachine
=
_virtualboxRegisterMachine
,
.
RegisterMachine
=
_virtualboxRegisterMachine
,
.
FindMedium
=
_virtualboxFindMedium
,
.
FindMedium
=
_virtualboxFindMedium
,
.
OpenMedium
=
_virtualboxOpenMedium
,
.
OpenMedium
=
_virtualboxOpenMedium
,
.
GetHardDiskByIID
=
_virtualboxGetHardDiskByIID
,
.
FindDHCPServerByNetworkName
=
_virtualboxFindDHCPServerByNetworkName
,
.
FindDHCPServerByNetworkName
=
_virtualboxFindDHCPServerByNetworkName
,
.
CreateDHCPServer
=
_virtualboxCreateDHCPServer
,
.
CreateDHCPServer
=
_virtualboxCreateDHCPServer
,
.
RemoveDHCPServer
=
_virtualboxRemoveDHCPServer
,
.
RemoveDHCPServer
=
_virtualboxRemoveDHCPServer
,
...
...
src/vbox/vbox_uniformed_api.h
浏览文件 @
f67ae174
...
@@ -198,6 +198,7 @@ typedef struct {
...
@@ -198,6 +198,7 @@ typedef struct {
nsresult
(
*
RegisterMachine
)(
IVirtualBox
*
vboxObj
,
IMachine
*
machine
);
nsresult
(
*
RegisterMachine
)(
IVirtualBox
*
vboxObj
,
IMachine
*
machine
);
nsresult
(
*
FindMedium
)(
IVirtualBox
*
vboxObj
,
PRUnichar
*
location
,
PRUint32
deviceType
,
PRUint32
accessMode
,
IMedium
**
medium
);
nsresult
(
*
FindMedium
)(
IVirtualBox
*
vboxObj
,
PRUnichar
*
location
,
PRUint32
deviceType
,
PRUint32
accessMode
,
IMedium
**
medium
);
nsresult
(
*
OpenMedium
)(
IVirtualBox
*
vboxObj
,
PRUnichar
*
location
,
PRUint32
deviceType
,
PRUint32
accessMode
,
IMedium
**
medium
);
nsresult
(
*
OpenMedium
)(
IVirtualBox
*
vboxObj
,
PRUnichar
*
location
,
PRUint32
deviceType
,
PRUint32
accessMode
,
IMedium
**
medium
);
nsresult
(
*
GetHardDiskByIID
)(
IVirtualBox
*
vboxObj
,
vboxIIDUnion
*
iidu
,
IHardDisk
**
hardDisk
);
nsresult
(
*
FindDHCPServerByNetworkName
)(
IVirtualBox
*
vboxObj
,
PRUnichar
*
name
,
IDHCPServer
**
server
);
nsresult
(
*
FindDHCPServerByNetworkName
)(
IVirtualBox
*
vboxObj
,
PRUnichar
*
name
,
IDHCPServer
**
server
);
nsresult
(
*
CreateDHCPServer
)(
IVirtualBox
*
vboxObj
,
PRUnichar
*
name
,
IDHCPServer
**
server
);
nsresult
(
*
CreateDHCPServer
)(
IVirtualBox
*
vboxObj
,
PRUnichar
*
name
,
IDHCPServer
**
server
);
nsresult
(
*
RemoveDHCPServer
)(
IVirtualBox
*
vboxObj
,
IDHCPServer
*
server
);
nsresult
(
*
RemoveDHCPServer
)(
IVirtualBox
*
vboxObj
,
IDHCPServer
*
server
);
...
@@ -598,7 +599,7 @@ virStoragePoolPtr vboxStoragePoolLookupByName(virConnectPtr conn, const char *na
...
@@ -598,7 +599,7 @@ virStoragePoolPtr vboxStoragePoolLookupByName(virConnectPtr conn, const char *na
int
vboxStoragePoolNumOfVolumes
(
virStoragePoolPtr
pool
);
int
vboxStoragePoolNumOfVolumes
(
virStoragePoolPtr
pool
);
int
vboxStoragePoolListVolumes
(
virStoragePoolPtr
pool
,
char
**
const
names
,
int
nnames
);
int
vboxStoragePoolListVolumes
(
virStoragePoolPtr
pool
,
char
**
const
names
,
int
nnames
);
virStorageVolPtr
vboxStorageVolLookupByName
(
virStoragePoolPtr
pool
,
const
char
*
name
);
virStorageVolPtr
vboxStorageVolLookupByName
(
virStoragePoolPtr
pool
,
const
char
*
name
);
virStorageVolPtr
vboxStorageVolLookupByKey
(
virConnectPtr
conn
,
const
char
*
key
);
/* Version specified functions for installing uniformed API */
/* Version specified functions for installing uniformed API */
void
vbox22InstallUniformedAPI
(
vboxUniformedAPI
*
pVBoxAPI
);
void
vbox22InstallUniformedAPI
(
vboxUniformedAPI
*
pVBoxAPI
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录