Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
b3c649ac
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,发现更多精彩内容 >>
提交
b3c649ac
编写于
5月 03, 2013
作者:
M
Michal Privoznik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapt to VIR_STRDUP and VIR_STRNDUP in src/parallels/*
上级
0ca51d5c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
57 addition
and
101 deletion
+57
-101
src/parallels/parallels_driver.c
src/parallels/parallels_driver.c
+29
-43
src/parallels/parallels_network.c
src/parallels/parallels_network.c
+9
-14
src/parallels/parallels_storage.c
src/parallels/parallels_storage.c
+19
-44
未找到文件。
src/parallels/parallels_driver.c
浏览文件 @
b3c649ac
...
...
@@ -186,8 +186,8 @@ parallelsGetSerialInfo(virDomainChrDefPtr chr,
return
-
1
;
}
if
(
!
(
chr
->
source
.
data
.
file
.
path
=
strdup
(
tmp
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
chr
->
source
.
data
.
file
.
path
,
tmp
)
<
0
)
return
-
1
;
}
else
if
(
virJSONValueObjectHasKey
(
value
,
"socket"
))
{
chr
->
source
.
type
=
VIR_DOMAIN_CHR_TYPE_UNIX
;
...
...
@@ -197,8 +197,8 @@ parallelsGetSerialInfo(virDomainChrDefPtr chr,
return
-
1
;
}
if
(
!
(
chr
->
source
.
data
.
nix
.
path
=
strdup
(
tmp
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
chr
->
source
.
data
.
nix
.
path
,
tmp
)
<
0
)
return
-
1
;
chr
->
source
.
data
.
nix
.
listen
=
false
;
}
else
if
(
virJSONValueObjectHasKey
(
value
,
"real"
))
{
chr
->
source
.
type
=
VIR_DOMAIN_CHR_TYPE_DEV
;
...
...
@@ -209,18 +209,14 @@ parallelsGetSerialInfo(virDomainChrDefPtr chr,
return
-
1
;
}
if
(
!
(
chr
->
source
.
data
.
file
.
path
=
strdup
(
tmp
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
chr
->
source
.
data
.
file
.
path
,
tmp
)
<
0
)
return
-
1
;
}
else
{
parallelsParseError
();
return
-
1
;
}
return
0
;
no_memory:
virReportOOMError
();
return
-
1
;
}
static
int
...
...
@@ -318,10 +314,8 @@ parallelsGetHddInfo(virDomainDefPtr def,
return
-
1
;
}
if
(
!
(
disk
->
src
=
strdup
(
tmp
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
disk
->
src
,
tmp
)
<
0
)
return
-
1
;
}
}
else
{
disk
->
type
=
VIR_DOMAIN_DISK_TYPE_FILE
;
...
...
@@ -330,10 +324,8 @@ parallelsGetHddInfo(virDomainDefPtr def,
return
-
1
;
}
if
(
!
(
disk
->
src
=
strdup
(
tmp
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
disk
->
src
,
tmp
)
<
0
)
return
-
1
;
}
}
tmp
=
virJSONValueObjectGetString
(
value
,
"port"
);
...
...
@@ -454,10 +446,8 @@ parallelsGetNetInfo(virDomainNetDefPtr net,
/* use device name, shown by prlctl as target device
* for identifying network adapter in virDomainDefineXML */
if
(
!
(
net
->
ifname
=
strdup
(
key
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
net
->
ifname
,
key
)
<
0
)
goto
error
;
}
net
->
type
=
VIR_DOMAIN_NET_TYPE_NETWORK
;
...
...
@@ -478,10 +468,8 @@ parallelsGetNetInfo(virDomainNetDefPtr net,
goto
error
;
}
if
(
!
(
net
->
data
.
network
.
name
=
strdup
(
tmp
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
net
->
data
.
network
.
name
,
tmp
)
<
0
)
goto
error
;
}
}
else
if
(
virJSONValueObjectHasKey
(
value
,
"type"
))
{
if
(
!
(
tmp
=
virJSONValueObjectGetString
(
value
,
"type"
)))
{
parallelsParseError
();
...
...
@@ -493,10 +481,9 @@ parallelsGetNetInfo(virDomainNetDefPtr net,
goto
error
;
}
if
(
!
(
net
->
data
.
network
.
name
=
strdup
(
PARALLELS_ROUTED_NETWORK_NAME
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
net
->
data
.
network
.
name
,
PARALLELS_ROUTED_NETWORK_NAME
)
<
0
)
goto
error
;
}
}
else
{
parallelsParseError
();
goto
error
;
...
...
@@ -641,8 +628,8 @@ parallelsAddVNCInfo(virDomainDefPtr def, virJSONValuePtr jobj_root)
gr
->
nListens
=
1
;
if
(
!
(
gr
->
listens
[
0
].
address
=
strdup
(
tmp
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
gr
->
listens
[
0
].
address
,
tmp
)
<
0
)
goto
cleanup
;
gr
->
listens
[
0
].
type
=
VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS
;
...
...
@@ -686,8 +673,8 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj)
parallelsParseError
();
goto
cleanup
;
}
if
(
!
(
def
->
name
=
strdup
(
tmp
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
def
->
name
,
tmp
)
<
0
)
goto
cleanup
;
if
(
!
(
tmp
=
virJSONValueObjectGetString
(
jobj
,
"ID"
)))
{
parallelsParseError
();
...
...
@@ -704,8 +691,8 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj)
parallelsParseError
();
goto
cleanup
;
}
if
(
!
(
def
->
description
=
strdup
(
tmp
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
def
->
description
,
tmp
)
<
0
)
goto
cleanup
;
if
(
!
(
jobj2
=
virJSONValueObjectGet
(
jobj
,
"Hardware"
)))
{
parallelsParseError
();
...
...
@@ -771,13 +758,13 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj)
}
if
(
STREQ
(
tmp
,
"CT"
))
{
if
(
!
(
def
->
os
.
type
=
strdup
(
"exe"
))
)
goto
no_memory
;
if
(
!
(
def
->
os
.
init
=
strdup
(
"/sbin/init"
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
def
->
os
.
type
,
"exe"
)
<
0
)
goto
cleanup
;
if
(
VIR_STRDUP
(
def
->
os
.
init
,
"/sbin/init"
)
<
0
)
goto
cleanup
;
}
else
if
(
STREQ
(
tmp
,
"VM"
))
{
if
(
!
(
def
->
os
.
type
=
strdup
(
"hvm"
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
def
->
os
.
type
,
"hvm"
)
<
0
)
goto
cleanup
;
}
def
->
os
.
arch
=
VIR_ARCH_X86_64
;
...
...
@@ -792,16 +779,16 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj)
parallelsParseError
();
goto
cleanup
;
}
if
(
!
(
pdom
->
uuid
=
strdup
(
tmp
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
pdom
->
uuid
,
tmp
)
<
0
)
goto
cleanup
;
if
(
!
(
tmp
=
virJSONValueObjectGetString
(
jobj
,
"Home"
)))
{
parallelsParseError
();
goto
cleanup
;
}
if
(
!
(
pdom
->
home
=
strdup
(
tmp
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
pdom
->
home
,
tmp
)
<
0
)
goto
cleanup
;
if
(
!
(
state
=
virJSONValueObjectGetString
(
jobj
,
"State"
)))
{
parallelsParseError
();
...
...
@@ -1246,8 +1233,7 @@ parallelsDomainGetOSType(virDomainPtr domain)
goto
cleanup
;
}
if
(
!
(
ret
=
strdup
(
privdom
->
def
->
os
.
type
)))
virReportOOMError
();
ignore_value
(
VIR_STRDUP
(
ret
,
privdom
->
def
->
os
.
type
));
cleanup:
if
(
privdom
)
...
...
src/parallels/parallels_network.c
浏览文件 @
b3c649ac
...
...
@@ -66,10 +66,8 @@ static int parallelsGetBridgedNetInfo(virNetworkDefPtr def, virJSONValuePtr jobj
goto
cleanup
;
}
if
(
!
(
def
->
bridge
=
strdup
(
last_component
(
bridgePath
))))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
def
->
bridge
,
last_component
(
bridgePath
))
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
bridgeAddressPath
,
"%s/%s/brport/bridge/address"
,
SYSFS_NET_DIR
,
ifname
)
<
0
)
{
...
...
@@ -130,10 +128,9 @@ static int parallelsGetHostOnlyNetInfo(virNetworkDefPtr def, const char *name)
goto
cleanup
;
}
if
(
!
(
def
->
ips
[
0
].
family
=
strdup
(
"ipv4"
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
def
->
ips
[
0
].
family
,
"ipv4"
)
<
0
)
goto
cleanup
;
};
if
(
!
(
tmp
=
virJSONValueObjectGetString
(
jobj2
,
"IP address"
)))
{
parallelsParseError
();
goto
cleanup
;
...
...
@@ -207,8 +204,8 @@ parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr jobj)
goto
cleanup
;
}
if
(
!
(
def
->
name
=
strdup
(
tmp
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
def
->
name
,
tmp
)
<
0
)
goto
cleanup
;
/* Network names are unique in Parallels Cloud Server, so we can make
* an UUID from it */
...
...
@@ -264,8 +261,8 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
def
->
forward
.
type
=
VIR_NETWORK_FORWARD_ROUTE
;
if
(
!
(
def
->
name
=
strdup
(
PARALLELS_ROUTED_NETWORK_NAME
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
def
->
name
,
PARALLELS_ROUTED_NETWORK_NAME
)
<
0
)
goto
cleanup
;
if
(
virUUIDParse
(
PARALLELS_ROUTED_NETWORK_UUID
,
def
->
uuid
)
<
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
...
...
@@ -390,9 +387,8 @@ static int parallelsConnectListNetworks(virConnectPtr conn,
for
(
i
=
0
;
i
<
privconn
->
networks
.
count
&&
got
<
nnames
;
i
++
)
{
virNetworkObjLock
(
privconn
->
networks
.
objs
[
i
]);
if
(
virNetworkObjIsActive
(
privconn
->
networks
.
objs
[
i
]))
{
if
(
!
(
names
[
got
]
=
strdup
(
privconn
->
networks
.
objs
[
i
]
->
def
->
name
))
)
{
if
(
VIR_STRDUP
(
names
[
got
],
privconn
->
networks
.
objs
[
i
]
->
def
->
name
)
<
0
)
{
virNetworkObjUnlock
(
privconn
->
networks
.
objs
[
i
]);
virReportOOMError
();
goto
cleanup
;
}
got
++
;
...
...
@@ -438,9 +434,8 @@ static int parallelsConnectListDefinedNetworks(virConnectPtr conn,
for
(
i
=
0
;
i
<
privconn
->
networks
.
count
&&
got
<
nnames
;
i
++
)
{
virNetworkObjLock
(
privconn
->
networks
.
objs
[
i
]);
if
(
!
virNetworkObjIsActive
(
privconn
->
networks
.
objs
[
i
]))
{
if
(
!
(
names
[
got
]
=
strdup
(
privconn
->
networks
.
objs
[
i
]
->
def
->
name
))
)
{
if
(
VIR_STRDUP
(
names
[
got
],
privconn
->
networks
.
objs
[
i
]
->
def
->
name
)
<
0
)
{
virNetworkObjUnlock
(
privconn
->
networks
.
objs
[
i
]);
virReportOOMError
();
goto
cleanup
;
}
got
++
;
...
...
src/parallels/parallels_storage.c
浏览文件 @
b3c649ac
...
...
@@ -136,20 +136,9 @@ static char *parallelsMakePoolName(virConnectPtr conn, const char *path)
bool
found
=
false
;
int
j
;
if
(
!
(
name
=
strdup
(
path
)))
{
virReportOOMError
();
if
(
(
!
i
&&
VIR_STRDUP
(
name
,
path
)
<
0
)
||
(
i
&&
virAsprintf
(
&
name
,
"%s-%u"
,
path
,
i
)
<
0
))
return
NULL
;
}
if
(
i
==
0
)
name
=
strdup
(
path
);
else
ignore_value
(
virAsprintf
(
&
name
,
"%s-%u"
,
path
,
i
));
if
(
!
name
)
{
virReportOOMError
();
return
0
;
}
for
(
j
=
0
;
j
<
strlen
(
name
);
j
++
)
if
(
name
[
j
]
==
'/'
)
...
...
@@ -195,7 +184,8 @@ parallelsPoolCreateByPath(virConnectPtr conn, const char *path)
}
def
->
type
=
VIR_STORAGE_POOL_DIR
;
def
->
target
.
path
=
strdup
(
path
);
if
(
VIR_STRDUP
(
def
->
target
.
path
,
path
)
<
0
)
goto
error
;
if
(
!
(
pool
=
virStoragePoolObjAssignDef
(
pools
,
def
)))
goto
error
;
...
...
@@ -324,8 +314,8 @@ static int parallelsAddDiskVolume(virStoragePoolObjPtr pool,
if
(
!
(
def
->
target
.
path
=
realpath
(
diskPath
,
NULL
)))
goto
no_memory
;
if
(
!
(
def
->
key
=
strdup
(
def
->
target
.
path
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
def
->
key
,
def
->
target
.
path
)
<
0
)
goto
error
;
if
(
VIR_REALLOC_N
(
pool
->
volumes
.
objs
,
pool
->
volumes
.
count
+
1
)
<
0
)
goto
no_memory
;
...
...
@@ -425,8 +415,8 @@ static int parallelsLoadPools(virConnectPtr conn)
char
*
base
=
NULL
;
size_t
i
;
if
(
(
base
=
strdup
(
SYSCONFDIR
"/libvirt"
))
==
NULL
)
goto
out_of_memory
;
if
(
VIR_STRDUP
(
base
,
SYSCONFDIR
"/libvirt"
)
<
0
)
goto
error
;
/* Configuration path is /etc/libvirt/parallels-storage/... . */
if
(
virAsprintf
(
&
storageState
->
configDir
,
...
...
@@ -540,9 +530,9 @@ parallelsConnectListStoragePools(virConnectPtr conn, char **const names, int nna
for
(
i
=
0
;
i
<
privconn
->
pools
.
count
&&
n
<
nnames
;
i
++
)
{
virStoragePoolObjLock
(
privconn
->
pools
.
objs
[
i
]);
if
(
virStoragePoolObjIsActive
(
privconn
->
pools
.
objs
[
i
])
&&
!
(
names
[
n
++
]
=
strdup
(
privconn
->
pools
.
objs
[
i
]
->
def
->
name
))
)
{
VIR_STRDUP
(
names
[
n
++
],
privconn
->
pools
.
objs
[
i
]
->
def
->
name
)
<
0
)
{
virStoragePoolObjUnlock
(
privconn
->
pools
.
objs
[
i
]);
goto
no_memory
;
goto
error
;
}
virStoragePoolObjUnlock
(
privconn
->
pools
.
objs
[
i
]);
}
...
...
@@ -550,8 +540,7 @@ parallelsConnectListStoragePools(virConnectPtr conn, char **const names, int nna
return
n
;
no_memory:
virReportOOMError
();
error:
for
(
n
=
0
;
n
<
nnames
;
n
++
)
VIR_FREE
(
names
[
n
]);
parallelsDriverUnlock
(
privconn
);
...
...
@@ -590,9 +579,9 @@ parallelsConnectListDefinedStoragePools(virConnectPtr conn,
for
(
i
=
0
;
i
<
privconn
->
pools
.
count
&&
n
<
nnames
;
i
++
)
{
virStoragePoolObjLock
(
privconn
->
pools
.
objs
[
i
]);
if
(
!
virStoragePoolObjIsActive
(
privconn
->
pools
.
objs
[
i
])
&&
!
(
names
[
n
++
]
=
strdup
(
privconn
->
pools
.
objs
[
i
]
->
def
->
name
))
)
{
VIR_STRDUP
(
names
[
n
++
],
privconn
->
pools
.
objs
[
i
]
->
def
->
name
)
<
0
)
{
virStoragePoolObjUnlock
(
privconn
->
pools
.
objs
[
i
]);
goto
no_memory
;
goto
error
;
}
virStoragePoolObjUnlock
(
privconn
->
pools
.
objs
[
i
]);
}
...
...
@@ -600,8 +589,7 @@ parallelsConnectListDefinedStoragePools(virConnectPtr conn,
return
n
;
no_memory:
virReportOOMError
();
error:
for
(
n
=
0
;
n
<
nnames
;
n
++
)
VIR_FREE
(
names
[
n
]);
parallelsDriverUnlock
(
privconn
);
...
...
@@ -758,11 +746,8 @@ parallelsStoragePoolDefineXML(virConnectPtr conn,
}
def
=
NULL
;
pool
->
configFile
=
strdup
(
"
\0
"
);
if
(
!
pool
->
configFile
)
{
virReportOOMError
();
if
(
VIR_STRDUP
(
pool
->
configFile
,
"
\0
"
)
<
0
)
goto
cleanup
;
}
ret
=
virGetStoragePool
(
conn
,
pool
->
def
->
name
,
pool
->
def
->
uuid
,
NULL
,
NULL
);
...
...
@@ -1085,10 +1070,8 @@ parallelsStoragePoolListVolumes(virStoragePoolPtr pool,
}
for
(
i
=
0
;
i
<
privpool
->
volumes
.
count
&&
n
<
maxnames
;
i
++
)
{
if
((
names
[
n
++
]
=
strdup
(
privpool
->
volumes
.
objs
[
i
]
->
name
))
==
NULL
)
{
virReportOOMError
();
if
(
VIR_STRDUP
(
names
[
n
++
],
privpool
->
volumes
.
objs
[
i
]
->
name
)
<
0
)
goto
error
;
}
}
virStoragePoolObjUnlock
(
privpool
);
...
...
@@ -1271,11 +1254,8 @@ parallelsStorageVolDefineXML(virStoragePoolObjPtr pool,
goto
cleanup
;
}
privvol
->
key
=
strdup
(
privvol
->
target
.
path
);
if
(
privvol
->
key
==
NULL
)
{
virReportOOMError
();
if
(
VIR_STRDUP
(
privvol
->
key
,
privvol
->
target
.
path
)
<
0
)
goto
cleanup
;
}
if
(
is_new
)
{
xml_path
=
parallelsAddFileExt
(
privvol
->
target
.
path
,
".xml"
);
...
...
@@ -1412,11 +1392,8 @@ parallelsStorageVolCreateXMLFrom(virStoragePoolPtr pool,
goto
cleanup
;
}
privvol
->
key
=
strdup
(
privvol
->
target
.
path
);
if
(
privvol
->
key
==
NULL
)
{
virReportOOMError
();
if
(
VIR_STRDUP
(
privvol
->
key
,
privvol
->
target
.
path
)
<
0
)
goto
cleanup
;
}
privpool
->
def
->
allocation
+=
privvol
->
allocation
;
privpool
->
def
->
available
=
(
privpool
->
def
->
capacity
-
...
...
@@ -1659,9 +1636,7 @@ parallelsStorageVolGetPath(virStorageVolPtr vol)
goto
cleanup
;
}
ret
=
strdup
(
privvol
->
target
.
path
);
if
(
ret
==
NULL
)
virReportOOMError
();
ignore_value
(
VIR_STRDUP
(
ret
,
privvol
->
target
.
path
));
cleanup:
if
(
privpool
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录