Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
b0bcffda
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,发现更多精彩内容 >>
提交
b0bcffda
编写于
5月 29, 2008
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Misc OOM / memory leak fixes
上级
364f53a6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
54 addition
and
6 deletion
+54
-6
ChangeLog
ChangeLog
+8
-0
src/capabilities.c
src/capabilities.c
+14
-1
src/qemu_conf.c
src/qemu_conf.c
+9
-1
src/qparams.c
src/qparams.c
+23
-4
未找到文件。
ChangeLog
浏览文件 @
b0bcffda
Thu May 29 11:23:00 EST 2008 Daniel P. Berrange <berrange@redhat.com>
Misc memory handling / cleanup fixes
* src/capabilities.c: Avoiding deferencing NULL pointer in
cleanup code
* src/qemu_conf.c: Free sound structs on cleanup
* src/qparams.c: raise a libvirt error upon OOM
Thu May 29 11:12:00 EST 2008 Daniel P. Berrange <berrange@redhat.com>
Thu May 29 11:12:00 EST 2008 Daniel P. Berrange <berrange@redhat.com>
* tests/testutils.c, tests/testutils.h: Add generic main()
* tests/testutils.c, tests/testutils.h: Add generic main()
...
...
src/capabilities.c
浏览文件 @
b0bcffda
...
@@ -44,7 +44,7 @@ virCapabilitiesNew(const char *arch,
...
@@ -44,7 +44,7 @@ virCapabilitiesNew(const char *arch,
virCapsPtr
caps
;
virCapsPtr
caps
;
if
(
VIR_ALLOC
(
caps
)
<
0
)
if
(
VIR_ALLOC
(
caps
)
<
0
)
goto
no_memory
;
return
NULL
;
if
((
caps
->
host
.
arch
=
strdup
(
arch
))
==
NULL
)
if
((
caps
->
host
.
arch
=
strdup
(
arch
))
==
NULL
)
goto
no_memory
;
goto
no_memory
;
...
@@ -61,6 +61,9 @@ virCapabilitiesNew(const char *arch,
...
@@ -61,6 +61,9 @@ virCapabilitiesNew(const char *arch,
static
void
static
void
virCapabilitiesFreeHostNUMACell
(
virCapsHostNUMACellPtr
cell
)
virCapabilitiesFreeHostNUMACell
(
virCapsHostNUMACellPtr
cell
)
{
{
if
(
cell
==
NULL
)
return
;
VIR_FREE
(
cell
->
cpus
);
VIR_FREE
(
cell
->
cpus
);
VIR_FREE
(
cell
);
VIR_FREE
(
cell
);
}
}
...
@@ -69,6 +72,9 @@ static void
...
@@ -69,6 +72,9 @@ static void
virCapabilitiesFreeGuestDomain
(
virCapsGuestDomainPtr
dom
)
virCapabilitiesFreeGuestDomain
(
virCapsGuestDomainPtr
dom
)
{
{
int
i
;
int
i
;
if
(
dom
==
NULL
)
return
;
VIR_FREE
(
dom
->
info
.
emulator
);
VIR_FREE
(
dom
->
info
.
emulator
);
VIR_FREE
(
dom
->
info
.
loader
);
VIR_FREE
(
dom
->
info
.
loader
);
for
(
i
=
0
;
i
<
dom
->
info
.
nmachines
;
i
++
)
for
(
i
=
0
;
i
<
dom
->
info
.
nmachines
;
i
++
)
...
@@ -82,6 +88,8 @@ virCapabilitiesFreeGuestDomain(virCapsGuestDomainPtr dom)
...
@@ -82,6 +88,8 @@ virCapabilitiesFreeGuestDomain(virCapsGuestDomainPtr dom)
static
void
static
void
virCapabilitiesFreeGuestFeature
(
virCapsGuestFeaturePtr
feature
)
virCapabilitiesFreeGuestFeature
(
virCapsGuestFeaturePtr
feature
)
{
{
if
(
feature
==
NULL
)
return
;
VIR_FREE
(
feature
->
name
);
VIR_FREE
(
feature
->
name
);
VIR_FREE
(
feature
);
VIR_FREE
(
feature
);
}
}
...
@@ -90,6 +98,9 @@ static void
...
@@ -90,6 +98,9 @@ static void
virCapabilitiesFreeGuest
(
virCapsGuestPtr
guest
)
virCapabilitiesFreeGuest
(
virCapsGuestPtr
guest
)
{
{
int
i
;
int
i
;
if
(
guest
==
NULL
)
return
;
VIR_FREE
(
guest
->
ostype
);
VIR_FREE
(
guest
->
ostype
);
VIR_FREE
(
guest
->
arch
.
name
);
VIR_FREE
(
guest
->
arch
.
name
);
...
@@ -120,6 +131,8 @@ virCapabilitiesFreeGuest(virCapsGuestPtr guest)
...
@@ -120,6 +131,8 @@ virCapabilitiesFreeGuest(virCapsGuestPtr guest)
void
void
virCapabilitiesFree
(
virCapsPtr
caps
)
{
virCapabilitiesFree
(
virCapsPtr
caps
)
{
int
i
;
int
i
;
if
(
caps
==
NULL
)
return
;
for
(
i
=
0
;
i
<
caps
->
nguests
;
i
++
)
for
(
i
=
0
;
i
<
caps
->
nguests
;
i
++
)
virCapabilitiesFreeGuest
(
caps
->
guests
[
i
]);
virCapabilitiesFreeGuest
(
caps
->
guests
[
i
]);
...
...
src/qemu_conf.c
浏览文件 @
b0bcffda
...
@@ -214,6 +214,7 @@ void qemudFreeVMDef(struct qemud_vm_def *def) {
...
@@ -214,6 +214,7 @@ void qemudFreeVMDef(struct qemud_vm_def *def) {
struct
qemud_vm_input_def
*
input
=
def
->
inputs
;
struct
qemud_vm_input_def
*
input
=
def
->
inputs
;
struct
qemud_vm_chr_def
*
serial
=
def
->
serials
;
struct
qemud_vm_chr_def
*
serial
=
def
->
serials
;
struct
qemud_vm_chr_def
*
parallel
=
def
->
parallels
;
struct
qemud_vm_chr_def
*
parallel
=
def
->
parallels
;
struct
qemud_vm_sound_def
*
sound
=
def
->
sounds
;
while
(
disk
)
{
while
(
disk
)
{
struct
qemud_vm_disk_def
*
prev
=
disk
;
struct
qemud_vm_disk_def
*
prev
=
disk
;
...
@@ -240,6 +241,11 @@ void qemudFreeVMDef(struct qemud_vm_def *def) {
...
@@ -240,6 +241,11 @@ void qemudFreeVMDef(struct qemud_vm_def *def) {
parallel
=
parallel
->
next
;
parallel
=
parallel
->
next
;
free
(
prev
);
free
(
prev
);
}
}
while
(
sound
)
{
struct
qemud_vm_sound_def
*
prev
=
sound
;
sound
=
sound
->
next
;
free
(
prev
);
}
xmlFree
(
def
->
keymap
);
xmlFree
(
def
->
keymap
);
free
(
def
);
free
(
def
);
}
}
...
@@ -2186,8 +2192,10 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
...
@@ -2186,8 +2192,10 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
}
}
check
=
check
->
next
;
check
=
check
->
next
;
}
}
if
(
collision
)
if
(
collision
)
{
free
(
sound
);
continue
;
continue
;
}
def
->
nsounds
++
;
def
->
nsounds
++
;
sound
->
next
=
NULL
;
sound
->
next
=
NULL
;
...
...
src/qparams.c
浏览文件 @
b0bcffda
...
@@ -30,6 +30,14 @@
...
@@ -30,6 +30,14 @@
#include "memory.h"
#include "memory.h"
#include "qparams.h"
#include "qparams.h"
static
void
qparam_report_oom
(
void
)
{
const
char
*
virerr
=
__virErrorMsg
(
VIR_ERR_NO_MEMORY
,
NULL
);
__virRaiseError
(
NULL
,
NULL
,
NULL
,
VIR_FROM_NONE
,
VIR_ERR_NO_MEMORY
,
VIR_ERR_ERROR
,
virerr
,
NULL
,
NULL
,
-
1
,
-
1
,
virerr
,
NULL
);
}
struct
qparam_set
*
struct
qparam_set
*
new_qparam_set
(
int
init_alloc
,
...)
new_qparam_set
(
int
init_alloc
,
...)
{
{
...
@@ -39,12 +47,15 @@ new_qparam_set (int init_alloc, ...)
...
@@ -39,12 +47,15 @@ new_qparam_set (int init_alloc, ...)
if
(
init_alloc
<=
0
)
init_alloc
=
1
;
if
(
init_alloc
<=
0
)
init_alloc
=
1
;
if
(
VIR_ALLOC
(
ps
)
<
0
)
if
(
VIR_ALLOC
(
ps
)
<
0
)
{
qparam_report_oom
();
return
NULL
;
return
NULL
;
}
ps
->
n
=
0
;
ps
->
n
=
0
;
ps
->
alloc
=
init_alloc
;
ps
->
alloc
=
init_alloc
;
if
(
VIR_ALLOC_N
(
ps
->
p
,
ps
->
alloc
)
<
0
)
{
if
(
VIR_ALLOC_N
(
ps
->
p
,
ps
->
alloc
)
<
0
)
{
VIR_FREE
(
ps
);
VIR_FREE
(
ps
);
qparam_report_oom
();
return
NULL
;
return
NULL
;
}
}
...
@@ -88,7 +99,7 @@ grow_qparam_set (struct qparam_set *ps)
...
@@ -88,7 +99,7 @@ grow_qparam_set (struct qparam_set *ps)
{
{
if
(
ps
->
n
>=
ps
->
alloc
)
{
if
(
ps
->
n
>=
ps
->
alloc
)
{
if
(
VIR_REALLOC_N
(
ps
->
p
,
ps
->
alloc
*
2
)
<
0
)
{
if
(
VIR_REALLOC_N
(
ps
->
p
,
ps
->
alloc
*
2
)
<
0
)
{
perror
(
"realloc"
);
qparam_report_oom
(
);
return
-
1
;
return
-
1
;
}
}
ps
->
alloc
*=
2
;
ps
->
alloc
*=
2
;
...
@@ -104,12 +115,15 @@ append_qparam (struct qparam_set *ps,
...
@@ -104,12 +115,15 @@ append_qparam (struct qparam_set *ps,
char
*
pname
,
*
pvalue
;
char
*
pname
,
*
pvalue
;
pname
=
strdup
(
name
);
pname
=
strdup
(
name
);
if
(
!
pname
)
if
(
!
pname
)
{
qparam_report_oom
();
return
-
1
;
return
-
1
;
}
pvalue
=
strdup
(
value
);
pvalue
=
strdup
(
value
);
if
(
!
pvalue
)
{
if
(
!
pvalue
)
{
VIR_FREE
(
pname
);
VIR_FREE
(
pname
);
qparam_report_oom
();
return
-
1
;
return
-
1
;
}
}
...
@@ -143,6 +157,7 @@ qparam_get_query (const struct qparam_set *ps)
...
@@ -143,6 +157,7 @@ qparam_get_query (const struct qparam_set *ps)
}
}
if
(
virBufferError
(
&
buf
))
{
if
(
virBufferError
(
&
buf
))
{
qparam_report_oom
();
return
NULL
;
return
NULL
;
}
}
...
@@ -169,7 +184,10 @@ qparam_query_parse (const char *query)
...
@@ -169,7 +184,10 @@ qparam_query_parse (const char *query)
const
char
*
end
,
*
eq
;
const
char
*
end
,
*
eq
;
ps
=
new_qparam_set
(
0
,
NULL
);
ps
=
new_qparam_set
(
0
,
NULL
);
if
(
!
ps
)
return
NULL
;
if
(
!
ps
)
{
qparam_report_oom
();
return
NULL
;
}
if
(
!
query
||
query
[
0
]
==
'\0'
)
return
ps
;
if
(
!
query
||
query
[
0
]
==
'\0'
)
return
ps
;
...
@@ -240,6 +258,7 @@ qparam_query_parse (const char *query)
...
@@ -240,6 +258,7 @@ qparam_query_parse (const char *query)
return
ps
;
return
ps
;
out_of_memory:
out_of_memory:
qparam_report_oom
();
free_qparam_set
(
ps
);
free_qparam_set
(
ps
);
return
NULL
;
return
NULL
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录