Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
f5a60ebd
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看板
提交
f5a60ebd
编写于
7月 04, 2013
作者:
M
Michal Privoznik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapt to VIR_ALLOC and virAsprintf in src/parallels/*
上级
4079aca0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
47 addition
and
99 deletion
+47
-99
src/nodeinfo.c
src/nodeinfo.c
+1
-2
src/parallels/parallels_driver.c
src/parallels/parallels_driver.c
+24
-41
src/parallels/parallels_network.c
src/parallels/parallels_network.c
+6
-18
src/parallels/parallels_storage.c
src/parallels/parallels_storage.c
+15
-35
src/parallels/parallels_utils.c
src/parallels/parallels_utils.c
+1
-3
未找到文件。
src/nodeinfo.c
浏览文件 @
f5a60ebd
...
...
@@ -1486,8 +1486,7 @@ nodeCapsInitNUMAFake(virCapsPtr caps ATTRIBUTE_UNUSED)
cpus
[
id
].
core_id
=
c
;
if
(
!
(
cpus
[
id
].
siblings
=
virBitmapNew
(
ncpus
)))
goto
error
;
if
(
virBitmapSetBit
(
cpus
[
id
].
siblings
,
id
)
<
0
)
goto
error
;
ignore_value
(
virBitmapSetBit
(
cpus
[
id
].
siblings
,
id
));
id
++
;
}
}
...
...
src/parallels/parallels_driver.c
浏览文件 @
f5a60ebd
...
...
@@ -118,35 +118,34 @@ parallelsBuildCapabilities(void)
if
((
caps
=
virCapabilitiesNew
(
virArchFromHost
(),
0
,
0
))
==
NULL
)
goto
no_memory
;
return
NULL
;
if
(
nodeCapsInitNUMA
(
caps
)
<
0
)
goto
no_memory
;
goto
error
;
if
((
guest
=
virCapabilitiesAddGuest
(
caps
,
"hvm"
,
VIR_ARCH_X86_64
,
"parallels"
,
NULL
,
0
,
NULL
))
==
NULL
)
goto
no_memory
;
goto
error
;
if
(
virCapabilitiesAddGuestDomain
(
guest
,
"parallels"
,
NULL
,
NULL
,
0
,
NULL
)
==
NULL
)
goto
no_memory
;
goto
error
;
if
((
guest
=
virCapabilitiesAddGuest
(
caps
,
"exe"
,
VIR_ARCH_X86_64
,
"parallels"
,
NULL
,
0
,
NULL
))
==
NULL
)
goto
no_memory
;
goto
error
;
if
(
virCapabilitiesAddGuestDomain
(
guest
,
"parallels"
,
NULL
,
NULL
,
0
,
NULL
)
==
NULL
)
goto
no_memory
;
goto
error
;
return
caps
;
no_memory:
virReportOOMError
();
error:
virObjectUnref
(
caps
);
return
NULL
;
}
...
...
@@ -227,20 +226,18 @@ parallelsAddSerialInfo(virDomainChrDefPtr **serials, size_t *nserials,
virDomainChrDefPtr
chr
=
NULL
;
if
(
!
(
chr
=
virDomainChrDefNew
()))
goto
no_memory
;
goto
cleanup
;
if
(
parallelsGetSerialInfo
(
chr
,
key
,
value
))
goto
cleanup
;
if
(
VIR_REALLOC_N
(
*
serials
,
*
nserials
+
1
)
<
0
)
goto
no_memory
;
goto
cleanup
;
(
*
serials
)[(
*
nserials
)
++
]
=
chr
;
return
0
;
no_memory:
virReportOOMError
();
cleanup:
virDomainChrDefFree
(
chr
);
return
-
1
;
...
...
@@ -271,13 +268,13 @@ parallelsAddVideoInfo(virDomainDefPtr def, virJSONValuePtr value)
}
if
(
VIR_ALLOC
(
video
)
<
0
)
goto
no_memory
;
goto
error
;
if
(
VIR_ALLOC
(
accel
)
<
0
)
goto
no_memory
;
goto
error
;
if
(
VIR_REALLOC_N
(
def
->
videos
,
def
->
nvideos
+
1
)
<
0
)
goto
no_memory
;
goto
error
;
def
->
videos
[
def
->
nvideos
++
]
=
video
;
...
...
@@ -288,11 +285,9 @@ parallelsAddVideoInfo(virDomainDefPtr def, virJSONValuePtr value)
return
0
;
no_memory:
virReportOOMError
();
error:
VIR_FREE
(
accel
);
virDomainVideoDefFree
(
video
);
error:
return
-
1
;
}
...
...
@@ -386,20 +381,18 @@ parallelsAddHddInfo(virDomainDefPtr def, const char *key, virJSONValuePtr value)
virDomainDiskDefPtr
disk
=
NULL
;
if
(
VIR_ALLOC
(
disk
)
<
0
)
goto
no_memory
;
goto
error
;
if
(
parallelsGetHddInfo
(
def
,
disk
,
key
,
value
))
goto
error
;
if
(
VIR_REALLOC_N
(
def
->
disks
,
def
->
ndisks
+
1
)
<
0
)
goto
no_memory
;
goto
error
;
def
->
disks
[
def
->
ndisks
++
]
=
disk
;
return
0
;
no_memory:
virReportOOMError
();
error:
virDomainDiskDefFree
(
disk
);
return
-
1
;
...
...
@@ -508,20 +501,18 @@ parallelsAddNetInfo(virDomainDefPtr def, const char *key, virJSONValuePtr value)
virDomainNetDefPtr
net
=
NULL
;
if
(
VIR_ALLOC
(
net
)
<
0
)
goto
no_memory
;
goto
error
;
if
(
parallelsGetNetInfo
(
net
,
key
,
value
))
goto
error
;
if
(
VIR_EXPAND_N
(
def
->
nets
,
def
->
nnets
,
1
)
<
0
)
goto
no_memory
;
goto
error
;
def
->
nets
[
def
->
nnets
-
1
]
=
net
;
return
0
;
no_memory:
virReportOOMError
();
error:
virDomainNetDefFree
(
net
);
return
-
1
;
...
...
@@ -597,7 +588,7 @@ parallelsAddVNCInfo(virDomainDefPtr def, virJSONValuePtr jobj_root)
}
if
(
VIR_ALLOC
(
gr
)
<
0
)
goto
no_memory
;
goto
cleanup
;
if
(
STREQ
(
tmp
,
"auto"
))
{
if
(
virJSONValueObjectGetNumberUint
(
jobj
,
"port"
,
&
port
)
<
0
)
...
...
@@ -625,7 +616,7 @@ parallelsAddVNCInfo(virDomainDefPtr def, virJSONValuePtr jobj_root)
}
if
(
VIR_ALLOC
(
gr
->
listens
)
<
0
)
goto
no_memory
;
goto
cleanup
;
gr
->
nListens
=
1
;
...
...
@@ -635,13 +626,11 @@ parallelsAddVNCInfo(virDomainDefPtr def, virJSONValuePtr jobj_root)
gr
->
listens
[
0
].
type
=
VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS
;
if
(
VIR_REALLOC_N
(
def
->
graphics
,
def
->
ngraphics
+
1
)
<
0
)
goto
no_memory
;
goto
cleanup
;
def
->
graphics
[
def
->
ngraphics
++
]
=
gr
;
return
0
;
no_memory:
virReportOOMError
();
cleanup:
virDomainGraphicsDefFree
(
gr
);
return
ret
;
...
...
@@ -665,7 +654,7 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj)
const
char
*
state
;
if
(
VIR_ALLOC
(
def
)
<
0
)
goto
no_memory
;
goto
cleanup
;
def
->
virtType
=
VIR_DOMAIN_VIRT_PARALLELS
;
def
->
id
=
-
1
;
...
...
@@ -771,7 +760,7 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj)
def
->
os
.
arch
=
VIR_ARCH_X86_64
;
if
(
VIR_ALLOC
(
pdom
)
<
0
)
goto
no_memory
;
goto
cleanup
;
if
(
virJSONValueObjectGetNumberUint
(
jobj
,
"EnvID"
,
&
x
)
<
0
)
goto
cleanup
;
...
...
@@ -833,8 +822,6 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj)
return
dom
;
no_memory:
virReportOOMError
();
cleanup:
virDomainDefFree
(
def
);
parallelsDomObjFreePrivate
(
pdom
);
...
...
@@ -899,10 +886,8 @@ parallelsOpenDefault(virConnectPtr conn)
{
parallelsConnPtr
privconn
;
if
(
VIR_ALLOC
(
privconn
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
privconn
)
<
0
)
return
VIR_DRV_OPEN_ERROR
;
}
if
(
virMutexInit
(
&
privconn
->
lock
)
<
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"cannot initialize mutex"
));
...
...
@@ -1800,10 +1785,8 @@ static int parallelsApplyIfaceParams(parallelsDomObjPtr pdom,
if
(
!
oldnet
)
{
create
=
true
;
if
(
VIR_ALLOC
(
oldnet
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
oldnet
)
<
0
)
return
-
1
;
}
}
if
(
!
create
&&
oldnet
->
type
!=
newnet
->
type
)
{
...
...
src/parallels/parallels_network.c
浏览文件 @
f5a60ebd
...
...
@@ -57,10 +57,8 @@ static int parallelsGetBridgedNetInfo(virNetworkDefPtr def, virJSONValuePtr jobj
}
if
(
virAsprintf
(
&
bridgeLink
,
"%s/%s/brport/bridge"
,
SYSFS_NET_DIR
,
ifname
)
<
0
)
{
virReportOOMError
();
SYSFS_NET_DIR
,
ifname
)
<
0
)
goto
cleanup
;
}
if
(
virFileResolveLink
(
bridgeLink
,
&
bridgePath
)
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot read link '%s'"
),
bridgeLink
);
...
...
@@ -71,10 +69,8 @@ static int parallelsGetBridgedNetInfo(virNetworkDefPtr def, virJSONValuePtr jobj
goto
cleanup
;
if
(
virAsprintf
(
&
bridgeAddressPath
,
"%s/%s/brport/bridge/address"
,
SYSFS_NET_DIR
,
ifname
)
<
0
)
{
virReportOOMError
();
SYSFS_NET_DIR
,
ifname
)
<
0
)
goto
cleanup
;
}
if
((
len
=
virFileReadAll
(
bridgeAddressPath
,
18
,
&
bridgeAddress
))
<
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
...
...
@@ -112,10 +108,8 @@ static int parallelsGetHostOnlyNetInfo(virNetworkDefPtr def, const char *name)
virJSONValuePtr
jobj
=
NULL
,
jobj2
;
int
ret
=
-
1
;
if
(
VIR_EXPAND_N
(
def
->
ips
,
def
->
nips
,
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_EXPAND_N
(
def
->
ips
,
def
->
nips
,
1
)
<
0
)
goto
cleanup
;
}
jobj
=
parallelsParseOutput
(
"prlsrvctl"
,
"net"
,
"info"
,
"-j"
,
name
,
NULL
);
...
...
@@ -157,10 +151,8 @@ static int parallelsGetHostOnlyNetInfo(virNetworkDefPtr def, const char *name)
goto
cleanup
;
}
if
(
VIR_EXPAND_N
(
def
->
ips
[
0
].
ranges
,
def
->
ips
[
0
].
nranges
,
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_EXPAND_N
(
def
->
ips
[
0
].
ranges
,
def
->
ips
[
0
].
nranges
,
1
)
<
0
)
goto
cleanup
;
}
if
(
!
(
tmp
=
virJSONValueObjectGetString
(
jobj2
,
"IP scope start address"
)))
{
parallelsParseError
();
...
...
@@ -198,7 +190,7 @@ parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr jobj)
unsigned
char
md5
[
MD5_DIGEST_SIZE
];
if
(
VIR_ALLOC
(
def
)
<
0
)
goto
no_memory
;
goto
cleanup
;
if
(
!
(
tmp
=
virJSONValueObjectGetString
(
jobj
,
"Network ID"
)))
{
parallelsParseError
();
...
...
@@ -244,8 +236,6 @@ parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr jobj)
virNetworkObjUnlock
(
net
);
return
net
;
no_memory:
virReportOOMError
();
cleanup:
virNetworkDefFree
(
def
);
return
NULL
;
...
...
@@ -258,7 +248,7 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
virNetworkDefPtr
def
;
if
(
VIR_ALLOC
(
def
)
<
0
)
goto
no_memory
;
goto
cleanup
;
def
->
forward
.
type
=
VIR_NETWORK_FORWARD_ROUTE
;
...
...
@@ -283,8 +273,6 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
return
net
;
no_memory:
virReportOOMError
();
cleanup:
virNetworkDefFree
(
def
);
return
NULL
;
...
...
src/parallels/parallels_storage.c
浏览文件 @
f5a60ebd
...
...
@@ -106,10 +106,8 @@ parallelsFindVolumes(virStoragePoolObjPtr pool)
continue
;
if
(
!
(
path
=
virFileBuildPath
(
pool
->
def
->
target
.
path
,
ent
->
d_name
,
NULL
)))
{
virReportOOMError
();
ent
->
d_name
,
NULL
)))
goto
cleanup
;
}
if
(
!
parallelsStorageVolDefineXML
(
pool
,
NULL
,
path
,
false
))
goto
cleanup
;
...
...
@@ -170,13 +168,13 @@ parallelsPoolCreateByPath(virConnectPtr conn, const char *path)
virStoragePoolObjPtr
pool
=
NULL
;
if
(
VIR_ALLOC
(
def
)
<
0
)
goto
no_memory
;
goto
error
;
if
(
!
(
def
->
name
=
parallelsMakePoolName
(
conn
,
path
)))
goto
error
;
if
(
VIR_ALLOC_N
(
def
->
uuid
,
VIR_UUID_BUFLEN
))
goto
no_memory
;
goto
error
;
if
(
virUUIDGenerate
(
def
->
uuid
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
...
...
@@ -199,8 +197,6 @@ parallelsPoolCreateByPath(virConnectPtr conn, const char *path)
virStoragePoolObjUnlock
(
pool
);
return
pool
;
no_memory:
virReportOOMError
();
error:
virStoragePoolDefFree
(
def
);
if
(
pool
)
...
...
@@ -302,10 +298,10 @@ static int parallelsAddDiskVolume(virStoragePoolObjPtr pool,
virStorageVolDefPtr
def
=
NULL
;
if
(
VIR_ALLOC
(
def
))
goto
no_memory
;
goto
error
;
if
(
virAsprintf
(
&
def
->
name
,
"%s-%s"
,
dom
->
def
->
name
,
diskName
)
<
0
)
goto
no_memory
;
goto
error
;
def
->
type
=
VIR_STORAGE_VOL_FILE
;
...
...
@@ -319,7 +315,7 @@ static int parallelsAddDiskVolume(virStoragePoolObjPtr pool,
goto
error
;
if
(
VIR_REALLOC_N
(
pool
->
volumes
.
objs
,
pool
->
volumes
.
count
+
1
)
<
0
)
goto
no_memory
;
goto
error
;
pool
->
volumes
.
objs
[
pool
->
volumes
.
count
++
]
=
def
;
...
...
@@ -352,10 +348,8 @@ static int parallelsFindVmVolumes(virStoragePoolObjPtr pool,
VIR_FREE
(
diskPath
);
VIR_FREE
(
diskDescPath
);
if
(
!
(
diskPath
=
virFileBuildPath
(
pdom
->
home
,
ent
->
d_name
,
NULL
)))
{
virReportOOMError
();
if
(
!
(
diskPath
=
virFileBuildPath
(
pdom
->
home
,
ent
->
d_name
,
NULL
)))
goto
cleanup
;
}
if
(
lstat
(
diskPath
,
&
sb
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -368,10 +362,8 @@ static int parallelsFindVmVolumes(virStoragePoolObjPtr pool,
continue
;
if
(
!
(
diskDescPath
=
virFileBuildPath
(
diskPath
,
"DiskDescriptor"
,
".xml"
)))
{
virReportOOMError
();
"DiskDescriptor"
,
".xml"
)))
goto
cleanup
;
}
if
(
access
(
diskDescPath
,
F_OK
))
continue
;
...
...
@@ -422,11 +414,11 @@ static int parallelsLoadPools(virConnectPtr conn)
/* Configuration path is /etc/libvirt/parallels-storage/... . */
if
(
virAsprintf
(
&
storageState
->
configDir
,
"%s/parallels-storage"
,
base
)
==
-
1
)
goto
out_of_memory
;
goto
error
;
if
(
virAsprintf
(
&
storageState
->
autostartDir
,
"%s/parallels-storage/autostart"
,
base
)
==
-
1
)
goto
out_of_memory
;
goto
error
;
VIR_FREE
(
base
);
...
...
@@ -459,8 +451,6 @@ static int parallelsLoadPools(virConnectPtr conn)
return
0
;
out_of_memory:
virReportOOMError
();
error:
VIR_FREE
(
base
);
return
-
1
;
...
...
@@ -477,10 +467,8 @@ parallelsStorageOpen(virConnectPtr conn,
if
(
STRNEQ
(
conn
->
driver
->
name
,
"Parallels"
))
return
VIR_DRV_OPEN_DECLINED
;
if
(
VIR_ALLOC
(
storageState
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
storageState
)
<
0
)
return
VIR_DRV_OPEN_ERROR
;
}
if
(
virMutexInit
(
&
storageState
->
lock
)
<
0
)
{
VIR_FREE
(
storageState
);
...
...
@@ -1244,16 +1232,12 @@ parallelsStorageVolDefineXML(virStoragePoolObjPtr pool,
}
}
if
(
VIR_REALLOC_N
(
pool
->
volumes
.
objs
,
pool
->
volumes
.
count
+
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
pool
->
volumes
.
objs
,
pool
->
volumes
.
count
+
1
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
privvol
->
target
.
path
,
"%s/%s"
,
pool
->
def
->
target
.
path
,
privvol
->
name
)
<
0
)
{
virReportOOMError
();
pool
->
def
->
target
.
path
,
privvol
->
name
)
<
0
)
goto
cleanup
;
}
if
(
VIR_STRDUP
(
privvol
->
key
,
privvol
->
target
.
path
)
<
0
)
goto
cleanup
;
...
...
@@ -1382,16 +1366,12 @@ parallelsStorageVolCreateXMLFrom(virStoragePoolPtr pool,
privpool
->
def
->
allocation
);
if
(
VIR_REALLOC_N
(
privpool
->
volumes
.
objs
,
privpool
->
volumes
.
count
+
1
)
<
0
)
{
virReportOOMError
();
privpool
->
volumes
.
count
+
1
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
privvol
->
target
.
path
,
"%s/%s"
,
privpool
->
def
->
target
.
path
,
privvol
->
name
)
==
-
1
)
{
virReportOOMError
();
privpool
->
def
->
target
.
path
,
privvol
->
name
)
==
-
1
)
goto
cleanup
;
}
if
(
VIR_STRDUP
(
privvol
->
key
,
privvol
->
target
.
path
)
<
0
)
goto
cleanup
;
...
...
src/parallels/parallels_utils.c
浏览文件 @
f5a60ebd
...
...
@@ -130,10 +130,8 @@ parallelsAddFileExt(const char *path, const char *ext)
char
*
new_path
=
NULL
;
size_t
len
=
strlen
(
path
)
+
strlen
(
ext
)
+
1
;
if
(
VIR_ALLOC_N
(
new_path
,
len
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
new_path
,
len
)
<
0
)
return
NULL
;
}
if
(
!
virStrcpy
(
new_path
,
path
,
len
))
{
VIR_FREE
(
new_path
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录