Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
247ad915
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看板
提交
247ad915
编写于
11月 13, 2014
作者:
M
Martin Kletzander
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unnecessary curly brackets in rest of src/esx/
Signed-off-by:
N
Martin Kletzander
<
mkletzan@redhat.com
>
上级
090cb1e6
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
198 addition
and
396 deletion
+198
-396
src/esx/esx_device_monitor.c
src/esx/esx_device_monitor.c
+1
-2
src/esx/esx_interface_driver.c
src/esx/esx_interface_driver.c
+4
-8
src/esx/esx_network_driver.c
src/esx/esx_network_driver.c
+19
-38
src/esx/esx_nwfilter_driver.c
src/esx/esx_nwfilter_driver.c
+1
-2
src/esx/esx_secret_driver.c
src/esx/esx_secret_driver.c
+1
-2
src/esx/esx_storage_backend_iscsi.c
src/esx/esx_storage_backend_iscsi.c
+15
-30
src/esx/esx_storage_backend_vmfs.c
src/esx/esx_storage_backend_vmfs.c
+17
-34
src/esx/esx_storage_driver.c
src/esx/esx_storage_driver.c
+27
-54
src/esx/esx_util.c
src/esx/esx_util.c
+15
-30
src/esx/esx_vi.c
src/esx/esx_vi.c
+83
-166
src/esx/esx_vi_types.c
src/esx/esx_vi_types.c
+15
-30
未找到文件。
src/esx/esx_device_monitor.c
浏览文件 @
247ad915
...
...
@@ -43,9 +43,8 @@ esxNodeDeviceOpen(virConnectPtr conn,
{
virCheckFlags
(
VIR_CONNECT_RO
,
VIR_DRV_OPEN_ERROR
);
if
(
conn
->
driver
->
no
!=
VIR_DRV_ESX
)
{
if
(
conn
->
driver
->
no
!=
VIR_DRV_ESX
)
return
VIR_DRV_OPEN_DECLINED
;
}
return
VIR_DRV_OPEN_SUCCESS
;
}
...
...
src/esx/esx_interface_driver.c
浏览文件 @
247ad915
...
...
@@ -46,9 +46,8 @@ esxInterfaceOpen(virConnectPtr conn,
{
virCheckFlags
(
VIR_CONNECT_RO
,
VIR_DRV_OPEN_ERROR
);
if
(
conn
->
driver
->
no
!=
VIR_DRV_ESX
)
{
if
(
conn
->
driver
->
no
!=
VIR_DRV_ESX
)
return
VIR_DRV_OPEN_DECLINED
;
}
return
VIR_DRV_OPEN_SUCCESS
;
}
...
...
@@ -98,9 +97,8 @@ esxConnectListInterfaces(virConnectPtr conn, char **const names, int maxnames)
int
count
=
0
;
size_t
i
;
if
(
maxnames
==
0
)
{
if
(
maxnames
==
0
)
return
0
;
}
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
||
esxVI_LookupPhysicalNicList
(
priv
->
primary
,
&
physicalNicList
)
<
0
)
{
...
...
@@ -119,9 +117,8 @@ esxConnectListInterfaces(virConnectPtr conn, char **const names, int maxnames)
cleanup:
if
(
!
success
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
VIR_FREE
(
names
[
i
]);
}
count
=
-
1
;
}
...
...
@@ -234,9 +231,8 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags)
if
(
physicalNic
->
spec
->
ip
)
{
protocol
.
family
=
(
char
*
)
"ipv4"
;
if
(
physicalNic
->
spec
->
ip
->
dhcp
==
esxVI_Boolean_True
)
{
if
(
physicalNic
->
spec
->
ip
->
dhcp
==
esxVI_Boolean_True
)
protocol
.
dhcp
=
1
;
}
if
(
physicalNic
->
spec
->
ip
->
ipAddress
&&
physicalNic
->
spec
->
ip
->
subnetMask
&&
...
...
src/esx/esx_network_driver.c
浏览文件 @
247ad915
...
...
@@ -52,9 +52,8 @@ esxNetworkOpen(virConnectPtr conn,
{
virCheckFlags
(
VIR_CONNECT_RO
,
VIR_DRV_OPEN_ERROR
);
if
(
conn
->
driver
->
no
!=
VIR_DRV_ESX
)
{
if
(
conn
->
driver
->
no
!=
VIR_DRV_ESX
)
return
VIR_DRV_OPEN_DECLINED
;
}
return
VIR_DRV_OPEN_SUCCESS
;
}
...
...
@@ -105,9 +104,8 @@ esxConnectListNetworks(virConnectPtr conn, char **const names, int maxnames)
int
count
=
0
;
size_t
i
;
if
(
maxnames
==
0
)
{
if
(
maxnames
==
0
)
return
0
;
}
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
||
esxVI_LookupHostVirtualSwitchList
(
priv
->
primary
,
...
...
@@ -127,9 +125,8 @@ esxConnectListNetworks(virConnectPtr conn, char **const names, int maxnames)
cleanup:
if
(
!
success
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
VIR_FREE
(
names
[
i
]);
}
count
=
-
1
;
}
...
...
@@ -181,9 +178,8 @@ esxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
hostVirtualSwitch
=
hostVirtualSwitch
->
_next
)
{
md5_buffer
(
hostVirtualSwitch
->
key
,
strlen
(
hostVirtualSwitch
->
key
),
md5
);
if
(
memcmp
(
uuid
,
md5
,
VIR_UUID_BUFLEN
)
==
0
)
{
if
(
memcmp
(
uuid
,
md5
,
VIR_UUID_BUFLEN
)
==
0
)
break
;
}
}
if
(
!
hostVirtualSwitch
)
{
...
...
@@ -265,34 +261,30 @@ esxBandwidthToShapingPolicy(virNetDevBandwidthPtr bandwidth,
return
0
;
}
if
(
esxVI_HostNetworkTrafficShapingPolicy_Alloc
(
shapingPolicy
)
<
0
)
{
if
(
esxVI_HostNetworkTrafficShapingPolicy_Alloc
(
shapingPolicy
)
<
0
)
goto
cleanup
;
}
(
*
shapingPolicy
)
->
enabled
=
esxVI_Boolean_True
;
if
(
bandwidth
->
in
->
average
>
0
)
{
if
(
esxVI_Long_Alloc
(
&
(
*
shapingPolicy
)
->
averageBandwidth
)
<
0
)
{
if
(
esxVI_Long_Alloc
(
&
(
*
shapingPolicy
)
->
averageBandwidth
)
<
0
)
goto
cleanup
;
}
/* Scale kilobytes per second to bits per second */
(
*
shapingPolicy
)
->
averageBandwidth
->
value
=
bandwidth
->
in
->
average
*
8
*
1000
;
}
if
(
bandwidth
->
in
->
peak
>
0
)
{
if
(
esxVI_Long_Alloc
(
&
(
*
shapingPolicy
)
->
peakBandwidth
)
<
0
)
{
if
(
esxVI_Long_Alloc
(
&
(
*
shapingPolicy
)
->
peakBandwidth
)
<
0
)
goto
cleanup
;
}
/* Scale kilobytes per second to bits per second */
(
*
shapingPolicy
)
->
peakBandwidth
->
value
=
bandwidth
->
in
->
peak
*
8
*
1000
;
}
if
(
bandwidth
->
in
->
burst
>
0
)
{
if
(
esxVI_Long_Alloc
(
&
(
*
shapingPolicy
)
->
burstSize
)
<
0
)
{
if
(
esxVI_Long_Alloc
(
&
(
*
shapingPolicy
)
->
burstSize
)
<
0
)
goto
cleanup
;
}
/* Scale kilobytes to bytes */
(
*
shapingPolicy
)
->
burstSize
->
value
=
bandwidth
->
in
->
burst
*
1024
;
...
...
@@ -301,9 +293,8 @@ esxBandwidthToShapingPolicy(virNetDevBandwidthPtr bandwidth,
result
=
0
;
cleanup:
if
(
result
<
0
)
{
if
(
result
<
0
)
esxVI_HostNetworkTrafficShapingPolicy_Free
(
shapingPolicy
);
}
return
result
;
}
...
...
@@ -328,16 +319,14 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
unsigned
char
md5
[
MD5_DIGEST_SIZE
];
/* MD5_DIGEST_SIZE = VIR_UUID_BUFLEN = 16 */
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
NULL
;
}
/* Parse network XML */
def
=
virNetworkDefParseString
(
xml
);
if
(
!
def
)
{
if
(
!
def
)
return
NULL
;
}
/* Check if an existing HostVirtualSwitch should be edited */
if
(
esxVI_LookupHostVirtualSwitchByName
(
priv
->
primary
,
def
->
name
,
...
...
@@ -372,9 +361,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
/* Verify that specified HostPortGroups don't exist already */
if
(
def
->
nPortGroups
>
0
)
{
if
(
esxVI_LookupHostPortGroupList
(
priv
->
primary
,
&
hostPortGroupList
)
<
0
)
{
if
(
esxVI_LookupHostPortGroupList
(
priv
->
primary
,
&
hostPortGroupList
)
<
0
)
goto
cleanup
;
}
for
(
i
=
0
;
i
<
def
->
nPortGroups
;
++
i
)
{
for
(
hostPortGroup
=
hostPortGroupList
;
hostPortGroup
;
...
...
@@ -405,9 +393,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
(
esxVI_HostVirtualSwitchBridge
*
)
hostVirtualSwitchBondBridge
;
/* Lookup PhysicalNic list and match by name to get key */
if
(
esxVI_LookupPhysicalNicList
(
priv
->
primary
,
&
physicalNicList
)
<
0
)
{
if
(
esxVI_LookupPhysicalNicList
(
priv
->
primary
,
&
physicalNicList
)
<
0
)
goto
cleanup
;
}
for
(
i
=
0
;
i
<
def
->
forward
.
nifs
;
++
i
)
{
bool
found
=
false
;
...
...
@@ -447,9 +434,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
hostVirtualSwitchSpec
->
numPorts
->
value
=
128
;
if
(
def
->
bandwidth
)
{
if
(
esxVI_HostNetworkPolicy_Alloc
(
&
hostVirtualSwitchSpec
->
policy
)
<
0
)
{
if
(
esxVI_HostNetworkPolicy_Alloc
(
&
hostVirtualSwitchSpec
->
policy
)
<
0
)
goto
cleanup
;
}
if
(
esxBandwidthToShapingPolicy
(
def
->
bandwidth
,
...
...
@@ -530,9 +516,8 @@ esxNetworkUndefine(virNetworkPtr network)
esxVI_HostPortGroup
*
hostPortGroup
=
NULL
;
esxVI_HostPortGroupPort
*
hostPortGroupPort
=
NULL
;
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
-
1
;
}
/* Lookup HostVirtualSwitch and HostPortGroup list*/
if
(
esxVI_LookupHostVirtualSwitchByName
(
priv
->
primary
,
network
->
name
,
...
...
@@ -630,9 +615,8 @@ esxShapingPolicyToBandwidth(esxVI_HostNetworkTrafficShapingPolicy *shapingPolicy
return
-
1
;
}
if
(
!
shapingPolicy
||
shapingPolicy
->
enabled
!=
esxVI_Boolean_True
)
{
if
(
!
shapingPolicy
||
shapingPolicy
->
enabled
!=
esxVI_Boolean_True
)
return
0
;
}
if
(
VIR_ALLOC
(
*
bandwidth
)
<
0
||
VIR_ALLOC
((
*
bandwidth
)
->
in
)
<
0
||
...
...
@@ -682,9 +666,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
esxVI_String
*
networkName
=
NULL
;
virNetworkDefPtr
def
;
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
NULL
;
}
if
(
VIR_ALLOC
(
def
)
<
0
)
goto
cleanup
;
...
...
@@ -718,9 +701,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
goto
cleanup
;
/* Find PhysicalNic by key */
if
(
esxVI_LookupPhysicalNicList
(
priv
->
primary
,
&
physicalNicList
)
<
0
)
{
if
(
esxVI_LookupPhysicalNicList
(
priv
->
primary
,
&
physicalNicList
)
<
0
)
goto
cleanup
;
}
for
(
physicalNicKey
=
hostVirtualSwitch
->
pnic
;
physicalNicKey
;
physicalNicKey
=
physicalNicKey
->
_next
)
{
...
...
@@ -781,9 +763,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
}
/* Find HostPortGroup by key */
if
(
esxVI_LookupHostPortGroupList
(
priv
->
primary
,
&
hostPortGroupList
)
<
0
)
{
if
(
esxVI_LookupHostPortGroupList
(
priv
->
primary
,
&
hostPortGroupList
)
<
0
)
goto
cleanup
;
}
for
(
hostPortGroupKey
=
hostVirtualSwitch
->
portgroup
;
hostPortGroupKey
;
hostPortGroupKey
=
hostPortGroupKey
->
_next
)
{
...
...
src/esx/esx_nwfilter_driver.c
浏览文件 @
247ad915
...
...
@@ -43,9 +43,8 @@ esxNWFilterOpen(virConnectPtr conn,
{
virCheckFlags
(
VIR_CONNECT_RO
,
VIR_DRV_OPEN_ERROR
);
if
(
conn
->
driver
->
no
!=
VIR_DRV_ESX
)
{
if
(
conn
->
driver
->
no
!=
VIR_DRV_ESX
)
return
VIR_DRV_OPEN_DECLINED
;
}
return
VIR_DRV_OPEN_SUCCESS
;
}
...
...
src/esx/esx_secret_driver.c
浏览文件 @
247ad915
...
...
@@ -41,9 +41,8 @@ esxSecretOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED,
{
virCheckFlags
(
VIR_CONNECT_RO
,
VIR_DRV_OPEN_ERROR
);
if
(
conn
->
driver
->
no
!=
VIR_DRV_ESX
)
{
if
(
conn
->
driver
->
no
!=
VIR_DRV_ESX
)
return
VIR_DRV_OPEN_DECLINED
;
}
return
VIR_DRV_OPEN_SUCCESS
;
}
...
...
src/esx/esx_storage_backend_iscsi.c
浏览文件 @
247ad915
...
...
@@ -104,9 +104,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
esxVI_HostInternetScsiHbaStaticTarget
*
target
;
size_t
i
;
if
(
maxnames
==
0
)
{
if
(
maxnames
==
0
)
return
0
;
}
if
(
esxVI_LookupHostInternetScsiHba
(
priv
->
primary
,
&
hostInternetScsiHba
)
<
0
)
{
...
...
@@ -140,9 +139,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
cleanup:
if
(
!
success
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
VIR_FREE
(
names
[
i
]);
}
}
esxVI_HostInternetScsiHba_Free
(
&
hostInternetScsiHba
);
...
...
@@ -222,9 +220,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
target
;
target
=
target
->
_next
)
{
md5_buffer
(
target
->
iScsiName
,
strlen
(
target
->
iScsiName
),
md5
);
if
(
memcmp
(
uuid
,
md5
,
VIR_UUID_STRING_BUFLEN
)
==
0
)
{
if
(
memcmp
(
uuid
,
md5
,
VIR_UUID_STRING_BUFLEN
)
==
0
)
break
;
}
}
if
(
!
target
)
{
...
...
@@ -304,15 +301,13 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
memset
(
&
def
,
0
,
sizeof
(
def
));
if
(
esxVI_LookupHostInternetScsiHba
(
priv
->
primary
,
&
hostInternetScsiHba
))
{
if
(
esxVI_LookupHostInternetScsiHba
(
priv
->
primary
,
&
hostInternetScsiHba
))
goto
cleanup
;
}
for
(
target
=
hostInternetScsiHba
->
configuredStaticTarget
;
target
;
target
=
target
->
_next
)
{
if
(
STREQ
(
target
->
iScsiName
,
pool
->
name
))
{
if
(
STREQ
(
target
->
iScsiName
,
pool
->
name
))
break
;
}
}
if
(
!
target
)
{
...
...
@@ -338,9 +333,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
def
.
source
.
hosts
[
0
].
name
=
target
->
address
;
if
(
target
->
port
)
{
if
(
target
->
port
)
def
.
source
.
hosts
[
0
].
port
=
target
->
port
->
value
;
}
/* TODO: add CHAP authentication params */
xml
=
virStoragePoolDefFormat
(
&
def
);
...
...
@@ -403,9 +397,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
return
0
;
}
if
(
esxVI_LookupScsiLunList
(
priv
->
primary
,
&
scsiLunList
)
<
0
)
{
if
(
esxVI_LookupScsiLunList
(
priv
->
primary
,
&
scsiLunList
)
<
0
)
goto
cleanup
;
}
for
(
scsiLun
=
scsiLunList
;
scsiLun
&&
count
<
maxnames
;
scsiLun
=
scsiLun
->
_next
)
{
...
...
@@ -425,9 +418,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
cleanup:
if
(
!
success
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
VIR_FREE
(
names
[
i
]);
}
count
=
-
1
;
}
...
...
@@ -452,9 +444,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool,
unsigned
char
md5
[
MD5_DIGEST_SIZE
];
char
uuid_string
[
VIR_UUID_STRING_BUFLEN
]
=
""
;
if
(
esxVI_LookupScsiLunList
(
priv
->
primary
,
&
scsiLunList
)
<
0
)
{
if
(
esxVI_LookupScsiLunList
(
priv
->
primary
,
&
scsiLunList
)
<
0
)
goto
cleanup
;
}
for
(
scsiLun
=
scsiLunList
;
scsiLun
;
scsiLun
=
scsiLun
->
_next
)
{
...
...
@@ -500,9 +491,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
unsigned
char
md5
[
MD5_DIGEST_SIZE
];
char
uuid_string
[
VIR_UUID_STRING_BUFLEN
]
=
""
;
if
(
esxVI_LookupScsiLunList
(
priv
->
primary
,
&
scsiLunList
)
<
0
)
{
if
(
esxVI_LookupScsiLunList
(
priv
->
primary
,
&
scsiLunList
)
<
0
)
goto
cleanup
;
}
for
(
scsiLun
=
scsiLunList
;
scsiLun
;
scsiLun
=
scsiLun
->
_next
)
{
hostScsiDisk
=
esxVI_HostScsiDisk_DynamicCast
(
scsiLun
);
...
...
@@ -548,13 +538,11 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
char
uuid_string
[
VIR_UUID_STRING_BUFLEN
]
=
""
;
/* key may be LUN device path */
if
(
STRPREFIX
(
key
,
"/"
))
{
if
(
STRPREFIX
(
key
,
"/"
))
return
esxStorageVolLookupByPath
(
conn
,
key
);
}
if
(
esxVI_LookupScsiLunList
(
priv
->
primary
,
&
scsiLunList
)
<
0
)
{
if
(
esxVI_LookupScsiLunList
(
priv
->
primary
,
&
scsiLunList
)
<
0
)
goto
cleanup
;
}
for
(
scsiLun
=
scsiLunList
;
scsiLun
;
scsiLun
=
scsiLun
->
_next
)
{
...
...
@@ -631,9 +619,8 @@ esxStorageVolGetInfo(virStorageVolPtr volume,
esxVI_ScsiLun
*
scsiLun
;
esxVI_HostScsiDisk
*
hostScsiDisk
=
NULL
;
if
(
esxVI_LookupScsiLunList
(
priv
->
primary
,
&
scsiLunList
)
<
0
)
{
if
(
esxVI_LookupScsiLunList
(
priv
->
primary
,
&
scsiLunList
)
<
0
)
goto
cleanup
;
}
for
(
scsiLun
=
scsiLunList
;
scsiLun
;
scsiLun
=
scsiLun
->
_next
)
{
...
...
@@ -687,9 +674,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
memset
(
&
pool
,
0
,
sizeof
(
pool
));
memset
(
&
def
,
0
,
sizeof
(
def
));
if
(
esxVI_LookupScsiLunList
(
priv
->
primary
,
&
scsiLunList
)
<
0
)
{
if
(
esxVI_LookupScsiLunList
(
priv
->
primary
,
&
scsiLunList
)
<
0
)
goto
cleanup
;
}
for
(
scsiLun
=
scsiLunList
;
scsiLun
;
scsiLun
=
scsiLun
->
_next
)
{
...
...
@@ -715,9 +701,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
virUUIDFormat
(
md5
,
uuid_string
);
if
(
VIR_STRDUP
(
def
.
key
,
uuid_string
)
<
0
)
{
if
(
VIR_STRDUP
(
def
.
key
,
uuid_string
)
<
0
)
goto
cleanup
;
}
/* iSCSI LUN exposes a block device */
def
.
type
=
VIR_STORAGE_VOL_BLOCK
;
...
...
src/esx/esx_storage_backend_vmfs.c
浏览文件 @
247ad915
...
...
@@ -120,9 +120,8 @@ esxConnectNumOfStoragePools(virConnectPtr conn)
esxVI_ObjectContent
*
datastoreList
=
NULL
;
esxVI_ObjectContent
*
datastore
=
NULL
;
if
(
esxVI_LookupDatastoreList
(
priv
->
primary
,
NULL
,
&
datastoreList
)
<
0
)
{
if
(
esxVI_LookupDatastoreList
(
priv
->
primary
,
NULL
,
&
datastoreList
)
<
0
)
return
-
1
;
}
for
(
datastore
=
datastoreList
;
datastore
;
datastore
=
datastore
->
_next
)
{
...
...
@@ -149,9 +148,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
int
count
=
0
;
size_t
i
;
if
(
maxnames
==
0
)
{
if
(
maxnames
==
0
)
return
0
;
}
if
(
esxVI_String_AppendValueToList
(
&
propertyNameList
,
"summary.name"
)
<
0
||
...
...
@@ -185,9 +183,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
cleanup:
if
(
!
success
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
VIR_FREE
(
names
[
i
]);
}
count
=
-
1
;
}
...
...
@@ -295,9 +292,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
md5_buffer
(
hostMount
->
mountInfo
->
path
,
strlen
(
hostMount
->
mountInfo
->
path
),
md5
);
if
(
memcmp
(
uuid
,
md5
,
VIR_UUID_BUFLEN
)
==
0
)
{
if
(
memcmp
(
uuid
,
md5
,
VIR_UUID_BUFLEN
)
==
0
)
break
;
}
}
if
(
!
datastore
)
{
...
...
@@ -580,9 +576,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
return
-
1
;
}
if
(
maxnames
==
0
)
{
if
(
maxnames
==
0
)
return
0
;
}
if
(
esxVI_LookupDatastoreContentByDatastoreName
(
priv
->
primary
,
pool
->
name
,
&
searchResultsList
)
<
0
)
{
...
...
@@ -626,9 +621,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
cleanup:
if
(
!
success
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
VIR_FREE
(
names
[
i
]);
}
count
=
-
1
;
}
...
...
@@ -807,9 +801,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
goto
cleanup
;
}
if
(
esxUtil_ReformatUuid
(
uuid_string
,
key_candidate
)
<
0
)
{
if
(
esxUtil_ReformatUuid
(
uuid_string
,
key_candidate
)
<
0
)
goto
cleanup
;
}
if
(
STREQ
(
key
,
key_candidate
))
{
/* Found matching UUID */
...
...
@@ -873,9 +866,8 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
/* Parse config */
def
=
virStorageVolDefParseString
(
&
poolDef
,
xmldesc
);
if
(
!
def
)
{
if
(
!
def
)
goto
cleanup
;
}
if
(
def
->
type
!=
VIR_STORAGE_VOL_FILE
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
...
...
@@ -914,16 +906,14 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
directoryName
=
esxUtil_EscapeDatastoreItem
(
unescapedDirectoryName
);
if
(
!
directoryName
)
{
if
(
!
directoryName
)
goto
cleanup
;
}
fileName
=
esxUtil_EscapeDatastoreItem
(
unescapedDirectoryAndFileName
+
strlen
(
unescapedDirectoryName
)
+
1
);
if
(
!
fileName
)
{
if
(
!
fileName
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
datastorePathWithoutFileName
,
"[%s] %s"
,
pool
->
name
,
directoryName
)
<
0
)
...
...
@@ -1012,14 +1002,12 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
goto
cleanup
;
}
if
(
esxUtil_ReformatUuid
(
uuid_string
,
key
)
<
0
)
{
if
(
esxUtil_ReformatUuid
(
uuid_string
,
key
)
<
0
)
goto
cleanup
;
}
}
else
{
/* Fall back to the path as key */
if
(
VIR_STRDUP
(
key
,
datastorePath
)
<
0
)
{
if
(
VIR_STRDUP
(
key
,
datastorePath
)
<
0
)
goto
cleanup
;
}
}
}
else
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
...
...
@@ -1099,9 +1087,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
/* Parse config */
def
=
virStorageVolDefParseString
(
&
poolDef
,
xmldesc
);
if
(
!
def
)
{
if
(
!
def
)
goto
cleanup
;
}
if
(
def
->
type
!=
VIR_STORAGE_VOL_FILE
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
...
...
@@ -1140,16 +1127,14 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
directoryName
=
esxUtil_EscapeDatastoreItem
(
unescapedDirectoryName
);
if
(
!
directoryName
)
{
if
(
!
directoryName
)
goto
cleanup
;
}
fileName
=
esxUtil_EscapeDatastoreItem
(
unescapedDirectoryAndFileName
+
strlen
(
unescapedDirectoryName
)
+
1
);
if
(
!
fileName
)
{
if
(
!
fileName
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
datastorePathWithoutFileName
,
"[%s] %s"
,
pool
->
name
,
directoryName
)
<
0
)
...
...
@@ -1204,14 +1189,12 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
goto
cleanup
;
}
if
(
esxUtil_ReformatUuid
(
uuid_string
,
key
)
<
0
)
{
if
(
esxUtil_ReformatUuid
(
uuid_string
,
key
)
<
0
)
goto
cleanup
;
}
}
else
{
/* Fall back to the path as key */
if
(
VIR_STRDUP
(
key
,
datastorePath
)
<
0
)
{
if
(
VIR_STRDUP
(
key
,
datastorePath
)
<
0
)
goto
cleanup
;
}
}
}
else
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
...
...
src/esx/esx_storage_driver.c
浏览文件 @
247ad915
...
...
@@ -60,9 +60,8 @@ esxStorageOpen(virConnectPtr conn,
{
virCheckFlags
(
VIR_CONNECT_RO
,
VIR_DRV_OPEN_ERROR
);
if
(
conn
->
driver
->
no
!=
VIR_DRV_ESX
)
{
if
(
conn
->
driver
->
no
!=
VIR_DRV_ESX
)
return
VIR_DRV_OPEN_DECLINED
;
}
return
VIR_DRV_OPEN_SUCCESS
;
}
...
...
@@ -85,16 +84,14 @@ esxConnectNumOfStoragePools(virConnectPtr conn)
size_t
i
;
int
tmp
;
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
-
1
;
}
for
(
i
=
0
;
i
<
LAST_BACKEND
;
++
i
)
{
tmp
=
backends
[
i
]
->
connectNumOfStoragePools
(
conn
);
if
(
tmp
<
0
)
{
if
(
tmp
<
0
)
return
-
1
;
}
count
+=
tmp
;
}
...
...
@@ -113,20 +110,17 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, int maxnames)
size_t
i
;
int
tmp
;
if
(
maxnames
==
0
)
{
if
(
maxnames
==
0
)
return
0
;
}
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
-
1
;
}
for
(
i
=
0
;
i
<
LAST_BACKEND
;
++
i
)
{
tmp
=
backends
[
i
]
->
connectListStoragePools
(
conn
,
&
names
[
count
],
maxnames
-
count
);
if
(
tmp
<
0
)
{
if
(
tmp
<
0
)
goto
cleanup
;
}
count
+=
tmp
;
}
...
...
@@ -135,9 +129,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, int maxnames)
cleanup:
if
(
!
success
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
{
for
(
i
=
0
;
i
<
count
;
++
i
)
VIR_FREE
(
names
[
i
]);
}
count
=
-
1
;
}
...
...
@@ -176,16 +169,14 @@ esxStoragePoolLookupByName(virConnectPtr conn, const char *name)
virCheckNonNullArgReturn
(
name
,
NULL
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
NULL
;
}
for
(
i
=
0
;
i
<
LAST_BACKEND
;
++
i
)
{
pool
=
backends
[
i
]
->
storagePoolLookupByName
(
conn
,
name
);
if
(
pool
)
{
if
(
pool
)
return
pool
;
}
}
virReportError
(
VIR_ERR_NO_STORAGE_POOL
,
...
...
@@ -204,17 +195,15 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
virStoragePoolPtr
pool
;
char
uuid_string
[
VIR_UUID_STRING_BUFLEN
]
=
""
;
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
NULL
;
}
/* invoke backend drive method to search all known pools */
for
(
i
=
0
;
i
<
LAST_BACKEND
;
++
i
)
{
pool
=
backends
[
i
]
->
storagePoolLookupByUUID
(
conn
,
uuid
);
if
(
pool
)
{
if
(
pool
)
return
pool
;
}
}
virUUIDFormat
(
uuid
,
uuid_string
);
...
...
@@ -243,9 +232,8 @@ esxStoragePoolRefresh(virStoragePoolPtr pool, unsigned int flags)
virCheckNonNullArgReturn
(
pool
->
privateData
,
-
1
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
-
1
;
}
return
backend
->
storagePoolRefresh
(
pool
,
flags
);
}
...
...
@@ -262,9 +250,8 @@ esxStoragePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr info)
memset
(
info
,
0
,
sizeof
(
*
info
));
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
-
1
;
}
return
backend
->
storagePoolGetInfo
(
pool
,
info
);
}
...
...
@@ -279,9 +266,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
virCheckNonNullArgReturn
(
pool
->
privateData
,
NULL
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
NULL
;
}
return
backend
->
storagePoolGetXMLDesc
(
pool
,
flags
);
}
...
...
@@ -326,9 +312,8 @@ esxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
virCheckNonNullArgReturn
(
pool
->
privateData
,
-
1
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
-
1
;
}
return
backend
->
storagePoolNumOfVolumes
(
pool
);
}
...
...
@@ -344,9 +329,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
virCheckNonNullArgReturn
(
pool
->
privateData
,
-
1
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
-
1
;
}
return
backend
->
storagePoolListVolumes
(
pool
,
names
,
maxnames
);
}
...
...
@@ -361,9 +345,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, const char *name)
virCheckNonNullArgReturn
(
pool
->
privateData
,
NULL
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
NULL
;
}
return
backend
->
storageVolLookupByName
(
pool
,
name
);
}
...
...
@@ -375,9 +358,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
{
esxPrivate
*
priv
=
conn
->
privateData
;
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
NULL
;
}
/*
* FIXME: calling backends blindly may set unwanted error codes
...
...
@@ -408,16 +390,14 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
esxPrivate
*
priv
=
conn
->
privateData
;
size_t
i
;
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
NULL
;
}
for
(
i
=
0
;
i
<
LAST_BACKEND
;
++
i
)
{
volume
=
backends
[
i
]
->
storageVolLookupByKey
(
conn
,
key
);
if
(
volume
)
{
if
(
volume
)
return
volume
;
}
}
virReportError
(
VIR_ERR_NO_STORAGE_VOL
,
...
...
@@ -438,9 +418,8 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, const char *xmldesc,
virCheckNonNullArgReturn
(
pool
->
privateData
,
NULL
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
NULL
;
}
return
backend
->
storageVolCreateXML
(
pool
,
xmldesc
,
flags
);
}
...
...
@@ -456,9 +435,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, const char *xmldesc,
virCheckNonNullArgReturn
(
pool
->
privateData
,
NULL
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
NULL
;
}
return
backend
->
storageVolCreateXMLFrom
(
pool
,
xmldesc
,
sourceVolume
,
flags
);
}
...
...
@@ -473,9 +451,8 @@ esxStorageVolDelete(virStorageVolPtr volume, unsigned int flags)
virCheckNonNullArgReturn
(
volume
->
privateData
,
-
1
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
-
1
;
}
return
backend
->
storageVolDelete
(
volume
,
flags
);
}
...
...
@@ -490,9 +467,8 @@ esxStorageVolWipe(virStorageVolPtr volume, unsigned int flags)
virCheckNonNullArgReturn
(
volume
->
privateData
,
-
1
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
-
1
;
}
return
backend
->
storageVolWipe
(
volume
,
flags
);
}
...
...
@@ -507,9 +483,8 @@ esxStorageVolGetInfo(virStorageVolPtr volume, virStorageVolInfoPtr info)
virCheckNonNullArgReturn
(
volume
->
privateData
,
-
1
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
-
1
;
}
return
backend
->
storageVolGetInfo
(
volume
,
info
);
}
...
...
@@ -524,9 +499,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, unsigned int flags)
virCheckNonNullArgReturn
(
volume
->
privateData
,
NULL
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
NULL
;
}
return
backend
->
storageVolGetXMLDesc
(
volume
,
flags
);
}
...
...
@@ -541,9 +515,8 @@ esxStorageVolGetPath(virStorageVolPtr volume)
virCheckNonNullArgReturn
(
volume
->
privateData
,
NULL
);
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
{
if
(
esxVI_EnsureSession
(
priv
->
primary
)
<
0
)
return
NULL
;
}
return
backend
->
storageVolGetPath
(
volume
);
}
...
...
src/esx/esx_util.c
浏览文件 @
247ad915
...
...
@@ -166,9 +166,8 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
result
=
0
;
cleanup:
if
(
result
<
0
)
{
if
(
result
<
0
)
esxUtil_FreeParsedUri
(
parsedUri
);
}
return
result
;
}
...
...
@@ -179,9 +178,8 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
void
esxUtil_FreeParsedUri
(
esxUtil_ParsedUri
**
parsedUri
)
{
if
(
!
parsedUri
||
!
(
*
parsedUri
))
{
if
(
!
parsedUri
||
!
(
*
parsedUri
))
return
;
}
VIR_FREE
((
*
parsedUri
)
->
transport
);
VIR_FREE
((
*
parsedUri
)
->
vCenter
);
...
...
@@ -197,18 +195,16 @@ int
esxUtil_ParseVirtualMachineIDString
(
const
char
*
id_string
,
int
*
id
)
{
/* Try to parse an integer from the complete string. */
if
(
virStrToLong_i
(
id_string
,
NULL
,
10
,
id
)
==
0
)
{
if
(
virStrToLong_i
(
id_string
,
NULL
,
10
,
id
)
==
0
)
return
0
;
}
/*
* If that fails try to parse an integer from the string tail
* assuming the naming scheme Virtual Center seems to use.
*/
if
(
STRPREFIX
(
id_string
,
"vm-"
))
{
if
(
virStrToLong_i
(
id_string
+
3
,
NULL
,
10
,
id
)
==
0
)
{
if
(
virStrToLong_i
(
id_string
+
3
,
NULL
,
10
,
id
)
==
0
)
return
0
;
}
}
return
-
1
;
...
...
@@ -234,9 +230,8 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
return
-
1
;
}
if
(
VIR_STRDUP
(
copyOfDatastorePath
,
datastorePath
)
<
0
)
{
if
(
VIR_STRDUP
(
copyOfDatastorePath
,
datastorePath
)
<
0
)
goto
cleanup
;
}
/* Expected format: '[<datastore>] <path>' where <path> is optional */
if
(
!
(
tmp
=
STRSKIP
(
copyOfDatastorePath
,
"["
))
||
*
tmp
==
']'
||
...
...
@@ -270,30 +265,25 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
/* Split <path> into <directory>/<file> and remove /<file> */
tmp
=
strrchr
(
preliminaryDirectoryAndFileName
,
'/'
);
if
(
tmp
)
{
if
(
tmp
)
*
tmp
=
'\0'
;
}
if
(
VIR_STRDUP
(
*
directoryName
,
preliminaryDirectoryAndFileName
)
<
0
)
{
if
(
VIR_STRDUP
(
*
directoryName
,
preliminaryDirectoryAndFileName
)
<
0
)
goto
cleanup
;
}
}
result
=
0
;
cleanup:
if
(
result
<
0
)
{
if
(
datastoreName
)
{
if
(
datastoreName
)
VIR_FREE
(
*
datastoreName
);
}
if
(
directoryName
)
{
if
(
directoryName
)
VIR_FREE
(
*
directoryName
);
}
if
(
directoryAndFileName
)
{
if
(
directoryAndFileName
)
VIR_FREE
(
*
directoryAndFileName
);
}
}
VIR_FREE
(
copyOfDatastorePath
);
...
...
@@ -408,20 +398,17 @@ esxUtil_EscapeBase64(const char *string)
virBufferAddChar
(
&
buffer
,
base64
[(
c1
>>
2
)
&
0x3f
]);
virBufferAddChar
(
&
buffer
,
base64
[((
c1
<<
4
)
+
(
c2
>>
4
))
&
0x3f
]);
if
(
length
>
1
)
{
if
(
length
>
1
)
virBufferAddChar
(
&
buffer
,
base64
[((
c2
<<
2
)
+
(
c3
>>
6
))
&
0x3f
]);
}
if
(
length
>
2
)
{
if
(
length
>
2
)
virBufferAddChar
(
&
buffer
,
base64
[
c3
&
0x3f
]);
}
length
-=
length
>
3
?
3
:
length
;
}
if
(
*
tmp1
!=
'\0'
)
{
if
(
*
tmp1
!=
'\0'
)
virBufferAddChar
(
&
buffer
,
'-'
);
}
}
}
...
...
@@ -450,9 +437,8 @@ esxUtil_ReplaceSpecialWindowsPathChars(char *string)
--
length
;
}
if
(
*
tmp
!=
'\0'
)
{
if
(
*
tmp
!=
'\0'
)
++
tmp
;
}
}
}
...
...
@@ -472,9 +458,8 @@ esxUtil_EscapeDatastoreItem(const char *string)
escaped1
=
virVMXEscapeHexPercent
(
replaced
);
if
(
!
escaped1
)
{
if
(
!
escaped1
)
goto
cleanup
;
}
escaped2
=
esxUtil_EscapeBase64
(
escaped1
);
...
...
src/esx/esx_vi.c
浏览文件 @
247ad915
此差异已折叠。
点击以展开。
src/esx/esx_vi_types.c
浏览文件 @
247ad915
...
...
@@ -944,13 +944,11 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src)
return
-
1
;
}
if
(
!
src
)
{
if
(
!
src
)
return
0
;
}
if
(
esxVI_AnyType_Alloc
(
dest
)
<
0
)
{
if
(
esxVI_AnyType_Alloc
(
dest
)
<
0
)
goto
failure
;
}
(
*
dest
)
->
_type
=
src
->
_type
;
(
*
dest
)
->
node
=
xmlCopyNode
(
src
->
node
,
1
);
...
...
@@ -1015,9 +1013,8 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
return
-
1
;
}
if
(
esxVI_AnyType_Alloc
(
anyType
)
<
0
)
{
if
(
esxVI_AnyType_Alloc
(
anyType
)
<
0
)
return
-
1
;
}
(
*
anyType
)
->
node
=
xmlCopyNode
(
node
,
1
);
...
...
@@ -1151,9 +1148,8 @@ esxVI_String_ListContainsValue(esxVI_String *stringList, const char *value)
esxVI_String
*
string
;
for
(
string
=
stringList
;
string
;
string
=
string
->
_next
)
{
if
(
STREQ
(
string
->
value
,
value
))
{
if
(
STREQ
(
string
->
value
,
value
))
return
true
;
}
}
return
false
;
...
...
@@ -1167,16 +1163,14 @@ esxVI_String_AppendValueToList(esxVI_String **stringList, const char *value)
{
esxVI_String
*
string
=
NULL
;
if
(
esxVI_String_Alloc
(
&
string
)
<
0
)
{
if
(
esxVI_String_Alloc
(
&
string
)
<
0
)
return
-
1
;
}
if
(
VIR_STRDUP
(
string
->
value
,
value
)
<
0
)
goto
failure
;
if
(
esxVI_String_AppendToList
(
stringList
,
string
)
<
0
)
{
if
(
esxVI_String_AppendToList
(
stringList
,
string
)
<
0
)
goto
failure
;
}
return
0
;
...
...
@@ -1194,16 +1188,14 @@ esxVI_String_AppendValueListToList(esxVI_String **stringList,
const
char
*
value
=
valueList
;
while
(
value
&&
*
value
!=
'\0'
)
{
if
(
esxVI_String_AppendValueToList
(
&
stringListToAppend
,
value
)
<
0
)
{
if
(
esxVI_String_AppendValueToList
(
&
stringListToAppend
,
value
)
<
0
)
goto
failure
;
}
value
+=
strlen
(
value
)
+
1
;
}
if
(
esxVI_String_AppendToList
(
stringList
,
stringListToAppend
)
<
0
)
{
if
(
esxVI_String_AppendToList
(
stringList
,
stringListToAppend
)
<
0
)
goto
failure
;
}
return
0
;
...
...
@@ -1230,9 +1222,8 @@ esxVI_String_DeepCopyValue(char **dest, const char *src)
return
-
1
;
}
if
(
!
src
)
{
if
(
!
src
)
return
0
;
}
return
VIR_STRDUP
(
*
dest
,
src
);
}
...
...
@@ -1263,9 +1254,8 @@ esxVI_String_SerializeValue(const char *value, const char *element,
return
-
1
;
}
if
(
!
value
)
{
if
(
!
value
)
return
0
;
}
ESV_VI__XML_TAG__OPEN
(
output
,
element
,
"xsd:string"
);
...
...
@@ -1483,9 +1473,8 @@ esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime)
return
-
1
;
}
if
(
esxVI_DateTime_Alloc
(
dateTime
)
<
0
)
{
if
(
esxVI_DateTime_Alloc
(
dateTime
)
<
0
)
return
-
1
;
}
(
*
dateTime
)
->
value
=
(
char
*
)
xmlNodeListGetString
(
node
->
doc
,
node
->
children
,
1
);
...
...
@@ -1577,9 +1566,8 @@ esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime,
tz_offset
=
tz_hours
*
60
*
60
+
tz_minutes
*
60
;
if
(
sign
==
'-'
)
{
if
(
sign
==
'-'
)
tz_offset
=
-
tz_offset
;
}
}
else
if
(
STREQ
(
tmp
,
"Z"
))
{
/* Z refers to UTC. tz_offset is already initialized to zero */
}
else
{
...
...
@@ -1657,9 +1645,8 @@ esxVI_MethodFault_Deserialize(xmlNodePtr node, esxVI_MethodFault **methodFault)
return
-
1
;
}
if
(
esxVI_MethodFault_Alloc
(
methodFault
)
<
0
)
{
if
(
esxVI_MethodFault_Alloc
(
methodFault
)
<
0
)
return
-
1
;
}
(
*
methodFault
)
->
_actualType
=
(
char
*
)
xmlGetNsProp
(
node
,
BAD_CAST
"type"
,
...
...
@@ -1723,9 +1710,8 @@ esxVI_ManagedObjectReference_Serialize
return
-
1
;
}
if
(
!
managedObjectReference
)
{
if
(
!
managedObjectReference
)
return
0
;
}
virBufferAddLit
(
output
,
"<"
);
virBufferAdd
(
output
,
element
,
-
1
);
...
...
@@ -1753,9 +1739,8 @@ esxVI_ManagedObjectReference_Deserialize
return
-
1
;
}
if
(
esxVI_ManagedObjectReference_Alloc
(
managedObjectReference
)
<
0
)
{
if
(
esxVI_ManagedObjectReference_Alloc
(
managedObjectReference
)
<
0
)
return
-
1
;
}
(
*
managedObjectReference
)
->
type
=
(
char
*
)
xmlGetNoNsProp
(
node
,
BAD_CAST
"type"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录