Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
84c50347
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看板
提交
84c50347
编写于
7月 04, 2013
作者:
M
Michal Privoznik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapt to VIR_ALLOC and virAsprintf in src/esx/*
上级
d85722d7
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
58 addition
and
156 deletion
+58
-156
src/esx/esx_driver.c
src/esx/esx_driver.c
+16
-46
src/esx/esx_network_driver.c
src/esx/esx_network_driver.c
+4
-12
src/esx/esx_storage_backend_iscsi.c
src/esx/esx_storage_backend_iscsi.c
+1
-3
src/esx/esx_storage_backend_vmfs.c
src/esx/esx_storage_backend_vmfs.c
+17
-55
src/esx/esx_util.c
src/esx/esx_util.c
+1
-3
src/esx/esx_vi.c
src/esx/esx_vi.c
+15
-35
src/esx/esx_vi.h
src/esx/esx_vi.h
+2
-1
src/esx/esx_vi_types.c
src/esx/esx_vi_types.c
+2
-1
未找到文件。
src/esx/esx_driver.c
浏览文件 @
84c50347
...
...
@@ -146,10 +146,8 @@ esxParseVMXFileName(const char *fileName, void *opaque)
if
(
strchr
(
fileName
,
'/'
)
==
NULL
&&
strchr
(
fileName
,
'\\'
)
==
NULL
)
{
/* Plain file name, use same directory as for the .vmx file */
if
(
virAsprintf
(
&
result
,
"%s/%s"
,
data
->
datastorePathWithoutFileName
,
fileName
)
<
0
)
{
virReportOOMError
();
data
->
datastorePathWithoutFileName
,
fileName
)
<
0
)
goto
cleanup
;
}
}
else
{
if
(
esxVI_String_AppendValueToList
(
&
propertyNameList
,
"summary.name"
)
<
0
||
...
...
@@ -199,10 +197,8 @@ esxParseVMXFileName(const char *fileName, void *opaque)
}
if
(
virAsprintf
(
&
result
,
"[%s] %s"
,
datastoreName
,
strippedFileName
)
<
0
)
{
virReportOOMError
();
strippedFileName
)
<
0
)
goto
cleanup
;
}
break
;
}
...
...
@@ -239,10 +235,8 @@ esxParseVMXFileName(const char *fileName, void *opaque)
}
if
(
virAsprintf
(
&
result
,
"[%s] %s"
,
datastoreName
,
directoryAndFileName
)
<
0
)
{
virReportOOMError
();
directoryAndFileName
)
<
0
)
goto
cleanup
;
}
}
/* If it's an absolute path outside of a datastore just use it as is */
...
...
@@ -587,10 +581,8 @@ esxCapsInit(esxPrivate *priv)
caps
=
virCapabilitiesNew
(
VIR_ARCH_I686
,
1
,
1
);
}
if
(
caps
==
NULL
)
{
virReportOOMError
();
if
(
caps
==
NULL
)
return
NULL
;
}
virCapabilitiesAddHostMigrateTransport
(
caps
,
"vpxmigr"
);
...
...
@@ -695,10 +687,8 @@ esxConnectToHost(esxPrivate *priv,
}
if
(
virAsprintf
(
&
url
,
"%s://%s:%d/sdk"
,
priv
->
parsedUri
->
transport
,
conn
->
uri
->
server
,
conn
->
uri
->
port
)
<
0
)
{
virReportOOMError
();
conn
->
uri
->
server
,
conn
->
uri
->
port
)
<
0
)
goto
cleanup
;
}
if
(
esxVI_Context_Alloc
(
&
priv
->
host
)
<
0
||
esxVI_Context_Connect
(
priv
->
host
,
url
,
ipAddress
,
username
,
password
,
...
...
@@ -818,10 +808,8 @@ esxConnectToVCenter(esxPrivate *priv,
}
if
(
virAsprintf
(
&
url
,
"%s://%s:%d/sdk"
,
priv
->
parsedUri
->
transport
,
hostname
,
conn
->
uri
->
port
)
<
0
)
{
virReportOOMError
();
hostname
,
conn
->
uri
->
port
)
<
0
)
goto
cleanup
;
}
if
(
esxVI_Context_Alloc
(
&
priv
->
vCenter
)
<
0
||
esxVI_Context_Connect
(
priv
->
vCenter
,
url
,
ipAddress
,
username
,
...
...
@@ -973,10 +961,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
}
/* Allocate per-connection private data */
if
(
VIR_ALLOC
(
priv
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
priv
)
<
0
)
goto
cleanup
;
}
if
(
esxUtil_ParseUri
(
&
priv
->
parsedUri
,
conn
->
uri
)
<
0
)
{
goto
cleanup
;
...
...
@@ -1269,10 +1255,8 @@ esxConnectGetHostname(virConnectPtr conn)
if
(
VIR_STRDUP
(
complete
,
hostName
)
<
0
)
goto
cleanup
;
}
else
{
if
(
virAsprintf
(
&
complete
,
"%s.%s"
,
hostName
,
domainName
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
complete
,
"%s.%s"
,
hostName
,
domainName
)
<
0
)
goto
cleanup
;
}
}
cleanup:
...
...
@@ -2739,16 +2723,12 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
if
(
directoryName
==
NULL
)
{
if
(
virAsprintf
(
&
data
.
datastorePathWithoutFileName
,
"[%s]"
,
datastoreName
)
<
0
)
{
virReportOOMError
();
datastoreName
)
<
0
)
goto
cleanup
;
}
}
else
{
if
(
virAsprintf
(
&
data
.
datastorePathWithoutFileName
,
"[%s] %s"
,
datastoreName
,
directoryName
)
<
0
)
{
virReportOOMError
();
datastoreName
,
directoryName
)
<
0
)
goto
cleanup
;
}
}
ctx
.
opaque
=
&
data
;
...
...
@@ -3213,16 +3193,12 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
/* Register the domain */
if
(
directoryName
!=
NULL
)
{
if
(
virAsprintf
(
&
datastoreRelatedPath
,
"[%s] %s/%s.vmx"
,
datastoreName
,
directoryName
,
escapedName
)
<
0
)
{
virReportOOMError
();
directoryName
,
escapedName
)
<
0
)
goto
cleanup
;
}
}
else
{
if
(
virAsprintf
(
&
datastoreRelatedPath
,
"[%s] %s.vmx"
,
datastoreName
,
escapedName
)
<
0
)
{
virReportOOMError
();
escapedName
)
<
0
)
goto
cleanup
;
}
}
if
(
esxVI_RegisterVM_Task
(
priv
->
primary
,
priv
->
primary
->
datacenter
->
vmFolder
,
...
...
@@ -3860,10 +3836,8 @@ esxDomainMigratePrepare(virConnectPtr dconn,
if
(
virAsprintf
(
uri_out
,
"vpxmigr://%s/%s/%s"
,
priv
->
vCenter
->
ipAddress
,
priv
->
vCenter
->
computeResource
->
resourcePool
->
value
,
priv
->
vCenter
->
hostSystem
->
_reference
->
value
)
<
0
)
{
virReportOOMError
();
priv
->
vCenter
->
hostSystem
->
_reference
->
value
)
<
0
)
return
-
1
;
}
}
return
0
;
...
...
@@ -5020,7 +4994,7 @@ esxConnectListAllDomains(virConnectPtr conn,
!
MATCH
(
VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE
)))
{
if
(
domains
&&
VIR_ALLOC_N
(
*
domains
,
1
)
<
0
)
goto
no_memory
;
goto
cleanup
;
ret
=
0
;
goto
cleanup
;
...
...
@@ -5074,7 +5048,7 @@ esxConnectListAllDomains(virConnectPtr conn,
if
(
domains
)
{
if
(
VIR_ALLOC_N
(
doms
,
1
)
<
0
)
goto
no_memory
;
goto
cleanup
;
ndoms
=
1
;
}
...
...
@@ -5167,7 +5141,7 @@ esxConnectListAllDomains(virConnectPtr conn,
}
if
(
VIR_RESIZE_N
(
doms
,
ndoms
,
count
,
2
)
<
0
)
goto
no_memory
;
goto
cleanup
;
if
(
!
(
dom
=
virGetDomain
(
conn
,
name
,
uuid
)))
goto
cleanup
;
...
...
@@ -5203,10 +5177,6 @@ cleanup:
esxVI_VirtualMachineSnapshotTree_Free
(
&
rootSnapshotTreeList
);
return
ret
;
no_memory:
virReportOOMError
();
goto
cleanup
;
}
#undef MATCH
...
...
src/esx/esx_network_driver.c
浏览文件 @
84c50347
...
...
@@ -642,10 +642,8 @@ esxShapingPolicyToBandwidth(esxVI_HostNetworkTrafficShapingPolicy *shapingPolicy
if
(
VIR_ALLOC
(
*
bandwidth
)
<
0
||
VIR_ALLOC
((
*
bandwidth
)
->
in
)
<
0
||
VIR_ALLOC
((
*
bandwidth
)
->
out
)
<
0
)
{
virReportOOMError
();
VIR_ALLOC
((
*
bandwidth
)
->
out
)
<
0
)
return
-
1
;
}
if
(
shapingPolicy
->
averageBandwidth
!=
NULL
)
{
/* Scale bits per second to kilobytes per second */
...
...
@@ -694,10 +692,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
return
NULL
;
}
if
(
VIR_ALLOC
(
def
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
def
)
<
0
)
goto
cleanup
;
}
/* Lookup HostVirtualSwitch */
if
(
esxVI_LookupHostVirtualSwitchByName
(
priv
->
primary
,
network_
->
name
,
...
...
@@ -724,10 +720,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
if
(
count
>
0
)
{
def
->
forward
.
type
=
VIR_NETWORK_FORWARD_BRIDGE
;
if
(
VIR_ALLOC_N
(
def
->
forward
.
ifs
,
count
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
def
->
forward
.
ifs
,
count
)
<
0
)
goto
cleanup
;
}
/* Find PhysicalNic by key */
if
(
esxVI_LookupPhysicalNicList
(
priv
->
primary
,
&
physicalNicList
)
<
0
)
{
...
...
@@ -772,10 +766,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
}
if
(
count
>
0
)
{
if
(
VIR_ALLOC_N
(
def
->
portGroups
,
count
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
def
->
portGroups
,
count
)
<
0
)
goto
cleanup
;
}
/* Lookup Network list and create name list */
if
(
esxVI_String_AppendValueToList
(
&
propertyNameList
,
"name"
)
<
0
||
...
...
src/esx/esx_storage_backend_iscsi.c
浏览文件 @
84c50347
...
...
@@ -334,10 +334,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
def
.
source
.
nhost
=
1
;
if
(
VIR_ALLOC_N
(
def
.
source
.
hosts
,
def
.
source
.
nhost
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
def
.
source
.
hosts
,
def
.
source
.
nhost
)
<
0
)
goto
cleanup
;
}
def
.
source
.
hosts
[
0
].
name
=
target
->
address
;
...
...
src/esx/esx_storage_backend_vmfs.c
浏览文件 @
84c50347
...
...
@@ -484,10 +484,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
if
(
esxVI_LocalDatastoreInfo_DynamicCast
(
info
)
!=
NULL
)
{
def
.
type
=
VIR_STORAGE_POOL_DIR
;
}
else
if
((
nasInfo
=
esxVI_NasDatastoreInfo_DynamicCast
(
info
))
!=
NULL
)
{
if
(
VIR_ALLOC_N
(
def
.
source
.
hosts
,
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
def
.
source
.
hosts
,
1
)
<
0
)
goto
cleanup
;
}
def
.
type
=
VIR_STORAGE_POOL_NETFS
;
def
.
source
.
hosts
[
0
].
name
=
nasInfo
->
nas
->
remoteHost
;
def
.
source
.
dir
=
nasInfo
->
nas
->
remotePath
;
...
...
@@ -615,7 +613,6 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
goto
cleanup
;
}
else
if
(
virAsprintf
(
&
names
[
count
],
"%s/%s"
,
directoryAndFileName
,
fileInfo
->
path
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
...
...
@@ -651,10 +648,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool,
char
*
datastorePath
=
NULL
;
char
*
key
=
NULL
;
if
(
virAsprintf
(
&
datastorePath
,
"[%s] %s"
,
pool
->
name
,
name
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
datastorePath
,
"[%s] %s"
,
pool
->
name
,
name
)
<
0
)
goto
cleanup
;
}
if
(
esxVI_LookupStorageVolumeKeyByDatastorePath
(
priv
->
primary
,
datastorePath
,
&
key
)
<
0
)
{
...
...
@@ -789,15 +784,12 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
}
else
if
(
virAsprintf
(
&
volumeName
,
"%s/%s"
,
directoryAndFileName
,
fileInfo
->
path
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
if
(
virAsprintf
(
&
datastorePath
,
"[%s] %s"
,
datastoreName
,
volumeName
)
<
0
)
{
virReportOOMError
();
volumeName
)
<
0
)
goto
cleanup
;
}
if
(
esxVI_VmDiskFileInfo_DynamicCast
(
fileInfo
)
==
NULL
)
{
/* Only a VirtualDisk has a UUID */
...
...
@@ -907,10 +899,8 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
}
if
(
virAsprintf
(
&
unescapedDatastorePath
,
"[%s] %s"
,
pool
->
name
,
def
->
name
)
<
0
)
{
virReportOOMError
();
def
->
name
)
<
0
)
goto
cleanup
;
}
if
(
def
->
target
.
format
==
VIR_STORAGE_FILE_VMDK
)
{
/* Parse and escape datastore path */
...
...
@@ -934,16 +924,12 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
}
if
(
virAsprintf
(
&
datastorePathWithoutFileName
,
"[%s] %s"
,
pool
->
name
,
directoryName
)
<
0
)
{
virReportOOMError
();
directoryName
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
datastorePath
,
"[%s] %s/%s"
,
pool
->
name
,
directoryName
,
fileName
)
<
0
)
{
virReportOOMError
();
fileName
)
<
0
)
goto
cleanup
;
}
/* Create directory, if it doesn't exist yet */
if
(
esxVI_LookupFileInfoByDatastorePath
...
...
@@ -1015,10 +1001,8 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
}
if
(
priv
->
primary
->
hasQueryVirtualDiskUuid
)
{
if
(
VIR_ALLOC_N
(
key
,
VIR_UUID_STRING_BUFLEN
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
key
,
VIR_UUID_STRING_BUFLEN
)
<
0
)
goto
cleanup
;
}
if
(
esxVI_QueryVirtualDiskUuid
(
priv
->
primary
,
datastorePath
,
priv
->
primary
->
datacenter
->
_reference
,
...
...
@@ -1107,10 +1091,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
}
if
(
virAsprintf
(
&
sourceDatastorePath
,
"[%s] %s"
,
sourceVolume
->
pool
,
sourceVolume
->
name
)
<
0
)
{
virReportOOMError
();
sourceVolume
->
name
)
<
0
)
goto
cleanup
;
}
/* Parse config */
def
=
virStorageVolDefParseString
(
&
poolDef
,
xmldesc
);
...
...
@@ -1143,10 +1125,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
}
if
(
virAsprintf
(
&
unescapedDatastorePath
,
"[%s] %s"
,
pool
->
name
,
def
->
name
)
<
0
)
{
virReportOOMError
();
def
->
name
)
<
0
)
goto
cleanup
;
}
if
(
def
->
target
.
format
==
VIR_STORAGE_FILE_VMDK
)
{
/* Parse and escape datastore path */
...
...
@@ -1170,16 +1150,12 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
}
if
(
virAsprintf
(
&
datastorePathWithoutFileName
,
"[%s] %s"
,
pool
->
name
,
directoryName
)
<
0
)
{
virReportOOMError
();
directoryName
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
datastorePath
,
"[%s] %s/%s"
,
pool
->
name
,
directoryName
,
fileName
)
<
0
)
{
virReportOOMError
();
fileName
)
<
0
)
goto
cleanup
;
}
/* Create directory, if it doesn't exist yet */
if
(
esxVI_LookupFileInfoByDatastorePath
...
...
@@ -1217,10 +1193,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
}
if
(
priv
->
primary
->
hasQueryVirtualDiskUuid
)
{
if
(
VIR_ALLOC_N
(
key
,
VIR_UUID_STRING_BUFLEN
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
key
,
VIR_UUID_STRING_BUFLEN
)
<
0
)
goto
cleanup
;
}
if
(
esxVI_QueryVirtualDiskUuid
(
priv
->
primary
,
datastorePath
,
priv
->
primary
->
datacenter
->
_reference
,
...
...
@@ -1280,10 +1254,8 @@ esxStorageVolDelete(virStorageVolPtr volume, unsigned int flags)
virCheckFlags
(
0
,
-
1
);
if
(
virAsprintf
(
&
datastorePath
,
"[%s] %s"
,
volume
->
pool
,
volume
->
name
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
datastorePath
,
"[%s] %s"
,
volume
->
pool
,
volume
->
name
)
<
0
)
goto
cleanup
;
}
if
(
esxVI_DeleteVirtualDisk_Task
(
priv
->
primary
,
datastorePath
,
priv
->
primary
->
datacenter
->
_reference
,
...
...
@@ -1325,10 +1297,8 @@ esxStorageVolWipe(virStorageVolPtr volume, unsigned int flags)
virCheckFlags
(
0
,
-
1
);
if
(
virAsprintf
(
&
datastorePath
,
"[%s] %s"
,
volume
->
pool
,
volume
->
name
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
datastorePath
,
"[%s] %s"
,
volume
->
pool
,
volume
->
name
)
<
0
)
goto
cleanup
;
}
if
(
esxVI_ZeroFillVirtualDisk_Task
(
priv
->
primary
,
datastorePath
,
priv
->
primary
->
datacenter
->
_reference
,
...
...
@@ -1370,10 +1340,8 @@ esxStorageVolGetInfo(virStorageVolPtr volume,
memset
(
info
,
0
,
sizeof
(
*
info
));
if
(
virAsprintf
(
&
datastorePath
,
"[%s] %s"
,
volume
->
pool
,
volume
->
name
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
datastorePath
,
"[%s] %s"
,
volume
->
pool
,
volume
->
name
)
<
0
)
goto
cleanup
;
}
if
(
esxVI_LookupFileInfoByDatastorePath
(
priv
->
primary
,
datastorePath
,
false
,
&
fileInfo
,
...
...
@@ -1430,10 +1398,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
}
/* Lookup file info */
if
(
virAsprintf
(
&
datastorePath
,
"[%s] %s"
,
volume
->
pool
,
volume
->
name
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
datastorePath
,
"[%s] %s"
,
volume
->
pool
,
volume
->
name
)
<
0
)
goto
cleanup
;
}
if
(
esxVI_LookupFileInfoByDatastorePath
(
priv
->
primary
,
datastorePath
,
false
,
&
fileInfo
,
...
...
@@ -1494,11 +1460,7 @@ esxStorageVolGetPath(virStorageVolPtr volume)
{
char
*
path
;
if
(
virAsprintf
(
&
path
,
"[%s] %s"
,
volume
->
pool
,
volume
->
name
)
<
0
)
{
virReportOOMError
();
return
NULL
;
}
ignore_value
(
virAsprintf
(
&
path
,
"[%s] %s"
,
volume
->
pool
,
volume
->
name
));
return
path
;
}
...
...
src/esx/esx_util.c
浏览文件 @
84c50347
...
...
@@ -54,10 +54,8 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
return
-
1
;
}
if
(
VIR_ALLOC
(
*
parsedUri
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
*
parsedUri
)
<
0
)
return
-
1
;
}
for
(
i
=
0
;
i
<
uri
->
paramsCount
;
i
++
)
{
virURIParamPtr
queryParam
=
&
uri
->
params
[
i
];
...
...
src/esx/esx_vi.c
浏览文件 @
84c50347
...
...
@@ -51,7 +51,8 @@
int \
esxVI_##_type##_Alloc(esxVI_##_type **ptrptr) \
{ \
return esxVI_Alloc((void **)ptrptr, sizeof(esxVI_##_type)); \
return esxVI_Alloc((void **)ptrptr, sizeof(esxVI_##_type), \
__FILE__, __FUNCTION__, __LINE__); \
}
...
...
@@ -392,15 +393,11 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content,
return
-
1
;
}
if
(
virAsprintf
(
&
range
,
"%llu-%llu"
,
offset
,
offset
+
*
length
-
1
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
range
,
"%llu-%llu"
,
offset
,
offset
+
*
length
-
1
)
<
0
)
goto
cleanup
;
}
}
else
if
(
offset
>
0
)
{
if
(
virAsprintf
(
&
range
,
"%llu-"
,
offset
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
range
,
"%llu-"
,
offset
)
<
0
)
goto
cleanup
;
}
}
virMutexLock
(
&
curl
->
lock
);
...
...
@@ -808,10 +805,8 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
return
-
1
;
}
if
(
VIR_ALLOC
(
ctx
->
sessionLock
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
ctx
->
sessionLock
)
<
0
)
return
-
1
;
}
if
(
virMutexInit
(
ctx
->
sessionLock
)
<
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
...
...
@@ -1315,10 +1310,8 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
}
else
{
if
(
virAsprintf
(
&
xpathExpression
,
"/soapenv:Envelope/soapenv:Body/vim:%sResponse"
,
methodName
)
<
0
)
{
virReportOOMError
();
methodName
)
<
0
)
goto
cleanup
;
}
responseNode
=
virXPathNode
(
xpathExpression
,
xpathContext
);
...
...
@@ -1743,19 +1736,16 @@ esxVI_List_Deserialize(xmlNodePtr node, esxVI_List **list,
*/
int
esxVI_Alloc
(
void
**
ptrptr
,
size_t
size
)
esxVI_Alloc
(
void
**
ptrptr
,
size_t
size
,
const
char
*
file
,
const
char
*
function
,
size_t
linenr
)
{
if
(
ptrptr
==
NULL
||
*
ptrptr
!=
NULL
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"Invalid argument"
));
return
-
1
;
}
if
(
virAllocN
(
ptrptr
,
size
,
1
,
false
,
0
,
NULL
,
NULL
,
0
)
<
0
)
{
virReportOOMError
();
return
-
1
;
}
return
0
;
return
virAllocN
(
ptrptr
,
size
,
1
,
true
,
VIR_FROM_THIS
,
file
,
function
,
linenr
);
}
...
...
@@ -3480,20 +3470,16 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
* that the <path> part is actually the file name.
*/
if
(
virAsprintf
(
&
datastorePathWithoutFileName
,
"[%s]"
,
datastoreName
)
<
0
)
{
virReportOOMError
();
datastoreName
)
<
0
)
goto
cleanup
;
}
if
(
VIR_STRDUP
(
fileName
,
directoryAndFileName
)
<
0
)
{
goto
cleanup
;
}
}
else
{
if
(
virAsprintf
(
&
datastorePathWithoutFileName
,
"[%s] %s"
,
datastoreName
,
directoryName
)
<
0
)
{
virReportOOMError
();
datastoreName
,
directoryName
)
<
0
)
goto
cleanup
;
}
length
=
strlen
(
directoryName
);
...
...
@@ -3715,10 +3701,8 @@ esxVI_LookupDatastoreContentByDatastoreName
}
/* Search datastore for files */
if
(
virAsprintf
(
&
datastorePath
,
"[%s]"
,
datastoreName
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
datastorePath
,
"[%s]"
,
datastoreName
)
<
0
)
goto
cleanup
;
}
if
(
esxVI_SearchDatastoreSubFolders_Task
(
ctx
,
hostDatastoreBrowser
,
datastorePath
,
searchSpec
,
...
...
@@ -3788,10 +3772,8 @@ esxVI_LookupStorageVolumeKeyByDatastorePath(esxVI_Context *ctx,
goto
cleanup
;
}
if
(
VIR_ALLOC_N
(
*
key
,
VIR_UUID_STRING_BUFLEN
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
*
key
,
VIR_UUID_STRING_BUFLEN
)
<
0
)
goto
cleanup
;
}
if
(
esxUtil_ReformatUuid
(
uuid_string
,
*
key
)
<
0
)
{
goto
cleanup
;
...
...
@@ -4493,10 +4475,8 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
}
else
{
if
(
virAsprintf
(
errorMessage
,
"%s - %s"
,
taskInfo
->
error
->
fault
->
_actualType
,
taskInfo
->
error
->
localizedMessage
)
<
0
)
{
virReportOOMError
();
taskInfo
->
error
->
localizedMessage
)
<
0
)
goto
cleanup
;
}
}
}
...
...
src/esx/esx_vi.h
浏览文件 @
84c50347
...
...
@@ -330,7 +330,8 @@ int esxVI_List_Deserialize(xmlNodePtr node, esxVI_List **list,
* - 'get' functions get information from a local object
*/
int
esxVI_Alloc
(
void
**
ptrptr
,
size_t
size
);
int
esxVI_Alloc
(
void
**
ptrptr
,
size_t
size
,
const
char
*
file
,
const
char
*
function
,
size_t
linenr
);
int
esxVI_BuildSelectSet
(
esxVI_SelectionSpec
**
selectSet
,
const
char
*
name
,
...
...
src/esx/esx_vi_types.c
浏览文件 @
84c50347
...
...
@@ -43,7 +43,8 @@
int \
esxVI_##__type##_Alloc(esxVI_##__type **ptrptr) \
{ \
if (esxVI_Alloc((void **)ptrptr, sizeof(esxVI_##__type)) < 0) { \
if (esxVI_Alloc((void **)ptrptr, sizeof(esxVI_##__type), \
__FILE__, __FUNCTION__, __LINE__) < 0) { \
return -1; \
} \
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录