Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
73dd7f0f
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看板
提交
73dd7f0f
编写于
4月 06, 2007
作者:
D
Daniel Veillard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* src/test.c: converted to new XPath APIs
* src/xml.c: fixed a return comment Daniel
上级
4bdac20a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
109 addition
and
154 deletion
+109
-154
ChangeLog
ChangeLog
+5
-0
src/test.c
src/test.c
+102
-153
src/xml.c
src/xml.c
+2
-1
未找到文件。
ChangeLog
浏览文件 @
73dd7f0f
Fri Apr 6 17:33:13 CEST 2007 Daniel Veillard <veillard@redhat.com>
* src/test.c: converted to new XPath APIs
* src/xml.c: fixed a return comment
Fri Apr 6 14:27:13 CEST 2007 Daniel Veillard <veillard@redhat.com>
Fri Apr 6 14:27:13 CEST 2007 Daniel Veillard <veillard@redhat.com>
* src/xml.[ch]: first patch to clean up XPath accesses with new
* src/xml.[ch]: first patch to clean up XPath accesses with new
...
...
src/test.c
浏览文件 @
73dd7f0f
...
@@ -261,7 +261,6 @@ static int testLoadDomain(virConnectPtr conn,
...
@@ -261,7 +261,6 @@ static int testLoadDomain(virConnectPtr conn,
xmlDocPtr
xml
)
{
xmlDocPtr
xml
)
{
xmlNodePtr
root
=
NULL
;
xmlNodePtr
root
=
NULL
;
xmlXPathContextPtr
ctxt
=
NULL
;
xmlXPathContextPtr
ctxt
=
NULL
;
xmlXPathObjectPtr
obj
=
NULL
;
char
*
name
=
NULL
;
char
*
name
=
NULL
;
unsigned
char
rawuuid
[
VIR_UUID_BUFLEN
];
unsigned
char
rawuuid
[
VIR_UUID_BUFLEN
];
char
*
dst_uuid
;
char
*
dst_uuid
;
...
@@ -270,8 +269,9 @@ static int testLoadDomain(virConnectPtr conn,
...
@@ -270,8 +269,9 @@ static int testLoadDomain(virConnectPtr conn,
unsigned
long
memory
=
0
;
unsigned
long
memory
=
0
;
unsigned
long
maxMem
=
0
;
unsigned
long
maxMem
=
0
;
int
nrVirtCpu
;
int
nrVirtCpu
;
char
*
conv
;
char
*
str
;
int
handle
=
-
1
,
i
;
int
handle
=
-
1
,
i
,
ret
;
long
l
;
virDomainRestart
onReboot
=
VIR_DOMAIN_RESTART
;
virDomainRestart
onReboot
=
VIR_DOMAIN_RESTART
;
virDomainRestart
onPoweroff
=
VIR_DOMAIN_DESTROY
;
virDomainRestart
onPoweroff
=
VIR_DOMAIN_DESTROY
;
virDomainRestart
onCrash
=
VIR_DOMAIN_RENAME_RESTART
;
virDomainRestart
onCrash
=
VIR_DOMAIN_RENAME_RESTART
;
...
@@ -294,102 +294,81 @@ static int testLoadDomain(virConnectPtr conn,
...
@@ -294,102 +294,81 @@ static int testLoadDomain(virConnectPtr conn,
goto
error
;
goto
error
;
}
}
obj
=
xmlXPathEval
(
BAD_CAST
"string(/domain/name[1])"
,
ctxt
);
name
=
virXPathString
(
"string(/domain/name[1])"
,
ctxt
);
if
((
obj
==
NULL
)
||
(
obj
->
type
!=
XPATH_STRING
)
||
if
(
name
==
NULL
)
{
(
obj
->
stringval
==
NULL
)
||
(
obj
->
stringval
[
0
]
==
0
))
{
testError
(
conn
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"domain name"
));
testError
(
conn
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"domain name"
));
goto
error
;
goto
error
;
}
}
name
=
strdup
((
const
char
*
)
obj
->
stringval
);
xmlXPathFreeObject
(
obj
);
obj
=
xmlXPathEval
(
BAD_CAST
"string(/domain/uuid[1])"
,
ctxt
);
str
=
virXPathString
(
"string(/domain/uuid[1])"
,
ctxt
);
if
((
obj
==
NULL
)
||
(
obj
->
type
!=
XPATH_STRING
)
||
if
(
str
==
NULL
)
{
(
obj
->
stringval
==
NULL
)
||
(
obj
->
stringval
[
0
]
==
0
))
{
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain uuid"
));
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain uuid"
));
goto
error
;
goto
error
;
}
}
dst_uuid
=
(
char
*
)
&
rawuuid
[
0
];
dst_uuid
=
(
char
*
)
&
rawuuid
[
0
];
if
(
!
(
virParseUUID
((
char
**
)
&
dst_uuid
,
(
const
char
*
)
obj
->
stringval
)))
{
if
(
!
(
virParseUUID
((
char
**
)
&
dst_uuid
,
str
)))
{
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain uuid"
));
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain uuid"
));
goto
error
;
goto
error
;
}
}
xmlXPathFreeObject
(
obj
);
free
(
str
);
obj
=
xmlXPathEval
(
BAD_CAST
"string(/domain/memory[1])"
,
ctxt
);
if
((
obj
==
NULL
)
||
(
obj
->
type
!=
XPATH_STRING
)
||
ret
=
virXPathLong
(
"string(/domain/memory[1])"
,
ctxt
,
&
l
);
(
obj
->
stringval
==
NULL
)
||
(
obj
->
stringval
[
0
]
==
0
))
{
if
(
ret
!=
0
)
{
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain memory"
));
goto
error
;
}
maxMem
=
strtoll
((
const
char
*
)
obj
->
stringval
,
&
conv
,
10
);
if
(
conv
==
(
const
char
*
)
obj
->
stringval
)
{
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain memory"
));
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain memory"
));
goto
error
;
goto
error
;
}
}
xmlXPathFreeObject
(
obj
)
;
maxMem
=
l
;
ret
=
virXPathLong
(
"string(/domain/currentMemory[1])"
,
ctxt
,
&
l
);
obj
=
xmlXPathEval
(
BAD_CAST
"string(/domain/currentMemory[1])"
,
ctxt
);
if
(
ret
==
-
1
)
{
if
((
obj
==
NULL
)
||
(
obj
->
type
!=
XPATH_STRING
)
||
(
obj
->
stringval
==
NULL
)
||
(
obj
->
stringval
[
0
]
==
0
))
{
memory
=
maxMem
;
memory
=
maxMem
;
}
else
if
(
ret
==
-
2
)
{
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain current memory"
));
goto
error
;
}
else
{
}
else
{
memory
=
strtoll
((
const
char
*
)
obj
->
stringval
,
&
conv
,
10
);
memory
=
l
;
if
(
conv
==
(
const
char
*
)
obj
->
stringval
)
{
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain current memory"
));
goto
error
;
}
}
}
if
(
obj
)
xmlXPathFreeObject
(
obj
);
obj
=
xmlXPathEval
(
BAD_CAST
"string(/domain/vcpu[1])"
,
ctxt
);
ret
=
virXPathLong
(
"string(/domain/vcpu[1])"
,
ctxt
,
&
l
);
if
((
obj
==
NULL
)
||
(
obj
->
type
!=
XPATH_STRING
)
||
if
(
ret
==
-
1
)
{
(
obj
->
stringval
==
NULL
)
||
(
obj
->
stringval
[
0
]
==
0
))
{
nrVirtCpu
=
1
;
nrVirtCpu
=
1
;
}
else
if
(
ret
==
-
2
)
{
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain vcpus"
));
goto
error
;
}
else
{
}
else
{
nrVirtCpu
=
strtoll
((
const
char
*
)
obj
->
stringval
,
&
conv
,
10
);
nrVirtCpu
=
l
;
if
(
conv
==
(
const
char
*
)
obj
->
stringval
)
{
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain vcpus"
));
goto
error
;
}
}
}
if
(
obj
)
xmlXPathFreeObject
(
obj
);
obj
=
xmlXPathEval
(
BAD_CAST
"string(/domain/on_reboot[1])"
,
ctxt
);
str
=
virXPathString
(
"string(/domain/on_reboot[1])"
,
ctxt
);
if
((
obj
!=
NULL
)
&&
(
obj
->
type
==
XPATH_STRING
)
&&
if
(
str
!=
NULL
)
{
(
obj
->
stringval
!=
NULL
)
&&
(
obj
->
stringval
[
0
]
!=
0
))
{
if
(
!
(
onReboot
=
testRestartStringToFlag
(
str
)))
{
if
(
!
(
onReboot
=
testRestartStringToFlag
((
const
char
*
)
obj
->
stringval
)))
{
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain reboot behaviour"
));
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain reboot behaviour"
));
free
(
str
);
goto
error
;
goto
error
;
}
}
free
(
str
);
}
}
if
(
obj
)
xmlXPathFreeObject
(
obj
);
obj
=
xmlXPathEval
(
BAD_CAST
"string(/domain/on_poweroff[1])"
,
ctxt
);
str
=
virXPathString
(
"string(/domain/on_poweroff[1])"
,
ctxt
);
if
((
obj
!=
NULL
)
&&
(
obj
->
type
==
XPATH_STRING
)
&&
if
(
str
!=
NULL
)
{
(
obj
->
stringval
!=
NULL
)
&&
(
obj
->
stringval
[
0
]
!=
0
))
{
if
(
!
(
onReboot
=
testRestartStringToFlag
(
str
)))
{
if
(
!
(
onReboot
=
testRestartStringToFlag
((
const
char
*
)
obj
->
stringval
)))
{
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain poweroff behaviour"
));
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain poweroff behaviour"
));
free
(
str
);
goto
error
;
goto
error
;
}
}
free
(
str
);
}
}
if
(
obj
)
xmlXPathFreeObject
(
obj
);
obj
=
xmlXPathEval
(
BAD_CAST
"string(/domain/on_crash[1])"
,
ctxt
);
str
=
virXPathString
(
"string(/domain/on_crash[1])"
,
ctxt
);
if
((
obj
!=
NULL
)
&&
(
obj
->
type
==
XPATH_STRING
)
&&
if
(
str
!=
NULL
)
{
(
obj
->
stringval
!=
NULL
)
&&
(
obj
->
stringval
[
0
]
!=
0
))
{
if
(
!
(
onReboot
=
testRestartStringToFlag
(
str
)))
{
if
(
!
(
onReboot
=
testRestartStringToFlag
((
const
char
*
)
obj
->
stringval
)))
{
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain crash behaviour"
));
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"domain crash behaviour"
));
free
(
str
);
goto
error
;
goto
error
;
}
}
free
(
str
);
}
}
if
(
obj
)
xmlXPathFreeObject
(
obj
);
priv
=
(
testPrivatePtr
)
conn
->
privateData
;
priv
=
(
testPrivatePtr
)
conn
->
privateData
;
con
=
&
node
->
connections
[
priv
->
handle
];
con
=
&
node
->
connections
[
priv
->
handle
];
...
@@ -427,8 +406,6 @@ static int testLoadDomain(virConnectPtr conn,
...
@@ -427,8 +406,6 @@ static int testLoadDomain(virConnectPtr conn,
return
(
0
);
return
(
0
);
error:
error:
if
(
obj
)
xmlXPathFreeObject
(
obj
);
if
(
name
)
if
(
name
)
free
(
name
);
free
(
name
);
return
(
-
1
);
return
(
-
1
);
...
@@ -539,11 +516,13 @@ static char *testBuildFilename(const char *relativeTo,
...
@@ -539,11 +516,13 @@ static char *testBuildFilename(const char *relativeTo,
static
int
testOpenFromFile
(
virConnectPtr
conn
,
static
int
testOpenFromFile
(
virConnectPtr
conn
,
int
connid
,
int
connid
,
const
char
*
file
)
{
const
char
*
file
)
{
int
fd
,
i
;
int
fd
,
i
,
ret
;
long
l
;
char
*
str
;
xmlDocPtr
xml
;
xmlDocPtr
xml
;
xmlNodePtr
root
=
NULL
;
xmlNodePtr
root
=
NULL
;
xmlNodePtr
*
domains
;
xmlXPathContextPtr
ctxt
=
NULL
;
xmlXPathContextPtr
ctxt
=
NULL
;
xmlXPathObjectPtr
obj
=
NULL
;
virNodeInfoPtr
nodeInfo
;
virNodeInfoPtr
nodeInfo
;
testPrivatePtr
priv
=
(
testPrivatePtr
)
conn
->
privateData
;
testPrivatePtr
priv
=
(
testPrivatePtr
)
conn
->
privateData
;
...
@@ -579,108 +558,79 @@ static int testOpenFromFile(virConnectPtr conn,
...
@@ -579,108 +558,79 @@ static int testOpenFromFile(virConnectPtr conn,
memmove
(
&
node
->
connections
[
connid
].
nodeInfo
,
&
defaultNodeInfo
,
sizeof
(
defaultNodeInfo
));
memmove
(
&
node
->
connections
[
connid
].
nodeInfo
,
&
defaultNodeInfo
,
sizeof
(
defaultNodeInfo
));
nodeInfo
=
&
node
->
connections
[
connid
].
nodeInfo
;
nodeInfo
=
&
node
->
connections
[
connid
].
nodeInfo
;
obj
=
xmlXPathEval
(
BAD_CAST
"string(/node/cpu/nodes[1])"
,
ctxt
);
ret
=
virXPathLong
(
"string(/node/cpu/nodes[1])"
,
ctxt
,
&
l
);
if
((
obj
!=
NULL
)
&&
(
obj
->
type
==
XPATH_STRING
)
&&
if
(
ret
==
0
)
{
(
obj
->
stringval
!=
NULL
)
&&
(
obj
->
stringval
[
0
]
!=
0
))
{
nodeInfo
->
nodes
=
l
;
char
*
conv
=
NULL
;
}
else
if
(
ret
==
-
2
)
{
nodeInfo
->
nodes
=
strtol
((
const
char
*
)
obj
->
stringval
,
&
conv
,
10
);
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node cpu numa nodes"
));
if
(
conv
==
(
const
char
*
)
obj
->
stringval
)
{
goto
error
;
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node cpu numa nodes"
));
goto
error
;
}
xmlXPathFreeObject
(
obj
);
}
}
obj
=
xmlXPathEval
(
BAD_CAST
"string(/node/cpu/sockets[1])"
,
ctxt
);
ret
=
virXPathLong
(
"string(/node/cpu/sockets[1])"
,
ctxt
,
&
l
);
if
((
obj
!=
NULL
)
&&
(
obj
->
type
==
XPATH_STRING
)
&&
if
(
ret
==
0
)
{
(
obj
->
stringval
!=
NULL
)
&&
(
obj
->
stringval
[
0
]
!=
0
))
{
nodeInfo
->
sockets
=
l
;
char
*
conv
=
NULL
;
}
else
if
(
ret
==
-
2
)
{
nodeInfo
->
sockets
=
strtol
((
const
char
*
)
obj
->
stringval
,
&
conv
,
10
);
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node cpu sockets"
));
if
(
conv
==
(
const
char
*
)
obj
->
stringval
)
{
goto
error
;
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node cpu sockets"
));
goto
error
;
}
xmlXPathFreeObject
(
obj
);
}
}
obj
=
xmlXPathEval
(
BAD_CAST
"string(/node/cpu/cores[1])"
,
ctxt
);
ret
=
virXPathLong
(
"string(/node/cpu/cores[1])"
,
ctxt
,
&
l
);
if
((
obj
!=
NULL
)
&&
(
obj
->
type
==
XPATH_STRING
)
&&
if
(
ret
==
0
)
{
(
obj
->
stringval
!=
NULL
)
&&
(
obj
->
stringval
[
0
]
!=
0
))
{
nodeInfo
->
cores
=
l
;
char
*
conv
=
NULL
;
}
else
if
(
ret
==
-
2
)
{
nodeInfo
->
cores
=
strtol
((
const
char
*
)
obj
->
stringval
,
&
conv
,
10
);
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node cpu cores"
));
if
(
conv
==
(
const
char
*
)
obj
->
stringval
)
{
goto
error
;
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node cpu cores"
));
goto
error
;
}
xmlXPathFreeObject
(
obj
);
}
}
obj
=
xmlXPathEval
(
BAD_CAST
"string(/node/cpu/threads[1])"
,
ctxt
);
ret
=
virXPathLong
(
"string(/node/cpu/threads[1])"
,
ctxt
,
&
l
);
if
((
obj
!=
NULL
)
&&
(
obj
->
type
==
XPATH_STRING
)
&&
if
(
ret
==
0
)
{
(
obj
->
stringval
!=
NULL
)
&&
(
obj
->
stringval
[
0
]
!=
0
))
{
nodeInfo
->
threads
=
l
;
char
*
conv
=
NULL
;
}
else
if
(
ret
==
-
2
)
{
nodeInfo
->
threads
=
strtol
((
const
char
*
)
obj
->
stringval
,
&
conv
,
10
);
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node cpu threads"
));
if
(
conv
==
(
const
char
*
)
obj
->
stringval
)
{
goto
error
;
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node cpu threads"
));
goto
error
;
}
xmlXPathFreeObject
(
obj
);
}
}
nodeInfo
->
cpus
=
nodeInfo
->
cores
*
nodeInfo
->
threads
*
nodeInfo
->
sockets
*
nodeInfo
->
nodes
;
nodeInfo
->
cpus
=
nodeInfo
->
cores
*
nodeInfo
->
threads
*
nodeInfo
->
sockets
*
nodeInfo
->
nodes
;
obj
=
xmlXPathEval
(
BAD_CAST
"string(/node/cpu/active[1])"
,
ctxt
);
ret
=
virXPathLong
(
"string(/node/cpu/active[1])"
,
ctxt
,
&
l
);
if
((
obj
!=
NULL
)
&&
(
obj
->
type
==
XPATH_STRING
)
&&
if
(
ret
==
0
)
{
(
obj
->
stringval
!=
NULL
)
&&
(
obj
->
stringval
[
0
]
!=
0
))
{
if
(
l
<
nodeInfo
->
cpus
)
{
char
*
conv
=
NULL
;
nodeInfo
->
cpus
=
l
;
unsigned
int
active
=
strtol
((
const
char
*
)
obj
->
stringval
,
&
conv
,
10
);
}
if
(
conv
==
(
const
char
*
)
obj
->
stringval
)
{
}
else
if
(
ret
==
-
2
)
{
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node active cpu"
));
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node active cpu"
));
goto
error
;
goto
error
;
}
}
if
(
active
<
nodeInfo
->
cpus
)
{
ret
=
virXPathLong
(
"string(/node/cpu/mhz[1])"
,
ctxt
,
&
l
);
nodeInfo
->
cpus
=
active
;
if
(
ret
==
0
)
{
}
nodeInfo
->
mhz
=
l
;
xmlXPathFreeObject
(
obj
);
}
else
if
(
ret
==
-
2
)
{
}
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node cpu mhz"
));
obj
=
xmlXPathEval
(
BAD_CAST
"string(/node/cpu/mhz[1])"
,
ctxt
);
goto
error
;
if
((
obj
!=
NULL
)
&&
(
obj
->
type
==
XPATH_STRING
)
&&
}
(
obj
->
stringval
!=
NULL
)
&&
(
obj
->
stringval
[
0
]
!=
0
))
{
char
*
conv
=
NULL
;
str
=
virXPathString
(
"string(/node/cpu/model[1])"
,
ctxt
);
nodeInfo
->
mhz
=
strtol
((
const
char
*
)
obj
->
stringval
,
&
conv
,
10
);
if
(
str
!=
NULL
)
{
if
(
conv
==
(
const
char
*
)
obj
->
stringval
)
{
strncpy
(
nodeInfo
->
model
,
str
,
sizeof
(
nodeInfo
->
model
)
-
1
);
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node cpu mhz"
));
goto
error
;
}
xmlXPathFreeObject
(
obj
);
}
obj
=
xmlXPathEval
(
BAD_CAST
"string(/node/cpu/model[1])"
,
ctxt
);
if
((
obj
!=
NULL
)
&&
(
obj
->
type
==
XPATH_STRING
)
&&
(
obj
->
stringval
!=
NULL
)
&&
(
obj
->
stringval
[
0
]
!=
0
))
{
strncpy
(
nodeInfo
->
model
,
(
const
char
*
)
obj
->
stringval
,
sizeof
(
nodeInfo
->
model
)
-
1
);
nodeInfo
->
model
[
sizeof
(
nodeInfo
->
model
)
-
1
]
=
'\0'
;
nodeInfo
->
model
[
sizeof
(
nodeInfo
->
model
)
-
1
]
=
'\0'
;
xmlXPathFreeObject
(
obj
);
free
(
str
);
}
}
obj
=
xmlXPathEval
(
BAD_CAST
"string(/node/memory[1])"
,
ctxt
);
ret
=
virXPathLong
(
"string(/node/memory[1])"
,
ctxt
,
&
l
);
if
((
obj
!=
NULL
)
&&
(
obj
->
type
==
XPATH_STRING
)
&&
if
(
ret
==
0
)
{
(
obj
->
stringval
!=
NULL
)
&&
(
obj
->
stringval
[
0
]
!=
0
))
{
nodeInfo
->
memory
=
l
;
char
*
conv
=
NULL
;
}
else
if
(
ret
==
-
2
)
{
nodeInfo
->
memory
=
strtol
((
const
char
*
)
obj
->
stringval
,
&
conv
,
10
);
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node memory"
));
if
(
conv
==
(
const
char
*
)
obj
->
stringval
)
{
goto
error
;
testError
(
conn
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node memory"
));
goto
error
;
}
xmlXPathFreeObject
(
obj
);
}
}
obj
=
xmlXPathEval
(
BAD_CAST
"/node/domain"
,
ctxt
);
ret
=
virXPathNodeSet
(
"/node/domain"
,
ctxt
,
&
domains
);
if
((
obj
==
NULL
)
||
(
obj
->
type
!=
XPATH_NODESET
)
||
if
(
ret
<
0
)
{
(
obj
->
nodesetval
==
NULL
))
{
testError
(
NULL
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node domain list"
));
testError
(
NULL
,
NULL
,
VIR_ERR_XML_ERROR
,
_
(
"node domain list"
));
goto
error
;
goto
error
;
}
}
for
(
i
=
0
;
i
<
obj
->
nodesetval
->
nodeNr
;
i
++
)
{
for
(
i
=
0
;
i
<
ret
;
i
++
)
{
xmlChar
*
domFile
=
xmlGetProp
(
obj
->
nodesetval
->
nodeTab
[
i
],
BAD_CAST
"file"
);
xmlChar
*
domFile
=
xmlGetProp
(
domains
[
i
],
BAD_CAST
"file"
);
char
*
absFile
=
testBuildFilename
(
file
,
(
const
char
*
)
domFile
);
char
*
absFile
=
testBuildFilename
(
file
,
(
const
char
*
)
domFile
);
int
domid
=
nextDomID
++
;
int
domid
=
nextDomID
++
;
free
(
domFile
);
free
(
domFile
);
...
@@ -695,8 +645,9 @@ static int testOpenFromFile(virConnectPtr conn,
...
@@ -695,8 +645,9 @@ static int testOpenFromFile(virConnectPtr conn,
free
(
absFile
);
free
(
absFile
);
node
->
connections
[
connid
].
numDomains
++
;
node
->
connections
[
connid
].
numDomains
++
;
}
}
if
(
domains
!=
NULL
)
free
(
domains
);
xmlXPathFreeObject
(
obj
);
xmlFreeDoc
(
xml
);
xmlFreeDoc
(
xml
);
return
(
0
);
return
(
0
);
...
@@ -709,8 +660,6 @@ static int testOpenFromFile(virConnectPtr conn,
...
@@ -709,8 +660,6 @@ static int testOpenFromFile(virConnectPtr conn,
node
->
connections
[
connid
].
numDomains
=
0
;
node
->
connections
[
connid
].
numDomains
=
0
;
node
->
connections
[
connid
].
active
=
0
;
node
->
connections
[
connid
].
active
=
0
;
}
}
if
(
obj
)
xmlXPathFreeObject
(
obj
);
if
(
xml
)
if
(
xml
)
xmlFreeDoc
(
xml
);
xmlFreeDoc
(
xml
);
if
(
fd
!=
-
1
)
if
(
fd
!=
-
1
)
...
...
src/xml.c
浏览文件 @
73dd7f0f
...
@@ -120,7 +120,8 @@ virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, double *value) {
...
@@ -120,7 +120,8 @@ virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, double *value) {
* Convenience function to evaluate an XPath number
* Convenience function to evaluate an XPath number
*
*
* Returns 0 in case of success in which case @value is set,
* Returns 0 in case of success in which case @value is set,
* or -1 if the evaluation failed.
* or -1 if the XPath evaluation failed or -2 if the
* value doesn't have a long format.
*/
*/
int
int
virXPathLong
(
const
char
*
xpath
,
xmlXPathContextPtr
ctxt
,
long
*
value
)
{
virXPathLong
(
const
char
*
xpath
,
xmlXPathContextPtr
ctxt
,
long
*
value
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录