Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
8d8815ea
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,发现更多精彩内容 >>
提交
8d8815ea
编写于
2月 24, 2010
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use common XML parsing functions
上级
26be7a0a
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
65 addition
and
477 deletion
+65
-477
src/conf/domain_conf.c
src/conf/domain_conf.c
+21
-109
src/conf/interface_conf.c
src/conf/interface_conf.c
+13
-80
src/conf/network_conf.c
src/conf/network_conf.c
+13
-80
src/conf/node_device_conf.c
src/conf/node_device_conf.c
+4
-56
src/conf/secret_conf.c
src/conf/secret_conf.c
+6
-50
src/conf/storage_conf.c
src/conf/storage_conf.c
+8
-102
未找到文件。
src/conf/domain_conf.c
浏览文件 @
8d8815ea
...
@@ -4168,99 +4168,35 @@ error:
...
@@ -4168,99 +4168,35 @@ error:
}
}
/* Called from SAX on parsing errors in the XML. */
static
virDomainDefPtr
static
void
virDomainDefParse
(
const
char
*
xmlStr
,
catchXMLError
(
void
*
ctx
,
const
char
*
msg
ATTRIBUTE_UNUSED
,
...)
const
char
*
filename
,
virCapsPtr
caps
,
int
flags
)
{
{
xmlParserCtxtPtr
ctxt
=
(
xmlParserCtxtPtr
)
ctx
;
xmlDocPtr
xml
;
virDomainDefPtr
def
=
NULL
;
if
(
ctxt
)
{
if
((
xml
=
virXMLParse
(
filename
,
xmlStr
,
"domain.xml"
)))
{
if
(
virGetLastError
()
==
NULL
&&
def
=
virDomainDefParseNode
(
caps
,
xml
,
xmlDocGetRootElement
(
xml
),
flags
);
ctxt
->
lastError
.
level
==
XML_ERR_FATAL
&&
xmlFreeDoc
(
xml
);
ctxt
->
lastError
.
message
!=
NULL
)
{
virDomainReportError
(
VIR_ERR_XML_DETAIL
,
_
(
"at line %d: %s"
),
ctxt
->
lastError
.
line
,
ctxt
->
lastError
.
message
);
}
}
}
return
def
;
}
}
virDomainDefPtr
virDomainDefParseString
(
virCapsPtr
caps
,
virDomainDefPtr
virDomainDefParseString
(
virCapsPtr
caps
,
const
char
*
xmlStr
,
const
char
*
xmlStr
,
int
flags
)
int
flags
)
{
{
xmlParserCtxtPtr
pctxt
;
return
virDomainDefParse
(
xmlStr
,
NULL
,
caps
,
flags
);
xmlDocPtr
xml
=
NULL
;
xmlNodePtr
root
;
virDomainDefPtr
def
=
NULL
;
/* Set up a parser context so we can catch the details of XML errors. */
pctxt
=
xmlNewParserCtxt
();
if
(
!
pctxt
||
!
pctxt
->
sax
)
goto
cleanup
;
pctxt
->
sax
->
error
=
catchXMLError
;
xml
=
xmlCtxtReadDoc
(
pctxt
,
BAD_CAST
xmlStr
,
"domain.xml"
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
if
(
!
xml
)
{
if
(
virGetLastError
()
==
NULL
)
virDomainReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"failed to parse xml document"
));
goto
cleanup
;
}
if
((
root
=
xmlDocGetRootElement
(
xml
))
==
NULL
)
{
virDomainReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing root element"
));
goto
cleanup
;
}
def
=
virDomainDefParseNode
(
caps
,
xml
,
root
,
flags
);
cleanup:
xmlFreeParserCtxt
(
pctxt
);
xmlFreeDoc
(
xml
);
return
def
;
}
}
virDomainDefPtr
virDomainDefParseFile
(
virCapsPtr
caps
,
virDomainDefPtr
virDomainDefParseFile
(
virCapsPtr
caps
,
const
char
*
filename
,
int
flags
)
const
char
*
filename
,
int
flags
)
{
{
xmlParserCtxtPtr
pctxt
;
return
virDomainDefParse
(
NULL
,
filename
,
caps
,
flags
);
xmlDocPtr
xml
=
NULL
;
xmlNodePtr
root
;
virDomainDefPtr
def
=
NULL
;
/* Set up a parser context so we can catch the details of XML errors. */
pctxt
=
xmlNewParserCtxt
();
if
(
!
pctxt
||
!
pctxt
->
sax
)
goto
cleanup
;
pctxt
->
sax
->
error
=
catchXMLError
;
xml
=
xmlCtxtReadFile
(
pctxt
,
filename
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
if
(
!
xml
)
{
if
(
virGetLastError
()
==
NULL
)
virDomainReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"failed to parse xml document"
));
goto
cleanup
;
}
if
((
root
=
xmlDocGetRootElement
(
xml
))
==
NULL
)
{
virDomainReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing root element"
));
goto
cleanup
;
}
def
=
virDomainDefParseNode
(
caps
,
xml
,
root
,
flags
);
cleanup:
xmlFreeParserCtxt
(
pctxt
);
xmlFreeDoc
(
xml
);
return
def
;
}
}
...
@@ -4296,38 +4232,14 @@ cleanup:
...
@@ -4296,38 +4232,14 @@ cleanup:
virDomainObjPtr
virDomainObjParseFile
(
virCapsPtr
caps
,
virDomainObjPtr
virDomainObjParseFile
(
virCapsPtr
caps
,
const
char
*
filename
)
const
char
*
filename
)
{
{
xmlParserCtxtPtr
pctxt
;
xmlDocPtr
xml
;
xmlDocPtr
xml
=
NULL
;
xmlNodePtr
root
;
virDomainObjPtr
obj
=
NULL
;
virDomainObjPtr
obj
=
NULL
;
/* Set up a parser context so we can catch the details of XML errors. */
if
((
xml
=
virXMLParseFile
(
filename
)))
{
pctxt
=
xmlNewParserCtxt
();
obj
=
virDomainObjParseNode
(
caps
,
xml
,
xmlDocGetRootElement
(
xml
));
if
(
!
pctxt
||
!
pctxt
->
sax
)
xmlFreeDoc
(
xml
);
goto
cleanup
;
pctxt
->
sax
->
error
=
catchXMLError
;
xml
=
xmlCtxtReadFile
(
pctxt
,
filename
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
if
(
!
xml
)
{
if
(
virGetLastError
()
==
NULL
)
virDomainReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"failed to parse xml document"
));
goto
cleanup
;
}
if
((
root
=
xmlDocGetRootElement
(
xml
))
==
NULL
)
{
virDomainReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing root element"
));
goto
cleanup
;
}
}
obj
=
virDomainObjParseNode
(
caps
,
xml
,
root
);
cleanup:
xmlFreeParserCtxt
(
pctxt
);
xmlFreeDoc
(
xml
);
return
obj
;
return
obj
;
}
}
...
...
src/conf/interface_conf.c
浏览文件 @
8d8815ea
...
@@ -851,96 +851,29 @@ cleanup:
...
@@ -851,96 +851,29 @@ cleanup:
return
def
;
return
def
;
}
}
/* Called from SAX on parsing errors in the XML. */
static
virInterfaceDefPtr
static
void
virInterfaceDefParse
(
const
char
*
xmlStr
,
catchXMLError
(
void
*
ctx
,
const
char
*
msg
ATTRIBUTE_UNUSED
,
...
)
const
char
*
filename
)
{
{
xmlParserCtxtPtr
ctxt
=
(
xmlParserCtxtPtr
)
ctx
;
xmlDocPtr
xml
;
virInterfaceDefPtr
def
=
NULL
;
if
(
ctxt
)
{
if
((
xml
=
virXMLParse
(
filename
,
xmlStr
,
"interface.xml"
)))
{
if
(
virGetLastError
()
==
NULL
&&
def
=
virInterfaceDefParseNode
(
xml
,
xmlDocGetRootElement
(
xml
));
ctxt
->
lastError
.
level
==
XML_ERR_FATAL
&&
xmlFreeDoc
(
xml
);
ctxt
->
lastError
.
message
!=
NULL
)
{
virInterfaceReportError
(
VIR_ERR_XML_DETAIL
,
_
(
"at line %d: %s"
),
ctxt
->
lastError
.
line
,
ctxt
->
lastError
.
message
);
}
}
}
return
def
;
}
}
virInterfaceDefPtr
virInterfaceDefParseString
(
const
char
*
xmlStr
)
virInterfaceDefPtr
virInterfaceDefParseString
(
const
char
*
xmlStr
)
{
{
xmlParserCtxtPtr
pctxt
;
return
virInterfaceDefParse
(
xmlStr
,
NULL
);
xmlDocPtr
xml
=
NULL
;
xmlNodePtr
root
;
virInterfaceDefPtr
def
=
NULL
;
/* Set up a parser context so we can catch the details of XML errors. */
pctxt
=
xmlNewParserCtxt
();
if
(
!
pctxt
||
!
pctxt
->
sax
)
goto
cleanup
;
pctxt
->
sax
->
error
=
catchXMLError
;
xml
=
xmlCtxtReadDoc
(
pctxt
,
BAD_CAST
xmlStr
,
"interface.xml"
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
if
(
!
xml
)
{
if
(
virGetLastError
()
==
NULL
)
virInterfaceReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"failed to parse xml document"
));
goto
cleanup
;
}
if
((
root
=
xmlDocGetRootElement
(
xml
))
==
NULL
)
{
virInterfaceReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing root element"
));
goto
cleanup
;
}
def
=
virInterfaceDefParseNode
(
xml
,
root
);
cleanup:
xmlFreeParserCtxt
(
pctxt
);
xmlFreeDoc
(
xml
);
return
def
;
}
}
virInterfaceDefPtr
virInterfaceDefParseFile
(
const
char
*
filename
)
virInterfaceDefPtr
virInterfaceDefParseFile
(
const
char
*
filename
)
{
{
xmlParserCtxtPtr
pctxt
;
return
virInterfaceDefParse
(
NULL
,
filename
);
xmlDocPtr
xml
=
NULL
;
xmlNodePtr
root
;
virInterfaceDefPtr
def
=
NULL
;
/* Set up a parser context so we can catch the details of XML errors. */
pctxt
=
xmlNewParserCtxt
();
if
(
!
pctxt
||
!
pctxt
->
sax
)
goto
cleanup
;
pctxt
->
sax
->
error
=
catchXMLError
;
xml
=
xmlCtxtReadFile
(
pctxt
,
filename
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
if
(
!
xml
)
{
if
(
virGetLastError
()
==
NULL
)
virInterfaceReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"failed to parse xml document"
));
goto
cleanup
;
}
if
((
root
=
xmlDocGetRootElement
(
xml
))
==
NULL
)
{
virInterfaceReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing root element"
));
goto
cleanup
;
}
def
=
virInterfaceDefParseNode
(
xml
,
root
);
cleanup:
xmlFreeParserCtxt
(
pctxt
);
xmlFreeDoc
(
xml
);
return
def
;
}
}
static
int
static
int
...
...
src/conf/network_conf.c
浏览文件 @
8d8815ea
...
@@ -504,96 +504,29 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
...
@@ -504,96 +504,29 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
return
NULL
;
return
NULL
;
}
}
/* Called from SAX on parsing errors in the XML. */
static
virNetworkDefPtr
static
void
virNetworkDefParse
(
const
char
*
xmlStr
,
catchXMLError
(
void
*
ctx
,
const
char
*
msg
ATTRIBUTE_UNUSED
,
...
)
const
char
*
filename
)
{
{
xmlParserCtxtPtr
ctxt
=
(
xmlParserCtxtPtr
)
ctx
;
xmlDocPtr
xml
;
virNetworkDefPtr
def
=
NULL
;
if
(
ctxt
)
{
if
((
xml
=
virXMLParse
(
filename
,
xmlStr
,
"network.xml"
)))
{
if
(
virGetLastError
()
==
NULL
&&
def
=
virNetworkDefParseNode
(
xml
,
xmlDocGetRootElement
(
xml
));
ctxt
->
lastError
.
level
==
XML_ERR_FATAL
&&
xmlFreeDoc
(
xml
);
ctxt
->
lastError
.
message
!=
NULL
)
{
virNetworkReportError
(
VIR_ERR_XML_DETAIL
,
_
(
"at line %d: %s"
),
ctxt
->
lastError
.
line
,
ctxt
->
lastError
.
message
);
}
}
}
return
def
;
}
}
virNetworkDefPtr
virNetworkDefParseString
(
const
char
*
xmlStr
)
virNetworkDefPtr
virNetworkDefParseString
(
const
char
*
xmlStr
)
{
{
xmlParserCtxtPtr
pctxt
;
return
virNetworkDefParse
(
xmlStr
,
NULL
);
xmlDocPtr
xml
=
NULL
;
xmlNodePtr
root
;
virNetworkDefPtr
def
=
NULL
;
/* Set up a parser context so we can catch the details of XML errors. */
pctxt
=
xmlNewParserCtxt
();
if
(
!
pctxt
||
!
pctxt
->
sax
)
goto
cleanup
;
pctxt
->
sax
->
error
=
catchXMLError
;
xml
=
xmlCtxtReadDoc
(
pctxt
,
BAD_CAST
xmlStr
,
"network.xml"
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
if
(
!
xml
)
{
if
(
virGetLastError
()
==
NULL
)
virNetworkReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"failed to parse xml document"
));
goto
cleanup
;
}
if
((
root
=
xmlDocGetRootElement
(
xml
))
==
NULL
)
{
virNetworkReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing root element"
));
goto
cleanup
;
}
def
=
virNetworkDefParseNode
(
xml
,
root
);
cleanup:
xmlFreeParserCtxt
(
pctxt
);
xmlFreeDoc
(
xml
);
return
def
;
}
}
virNetworkDefPtr
virNetworkDefParseFile
(
const
char
*
filename
)
virNetworkDefPtr
virNetworkDefParseFile
(
const
char
*
filename
)
{
{
xmlParserCtxtPtr
pctxt
;
return
virNetworkDefParse
(
NULL
,
filename
);
xmlDocPtr
xml
=
NULL
;
xmlNodePtr
root
;
virNetworkDefPtr
def
=
NULL
;
/* Set up a parser context so we can catch the details of XML errors. */
pctxt
=
xmlNewParserCtxt
();
if
(
!
pctxt
||
!
pctxt
->
sax
)
goto
cleanup
;
pctxt
->
sax
->
error
=
catchXMLError
;
xml
=
xmlCtxtReadFile
(
pctxt
,
filename
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
if
(
!
xml
)
{
if
(
virGetLastError
()
==
NULL
)
virNetworkReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"failed to parse xml document"
));
goto
cleanup
;
}
if
((
root
=
xmlDocGetRootElement
(
xml
))
==
NULL
)
{
virNetworkReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing root element"
));
goto
cleanup
;
}
def
=
virNetworkDefParseNode
(
xml
,
root
);
cleanup:
xmlFreeParserCtxt
(
pctxt
);
xmlFreeDoc
(
xml
);
return
def
;
}
}
...
...
src/conf/node_device_conf.c
浏览文件 @
8d8815ea
...
@@ -1224,71 +1224,19 @@ cleanup:
...
@@ -1224,71 +1224,19 @@ cleanup:
return
def
;
return
def
;
}
}
/* Called from SAX on parsing errors in the XML. */
static
void
catchXMLError
(
void
*
ctx
,
const
char
*
msg
ATTRIBUTE_UNUSED
,
...)
{
xmlParserCtxtPtr
ctxt
=
(
xmlParserCtxtPtr
)
ctx
;
if
(
ctxt
)
{
if
(
virGetLastError
()
==
NULL
&&
ctxt
->
lastError
.
level
==
XML_ERR_FATAL
&&
ctxt
->
lastError
.
message
!=
NULL
)
{
virNodeDeviceReportError
(
VIR_ERR_XML_DETAIL
,
_
(
"at line %d: %s"
),
ctxt
->
lastError
.
line
,
ctxt
->
lastError
.
message
);
}
}
}
static
virNodeDeviceDefPtr
static
virNodeDeviceDefPtr
virNodeDeviceDefParse
(
const
char
*
str
,
virNodeDeviceDefParse
(
const
char
*
str
,
const
char
*
filename
,
const
char
*
filename
,
int
create
)
int
create
)
{
{
xmlParserCtxtPtr
pctxt
;
xmlDocPtr
xml
;
xmlDocPtr
xml
=
NULL
;
xmlNodePtr
root
;
virNodeDeviceDefPtr
def
=
NULL
;
virNodeDeviceDefPtr
def
=
NULL
;
/* Set up a parser context so we can catch the details of XML errors. */
if
((
xml
=
virXMLParse
(
filename
,
str
,
"device.xml"
)))
{
pctxt
=
xmlNewParserCtxt
();
def
=
virNodeDeviceDefParseNode
(
xml
,
xmlDocGetRootElement
(
xml
),
create
);
if
(
!
pctxt
||
!
pctxt
->
sax
)
xmlFreeDoc
(
xml
);
goto
cleanup
;
pctxt
->
sax
->
error
=
catchXMLError
;
if
(
filename
)
{
xml
=
xmlCtxtReadFile
(
pctxt
,
filename
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
}
else
{
xml
=
xmlCtxtReadDoc
(
pctxt
,
BAD_CAST
str
,
"device.xml"
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
}
if
(
!
xml
)
{
if
(
virGetLastError
()
==
NULL
)
virNodeDeviceReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"failed to parse xml document"
));
goto
cleanup
;
}
if
((
root
=
xmlDocGetRootElement
(
xml
))
==
NULL
)
{
virNodeDeviceReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing root element"
));
goto
cleanup
;
}
}
def
=
virNodeDeviceDefParseNode
(
xml
,
root
,
create
);
cleanup:
xmlFreeParserCtxt
(
pctxt
);
xmlFreeDoc
(
xml
);
return
def
;
return
def
;
}
}
...
...
src/conf/secret_conf.c
浏览文件 @
8d8815ea
...
@@ -187,62 +187,18 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root)
...
@@ -187,62 +187,18 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root)
return
ret
;
return
ret
;
}
}
/* Called from SAX on parsing errors in the XML. */
static
void
catchXMLError
(
void
*
ctx
,
const
char
*
msg
ATTRIBUTE_UNUSED
,
...)
{
xmlParserCtxtPtr
ctxt
=
(
xmlParserCtxtPtr
)
ctx
;
if
(
ctxt
)
{
if
(
virGetLastError
()
==
NULL
&&
ctxt
->
lastError
.
level
==
XML_ERR_FATAL
&&
ctxt
->
lastError
.
message
!=
NULL
)
{
virSecretReportError
(
VIR_ERR_XML_DETAIL
,
_
(
"at line %d: %s"
),
ctxt
->
lastError
.
line
,
ctxt
->
lastError
.
message
);
}
}
}
static
virSecretDefPtr
static
virSecretDefPtr
virSecretDefParse
(
const
char
*
xmlStr
,
const
char
*
filename
)
virSecretDefParse
(
const
char
*
xmlStr
,
const
char
*
filename
)
{
{
xmlParserCtxtPtr
pctxt
;
xmlDocPtr
xml
;
xmlDocPtr
xml
=
NULL
;
xmlNodePtr
root
;
virSecretDefPtr
ret
=
NULL
;
virSecretDefPtr
ret
=
NULL
;
pctxt
=
xmlNewParserCtxt
();
if
((
xml
=
virXMLParse
(
filename
,
xmlStr
,
"secret.xml"
)))
{
if
(
pctxt
==
NULL
||
pctxt
->
sax
==
NULL
)
ret
=
secretXMLParseNode
(
xml
,
xmlDocGetRootElement
(
xml
));
goto
cleanup
;
xmlFreeDoc
(
xml
);
pctxt
->
sax
->
error
=
catchXMLError
;
if
(
filename
!=
NULL
)
xml
=
xmlCtxtReadFile
(
pctxt
,
filename
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
else
xml
=
xmlCtxtReadDoc
(
pctxt
,
BAD_CAST
xmlStr
,
"secret.xml"
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
if
(
xml
==
NULL
)
{
if
(
virGetLastError
()
==
NULL
)
virSecretReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"failed to parse xml document"
));
goto
cleanup
;
}
root
=
xmlDocGetRootElement
(
xml
);
if
(
root
==
NULL
)
{
virSecretReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing root element"
));
goto
cleanup
;
}
}
ret
=
secretXMLParseNode
(
xml
,
root
);
cleanup:
xmlFreeDoc
(
xml
);
xmlFreeParserCtxt
(
pctxt
);
return
ret
;
return
ret
;
}
}
...
...
src/conf/storage_conf.c
浏览文件 @
8d8815ea
...
@@ -717,24 +717,6 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) {
...
@@ -717,24 +717,6 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) {
return
NULL
;
return
NULL
;
}
}
/* Called from SAX on parsing errors in the XML. */
static
void
catchXMLError
(
void
*
ctx
,
const
char
*
msg
ATTRIBUTE_UNUSED
,
...)
{
xmlParserCtxtPtr
ctxt
=
(
xmlParserCtxtPtr
)
ctx
;
if
(
ctxt
)
{
if
(
virGetLastError
()
==
NULL
&&
ctxt
->
lastError
.
level
==
XML_ERR_FATAL
&&
ctxt
->
lastError
.
message
!=
NULL
)
{
virStorageReportError
(
VIR_ERR_XML_DETAIL
,
_
(
"at line %d: %s"
),
ctxt
->
lastError
.
line
,
ctxt
->
lastError
.
message
);
}
}
}
virStoragePoolDefPtr
virStoragePoolDefPtr
virStoragePoolDefParseNode
(
xmlDocPtr
xml
,
virStoragePoolDefParseNode
(
xmlDocPtr
xml
,
xmlNodePtr
root
)
{
xmlNodePtr
root
)
{
...
@@ -764,52 +746,14 @@ static virStoragePoolDefPtr
...
@@ -764,52 +746,14 @@ static virStoragePoolDefPtr
virStoragePoolDefParse
(
const
char
*
xmlStr
,
virStoragePoolDefParse
(
const
char
*
xmlStr
,
const
char
*
filename
)
{
const
char
*
filename
)
{
virStoragePoolDefPtr
ret
=
NULL
;
virStoragePoolDefPtr
ret
=
NULL
;
xmlParserCtxtPtr
pctxt
;
xmlDocPtr
xml
;
xmlDocPtr
xml
=
NULL
;
xmlNodePtr
node
=
NULL
;
/* Set up a parser context so we can catch the details of XML errors. */
pctxt
=
xmlNewParserCtxt
();
if
(
!
pctxt
||
!
pctxt
->
sax
)
goto
cleanup
;
pctxt
->
sax
->
error
=
catchXMLError
;
if
(
filename
)
{
xml
=
xmlCtxtReadFile
(
pctxt
,
filename
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
}
else
{
xml
=
xmlCtxtReadDoc
(
pctxt
,
BAD_CAST
xmlStr
,
"storage.xml"
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
}
if
(
!
xml
)
{
if
((
xml
=
virXMLParse
(
filename
,
xmlStr
,
"storage.xml"
)))
{
if
(
virGetLastError
()
==
NULL
)
ret
=
virStoragePoolDefParseNode
(
xml
,
xmlDocGetRootElement
(
xml
));
virStorageReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"failed to parse xml document"
));
goto
cleanup
;
}
node
=
xmlDocGetRootElement
(
xml
);
if
(
node
==
NULL
)
{
virStorageReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"missing root element"
));
goto
cleanup
;
}
ret
=
virStoragePoolDefParseNode
(
xml
,
node
);
xmlFreeParserCtxt
(
pctxt
);
xmlFreeDoc
(
xml
);
xmlFreeDoc
(
xml
);
}
return
ret
;
return
ret
;
cleanup:
xmlFreeParserCtxt
(
pctxt
);
xmlFreeDoc
(
xml
);
return
NULL
;
}
}
virStoragePoolDefPtr
virStoragePoolDefPtr
...
@@ -1163,52 +1107,14 @@ virStorageVolDefParse(virStoragePoolDefPtr pool,
...
@@ -1163,52 +1107,14 @@ virStorageVolDefParse(virStoragePoolDefPtr pool,
const
char
*
xmlStr
,
const
char
*
xmlStr
,
const
char
*
filename
)
{
const
char
*
filename
)
{
virStorageVolDefPtr
ret
=
NULL
;
virStorageVolDefPtr
ret
=
NULL
;
xmlParserCtxtPtr
pctxt
;
xmlDocPtr
xml
;
xmlDocPtr
xml
=
NULL
;
xmlNodePtr
node
=
NULL
;
/* Set up a parser context so we can catch the details of XML errors. */
pctxt
=
xmlNewParserCtxt
();
if
(
!
pctxt
||
!
pctxt
->
sax
)
goto
cleanup
;
pctxt
->
sax
->
error
=
catchXMLError
;
if
(
filename
)
{
xml
=
xmlCtxtReadFile
(
pctxt
,
filename
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
}
else
{
xml
=
xmlCtxtReadDoc
(
pctxt
,
BAD_CAST
xmlStr
,
"storage.xml"
,
NULL
,
XML_PARSE_NOENT
|
XML_PARSE_NONET
|
XML_PARSE_NOWARNING
);
}
if
(
!
xml
)
{
if
(
virGetLastError
()
==
NULL
)
virStorageReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"failed to parse xml document"
));
goto
cleanup
;
}
node
=
xmlDocGetRootElement
(
xml
);
if
(
node
==
NULL
)
{
virStorageReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"missing root element"
));
goto
cleanup
;
}
ret
=
virStorageVolDefParseNode
(
pool
,
xml
,
node
);
if
((
xml
=
virXMLParse
(
filename
,
xmlStr
,
"storage.xml"
)))
{
ret
=
virStorageVolDefParseNode
(
pool
,
xml
,
xmlDocGetRootElement
(
xml
));
xmlFreeParserCtxt
(
pctxt
);
xmlFreeDoc
(
xml
);
xmlFreeDoc
(
xml
);
}
return
ret
;
return
ret
;
cleanup:
xmlFreeParserCtxt
(
pctxt
);
xmlFreeDoc
(
xml
);
return
NULL
;
}
}
virStorageVolDefPtr
virStorageVolDefPtr
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录