提交 7165bef1 编写于 作者: C Cole Robinson

node conf: Make parsing routines consistent with other drivers

Add virNodeDeviceParseFile, and make virNodeDeviceParseNode non-static. These
will be used by the test driver.
Signed-off-by: NCole Robinson <crobinso@redhat.com>
上级 2eb9301b
......@@ -1097,8 +1097,11 @@ virNodeDeviceDefParseXML(virConnectPtr conn, xmlXPathContextPtr ctxt, int create
return NULL;
}
static virNodeDeviceDefPtr
virNodeDeviceDefParseNode(virConnectPtr conn, xmlDocPtr xml, xmlNodePtr root, int create)
virNodeDeviceDefPtr
virNodeDeviceDefParseNode(virConnectPtr conn,
xmlDocPtr xml,
xmlNodePtr root,
int create)
{
xmlXPathContextPtr ctxt = NULL;
virNodeDeviceDefPtr def = NULL;
......@@ -1143,8 +1146,13 @@ catchXMLError(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
}
}
virNodeDeviceDefPtr
virNodeDeviceDefParseString(virConnectPtr conn, const char *str, int create)
static virNodeDeviceDefPtr
virNodeDeviceDefParse(virConnectPtr conn,
const char *str,
const char *filename,
int create)
{
xmlParserCtxtPtr pctxt;
xmlDocPtr xml = NULL;
......@@ -1159,9 +1167,17 @@ virNodeDeviceDefParseString(virConnectPtr conn, const char *str, int create)
pctxt->_private = conn;
if (conn) virResetError (&conn->err);
xml = xmlCtxtReadDoc(pctxt, BAD_CAST str, "device.xml", NULL,
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOWARNING);
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 (conn && conn->err.code == VIR_ERR_NONE)
virNodeDeviceReportError(conn, VIR_ERR_XML_ERROR,
......@@ -1183,6 +1199,23 @@ cleanup:
return def;
}
virNodeDeviceDefPtr
virNodeDeviceDefParseString(virConnectPtr conn,
const char *str,
int create)
{
return virNodeDeviceDefParse(conn, str, NULL, create);
}
virNodeDeviceDefPtr
virNodeDeviceDefParseFile(virConnectPtr conn,
const char *filename,
int create)
{
return virNodeDeviceDefParse(conn, NULL, filename, create);
}
void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
{
union _virNodeDevCapData *data = &caps->data;
......
......@@ -28,6 +28,8 @@
#include "util.h"
#include "threads.h"
#include <libxml/tree.h>
#define CREATE_DEVICE 1
#define EXISTING_DEVICE 0
......@@ -211,6 +213,13 @@ char *virNodeDeviceDefFormat(virConnectPtr conn,
virNodeDeviceDefPtr virNodeDeviceDefParseString(virConnectPtr conn,
const char *str,
int create);
virNodeDeviceDefPtr virNodeDeviceDefParseFile(virConnectPtr conn,
const char *filename,
int create);
virNodeDeviceDefPtr virNodeDeviceDefParseNode(virConnectPtr conn,
xmlDocPtr xml,
xmlNodePtr root,
int create);
void virNodeDeviceDefFree(virNodeDeviceDefPtr def);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册