Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
5162a076
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看板
提交
5162a076
编写于
5月 03, 2013
作者:
M
Michal Privoznik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapt to VIR_STRDUP and VIR_STRNDUP in src/xen/*
上级
ed2193b1
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
56 addition
and
126 deletion
+56
-126
src/xen/block_stats.c
src/xen/block_stats.c
+8
-8
src/xen/xen_driver.c
src/xen/xen_driver.c
+4
-5
src/xen/xen_hypervisor.c
src/xen/xen_hypervisor.c
+5
-14
src/xen/xen_inotify.c
src/xen/xen_inotify.c
+4
-11
src/xen/xend_internal.c
src/xen/xend_internal.c
+16
-52
src/xen/xm_internal.c
src/xen/xm_internal.c
+3
-8
src/xen/xs_internal.c
src/xen/xs_internal.c
+16
-28
未找到文件。
src/xen/block_stats.c
浏览文件 @
5162a076
...
...
@@ -292,14 +292,14 @@ xenLinuxDomainDeviceID(int domid, const char *path)
* /sys/devices/xen-backend/(vbd|tap)-{domid}-{devid}/statistics/{...}
*/
if
(
strlen
(
path
)
>=
5
&&
STRPREFIX
(
path
,
"/dev/"
))
mod_path
=
strdup
(
path
);
else
ignore_value
(
virAsprintf
(
&
mod_path
,
"/dev/%s"
,
path
));
if
(
!
mod_path
)
{
virReportOOMError
()
;
return
-
1
;
if
(
strlen
(
path
)
>=
5
&&
STRPREFIX
(
path
,
"/dev/"
))
{
if
(
VIR_STRDUP
(
mod_path
,
path
)
<
0
)
return
-
1
;
}
else
{
if
(
virAsprintf
(
&
mod_path
,
"/dev/%s"
,
path
)
<
0
)
{
virReportOOMError
();
return
-
1
;
}
}
retval
=
-
1
;
...
...
src/xen/xen_driver.c
浏览文件 @
5162a076
...
...
@@ -469,10 +469,8 @@ xenUnifiedConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int f
priv
->
opened
[
XEN_UNIFIED_INOTIFY_OFFSET
]
=
1
;
#endif
if
(
!
(
priv
->
saveDir
=
strdup
(
XEN_SAVE_DIR
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
priv
->
saveDir
,
XEN_SAVE_DIR
)
<
0
)
goto
error
;
}
if
(
virFileMakePath
(
priv
->
saveDir
)
<
0
)
{
VIR_ERROR
(
_
(
"Errored to create save dir '%s': %s"
),
priv
->
saveDir
,
...
...
@@ -2586,8 +2584,8 @@ xenUnifiedAddDomainInfo(xenUnifiedDomainInfoListPtr list,
if
(
VIR_ALLOC
(
info
)
<
0
)
goto
memory_error
;
if
(
!
(
info
->
name
=
strdup
(
name
))
)
goto
memory_
error
;
if
(
VIR_STRDUP
(
info
->
name
,
name
)
<
0
)
goto
error
;
memcpy
(
info
->
uuid
,
uuid
,
VIR_UUID_BUFLEN
);
info
->
id
=
id
;
...
...
@@ -2603,6 +2601,7 @@ xenUnifiedAddDomainInfo(xenUnifiedDomainInfoListPtr list,
return
0
;
memory_error:
virReportOOMError
();
error:
if
(
info
)
VIR_FREE
(
info
->
name
);
VIR_FREE
(
info
);
...
...
src/xen/xen_hypervisor.c
浏览文件 @
5162a076
...
...
@@ -1142,16 +1142,12 @@ xenHypervisorGetSchedulerType(virConnectPtr conn,
switch
(
op
.
u
.
getschedulerid
.
sched_id
){
case
XEN_SCHEDULER_SEDF
:
schedulertype
=
strdup
(
"sedf"
);
if
(
schedulertype
==
NULL
)
virReportOOMError
();
ignore_value
(
VIR_STRDUP
(
schedulertype
,
"sedf"
));
if
(
nparams
)
*
nparams
=
XEN_SCHED_SEDF_NPARAM
;
break
;
case
XEN_SCHEDULER_CREDIT
:
schedulertype
=
strdup
(
"credit"
);
if
(
schedulertype
==
NULL
)
virReportOOMError
();
ignore_value
(
VIR_STRDUP
(
schedulertype
,
"credit"
));
if
(
nparams
)
*
nparams
=
XEN_SCHED_CRED_NPARAM
;
break
;
...
...
@@ -2541,14 +2537,9 @@ xenHypervisorDomainGetOSType(virConnectPtr conn,
return
NULL
;
}
if
(
XEN_GETDOMAININFO_FLAGS
(
dominfo
)
&
DOMFLAGS_HVM
)
ostype
=
strdup
(
"hvm"
);
else
ostype
=
strdup
(
"linux"
);
if
(
ostype
==
NULL
)
virReportOOMError
();
ignore_value
(
VIR_STRDUP
(
ostype
,
XEN_GETDOMAININFO_FLAGS
(
dominfo
)
&
DOMFLAGS_HVM
?
"hvm"
:
"linux"
));
return
ostype
;
}
...
...
src/xen/xen_inotify.c
浏览文件 @
5162a076
...
...
@@ -39,7 +39,7 @@
#include "virlog.h"
#include "viruuid.h"
#include "virfile.h"
#include "virstring.h"
#include "xm_internal.h"
/* for xenXMDomainConfigParse */
#define VIR_FROM_THIS VIR_FROM_XEN_INOTIFY
...
...
@@ -58,12 +58,9 @@ xenInotifyXenCacheLookup(virConnectPtr conn,
return
-
1
;
}
*
name
=
strdup
(
entry
->
def
->
name
);
memcpy
(
uuid
,
entry
->
def
->
uuid
,
VIR_UUID_BUFLEN
);
if
(
!*
name
)
{
if
(
VIR_STRDUP
(
*
name
,
entry
->
def
->
name
)
<
0
)
{
VIR_DEBUG
(
"Error getting dom from def"
);
virReportOOMError
();
return
-
1
;
}
return
0
;
...
...
@@ -103,11 +100,8 @@ xenInotifyXendDomainsDirLookup(virConnectPtr conn,
list info */
for
(
i
=
0
;
i
<
priv
->
configInfoList
->
count
;
i
++
)
{
if
(
!
memcmp
(
rawuuid
,
priv
->
configInfoList
->
doms
[
i
]
->
uuid
,
VIR_UUID_BUFLEN
))
{
*
name
=
strdup
(
priv
->
configInfoList
->
doms
[
i
]
->
name
);
if
(
!*
name
)
{
virReportOOMError
();
if
(
VIR_STRDUP
(
*
name
,
priv
->
configInfoList
->
doms
[
i
]
->
name
)
<
0
)
return
-
1
;
}
memcpy
(
uuid
,
priv
->
configInfoList
->
doms
[
i
]
->
uuid
,
VIR_UUID_BUFLEN
);
VIR_DEBUG
(
"Found dom on list"
);
return
0
;
...
...
@@ -118,8 +112,7 @@ xenInotifyXendDomainsDirLookup(virConnectPtr conn,
return
-
1
;
}
if
(
!
(
*
name
=
strdup
(
def
->
name
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
*
name
,
def
->
name
)
<
0
)
{
virDomainDefFree
(
def
);
return
-
1
;
}
...
...
src/xen/xend_internal.c
浏览文件 @
5162a076
...
...
@@ -772,8 +772,7 @@ xenDaemonListDomainsOld(virConnectPtr xend)
_for_i
=
_for_i
->
u
.
s
.
cdr
,
node
=
_for_i
->
u
.
s
.
car
)
{
if
(
node
->
kind
!=
SEXPR_VALUE
)
continue
;
ret
[
i
]
=
strdup
(
node
->
u
.
value
);
if
(
!
ret
[
i
])
if
(
VIR_STRDUP
(
ret
[
i
],
node
->
u
.
value
)
<
0
)
goto
no_memory
;
i
++
;
}
...
...
@@ -1396,14 +1395,8 @@ xenDaemonDomainGetOSType(virConnectPtr conn,
if
(
root
==
NULL
)
return
NULL
;
if
(
sexpr_lookup
(
root
,
"domain/image/hvm"
))
{
type
=
strdup
(
"hvm"
);
}
else
{
type
=
strdup
(
"linux"
);
}
if
(
type
==
NULL
)
virReportOOMError
();
ignore_value
(
VIR_STRDUP
(
type
,
sexpr_lookup
(
root
,
"domain/image/hvm"
)
?
"hvm"
:
"linux"
));
sexpr_free
(
root
);
...
...
@@ -2118,12 +2111,7 @@ xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
else
id
=
-
1
;
if
(
domname
)
{
name
=
strdup
(
domname
);
if
(
name
==
NULL
)
virReportOOMError
();
}
ignore_value
(
VIR_STRDUP
(
name
,
domname
));
sexpr_free
(
root
);
}
...
...
@@ -2284,12 +2272,9 @@ xenDaemonAttachDeviceFlags(virConnectPtr conn,
priv
->
xendConfigVersion
,
1
)
<
0
)
goto
cleanup
;
if
(
dev
->
data
.
disk
->
device
!=
VIR_DOMAIN_DISK_DEVICE_CDROM
)
{
if
(
!
(
target
=
strdup
(
dev
->
data
.
disk
->
dst
)))
{
virReportOOMError
();
goto
cleanup
;
}
}
if
(
dev
->
data
.
disk
->
device
!=
VIR_DOMAIN_DISK_DEVICE_CDROM
&&
VIR_STRDUP
(
target
,
dev
->
data
.
disk
->
dst
)
<
0
)
goto
cleanup
;
break
;
case
VIR_DOMAIN_DEVICE_NET
:
...
...
@@ -2303,10 +2288,8 @@ xenDaemonAttachDeviceFlags(virConnectPtr conn,
char
macStr
[
VIR_MAC_STRING_BUFLEN
];
virMacAddrFormat
(
&
dev
->
data
.
net
->
mac
,
macStr
);
if
(
!
(
target
=
strdup
(
macStr
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
target
,
macStr
)
<
0
)
goto
cleanup
;
}
break
;
case
VIR_DOMAIN_DEVICE_HOSTDEV
:
...
...
@@ -2618,12 +2601,9 @@ xenDaemonDomainSetAutostart(virConnectPtr conn,
/* Change the autostart value in place, then define the new sexpr */
VIR_FREE
(
autonode
->
u
.
s
.
car
->
u
.
value
);
autonode
->
u
.
s
.
car
->
u
.
value
=
(
autostart
?
strdup
(
"start"
)
:
strdup
(
"ignore"
));
if
(
!
(
autonode
->
u
.
s
.
car
->
u
.
value
))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
autonode
->
u
.
s
.
car
->
u
.
value
,
autostart
?
"start"
:
"ignore"
)
<
0
)
goto
error
;
}
if
(
sexpr2string
(
root
,
&
buffer
)
<
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
...
...
@@ -2783,9 +2763,7 @@ xenDaemonDomainMigratePerform(virConnectPtr conn,
virURIFree
(
uriptr
);
return
-
1
;
}
hostname
=
strdup
(
uriptr
->
server
);
if
(
!
hostname
)
{
virReportOOMError
();
if
(
VIR_STRDUP
(
hostname
,
uriptr
->
server
)
<
0
)
{
virURIFree
(
uriptr
);
return
-
1
;
}
...
...
@@ -2805,19 +2783,13 @@ xenDaemonDomainMigratePerform(virConnectPtr conn,
/* Get the hostname. */
n
=
p
-
uri
;
/* n = Length of hostname in bytes. */
hostname
=
strdup
(
uri
);
if
(
!
hostname
)
{
virReportOOMError
();
if
(
VIR_STRDUP
(
hostname
,
uri
)
<
0
)
return
-
1
;
}
hostname
[
n
]
=
'\0'
;
}
else
{
/* "hostname" (or IP address) */
hostname
=
strdup
(
uri
);
if
(
!
hostname
)
{
virReportOOMError
();
if
(
VIR_STRDUP
(
hostname
,
uri
)
<
0
)
return
-
1
;
}
}
VIR_DEBUG
(
"hostname = %s, port = %s"
,
hostname
,
port
);
...
...
@@ -2957,10 +2929,8 @@ xenDaemonListDefinedDomains(virConnectPtr conn,
if
(
node
->
kind
!=
SEXPR_VALUE
)
continue
;
if
((
names
[
ret
++
]
=
strdup
(
node
->
u
.
value
))
==
NULL
)
{
virReportOOMError
();
if
(
VIR_STRDUP
(
names
[
ret
++
],
node
->
u
.
value
)
<
0
)
goto
error
;
}
if
(
ret
>=
maxnames
)
break
;
...
...
@@ -3017,19 +2987,13 @@ xenDaemonGetSchedulerType(virConnectPtr conn,
goto
error
;
}
if
(
STREQ
(
ret
,
"credit"
))
{
schedulertype
=
strdup
(
"credit"
);
if
(
schedulertype
==
NULL
){
virReportOOMError
();
if
(
VIR_STRDUP
(
schedulertype
,
"credit"
)
<
0
)
goto
error
;
}
if
(
nparams
)
*
nparams
=
XEN_SCHED_CRED_NPARAM
;
}
else
if
(
STREQ
(
ret
,
"sedf"
))
{
schedulertype
=
strdup
(
"sedf"
);
if
(
schedulertype
==
NULL
){
virReportOOMError
();
if
(
VIR_STRDUP
(
schedulertype
,
"sedf"
)
<
0
)
goto
error
;
}
if
(
nparams
)
*
nparams
=
XEN_SCHED_SEDF_NPARAM
;
}
else
{
...
...
src/xen/xm_internal.c
浏览文件 @
5162a076
...
...
@@ -241,8 +241,7 @@ xenXMConfigCacheAddFile(virConnectPtr conn, const char *filename)
virReportOOMError
();
return
-
1
;
}
if
((
entry
->
filename
=
strdup
(
filename
))
==
NULL
)
{
virReportOOMError
();
if
(
VIR_STRDUP
(
entry
->
filename
,
filename
)
<
0
)
{
VIR_FREE
(
entry
);
return
-
1
;
}
...
...
@@ -1042,10 +1041,8 @@ xenXMDomainDefineXML(virConnectPtr conn, virDomainDefPtr def)
goto
error
;
}
if
((
entry
->
filename
=
strdup
(
filename
))
==
NULL
)
{
virReportOOMError
();
if
(
VIR_STRDUP
(
entry
->
filename
,
filename
)
<
0
)
goto
error
;
}
entry
->
def
=
def
;
if
(
virHashAddEntry
(
priv
->
configCache
,
filename
,
entry
)
<
0
)
{
...
...
@@ -1134,7 +1131,7 @@ xenXMListIterator(void *payload ATTRIBUTE_UNUSED, const void *name, void *data)
def
=
xenDaemonLookupByName
(
ctx
->
conn
,
name
);
if
(
!
def
)
{
if
(
!
(
ctx
->
names
[
ctx
->
count
]
=
strdup
(
name
))
)
if
(
VIR_STRDUP
(
ctx
->
names
[
ctx
->
count
],
name
)
<
0
)
ctx
->
oom
=
1
;
else
ctx
->
count
++
;
...
...
@@ -1174,8 +1171,6 @@ xenXMListDefinedDomains(virConnectPtr conn, char **const names, int maxnames)
if
(
ctx
.
oom
)
{
for
(
i
=
0
;
i
<
ctx
.
count
;
i
++
)
VIR_FREE
(
ctx
.
names
[
i
]);
virReportOOMError
();
goto
cleanup
;
}
...
...
src/xen/xs_internal.c
浏览文件 @
5162a076
...
...
@@ -50,6 +50,7 @@
#include "xen_driver.h"
#include "xs_internal.h"
#include "xen_hypervisor.h"
#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_XEN
...
...
@@ -428,11 +429,7 @@ xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac)
VIR_FREE
(
val
);
if
(
match
)
{
ret
=
strdup
(
list
[
i
]);
if
(
ret
==
NULL
)
virReportOOMError
();
ignore_value
(
VIR_STRDUP
(
ret
,
list
[
i
]));
break
;
}
}
...
...
@@ -481,10 +478,7 @@ xenStoreDomainGetDiskID(virConnectPtr conn, int id, const char *dev)
if
((
devlen
!=
len
)
||
memcmp
(
val
,
dev
,
len
))
{
VIR_FREE
(
val
);
}
else
{
ret
=
strdup
(
list
[
i
]);
if
(
ret
==
NULL
)
virReportOOMError
();
ignore_value
(
VIR_STRDUP
(
ret
,
list
[
i
]));
VIR_FREE
(
val
);
VIR_FREE
(
list
);
...
...
@@ -504,10 +498,7 @@ xenStoreDomainGetDiskID(virConnectPtr conn, int id, const char *dev)
if
((
devlen
!=
len
)
||
memcmp
(
val
,
dev
,
len
))
{
VIR_FREE
(
val
);
}
else
{
ret
=
strdup
(
list
[
i
]);
if
(
ret
==
NULL
)
virReportOOMError
();
ignore_value
(
VIR_STRDUP
(
ret
,
list
[
i
]));
VIR_FREE
(
val
);
VIR_FREE
(
list
);
...
...
@@ -559,7 +550,7 @@ xenStoreDomainGetPCIID(virConnectPtr conn, int id, const char *bdf)
VIR_FREE
(
val
);
if
(
match
)
{
ret
=
strdup
(
list
[
i
]
);
ignore_value
(
VIR_STRDUP
(
ret
,
list
[
i
])
);
break
;
}
}
...
...
@@ -665,22 +656,22 @@ xenStoreAddWatch(virConnectPtr conn,
}
}
if
(
VIR_ALLOC
(
watch
)
<
0
)
goto
no_memory
;
if
(
VIR_ALLOC
(
watch
)
<
0
)
{
virReportOOMError
();
goto
error
;
}
watch
->
path
=
strdup
(
path
);
watch
->
token
=
strdup
(
token
);
watch
->
cb
=
cb
;
watch
->
cb
=
cb
;
watch
->
opaque
=
opaque
;
if
(
watch
->
path
==
NULL
||
watch
->
token
==
NULL
)
{
goto
no_memory
;
}
if
(
VIR_STRDUP
(
watch
->
path
,
path
)
<
0
||
VIR_STRDUP
(
watch
->
token
,
token
)
<
0
)
goto
error
;
/* Make space on list */
n
=
list
->
count
;
if
(
VIR_REALLOC_N
(
list
->
watches
,
n
+
1
)
<
0
)
{
goto
no_memory
;
virReportOOMError
();
goto
error
;
}
list
->
watches
[
n
]
=
watch
;
...
...
@@ -688,15 +679,12 @@ xenStoreAddWatch(virConnectPtr conn,
return
xs_watch
(
priv
->
xshandle
,
watch
->
path
,
watch
->
token
);
no_memory
:
error
:
if
(
watch
)
{
VIR_FREE
(
watch
->
path
);
VIR_FREE
(
watch
->
token
);
VIR_FREE
(
watch
);
}
virReportOOMError
();
return
-
1
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录