Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
c9006b6b
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看板
提交
c9006b6b
编写于
12月 06, 2010
作者:
M
Matthias Bolte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
esx: Refactor storage pool type lookup into a function
上级
2a151699
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
56 addition
and
74 deletion
+56
-74
src/esx/esx_storage_driver.c
src/esx/esx_storage_driver.c
+56
-74
未找到文件。
src/esx/esx_storage_driver.c
浏览文件 @
c9006b6b
...
@@ -49,6 +49,58 @@ verify(MD5_DIGEST_SIZE == VIR_UUID_BUFLEN);
...
@@ -49,6 +49,58 @@ verify(MD5_DIGEST_SIZE == VIR_UUID_BUFLEN);
static
int
esxStoragePoolLookupType
(
esxVI_Context
*
ctx
,
const
char
*
poolName
,
int
*
poolType
)
{
int
result
=
-
1
;
esxVI_String
*
propertyNameList
=
NULL
;
esxVI_ObjectContent
*
datastore
=
NULL
;
esxVI_DynamicProperty
*
dynamicProperty
=
NULL
;
esxVI_DatastoreInfo
*
datastoreInfo
=
NULL
;
if
(
esxVI_String_AppendValueToList
(
&
propertyNameList
,
"info"
)
<
0
||
esxVI_LookupDatastoreByName
(
ctx
,
poolName
,
propertyNameList
,
&
datastore
,
esxVI_Occurrence_RequiredItem
)
<
0
)
{
goto
cleanup
;
}
for
(
dynamicProperty
=
datastore
->
propSet
;
dynamicProperty
!=
NULL
;
dynamicProperty
=
dynamicProperty
->
_next
)
{
if
(
STREQ
(
dynamicProperty
->
name
,
"info"
))
{
if
(
esxVI_DatastoreInfo_CastFromAnyType
(
dynamicProperty
->
val
,
&
datastoreInfo
)
<
0
)
{
goto
cleanup
;
}
break
;
}
}
if
(
esxVI_LocalDatastoreInfo_DynamicCast
(
datastoreInfo
)
!=
NULL
)
{
*
poolType
=
VIR_STORAGE_POOL_DIR
;
}
else
if
(
esxVI_NasDatastoreInfo_DynamicCast
(
datastoreInfo
)
!=
NULL
)
{
*
poolType
=
VIR_STORAGE_POOL_NETFS
;
}
else
if
(
esxVI_VmfsDatastoreInfo_DynamicCast
(
datastoreInfo
)
!=
NULL
)
{
*
poolType
=
VIR_STORAGE_POOL_FS
;
}
else
{
ESX_ERROR
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"DatastoreInfo has unexpected type"
));
goto
cleanup
;
}
result
=
0
;
cleanup:
esxVI_String_Free
(
&
propertyNameList
);
esxVI_ObjectContent_Free
(
&
datastore
);
esxVI_DatastoreInfo_Free
(
&
datastoreInfo
);
return
result
;
}
static
virDrvOpenStatus
static
virDrvOpenStatus
esxStorageOpen
(
virConnectPtr
conn
,
esxStorageOpen
(
virConnectPtr
conn
,
virConnectAuthPtr
auth
ATTRIBUTE_UNUSED
,
virConnectAuthPtr
auth
ATTRIBUTE_UNUSED
,
...
@@ -908,10 +960,6 @@ esxStorageVolumeCreateXML(virStoragePoolPtr pool, const char *xmldesc,
...
@@ -908,10 +960,6 @@ esxStorageVolumeCreateXML(virStoragePoolPtr pool, const char *xmldesc,
{
{
virStorageVolPtr
volume
=
NULL
;
virStorageVolPtr
volume
=
NULL
;
esxPrivate
*
priv
=
pool
->
conn
->
storagePrivateData
;
esxPrivate
*
priv
=
pool
->
conn
->
storagePrivateData
;
esxVI_String
*
propertyNameList
=
NULL
;
esxVI_ObjectContent
*
datastore
=
NULL
;
esxVI_DynamicProperty
*
dynamicProperty
=
NULL
;
esxVI_DatastoreInfo
*
datastoreInfo
=
NULL
;
virStoragePoolDef
poolDef
;
virStoragePoolDef
poolDef
;
virStorageVolDefPtr
def
=
NULL
;
virStorageVolDefPtr
def
=
NULL
;
char
*
tmp
;
char
*
tmp
;
...
@@ -938,36 +986,8 @@ esxStorageVolumeCreateXML(virStoragePoolPtr pool, const char *xmldesc,
...
@@ -938,36 +986,8 @@ esxStorageVolumeCreateXML(virStoragePoolPtr pool, const char *xmldesc,
return
NULL
;
return
NULL
;
}
}
/* Lookup storage pool type */
if
(
esxStoragePoolLookupType
(
priv
->
primary
,
pool
->
name
,
&
poolDef
.
type
)
<
0
)
{
if
(
esxVI_String_AppendValueToList
(
&
propertyNameList
,
"info"
)
<
0
||
return
NULL
;
esxVI_LookupDatastoreByName
(
priv
->
primary
,
pool
->
name
,
propertyNameList
,
&
datastore
,
esxVI_Occurrence_RequiredItem
)
<
0
)
{
goto
cleanup
;
}
for
(
dynamicProperty
=
datastore
->
propSet
;
dynamicProperty
!=
NULL
;
dynamicProperty
=
dynamicProperty
->
_next
)
{
if
(
STREQ
(
dynamicProperty
->
name
,
"info"
))
{
if
(
esxVI_DatastoreInfo_CastFromAnyType
(
dynamicProperty
->
val
,
&
datastoreInfo
)
<
0
)
{
goto
cleanup
;
}
break
;
}
}
if
(
esxVI_LocalDatastoreInfo_DynamicCast
(
datastoreInfo
)
!=
NULL
)
{
poolDef
.
type
=
VIR_STORAGE_POOL_DIR
;
}
else
if
(
esxVI_NasDatastoreInfo_DynamicCast
(
datastoreInfo
)
!=
NULL
)
{
poolDef
.
type
=
VIR_STORAGE_POOL_NETFS
;
}
else
if
(
esxVI_VmfsDatastoreInfo_DynamicCast
(
datastoreInfo
)
!=
NULL
)
{
poolDef
.
type
=
VIR_STORAGE_POOL_FS
;
}
else
{
ESX_ERROR
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"DatastoreInfo has unexpected type"
));
goto
cleanup
;
}
}
/* Parse config */
/* Parse config */
...
@@ -1140,9 +1160,6 @@ esxStorageVolumeCreateXML(virStoragePoolPtr pool, const char *xmldesc,
...
@@ -1140,9 +1160,6 @@ esxStorageVolumeCreateXML(virStoragePoolPtr pool, const char *xmldesc,
virtualDiskSpec
->
adapterType
=
NULL
;
virtualDiskSpec
->
adapterType
=
NULL
;
}
}
esxVI_String_Free
(
&
propertyNameList
);
esxVI_ObjectContent_Free
(
&
datastore
);
esxVI_DatastoreInfo_Free
(
&
datastoreInfo
);
virStorageVolDefFree
(
def
);
virStorageVolDefFree
(
def
);
VIR_FREE
(
unescapedDatastorePath
);
VIR_FREE
(
unescapedDatastorePath
);
VIR_FREE
(
unescapedDirectoryName
);
VIR_FREE
(
unescapedDirectoryName
);
...
@@ -1216,10 +1233,6 @@ static char *
...
@@ -1216,10 +1233,6 @@ static char *
esxStorageVolumeDumpXML
(
virStorageVolPtr
volume
,
unsigned
int
flags
)
esxStorageVolumeDumpXML
(
virStorageVolPtr
volume
,
unsigned
int
flags
)
{
{
esxPrivate
*
priv
=
volume
->
conn
->
storagePrivateData
;
esxPrivate
*
priv
=
volume
->
conn
->
storagePrivateData
;
esxVI_String
*
propertyNameList
=
NULL
;
esxVI_ObjectContent
*
datastore
=
NULL
;
esxVI_DynamicProperty
*
dynamicProperty
=
NULL
;
esxVI_DatastoreInfo
*
datastoreInfo
=
NULL
;
virStoragePoolDef
pool
;
virStoragePoolDef
pool
;
char
*
datastorePath
=
NULL
;
char
*
datastorePath
=
NULL
;
esxVI_FileInfo
*
fileInfo
=
NULL
;
esxVI_FileInfo
*
fileInfo
=
NULL
;
...
@@ -1238,36 +1251,8 @@ esxStorageVolumeDumpXML(virStorageVolPtr volume, unsigned int flags)
...
@@ -1238,36 +1251,8 @@ esxStorageVolumeDumpXML(virStorageVolPtr volume, unsigned int flags)
return
NULL
;
return
NULL
;
}
}
/* Lookup storage pool type */
if
(
esxStoragePoolLookupType
(
priv
->
primary
,
volume
->
pool
,
&
pool
.
type
)
<
0
)
{
if
(
esxVI_String_AppendValueToList
(
&
propertyNameList
,
"info"
)
<
0
||
return
NULL
;
esxVI_LookupDatastoreByName
(
priv
->
primary
,
volume
->
pool
,
propertyNameList
,
&
datastore
,
esxVI_Occurrence_RequiredItem
)
<
0
)
{
goto
cleanup
;
}
for
(
dynamicProperty
=
datastore
->
propSet
;
dynamicProperty
!=
NULL
;
dynamicProperty
=
dynamicProperty
->
_next
)
{
if
(
STREQ
(
dynamicProperty
->
name
,
"info"
))
{
if
(
esxVI_DatastoreInfo_CastFromAnyType
(
dynamicProperty
->
val
,
&
datastoreInfo
)
<
0
)
{
goto
cleanup
;
}
break
;
}
}
if
(
esxVI_LocalDatastoreInfo_DynamicCast
(
datastoreInfo
)
!=
NULL
)
{
pool
.
type
=
VIR_STORAGE_POOL_DIR
;
}
else
if
(
esxVI_NasDatastoreInfo_DynamicCast
(
datastoreInfo
)
!=
NULL
)
{
pool
.
type
=
VIR_STORAGE_POOL_NETFS
;
}
else
if
(
esxVI_VmfsDatastoreInfo_DynamicCast
(
datastoreInfo
)
!=
NULL
)
{
pool
.
type
=
VIR_STORAGE_POOL_FS
;
}
else
{
ESX_ERROR
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"DatastoreInfo has unexpected type"
));
goto
cleanup
;
}
}
/* Lookup file info */
/* Lookup file info */
...
@@ -1320,9 +1305,6 @@ esxStorageVolumeDumpXML(virStorageVolPtr volume, unsigned int flags)
...
@@ -1320,9 +1305,6 @@ esxStorageVolumeDumpXML(virStorageVolPtr volume, unsigned int flags)
xml
=
virStorageVolDefFormat
(
&
pool
,
&
def
);
xml
=
virStorageVolDefFormat
(
&
pool
,
&
def
);
cleanup:
cleanup:
esxVI_String_Free
(
&
propertyNameList
);
esxVI_ObjectContent_Free
(
&
datastore
);
esxVI_DatastoreInfo_Free
(
&
datastoreInfo
);
VIR_FREE
(
datastorePath
);
VIR_FREE
(
datastorePath
);
esxVI_FileInfo_Free
(
&
fileInfo
);
esxVI_FileInfo_Free
(
&
fileInfo
);
VIR_FREE
(
def
.
key
);
VIR_FREE
(
def
.
key
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录