mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-13 11:15:08 +00:00
* src/xml.c: applied patch from Jim Meyering fixing parseNumber
to detect overflow, and also reindented the module. Daniel
This commit is contained in:
parent
de327d23e7
commit
211a20aefb
@ -1,3 +1,8 @@
|
|||||||
|
Wed Oct 24 16:21:02 CEST 2007 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
|
* src/xml.c: applied patch from Jim Meyering fixing parseNumber
|
||||||
|
to detect overflow, and also reindented the module.
|
||||||
|
|
||||||
Wed Oct 24 10:38:38 CEST 2007 Daniel Veillard <veillard@redhat.com>
|
Wed Oct 24 10:38:38 CEST 2007 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* po/id.po: Remove again bogus Project-Id-Version field from merge error
|
* po/id.po: Remove again bogus Project-Id-Version field from merge error
|
||||||
|
238
src/xml.c
238
src/xml.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* xml.c: XML based interfaces for the libvir library
|
* xml.c: XML based interfaces for the libvir library
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005 Red Hat, Inc.
|
* Copyright (C) 2005, 2007 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* See COPYING.LIB for the License of this software
|
* See COPYING.LIB for the License of this software
|
||||||
*
|
*
|
||||||
@ -36,7 +36,8 @@
|
|||||||
* Report an error coming from the XML module.
|
* Report an error coming from the XML module.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
virXMLError(virConnectPtr conn, virErrorNumber error, const char *info, int value)
|
virXMLError(virConnectPtr conn, virErrorNumber error, const char *info,
|
||||||
|
int value)
|
||||||
{
|
{
|
||||||
const char *errmsg;
|
const char *errmsg;
|
||||||
|
|
||||||
@ -63,11 +64,13 @@ virXMLError(virConnectPtr conn, virErrorNumber error, const char *info, int valu
|
|||||||
* by xend
|
* by xend
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
skipSpaces(const char **str) {
|
skipSpaces(const char **str)
|
||||||
|
{
|
||||||
const char *cur = *str;
|
const char *cur = *str;
|
||||||
|
|
||||||
while ((*cur == ' ') || (*cur == '\t') || (*cur == '\n') ||
|
while ((*cur == ' ') || (*cur == '\t') || (*cur == '\n') ||
|
||||||
(*cur == '\r') || (*cur == '\\')) cur++;
|
(*cur == '\r') || (*cur == '\\'))
|
||||||
|
cur++;
|
||||||
*str = cur;
|
*str = cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,13 +78,14 @@ skipSpaces(const char **str) {
|
|||||||
* parseNumber:
|
* parseNumber:
|
||||||
* @str: pointer to the char pointer used
|
* @str: pointer to the char pointer used
|
||||||
*
|
*
|
||||||
* Parse a number
|
* Parse an unsigned number
|
||||||
*
|
*
|
||||||
* Returns the CPU number or -1 in case of error. @str will be
|
* Returns the unsigned number or -1 in case of error. @str will be
|
||||||
* updated to skip the number.
|
* updated to skip the number.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
parseNumber(const char **str) {
|
parseNumber(const char **str)
|
||||||
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
const char *cur = *str;
|
const char *cur = *str;
|
||||||
|
|
||||||
@ -89,7 +93,12 @@ parseNumber(const char **str) {
|
|||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
while ((*cur >= '0') && (*cur <= '9')) {
|
while ((*cur >= '0') && (*cur <= '9')) {
|
||||||
ret = ret * 10 + (*cur - '0');
|
unsigned int c = *cur - '0';
|
||||||
|
|
||||||
|
if ((ret > INT_MAX / 10) ||
|
||||||
|
((ret == INT_MAX / 10) && (c > INT_MAX % 10)))
|
||||||
|
return (-1);
|
||||||
|
ret = ret * 10 + c;
|
||||||
cur++;
|
cur++;
|
||||||
}
|
}
|
||||||
*str = cur;
|
*str = cur;
|
||||||
@ -107,7 +116,8 @@ parseNumber(const char **str) {
|
|||||||
* updated to skip the number.
|
* updated to skip the number.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
parseCpuNumber(const char **str, int maxcpu) {
|
parseCpuNumber(const char **str, int maxcpu)
|
||||||
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
const char *cur = *str;
|
const char *cur = *str;
|
||||||
|
|
||||||
@ -202,15 +212,16 @@ saveCpuSet(virConnectPtr conn, char *cpuset, int maxcpu)
|
|||||||
* @str is updated to the end of the part parsed
|
* @str is updated to the end of the part parsed
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virParseCpuSet(virConnectPtr conn, const char **str, char sep, char *cpuset,
|
virParseCpuSet(virConnectPtr conn, const char **str, char sep,
|
||||||
int maxcpu)
|
char *cpuset, int maxcpu)
|
||||||
{
|
{
|
||||||
const char *cur;
|
const char *cur;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int i, start, last;
|
int i, start, last;
|
||||||
int neg = 0;
|
int neg = 0;
|
||||||
|
|
||||||
if ((str == NULL) || (cpuset == NULL) || (maxcpu <= 0) || (maxcpu >100000))
|
if ((str == NULL) || (cpuset == NULL) || (maxcpu <= 0) ||
|
||||||
|
(maxcpu > 100000))
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
cur = *str;
|
cur = *str;
|
||||||
@ -299,8 +310,8 @@ parse_error:
|
|||||||
* Returns 0 in case of success, -1 in case of error
|
* Returns 0 in case of success, -1 in case of error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virParseXenCpuTopology(virConnectPtr conn, virBufferPtr xml, const char *str,
|
virParseXenCpuTopology(virConnectPtr conn, virBufferPtr xml,
|
||||||
int maxcpu)
|
const char *str, int maxcpu)
|
||||||
{
|
{
|
||||||
const char *cur;
|
const char *cur;
|
||||||
char *cpuset = NULL;
|
char *cpuset = NULL;
|
||||||
@ -353,7 +364,8 @@ virParseXenCpuTopology(virConnectPtr conn, virBufferPtr xml, const char *str,
|
|||||||
|
|
||||||
dump = saveCpuSet(conn, cpuset, maxcpu);
|
dump = saveCpuSet(conn, cpuset, maxcpu);
|
||||||
if (dump != NULL) {
|
if (dump != NULL) {
|
||||||
virBufferVSprintf (xml, " <dump>%s</dump>\n", dump);
|
virBufferVSprintf(xml, " <dump>%s</dump>\n",
|
||||||
|
dump);
|
||||||
free(dump);
|
free(dump);
|
||||||
} else {
|
} else {
|
||||||
virBufferVSprintf(xml, " <error>%s</error>\n",
|
virBufferVSprintf(xml, " <error>%s</error>\n",
|
||||||
@ -382,8 +394,7 @@ virParseXenCpuTopology(virConnectPtr conn, virBufferPtr xml, const char *str,
|
|||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
parse_error:
|
parse_error:
|
||||||
virXMLError(conn, VIR_ERR_XEN_CALL,
|
virXMLError(conn, VIR_ERR_XEN_CALL, _("topology syntax error"), 0);
|
||||||
_("topology syntax error"), 0);
|
|
||||||
error:
|
error:
|
||||||
if (cpuset != NULL)
|
if (cpuset != NULL)
|
||||||
free(cpuset);
|
free(cpuset);
|
||||||
@ -416,7 +427,8 @@ memory_error:
|
|||||||
* if the evaluation failed.
|
* if the evaluation failed.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
virXPathString(const char *xpath, xmlXPathContextPtr ctxt) {
|
virXPathString(const char *xpath, xmlXPathContextPtr ctxt)
|
||||||
|
{
|
||||||
xmlXPathObjectPtr obj;
|
xmlXPathObjectPtr obj;
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
@ -452,7 +464,8 @@ virXPathString(const char *xpath, xmlXPathContextPtr ctxt) {
|
|||||||
* or -1 if the evaluation failed.
|
* or -1 if the evaluation failed.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, double *value) {
|
virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, double *value)
|
||||||
|
{
|
||||||
xmlXPathObjectPtr obj;
|
xmlXPathObjectPtr obj;
|
||||||
|
|
||||||
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
|
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
|
||||||
@ -485,7 +498,8 @@ virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, double *value) {
|
|||||||
* value doesn't have a long format.
|
* 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)
|
||||||
|
{
|
||||||
xmlXPathObjectPtr obj;
|
xmlXPathObjectPtr obj;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -530,7 +544,8 @@ virXPathLong(const char *xpath, xmlXPathContextPtr ctxt, long *value) {
|
|||||||
* Returns 0 if false, 1 if true, or -1 if the evaluation failed.
|
* Returns 0 if false, 1 if true, or -1 if the evaluation failed.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virXPathBoolean(const char *xpath, xmlXPathContextPtr ctxt) {
|
virXPathBoolean(const char *xpath, xmlXPathContextPtr ctxt)
|
||||||
|
{
|
||||||
xmlXPathObjectPtr obj;
|
xmlXPathObjectPtr obj;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -562,7 +577,8 @@ virXPathBoolean(const char *xpath, xmlXPathContextPtr ctxt) {
|
|||||||
* Returns a pointer to the node or NULL if the evaluation failed.
|
* Returns a pointer to the node or NULL if the evaluation failed.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr
|
xmlNodePtr
|
||||||
virXPathNode(const char *xpath, xmlXPathContextPtr ctxt) {
|
virXPathNode(const char *xpath, xmlXPathContextPtr ctxt)
|
||||||
|
{
|
||||||
xmlXPathObjectPtr obj;
|
xmlXPathObjectPtr obj;
|
||||||
xmlNodePtr ret;
|
xmlNodePtr ret;
|
||||||
|
|
||||||
@ -583,6 +599,7 @@ virXPathNode(const char *xpath, xmlXPathContextPtr ctxt) {
|
|||||||
xmlXPathFreeObject(obj);
|
xmlXPathFreeObject(obj);
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virXPathNodeSet:
|
* virXPathNodeSet:
|
||||||
* @xpath: the XPath string to evaluate
|
* @xpath: the XPath string to evaluate
|
||||||
@ -595,7 +612,9 @@ virXPathNode(const char *xpath, xmlXPathContextPtr ctxt) {
|
|||||||
* must be freed) or -1 if the evaluation failed.
|
* must be freed) or -1 if the evaluation failed.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt, xmlNodePtr **list) {
|
virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt,
|
||||||
|
xmlNodePtr ** list)
|
||||||
|
{
|
||||||
xmlXPathObjectPtr obj;
|
xmlXPathObjectPtr obj;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -619,9 +638,11 @@ virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt, xmlNodePtr **list) {
|
|||||||
*list = malloc(ret * sizeof(xmlNodePtr));
|
*list = malloc(ret * sizeof(xmlNodePtr));
|
||||||
if (*list == NULL) {
|
if (*list == NULL) {
|
||||||
virXMLError(NULL, VIR_ERR_NO_MEMORY,
|
virXMLError(NULL, VIR_ERR_NO_MEMORY,
|
||||||
_("allocate string array"), ret * sizeof(xmlNodePtr));
|
_("allocate string array"),
|
||||||
|
ret * sizeof(xmlNodePtr));
|
||||||
} else {
|
} else {
|
||||||
memcpy(*list, obj->nodesetval->nodeTab, ret * sizeof(xmlNodePtr));
|
memcpy(*list, obj->nodesetval->nodeTab,
|
||||||
|
ret * sizeof(xmlNodePtr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xmlXPathFreeObject(obj);
|
xmlXPathFreeObject(obj);
|
||||||
@ -648,7 +669,10 @@ virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt, xmlNodePtr **list) {
|
|||||||
*
|
*
|
||||||
* Returns 0 in case of success, -1 in case of error
|
* Returns 0 in case of success, -1 in case of error
|
||||||
*/
|
*/
|
||||||
static int virDomainParseXMLGraphicsDescImage(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, virBufferPtr buf, int xendConfigVersion)
|
static int
|
||||||
|
virDomainParseXMLGraphicsDescImage(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
|
xmlNodePtr node, virBufferPtr buf,
|
||||||
|
int xendConfigVersion)
|
||||||
{
|
{
|
||||||
xmlChar *graphics_type = NULL;
|
xmlChar *graphics_type = NULL;
|
||||||
|
|
||||||
@ -662,20 +686,22 @@ static int virDomainParseXMLGraphicsDescImage(virConnectPtr conn ATTRIBUTE_UNUSE
|
|||||||
*virBufferAdd(buf, "(display localhost:10.0)", 24);
|
*virBufferAdd(buf, "(display localhost:10.0)", 24);
|
||||||
*virBufferAdd(buf, "(xauthority /root/.Xauthority)", 30);
|
*virBufferAdd(buf, "(xauthority /root/.Xauthority)", 30);
|
||||||
*/
|
*/
|
||||||
}
|
} else if (xmlStrEqual(graphics_type, BAD_CAST "vnc")) {
|
||||||
else if (xmlStrEqual(graphics_type, BAD_CAST "vnc")) {
|
|
||||||
virBufferAdd(buf, "(vnc 1)", 7);
|
virBufferAdd(buf, "(vnc 1)", 7);
|
||||||
if (xendConfigVersion >= 2) {
|
if (xendConfigVersion >= 2) {
|
||||||
xmlChar *vncport = xmlGetProp(node, BAD_CAST "port");
|
xmlChar *vncport = xmlGetProp(node, BAD_CAST "port");
|
||||||
xmlChar *vnclisten = xmlGetProp(node, BAD_CAST "listen");
|
xmlChar *vnclisten = xmlGetProp(node, BAD_CAST "listen");
|
||||||
xmlChar *vncpasswd = xmlGetProp(node, BAD_CAST "passwd");
|
xmlChar *vncpasswd = xmlGetProp(node, BAD_CAST "passwd");
|
||||||
xmlChar *keymap = xmlGetProp(node, BAD_CAST "keymap");
|
xmlChar *keymap = xmlGetProp(node, BAD_CAST "keymap");
|
||||||
|
|
||||||
if (vncport != NULL) {
|
if (vncport != NULL) {
|
||||||
long port = strtol((const char *) vncport, NULL, 10);
|
long port = strtol((const char *) vncport, NULL, 10);
|
||||||
|
|
||||||
if (port == -1)
|
if (port == -1)
|
||||||
virBufferAdd(buf, "(vncunused 1)", 13);
|
virBufferAdd(buf, "(vncunused 1)", 13);
|
||||||
else if (port >= 5900)
|
else if (port >= 5900)
|
||||||
virBufferVSprintf(buf, "(vncdisplay %ld)", port - 5900);
|
virBufferVSprintf(buf, "(vncdisplay %ld)",
|
||||||
|
port - 5900);
|
||||||
xmlFree(vncport);
|
xmlFree(vncport);
|
||||||
}
|
}
|
||||||
if (vnclisten != NULL) {
|
if (vnclisten != NULL) {
|
||||||
@ -711,7 +737,9 @@ static int virDomainParseXMLGraphicsDescImage(virConnectPtr conn ATTRIBUTE_UNUSE
|
|||||||
*
|
*
|
||||||
* Returns 0 in case of success, -1 in case of error
|
* Returns 0 in case of success, -1 in case of error
|
||||||
*/
|
*/
|
||||||
static int virDomainParseXMLGraphicsDescVFB(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, virBufferPtr buf)
|
static int
|
||||||
|
virDomainParseXMLGraphicsDescVFB(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
|
xmlNodePtr node, virBufferPtr buf)
|
||||||
{
|
{
|
||||||
xmlChar *graphics_type = NULL;
|
xmlChar *graphics_type = NULL;
|
||||||
|
|
||||||
@ -727,19 +755,21 @@ static int virDomainParseXMLGraphicsDescVFB(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
*virBufferAdd(buf, "(display localhost:10.0)", 24);
|
*virBufferAdd(buf, "(display localhost:10.0)", 24);
|
||||||
*virBufferAdd(buf, "(xauthority /root/.Xauthority)", 30);
|
*virBufferAdd(buf, "(xauthority /root/.Xauthority)", 30);
|
||||||
*/
|
*/
|
||||||
}
|
} else if (xmlStrEqual(graphics_type, BAD_CAST "vnc")) {
|
||||||
else if (xmlStrEqual(graphics_type, BAD_CAST "vnc")) {
|
|
||||||
virBufferAdd(buf, "(type vnc)", 10);
|
virBufferAdd(buf, "(type vnc)", 10);
|
||||||
xmlChar *vncport = xmlGetProp(node, BAD_CAST "port");
|
xmlChar *vncport = xmlGetProp(node, BAD_CAST "port");
|
||||||
xmlChar *vnclisten = xmlGetProp(node, BAD_CAST "listen");
|
xmlChar *vnclisten = xmlGetProp(node, BAD_CAST "listen");
|
||||||
xmlChar *vncpasswd = xmlGetProp(node, BAD_CAST "passwd");
|
xmlChar *vncpasswd = xmlGetProp(node, BAD_CAST "passwd");
|
||||||
xmlChar *keymap = xmlGetProp(node, BAD_CAST "keymap");
|
xmlChar *keymap = xmlGetProp(node, BAD_CAST "keymap");
|
||||||
|
|
||||||
if (vncport != NULL) {
|
if (vncport != NULL) {
|
||||||
long port = strtol((const char *) vncport, NULL, 10);
|
long port = strtol((const char *) vncport, NULL, 10);
|
||||||
|
|
||||||
if (port == -1)
|
if (port == -1)
|
||||||
virBufferAdd(buf, "(vncunused 1)", 13);
|
virBufferAdd(buf, "(vncunused 1)", 13);
|
||||||
else if (port >= 5900)
|
else if (port >= 5900)
|
||||||
virBufferVSprintf(buf, "(vncdisplay %ld)", port - 5900);
|
virBufferVSprintf(buf, "(vncdisplay %ld)",
|
||||||
|
port - 5900);
|
||||||
xmlFree(vncport);
|
xmlFree(vncport);
|
||||||
}
|
}
|
||||||
if (vnclisten != NULL) {
|
if (vnclisten != NULL) {
|
||||||
@ -779,7 +809,9 @@ static int virDomainParseXMLGraphicsDescVFB(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
* Returns 0 in case of success, -1 in case of error.
|
* Returns 0 in case of success, -1 in case of error.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr ctxt, int vcpus, int xendConfigVersion)
|
virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
|
||||||
|
virBufferPtr buf, xmlXPathContextPtr ctxt,
|
||||||
|
int vcpus, int xendConfigVersion)
|
||||||
{
|
{
|
||||||
xmlNodePtr cur, txt;
|
xmlNodePtr cur, txt;
|
||||||
xmlNodePtr *nodes = NULL;
|
xmlNodePtr *nodes = NULL;
|
||||||
@ -793,8 +825,8 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf
|
|||||||
cur = node->children;
|
cur = node->children;
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
if (cur->type == XML_ELEMENT_NODE) {
|
if (cur->type == XML_ELEMENT_NODE) {
|
||||||
if ((type == NULL)
|
if ((type == NULL) &&
|
||||||
&& (xmlStrEqual(cur->name, BAD_CAST "type"))) {
|
(xmlStrEqual(cur->name, BAD_CAST "type"))) {
|
||||||
txt = cur->children;
|
txt = cur->children;
|
||||||
if ((txt != NULL) && (txt->type == XML_TEXT_NODE) &&
|
if ((txt != NULL) && (txt->type == XML_TEXT_NODE) &&
|
||||||
(txt->next == NULL))
|
(txt->next == NULL))
|
||||||
@ -807,8 +839,11 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf
|
|||||||
loader = txt->content;
|
loader = txt->content;
|
||||||
} else if ((xmlStrEqual(cur->name, BAD_CAST "boot"))) {
|
} else if ((xmlStrEqual(cur->name, BAD_CAST "boot"))) {
|
||||||
xmlChar *boot_dev = xmlGetProp(cur, BAD_CAST "dev");
|
xmlChar *boot_dev = xmlGetProp(cur, BAD_CAST "dev");
|
||||||
if (nbootorder == ((sizeof(bootorder)/sizeof(bootorder[0]))-1)) {
|
|
||||||
virXMLError(conn, VIR_ERR_XML_ERROR, "too many boot devices", 0);
|
if (nbootorder ==
|
||||||
|
((sizeof(bootorder) / sizeof(bootorder[0])) - 1)) {
|
||||||
|
virXMLError(conn, VIR_ERR_XML_ERROR,
|
||||||
|
"too many boot devices", 0);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (xmlStrEqual(boot_dev, BAD_CAST "fd")) {
|
if (xmlStrEqual(boot_dev, BAD_CAST "fd")) {
|
||||||
@ -859,10 +894,12 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf
|
|||||||
virBufferVSprintf(buf, "(boot %s)", bootorder);
|
virBufferVSprintf(buf, "(boot %s)", bootorder);
|
||||||
|
|
||||||
/* get the 1st floppy device file */
|
/* get the 1st floppy device file */
|
||||||
cur = virXPathNode("/domain/devices/disk[@device='floppy' and target/@dev='fda']/source",
|
cur = virXPathNode(
|
||||||
|
"/domain/devices/disk[@device='floppy' and target/@dev='fda']/source",
|
||||||
ctxt);
|
ctxt);
|
||||||
if (cur != NULL) {
|
if (cur != NULL) {
|
||||||
xmlChar *fdfile;
|
xmlChar *fdfile;
|
||||||
|
|
||||||
fdfile = xmlGetProp(cur, BAD_CAST "file");
|
fdfile = xmlGetProp(cur, BAD_CAST "file");
|
||||||
if (fdfile != NULL) {
|
if (fdfile != NULL) {
|
||||||
virBufferVSprintf(buf, "(fda '%s')", fdfile);
|
virBufferVSprintf(buf, "(fda '%s')", fdfile);
|
||||||
@ -871,10 +908,12 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get the 2nd floppy device file */
|
/* get the 2nd floppy device file */
|
||||||
cur = virXPathNode("/domain/devices/disk[@device='floppy' and target/@dev='fdb']/source",
|
cur = virXPathNode(
|
||||||
|
"/domain/devices/disk[@device='floppy' and target/@dev='fdb']/source",
|
||||||
ctxt);
|
ctxt);
|
||||||
if (cur != NULL) {
|
if (cur != NULL) {
|
||||||
xmlChar *fdfile;
|
xmlChar *fdfile;
|
||||||
|
|
||||||
fdfile = xmlGetProp(cur, BAD_CAST "file");
|
fdfile = xmlGetProp(cur, BAD_CAST "file");
|
||||||
if (fdfile != NULL) {
|
if (fdfile != NULL) {
|
||||||
virBufferVSprintf(buf, "(fdb '%s')", fdfile);
|
virBufferVSprintf(buf, "(fdb '%s')", fdfile);
|
||||||
@ -886,7 +925,8 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf
|
|||||||
/* get the cdrom device file */
|
/* get the cdrom device file */
|
||||||
/* Only XenD <= 3.0.2 wants cdrom config here */
|
/* Only XenD <= 3.0.2 wants cdrom config here */
|
||||||
if (xendConfigVersion == 1) {
|
if (xendConfigVersion == 1) {
|
||||||
cur = virXPathNode("/domain/devices/disk[@device='cdrom' and target/@dev='hdc']/source",
|
cur = virXPathNode(
|
||||||
|
"/domain/devices/disk[@device='cdrom' and target/@dev='hdc']/source",
|
||||||
ctxt);
|
ctxt);
|
||||||
if (cur != NULL) {
|
if (cur != NULL) {
|
||||||
xmlChar *cdfile;
|
xmlChar *cdfile;
|
||||||
@ -911,6 +951,7 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf
|
|||||||
nb_nodes = virXPathNodeSet("/domain/devices/input", ctxt, &nodes);
|
nb_nodes = virXPathNodeSet("/domain/devices/input", ctxt, &nodes);
|
||||||
if (nb_nodes > 0) {
|
if (nb_nodes > 0) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_nodes; i++) {
|
for (i = 0; i < nb_nodes; i++) {
|
||||||
xmlChar *itype = NULL, *bus = NULL;
|
xmlChar *itype = NULL, *bus = NULL;
|
||||||
int isMouse = 1;
|
int isMouse = 1;
|
||||||
@ -1013,7 +1054,9 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf
|
|||||||
* Returns 0 in case of success, -1 in case of error.
|
* Returns 0 in case of success, -1 in case of error.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
virDomainParseXMLOSDescPV(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr ctxt, int xendConfigVersion)
|
virDomainParseXMLOSDescPV(virConnectPtr conn, xmlNodePtr node,
|
||||||
|
virBufferPtr buf, xmlXPathContextPtr ctxt,
|
||||||
|
int xendConfigVersion)
|
||||||
{
|
{
|
||||||
xmlNodePtr cur, txt;
|
xmlNodePtr cur, txt;
|
||||||
const xmlChar *type = NULL;
|
const xmlChar *type = NULL;
|
||||||
@ -1106,7 +1149,8 @@ virDomainParseXMLOSDescPV(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf,
|
|||||||
* error reporting.
|
* error reporting.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
virCatchXMLParseError(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...) {
|
virCatchXMLParseError(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
|
||||||
|
{
|
||||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
|
|
||||||
if ((ctxt != NULL) &&
|
if ((ctxt != NULL) &&
|
||||||
@ -1132,7 +1176,8 @@ virCatchXMLParseError(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...) {
|
|||||||
* Returns 0 in case of success, -1 in case of error.
|
* Returns 0 in case of success, -1 in case of error.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf, int hvm, int xendConfigVersion)
|
virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node,
|
||||||
|
virBufferPtr buf, int hvm, int xendConfigVersion)
|
||||||
{
|
{
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
xmlChar *type = NULL;
|
xmlChar *type = NULL;
|
||||||
@ -1189,9 +1234,7 @@ virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf,
|
|||||||
/* There is a case without the source
|
/* There is a case without the source
|
||||||
* to the CD-ROM device
|
* to the CD-ROM device
|
||||||
*/
|
*/
|
||||||
if (hvm &&
|
if (hvm && device && !strcmp((const char *) device, "cdrom")) {
|
||||||
device &&
|
|
||||||
!strcmp((const char *)device, "cdrom")) {
|
|
||||||
isNoSrcCdrom = 1;
|
isNoSrcCdrom = 1;
|
||||||
}
|
}
|
||||||
if (!isNoSrcCdrom) {
|
if (!isNoSrcCdrom) {
|
||||||
@ -1209,16 +1252,12 @@ virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf,
|
|||||||
/* Xend (all versions) put the floppy device config
|
/* Xend (all versions) put the floppy device config
|
||||||
* under the hvm (image (os)) block
|
* under the hvm (image (os)) block
|
||||||
*/
|
*/
|
||||||
if (hvm &&
|
if (hvm && device && !strcmp((const char *) device, "floppy")) {
|
||||||
device &&
|
|
||||||
!strcmp((const char *)device, "floppy")) {
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Xend <= 3.0.2 doesn't include cdrom config here */
|
/* Xend <= 3.0.2 doesn't include cdrom config here */
|
||||||
if (hvm &&
|
if (hvm && device && !strcmp((const char *) device, "cdrom")) {
|
||||||
device &&
|
|
||||||
!strcmp((const char *)device, "cdrom")) {
|
|
||||||
if (xendConfigVersion == 1)
|
if (xendConfigVersion == 1)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
else
|
else
|
||||||
@ -1228,8 +1267,8 @@ virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf,
|
|||||||
|
|
||||||
virBufferAdd(buf, "(device ", 8);
|
virBufferAdd(buf, "(device ", 8);
|
||||||
/* Normally disks are in a (device (vbd ...)) block
|
/* Normally disks are in a (device (vbd ...)) block
|
||||||
but blktap disks ended up in a differently named
|
* but blktap disks ended up in a differently named
|
||||||
(device (tap ....)) block.... */
|
* (device (tap ....)) block.... */
|
||||||
if (drvName && !strcmp((const char *) drvName, "tap")) {
|
if (drvName && !strcmp((const char *) drvName, "tap")) {
|
||||||
virBufferAdd(buf, "(tap ", 5);
|
virBufferAdd(buf, "(tap ", 5);
|
||||||
} else {
|
} else {
|
||||||
@ -1238,6 +1277,7 @@ virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf,
|
|||||||
|
|
||||||
if (hvm) {
|
if (hvm) {
|
||||||
char *tmp = (char *) target;
|
char *tmp = (char *) target;
|
||||||
|
|
||||||
/* Just in case user mistakenly still puts ioemu: in their XML */
|
/* Just in case user mistakenly still puts ioemu: in their XML */
|
||||||
if (!strncmp((const char *) tmp, "ioemu:", 6))
|
if (!strncmp((const char *) tmp, "ioemu:", 6))
|
||||||
tmp += 6;
|
tmp += 6;
|
||||||
@ -1246,7 +1286,8 @@ virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf,
|
|||||||
if (xendConfigVersion == 1)
|
if (xendConfigVersion == 1)
|
||||||
virBufferVSprintf(buf, "(dev 'ioemu:%s')", (const char *) tmp);
|
virBufferVSprintf(buf, "(dev 'ioemu:%s')", (const char *) tmp);
|
||||||
else /* But newer does not */
|
else /* But newer does not */
|
||||||
virBufferVSprintf(buf, "(dev '%s%s')", (const char *)tmp, cdrom ? ":cdrom" : ":disk");
|
virBufferVSprintf(buf, "(dev '%s%s')", (const char *) tmp,
|
||||||
|
cdrom ? ":cdrom" : ":disk");
|
||||||
} else
|
} else
|
||||||
virBufferVSprintf(buf, "(dev '%s')", (const char *) target);
|
virBufferVSprintf(buf, "(dev '%s')", (const char *) target);
|
||||||
|
|
||||||
@ -1310,7 +1351,9 @@ virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node, virBufferPtr buf,
|
|||||||
* Returns 0 in case of success, -1 in case of error.
|
* Returns 0 in case of success, -1 in case of error.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, virBufferPtr buf, int hvm, int xendConfigVersion)
|
virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
|
xmlNodePtr node, virBufferPtr buf, int hvm,
|
||||||
|
int xendConfigVersion)
|
||||||
{
|
{
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
xmlChar *type = NULL;
|
xmlChar *type = NULL;
|
||||||
@ -1351,9 +1394,9 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, vi
|
|||||||
} else if ((ip == NULL) &&
|
} else if ((ip == NULL) &&
|
||||||
(xmlStrEqual(cur->name, BAD_CAST "ip"))) {
|
(xmlStrEqual(cur->name, BAD_CAST "ip"))) {
|
||||||
/* XXX in future expect to need to have > 1 ip
|
/* XXX in future expect to need to have > 1 ip
|
||||||
address element - eg ipv4 & ipv6. For now
|
* address element - eg ipv4 & ipv6. For now
|
||||||
xen only supports a single address though
|
* xen only supports a single address though
|
||||||
so lets ignore that complication */
|
* so lets ignore that complication */
|
||||||
ip = xmlGetProp(cur, BAD_CAST "address");
|
ip = xmlGetProp(cur, BAD_CAST "address");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1365,12 +1408,18 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, vi
|
|||||||
unsigned int addr[12];
|
unsigned int addr[12];
|
||||||
int tmp = sscanf((const char *) mac,
|
int tmp = sscanf((const char *) mac,
|
||||||
"%01x%01x:%01x%01x:%01x%01x:%01x%01x:%01x%01x:%01x%01x",
|
"%01x%01x:%01x%01x:%01x%01x:%01x%01x:%01x%01x:%01x%01x",
|
||||||
(unsigned int*)&addr[0], (unsigned int*)&addr[1],
|
(unsigned int *) &addr[0],
|
||||||
(unsigned int*)&addr[2], (unsigned int*)&addr[3],
|
(unsigned int *) &addr[1],
|
||||||
(unsigned int*)&addr[4], (unsigned int*)&addr[5],
|
(unsigned int *) &addr[2],
|
||||||
(unsigned int*)&addr[6], (unsigned int*)&addr[7],
|
(unsigned int *) &addr[3],
|
||||||
(unsigned int*)&addr[8], (unsigned int*)&addr[9],
|
(unsigned int *) &addr[4],
|
||||||
(unsigned int*)&addr[10], (unsigned int*)&addr[11]);
|
(unsigned int *) &addr[5],
|
||||||
|
(unsigned int *) &addr[6],
|
||||||
|
(unsigned int *) &addr[7],
|
||||||
|
(unsigned int *) &addr[8],
|
||||||
|
(unsigned int *) &addr[9],
|
||||||
|
(unsigned int *) &addr[10],
|
||||||
|
(unsigned int *) &addr[11]);
|
||||||
if (tmp != 12 || strlen((const char *) mac) != 17) {
|
if (tmp != 12 || strlen((const char *) mac) != 17) {
|
||||||
virXMLError(conn, VIR_ERR_INVALID_MAC, (const char *) mac, 0);
|
virXMLError(conn, VIR_ERR_INVALID_MAC, (const char *) mac, 0);
|
||||||
goto error;
|
goto error;
|
||||||
@ -1383,12 +1432,15 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, vi
|
|||||||
else if (typ == 1) /* TODO does that work like that ? */
|
else if (typ == 1) /* TODO does that work like that ? */
|
||||||
virBufferVSprintf(buf, "(dev '%s')", (const char *) source);
|
virBufferVSprintf(buf, "(dev '%s')", (const char *) source);
|
||||||
else {
|
else {
|
||||||
virNetworkPtr network = virNetworkLookupByName(conn, (const char *) source);
|
virNetworkPtr network =
|
||||||
|
virNetworkLookupByName(conn, (const char *) source);
|
||||||
char *bridge;
|
char *bridge;
|
||||||
|
|
||||||
if (!network || !(bridge = virNetworkGetBridgeName(network))) {
|
if (!network || !(bridge = virNetworkGetBridgeName(network))) {
|
||||||
if (network)
|
if (network)
|
||||||
virNetworkFree(network);
|
virNetworkFree(network);
|
||||||
virXMLError(conn, VIR_ERR_NO_SOURCE, (const char *) source, 0);
|
virXMLError(conn, VIR_ERR_NO_SOURCE, (const char *) source,
|
||||||
|
0);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
virNetworkFree(network);
|
virNetworkFree(network);
|
||||||
@ -1436,7 +1488,8 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, vi
|
|||||||
* the caller must free() the returned value.
|
* the caller must free() the returned value.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int xendConfigVersion)
|
virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name,
|
||||||
|
int xendConfigVersion)
|
||||||
{
|
{
|
||||||
xmlDocPtr xml = NULL;
|
xmlDocPtr xml = NULL;
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
@ -1473,8 +1526,8 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
|
|||||||
*/
|
*/
|
||||||
pctxt->sax->error = virCatchXMLParseError;
|
pctxt->sax->error = virCatchXMLParseError;
|
||||||
|
|
||||||
xml = xmlCtxtReadDoc(pctxt, (const xmlChar *) xmldesc, "domain.xml", NULL,
|
xml = xmlCtxtReadDoc(pctxt, (const xmlChar *) xmldesc, "domain.xml",
|
||||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
NULL, XML_PARSE_NOENT | XML_PARSE_NONET |
|
||||||
XML_PARSE_NOWARNING);
|
XML_PARSE_NOWARNING);
|
||||||
if (xml == NULL) {
|
if (xml == NULL) {
|
||||||
goto error;
|
goto error;
|
||||||
@ -1513,8 +1566,8 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
|
|||||||
max_mem = (f / 1024);
|
max_mem = (f / 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((virXPathNumber("number(/domain/currentMemory[1])", ctxt, &f) < 0) ||
|
if ((virXPathNumber("number(/domain/currentMemory[1])", ctxt, &f) < 0)
|
||||||
(f < MIN_XEN_GUEST_SIZE * 1024)) {
|
|| (f < MIN_XEN_GUEST_SIZE * 1024)) {
|
||||||
mem = max_mem;
|
mem = max_mem;
|
||||||
} else {
|
} else {
|
||||||
mem = (f / 1024);
|
mem = (f / 1024);
|
||||||
@ -1575,8 +1628,8 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
|
|||||||
*/
|
*/
|
||||||
bootloader = 1;
|
bootloader = 1;
|
||||||
free(str);
|
free(str);
|
||||||
} else if (virXPathNumber("count(/domain/bootloader)", ctxt, &f) == 0 &&
|
} else if (virXPathNumber("count(/domain/bootloader)", ctxt, &f) == 0
|
||||||
(f > 0)) {
|
&& (f > 0)) {
|
||||||
virBufferVSprintf(&buf, "(bootloader)");
|
virBufferVSprintf(&buf, "(bootloader)");
|
||||||
/*
|
/*
|
||||||
* if using a bootloader, the kernel and initrd strings are not
|
* if using a bootloader, the kernel and initrd strings are not
|
||||||
@ -1619,14 +1672,16 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
|
|||||||
|
|
||||||
if ((str == NULL) || (strcmp(str, "hvm"))) {
|
if ((str == NULL) || (strcmp(str, "hvm"))) {
|
||||||
res = virDomainParseXMLOSDescPV(conn, node,
|
res = virDomainParseXMLOSDescPV(conn, node,
|
||||||
&buf, ctxt, xendConfigVersion);
|
&buf, ctxt,
|
||||||
|
xendConfigVersion);
|
||||||
} else {
|
} else {
|
||||||
hvm = 1;
|
hvm = 1;
|
||||||
res = virDomainParseXMLOSDescHVM(conn, node, &buf, ctxt,
|
res = virDomainParseXMLOSDescHVM(conn, node, &buf, ctxt,
|
||||||
vcpus, xendConfigVersion);
|
vcpus, xendConfigVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str != NULL) free(str);
|
if (str != NULL)
|
||||||
|
free(str);
|
||||||
|
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -1654,7 +1709,9 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
|
|||||||
if (nb_nodes > 0) {
|
if (nb_nodes > 0) {
|
||||||
for (i = 0; i < nb_nodes; i++) {
|
for (i = 0; i < nb_nodes; i++) {
|
||||||
virBufferAdd(&buf, "(device ", 8);
|
virBufferAdd(&buf, "(device ", 8);
|
||||||
res = virDomainParseXMLIfDesc(conn, nodes[i], &buf, hvm, xendConfigVersion);
|
res =
|
||||||
|
virDomainParseXMLIfDesc(conn, nodes[i], &buf, hvm,
|
||||||
|
xendConfigVersion);
|
||||||
if (res != 0) {
|
if (res != 0) {
|
||||||
free(nodes);
|
free(nodes);
|
||||||
goto error;
|
goto error;
|
||||||
@ -1728,7 +1785,8 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
|
|||||||
* the caller must free() the returned value.
|
* the caller must free() the returned value.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
virParseXMLDevice(virConnectPtr conn, const char *xmldesc, int hvm, int xendConfigVersion)
|
virParseXMLDevice(virConnectPtr conn, const char *xmldesc, int hvm,
|
||||||
|
int xendConfigVersion)
|
||||||
{
|
{
|
||||||
xmlDocPtr xml = NULL;
|
xmlDocPtr xml = NULL;
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
@ -1751,14 +1809,15 @@ virParseXMLDevice(virConnectPtr conn, const char *xmldesc, int hvm, int xendConf
|
|||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
if (xmlStrEqual(node->name, BAD_CAST "disk")) {
|
if (xmlStrEqual(node->name, BAD_CAST "disk")) {
|
||||||
if (virDomainParseXMLDiskDesc(conn, node, &buf, hvm, xendConfigVersion) != 0)
|
if (virDomainParseXMLDiskDesc(conn, node, &buf, hvm,
|
||||||
|
xendConfigVersion) != 0)
|
||||||
goto error;
|
goto error;
|
||||||
/* SXP is not created when device is "floppy". */
|
/* SXP is not created when device is "floppy". */
|
||||||
else if (buf.use == 0)
|
else if (buf.use == 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
} else if (xmlStrEqual(node->name, BAD_CAST "interface")) {
|
||||||
else if (xmlStrEqual(node->name, BAD_CAST "interface")) {
|
if (virDomainParseXMLIfDesc(conn, node, &buf, hvm,
|
||||||
if (virDomainParseXMLIfDesc(conn, node, &buf, hvm, xendConfigVersion) != 0)
|
xendConfigVersion) != 0)
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
virXMLError(conn, VIR_ERR_XML_ERROR, (const char *) node->name, 0);
|
virXMLError(conn, VIR_ERR_XML_ERROR, (const char *) node->name, 0);
|
||||||
@ -1789,11 +1848,13 @@ virParseXMLDevice(virConnectPtr conn, const char *xmldesc, int hvm, int xendConf
|
|||||||
* Returns 0 in case of success, -1 in case of failure.
|
* Returns 0 in case of success, -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class, char *ref, int ref_len)
|
virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class,
|
||||||
|
char *ref, int ref_len)
|
||||||
{
|
{
|
||||||
xmlDocPtr xml = NULL;
|
xmlDocPtr xml = NULL;
|
||||||
xmlNodePtr node, cur;
|
xmlNodePtr node, cur;
|
||||||
xmlChar *attr = NULL;
|
xmlChar *attr = NULL;
|
||||||
|
|
||||||
#ifdef WITH_XEN
|
#ifdef WITH_XEN
|
||||||
char *xref;
|
char *xref;
|
||||||
#endif /* WITH_XEN */
|
#endif /* WITH_XEN */
|
||||||
@ -1813,7 +1874,8 @@ virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class, char *r
|
|||||||
strcpy(class, "vbd");
|
strcpy(class, "vbd");
|
||||||
for (cur = node->children; cur != NULL; cur = cur->next) {
|
for (cur = node->children; cur != NULL; cur = cur->next) {
|
||||||
if ((cur->type != XML_ELEMENT_NODE) ||
|
if ((cur->type != XML_ELEMENT_NODE) ||
|
||||||
(!xmlStrEqual(cur->name, BAD_CAST "target"))) continue;
|
(!xmlStrEqual(cur->name, BAD_CAST "target")))
|
||||||
|
continue;
|
||||||
attr = xmlGetProp(cur, BAD_CAST "dev");
|
attr = xmlGetProp(cur, BAD_CAST "dev");
|
||||||
if (attr == NULL)
|
if (attr == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
@ -1821,12 +1883,12 @@ virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class, char *r
|
|||||||
ref[ref_len - 1] = '\0';
|
ref[ref_len - 1] = '\0';
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
} else if (xmlStrEqual(node->name, BAD_CAST "interface")) {
|
||||||
else if (xmlStrEqual(node->name, BAD_CAST "interface")) {
|
|
||||||
strcpy(class, "vif");
|
strcpy(class, "vif");
|
||||||
for (cur = node->children; cur != NULL; cur = cur->next) {
|
for (cur = node->children; cur != NULL; cur = cur->next) {
|
||||||
if ((cur->type != XML_ELEMENT_NODE) ||
|
if ((cur->type != XML_ELEMENT_NODE) ||
|
||||||
(!xmlStrEqual(cur->name, BAD_CAST "mac"))) continue;
|
(!xmlStrEqual(cur->name, BAD_CAST "mac")))
|
||||||
|
continue;
|
||||||
attr = xmlGetProp(cur, BAD_CAST "address");
|
attr = xmlGetProp(cur, BAD_CAST "address");
|
||||||
if (attr == NULL)
|
if (attr == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
Loading…
Reference in New Issue
Block a user