diff --git a/ChangeLog b/ChangeLog index 133e492cc4419507a27741b94f579e13fad79f36..b3ccec699ed6c7429acb617767dd70e17a14bfae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +Thu Jan 8 14:41:55 CET 2009 Guido Günther + + pass flags argument to all virDomain*DefParse* functions + * src/domain_conf.c (virDomainDiskDefParseXML, + virDomainFSDefParseXML, virDomainNetDefParseXML, + virDomainChrDefParseXML, virDomainSoundDefParseXML, + virDomainHostdevSubsysUsbDefParseXML, virDomainHostdevDefParseXML, + virDomainDefParseString): Add and pass on flags argument + * src/domain_conf.h (virDomainDeviceDefParse, + virDomainDefParseString): Add flags argument + * src/lxc_driver.c (lxcDomainDefine): Pass VIR_DOMAIN_XML_INACTIVE + * src/openvz_driver.c (openvzDomainDefineXML): Likewise + * src/qemu_driver.c (qemudDomainCreate, qemudDomainRestore, + qemudDomainDefine, qemudDomainAttachDevice): Likewise + * src/test.c (testOpenDefault, testDomainCreateXML, testDomainRestore, + testDomainDefineXML): Likewise + * src/uml_driver.c (umlDomainCreate, umlDomainDefine): Likewise + * src/xend_internal.c (xenDaemonCreateXML, xenDaemonDomainCreateXML): + Likewise + * tests/qemuxml2xmltest.c (testCompareXMLToXMLFiles): Likewise + Thu Jan 8 09:48:04 CET 2009 Daniel P. Berrange poll: don't return uninitialized diff --git a/src/domain_conf.c b/src/domain_conf.c index ce7f170aacdfdf552b1c1d832d23996c50f8471f..8bb51f7f06db2afcef75abf0c15fc5f45ff5e5f1 100644 --- a/src/domain_conf.c +++ b/src/domain_conf.c @@ -534,7 +534,8 @@ int virDomainDiskCompare(virDomainDiskDefPtr a, */ static virDomainDiskDefPtr virDomainDiskDefParseXML(virConnectPtr conn, - xmlNodePtr node) { + xmlNodePtr node, + int flags ATTRIBUTE_UNUSED) { virDomainDiskDefPtr def; xmlNodePtr cur; char *type = NULL; @@ -721,7 +722,8 @@ cleanup: */ static virDomainFSDefPtr virDomainFSDefParseXML(virConnectPtr conn, - xmlNodePtr node) { + xmlNodePtr node, + int flags ATTRIBUTE_UNUSED) { virDomainFSDefPtr def; xmlNodePtr cur; char *type = NULL; @@ -807,7 +809,8 @@ cleanup: static virDomainNetDefPtr virDomainNetDefParseXML(virConnectPtr conn, virCapsPtr caps, - xmlNodePtr node) { + xmlNodePtr node, + int flags ATTRIBUTE_UNUSED) { virDomainNetDefPtr def; xmlNodePtr cur; char *macaddr = NULL; @@ -1038,7 +1041,8 @@ error: */ static virDomainChrDefPtr virDomainChrDefParseXML(virConnectPtr conn, - xmlNodePtr node) { + xmlNodePtr node, + int flags ATTRIBUTE_UNUSED) { xmlNodePtr cur; char *type = NULL; char *bindHost = NULL; @@ -1257,7 +1261,8 @@ error: static virDomainInputDefPtr virDomainInputDefParseXML(virConnectPtr conn, const char *ostype, - xmlNodePtr node) { + xmlNodePtr node, + int flags ATTRIBUTE_UNUSED) { virDomainInputDefPtr def; char *type = NULL; char *bus = NULL; @@ -1436,7 +1441,8 @@ error: static virDomainSoundDefPtr virDomainSoundDefParseXML(virConnectPtr conn, - const xmlNodePtr node) { + const xmlNodePtr node, + int flags ATTRIBUTE_UNUSED) { char *model; virDomainSoundDefPtr def; @@ -1467,7 +1473,8 @@ error: static int virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn, const xmlNodePtr node, - virDomainHostdevDefPtr def) { + virDomainHostdevDefPtr def, + int flags ATTRIBUTE_UNUSED) { int ret = -1; xmlNodePtr cur; @@ -1667,7 +1674,8 @@ out: static virDomainHostdevDefPtr virDomainHostdevDefParseXML(virConnectPtr conn, - const xmlNodePtr node) { + const xmlNodePtr node, + int flags) { xmlNodePtr cur; virDomainHostdevDefPtr def; @@ -1709,7 +1717,8 @@ virDomainHostdevDefParseXML(virConnectPtr conn, if (xmlStrEqual(cur->name, BAD_CAST "source")) { if (def->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) { - if (virDomainHostdevSubsysUsbDefParseXML(conn, cur, def) < 0) + if (virDomainHostdevSubsysUsbDefParseXML(conn, cur, + def, flags) < 0) goto error; } if (def->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && @@ -1763,7 +1772,8 @@ static int virDomainLifecycleParseXML(virConnectPtr conn, virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn, virCapsPtr caps, const virDomainDefPtr def, - const char *xmlStr) + const char *xmlStr, + int flags) { xmlDocPtr xml; xmlNodePtr node; @@ -1790,27 +1800,28 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn, if (xmlStrEqual(node->name, BAD_CAST "disk")) { dev->type = VIR_DOMAIN_DEVICE_DISK; - if (!(dev->data.disk = virDomainDiskDefParseXML(conn, node))) + if (!(dev->data.disk = virDomainDiskDefParseXML(conn, node, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "filesystem")) { dev->type = VIR_DOMAIN_DEVICE_FS; - if (!(dev->data.fs = virDomainFSDefParseXML(conn, node))) + if (!(dev->data.fs = virDomainFSDefParseXML(conn, node, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "interface")) { dev->type = VIR_DOMAIN_DEVICE_NET; - if (!(dev->data.net = virDomainNetDefParseXML(conn, caps, node))) + if (!(dev->data.net = virDomainNetDefParseXML(conn, caps, node, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "input")) { dev->type = VIR_DOMAIN_DEVICE_INPUT; - if (!(dev->data.input = virDomainInputDefParseXML(conn, def->os.type, node))) + if (!(dev->data.input = virDomainInputDefParseXML(conn, def->os.type, + node, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "sound")) { dev->type = VIR_DOMAIN_DEVICE_SOUND; - if (!(dev->data.sound = virDomainSoundDefParseXML(conn, node))) + if (!(dev->data.sound = virDomainSoundDefParseXML(conn, node, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "hostdev")) { dev->type = VIR_DOMAIN_DEVICE_HOSTDEV; - if (!(dev->data.hostdev = virDomainHostdevDefParseXML(conn, node))) + if (!(dev->data.hostdev = virDomainHostdevDefParseXML(conn, node, flags))) goto error; } else { virDomainReportError(conn, VIR_ERR_XML_ERROR, @@ -2090,7 +2101,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto no_memory; for (i = 0 ; i < n ; i++) { virDomainDiskDefPtr disk = virDomainDiskDefParseXML(conn, - nodes[i]); + nodes[i], + flags); if (!disk) goto error; @@ -2110,7 +2122,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto no_memory; for (i = 0 ; i < n ; i++) { virDomainFSDefPtr fs = virDomainFSDefParseXML(conn, - nodes[i]); + nodes[i], + flags); if (!fs) goto error; @@ -2129,7 +2142,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, for (i = 0 ; i < n ; i++) { virDomainNetDefPtr net = virDomainNetDefParseXML(conn, caps, - nodes[i]); + nodes[i], + flags); if (!net) goto error; @@ -2149,7 +2163,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, for (i = 0 ; i < n ; i++) { virDomainChrDefPtr chr = virDomainChrDefParseXML(conn, - nodes[i]); + nodes[i], + flags); if (!chr) goto error; @@ -2168,7 +2183,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, for (i = 0 ; i < n ; i++) { virDomainChrDefPtr chr = virDomainChrDefParseXML(conn, - nodes[i]); + nodes[i], + flags); if (!chr) goto error; @@ -2179,7 +2195,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, if ((node = virXPathNode(conn, "./devices/console[1]", ctxt)) != NULL) { virDomainChrDefPtr chr = virDomainChrDefParseXML(conn, - node); + node, + flags); if (!chr) goto error; @@ -2217,7 +2234,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, for (i = 0 ; i < n ; i++) { virDomainInputDefPtr input = virDomainInputDefParseXML(conn, def->os.type, - nodes[i]); + nodes[i], + flags); if (!input) goto error; @@ -2292,7 +2310,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, for (i = 0 ; i < n ; i++) { int collision = 0, j; virDomainSoundDefPtr sound = virDomainSoundDefParseXML(conn, - nodes[i]); + nodes[i], + flags); if (!sound) goto error; @@ -2319,7 +2338,9 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, if (n && VIR_ALLOC_N(def->hostdevs, n) < 0) goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainHostdevDefPtr hostdev = virDomainHostdevDefParseXML(conn, nodes[i]); + virDomainHostdevDefPtr hostdev = virDomainHostdevDefParseXML(conn, + nodes[i], + flags); if (!hostdev) goto error; @@ -2363,7 +2384,8 @@ catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...) virDomainDefPtr virDomainDefParseString(virConnectPtr conn, virCapsPtr caps, - const char *xmlStr) + const char *xmlStr, + int flags) { xmlParserCtxtPtr pctxt; xmlDocPtr xml = NULL; @@ -2394,8 +2416,7 @@ virDomainDefPtr virDomainDefParseString(virConnectPtr conn, goto cleanup; } - def = virDomainDefParseNode(conn, caps, xml, root, - VIR_DOMAIN_XML_INACTIVE); + def = virDomainDefParseNode(conn, caps, xml, root, flags); cleanup: xmlFreeParserCtxt (pctxt); diff --git a/src/domain_conf.h b/src/domain_conf.h index 3ad518b091af394aec61e5856f9b53b5d26c9a95..7320609faee29edd0633cfd9253454327b013ab8 100644 --- a/src/domain_conf.h +++ b/src/domain_conf.h @@ -525,10 +525,12 @@ void virDomainRemoveInactive(virDomainObjListPtr doms, virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn, virCapsPtr caps, const virDomainDefPtr def, - const char *xmlStr); + const char *xmlStr, + int flags); virDomainDefPtr virDomainDefParseString(virConnectPtr conn, virCapsPtr caps, - const char *xmlStr); + const char *xmlStr, + int flags); virDomainDefPtr virDomainDefParseFile(virConnectPtr conn, virCapsPtr caps, const char *filename, diff --git a/src/lxc_driver.c b/src/lxc_driver.c index 97e297aa5e73d1ba8f52353d1919c3631b45594a..13afae0bc4c760b4cc3efc8b9c26ab22c341f531 100644 --- a/src/lxc_driver.c +++ b/src/lxc_driver.c @@ -275,7 +275,8 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml) virDomainPtr dom = NULL; lxcDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml))) + if (!(def = virDomainDefParseString(conn, driver->caps, xml, + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if ((def->nets != NULL) && !(driver->have_netns)) { @@ -1002,7 +1003,8 @@ lxcDomainCreateAndStart(virConnectPtr conn, virDomainPtr dom = NULL; lxcDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml))) + if (!(def = virDomainDefParseString(conn, driver->caps, xml, + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if ((def->nets != NULL) && !(driver->have_netns)) { diff --git a/src/openvz_driver.c b/src/openvz_driver.c index bec0eb870b500a8db06ddc0fa7f0412b5249b8e1..597a06a97f2c885eed1f10d1ff0beab91782ca62 100644 --- a/src/openvz_driver.c +++ b/src/openvz_driver.c @@ -657,7 +657,8 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml) prog[0] = NULL; openvzDriverLock(driver); - if ((vmdef = virDomainDefParseString(conn, driver->caps, xml)) == NULL) + if ((vmdef = virDomainDefParseString(conn, driver->caps, xml, + VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; if (vmdef->os.init == NULL && @@ -733,7 +734,8 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, progcreate[0] = NULL; openvzDriverLock(driver); - if ((vmdef = virDomainDefParseString(conn, driver->caps, xml)) == NULL) + if ((vmdef = virDomainDefParseString(conn, driver->caps, xml, + VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; if (vmdef->os.init == NULL && diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 7307be5686d8d448bd290c8b521361ca9149678a..3d90670cc71d44ebf01736bf2f3860e1f1d505b5 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -1689,7 +1689,8 @@ static virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml, virDomainEventPtr event = NULL; qemuDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml))) + if (!(def = virDomainDefParseString(conn, driver->caps, xml, + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; vm = virDomainFindByName(&driver->domains, def->name); @@ -2574,7 +2575,8 @@ static int qemudDomainRestore(virConnectPtr conn, } /* Create a domain from this XML */ - if (!(def = virDomainDefParseString(conn, driver->caps, xml))) { + if (!(def = virDomainDefParseString(conn, driver->caps, xml, + VIR_DOMAIN_XML_INACTIVE))) { qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, "%s", _("failed to parse XML")); goto cleanup; @@ -2761,7 +2763,8 @@ static virDomainPtr qemudDomainDefine(virConnectPtr conn, const char *xml) { int newVM = 1; qemuDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml))) + if (!(def = virDomainDefParseString(conn, driver->caps, xml, + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; vm = virDomainFindByName(&driver->domains, def->name); @@ -3223,9 +3226,8 @@ static int qemudDomainAttachDevice(virDomainPtr dom, goto cleanup; } - dev = virDomainDeviceDefParse(dom->conn, - driver->caps, - vm->def, xml); + dev = virDomainDeviceDefParse(dom->conn, driver->caps, vm->def, xml, + VIR_DOMAIN_XML_INACTIVE); qemuDriverUnlock(driver); if (dev == NULL) goto cleanup; @@ -3361,7 +3363,8 @@ static int qemudDomainDetachDevice(virDomainPtr dom, goto cleanup; } - dev = virDomainDeviceDefParse(dom->conn, driver->caps, vm->def, xml); + dev = virDomainDeviceDefParse(dom->conn, driver->caps, vm->def, xml, + VIR_DOMAIN_XML_INACTIVE); qemuDriverUnlock(driver); if (dev == NULL) goto cleanup; @@ -3997,7 +4000,8 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, } /* Parse the domain XML. */ - if (!(def = virDomainDefParseString(dconn, driver->caps, dom_xml))) { + if (!(def = virDomainDefParseString(dconn, driver->caps, dom_xml, + VIR_DOMAIN_XML_INACTIVE))) { qemudReportError (dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED, "%s", _("failed to parse XML")); goto cleanup; diff --git a/src/test.c b/src/test.c index 5d28cced6ccdc57936c19e249b8109cbb632f261..7a09c5d94c81e9f98e485d7410854d9269992819 100644 --- a/src/test.c +++ b/src/test.c @@ -242,7 +242,9 @@ static int testOpenDefault(virConnectPtr conn) { privconn->nextDomID = 1; - if (!(domdef = virDomainDefParseString(conn, privconn->caps, defaultDomainXML))) + if (!(domdef = virDomainDefParseString(conn, privconn->caps, + defaultDomainXML, + VIR_DOMAIN_XML_INACTIVE))) goto error; if (!(domobj = virDomainAssignDef(conn, &privconn->domains, domdef))) { virDomainDefFree(domdef); @@ -719,7 +721,8 @@ testDomainCreateXML(virConnectPtr conn, const char *xml, virDomainObjPtr dom = NULL; testDriverLock(privconn); - if ((def = virDomainDefParseString(conn, privconn->caps, xml)) == NULL) + if ((def = virDomainDefParseString(conn, privconn->caps, xml, + VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; if ((dom = virDomainAssignDef(conn, &privconn->domains, @@ -1211,7 +1214,8 @@ static int testDomainRestore(virConnectPtr conn, xml[len] = '\0'; testDriverLock(privconn); - def = virDomainDefParseString(conn, privconn->caps, xml); + def = virDomainDefParseString(conn, privconn->caps, xml, + VIR_DOMAIN_XML_INACTIVE); if (!def) goto cleanup; @@ -1491,7 +1495,8 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn, virDomainObjPtr dom = NULL; testDriverLock(privconn); - if ((def = virDomainDefParseString(conn, privconn->caps, xml)) == NULL) + if ((def = virDomainDefParseString(conn, privconn->caps, xml, + VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; if ((dom = virDomainAssignDef(conn, &privconn->domains, diff --git a/src/uml_driver.c b/src/uml_driver.c index 77e19f6758926007b3fc8a8ea76815e6f858ffa8..38f74551d4d1d4e7f4a94b8ca44d6224c06174ab 100644 --- a/src/uml_driver.c +++ b/src/uml_driver.c @@ -1199,7 +1199,8 @@ static virDomainPtr umlDomainCreate(virConnectPtr conn, const char *xml, virDomainPtr dom = NULL; umlDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml))) + if (!(def = virDomainDefParseString(conn, driver->caps, xml, + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; vm = virDomainFindByName(&driver->domains, def->name); @@ -1574,7 +1575,8 @@ static virDomainPtr umlDomainDefine(virConnectPtr conn, const char *xml) { virDomainPtr dom = NULL; umlDriverLock(driver); - if (!(def = virDomainDefParseString(conn, driver->caps, xml))) + if (!(def = virDomainDefParseString(conn, driver->caps, xml, + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (!(vm = virDomainAssignDef(conn, diff --git a/src/xend_internal.c b/src/xend_internal.c index 39a92ff24b4068975fc7d813ace24390b18d448f..2b15592b99f1ee78ec69b6abf6389db231708cec 100644 --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -3772,7 +3772,8 @@ xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc, if (!(def = virDomainDefParseString(conn, priv->caps, - xmlDesc))) + xmlDesc, + VIR_DOMAIN_XML_INACTIVE))) return (NULL); if (!(sexpr = xenDaemonFormatSxpr(conn, def, priv->xendConfigVersion))) { @@ -4248,7 +4249,8 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) { if (priv->xendConfigVersion < 3) return(NULL); - if (!(def = virDomainDefParseString(conn, priv->caps, xmlDesc))) { + if (!(def = virDomainDefParseString(conn, priv->caps, xmlDesc, + VIR_DOMAIN_XML_INACTIVE))) { virXendError(conn, VIR_ERR_XML_ERROR, "%s", _("failed to parse domain description")); return (NULL); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 613926ab6ced961ed945b3501c0be21b4603e04b..bc02b5daf728b1810b1e5799917cb940d1919670 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -32,7 +32,8 @@ static int testCompareXMLToXMLFiles(const char *xml) { if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0) goto fail; - if (!(vmdef = virDomainDefParseString(NULL, driver.caps, xmlData))) + if (!(vmdef = virDomainDefParseString(NULL, driver.caps, xmlData, + VIR_DOMAIN_XML_INACTIVE))) goto fail; if (!(actual = virDomainDefFormat(NULL, vmdef, 0)))