mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
xml: Change virtual file names of xml documents parsed in memory
While parsing XML strings from memory, the previous convention in libvirt was to set the virtual file name to "domain.xml" or something similar. This could potentialy trick the user into looking for a file named domain.xml on the disk in an attempt to fix the error. This patch changes these filenames to something that can't be as easily confused for a valid filename. Examples of error messages: --------------------------- Error while loading file from disk: 15:07:59.015: 527: error : catchXMLError:709 : /path/to/domain.xml:1: StartTag: invalid element name <domain type='kvm'>< --------------------^ Error while parsing definition in memory: 15:08:43.581: 525: error : catchXMLError:709 : (domain definition):2: error parsing attribute name <name>vm1</name> --^
This commit is contained in:
parent
2acd4a1640
commit
498d783387
@ -7461,7 +7461,7 @@ virDomainDefParse(const char *xmlStr,
|
|||||||
xmlDocPtr xml;
|
xmlDocPtr xml;
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
|
|
||||||
if ((xml = virXMLParse(filename, xmlStr, "domain.xml"))) {
|
if ((xml = virXMLParse(filename, xmlStr, _("(domain definition)")))) {
|
||||||
def = virDomainDefParseNode(caps, xml, xmlDocGetRootElement(xml),
|
def = virDomainDefParseNode(caps, xml, xmlDocGetRootElement(xml),
|
||||||
expectedVirtTypes, flags);
|
expectedVirtTypes, flags);
|
||||||
xmlFreeDoc(xml);
|
xmlFreeDoc(xml);
|
||||||
|
@ -641,7 +641,8 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
|
|||||||
xmlDocPtr xml = NULL;
|
xmlDocPtr xml = NULL;
|
||||||
xmlXPathContextPtr ctxt = NULL;
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
|
|
||||||
if (!(xml = virXMLParseStringCtxt(xmlStr, "domain.xml", &ctxt))) {
|
if (!(xml = virXMLParseStringCtxt(xmlStr, _("(domain definition)"),
|
||||||
|
&ctxt))) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1306,7 +1306,7 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
|
|||||||
flags = VIR_DOMAIN_AFFECT_CONFIG;
|
flags = VIR_DOMAIN_AFFECT_CONFIG;
|
||||||
|
|
||||||
/* extract current network device description */
|
/* extract current network device description */
|
||||||
xml = virXMLParseStringCtxt(desc, "domain configuration", &ctxt);
|
xml = virXMLParseStringCtxt(desc, _("(domain definition)"), &ctxt);
|
||||||
VIR_FREE(desc);
|
VIR_FREE(desc);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
vshError(ctl, _("Failed to parse domain description xml"));
|
vshError(ctl, _("Failed to parse domain description xml"));
|
||||||
@ -1453,7 +1453,7 @@ cmdDomIfGetLink (vshControl *ctl, const vshCmd *cmd)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
xml = virXMLParseStringCtxt(desc, "domain configuration", &ctxt);
|
xml = virXMLParseStringCtxt(desc, _("(domain definition)"), &ctxt);
|
||||||
VIR_FREE(desc);
|
VIR_FREE(desc);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
vshError(ctl, _("Failed to parse domain description xml"));
|
vshError(ctl, _("Failed to parse domain description xml"));
|
||||||
@ -1662,7 +1662,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!xml)
|
if (!xml)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xmldoc = virXMLParseStringCtxt(xml, "domain.xml", &ctxt);
|
xmldoc = virXMLParseStringCtxt(xml, _("(domain definition)"), &ctxt);
|
||||||
if (!xmldoc)
|
if (!xmldoc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -3492,7 +3492,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
xml = virXMLParseStringCtxt(cap_xml, "node.xml", &ctxt);
|
xml = virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
vshError(ctl, "%s", _("unable to get node capabilities"));
|
vshError(ctl, "%s", _("unable to get node capabilities"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -9032,7 +9032,8 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static xmlChar *
|
static xmlChar *
|
||||||
makeCloneXML(const char *origxml, const char *newname) {
|
makeCloneXML(const char *origxml, const char *newname)
|
||||||
|
{
|
||||||
|
|
||||||
xmlDocPtr doc = NULL;
|
xmlDocPtr doc = NULL;
|
||||||
xmlXPathContextPtr ctxt = NULL;
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
@ -9040,7 +9041,7 @@ makeCloneXML(const char *origxml, const char *newname) {
|
|||||||
xmlChar *newxml = NULL;
|
xmlChar *newxml = NULL;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
doc = virXMLParseStringCtxt(origxml, "domain.xml", &ctxt);
|
doc = virXMLParseStringCtxt(origxml, _("(volume definition)"), &ctxt);
|
||||||
if (!doc)
|
if (!doc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -10831,7 +10832,7 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xml = virXMLParseStringCtxt(doc, "domain.xml", &ctxt);
|
xml = virXMLParseStringCtxt(doc, _("(domain definition)"), &ctxt);
|
||||||
VIR_FREE(doc);
|
VIR_FREE(doc);
|
||||||
if (!xml)
|
if (!xml)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -10899,7 +10900,7 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xml = virXMLParseStringCtxt(doc, "domain.xml", &ctxt);
|
xml = virXMLParseStringCtxt(doc, _("(domain definition)"), &ctxt);
|
||||||
VIR_FREE(doc);
|
VIR_FREE(doc);
|
||||||
if (!xml)
|
if (!xml)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -11286,7 +11287,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xml = virXMLParseStringCtxt(doc, "domain.xml", &ctxt);
|
xml = virXMLParseStringCtxt(doc, _("(domain definition)"), &ctxt);
|
||||||
VIR_FREE(doc);
|
VIR_FREE(doc);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
vshError(ctl, "%s", _("Failed to get interface information"));
|
vshError(ctl, "%s", _("Failed to get interface information"));
|
||||||
@ -11753,7 +11754,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xml = virXMLParseStringCtxt(doc, "domain.xml", &ctxt);
|
xml = virXMLParseStringCtxt(doc, _("(domain definition)"), &ctxt);
|
||||||
VIR_FREE(doc);
|
VIR_FREE(doc);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
vshError(ctl, "%s", _("Failed to get disk information"));
|
vshError(ctl, "%s", _("Failed to get disk information"));
|
||||||
@ -13023,7 +13024,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!doc)
|
if (!doc)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
xml = virXMLParseStringCtxt(doc, "domainsnapshot.xml", &ctxt);
|
xml = virXMLParseStringCtxt(doc, _("(domain snapshot)"), &ctxt);
|
||||||
if (!xml)
|
if (!xml)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -13184,7 +13185,7 @@ cmdSnapshotParent(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (!xml)
|
if (!xml)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
xmldoc = virXMLParseStringCtxt(xml, "domainsnapshot.xml", &ctxt);
|
xmldoc = virXMLParseStringCtxt(xml, _("(domain snapshot)"), &ctxt);
|
||||||
if (!xmldoc)
|
if (!xmldoc)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user