[libvirt] [PATCH] xml: Clean up rest of virtual XML document names for XML strings

Commit 498d783387389bfd74437bf84374583f5a3d3bf6 cleans up some of virtual file names for parsing strings in memory. This patch cleans up (hopefuly) the rest forgotten by the first patch. --- src/conf/domain_conf.c | 4 ++-- src/conf/interface_conf.c | 2 +- src/conf/network_conf.c | 2 +- src/conf/node_device_conf.c | 2 +- src/conf/nwfilter_conf.c | 2 +- src/conf/secret_conf.c | 2 +- src/conf/storage_conf.c | 6 +++--- src/cpu/cpu.c | 4 ++-- src/esx/esx_vi.c | 2 +- src/qemu/qemu_migration.c | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 11755fe..886aa53 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5739,7 +5739,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, xmlXPathContextPtr ctxt = NULL; virDomainDeviceDefPtr dev = NULL; - if (!(xml = virXMLParseStringCtxt(xmlStr, "device.xml", &ctxt))) { + if (!(xml = virXMLParseStringCtxt(xmlStr, _("(device definition)"), &ctxt))) { goto error; } node = ctxt->node; @@ -11573,7 +11573,7 @@ virDomainSnapshotDefParseString(const char *xmlStr, int active; char *tmp; - xml = virXMLParseCtxt(NULL, xmlStr, "domainsnapshot.xml", &ctxt); + xml = virXMLParseCtxt(NULL, xmlStr, _("(domain snapshot)"), &ctxt); if (!xml) { return NULL; } diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 10377e7..d320c81 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -864,7 +864,7 @@ virInterfaceDefParse(const char *xmlStr, xmlDocPtr xml; virInterfaceDefPtr def = NULL; - if ((xml = virXMLParse(filename, xmlStr, "interface.xml"))) { + if ((xml = virXMLParse(filename, xmlStr, _("(interface definition)")))) { def = virInterfaceDefParseNode(xml, xmlDocGetRootElement(xml)); xmlFreeDoc(xml); } diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index e055094..487d28c 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1084,7 +1084,7 @@ virNetworkDefParse(const char *xmlStr, xmlDocPtr xml; virNetworkDefPtr def = NULL; - if ((xml = virXMLParse(filename, xmlStr, "network.xml"))) { + if ((xml = virXMLParse(filename, xmlStr, _("(network definition)")))) { def = virNetworkDefParseNode(xml, xmlDocGetRootElement(xml)); xmlFreeDoc(xml); } diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 6b0ef50..b584356 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1231,7 +1231,7 @@ virNodeDeviceDefParse(const char *str, xmlDocPtr xml; virNodeDeviceDefPtr def = NULL; - if ((xml = virXMLParse(filename, str, "device.xml"))) { + if ((xml = virXMLParse(filename, str, _("(node device definition)")))) { def = virNodeDeviceDefParseNode(xml, xmlDocGetRootElement(xml), create); xmlFreeDoc(xml); } diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 04bfa22..035f7e4 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2119,7 +2119,7 @@ virNWFilterDefParse(virConnectPtr conn ATTRIBUTE_UNUSED, virNWFilterDefPtr def = NULL; xmlDocPtr xml; - if ((xml = virXMLParse(filename, xmlStr, "nwfilter.xml"))) { + if ((xml = virXMLParse(filename, xmlStr, _("(nwfilter definition")))) { def = virNWFilterDefParseNode(xml, xmlDocGetRootElement(xml)); xmlFreeDoc(xml); } diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 105afbe..39b20bf 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -195,7 +195,7 @@ virSecretDefParse(const char *xmlStr, xmlDocPtr xml; virSecretDefPtr ret = NULL; - if ((xml = virXMLParse(filename, xmlStr, "secret.xml"))) { + if ((xml = virXMLParse(filename, xmlStr, _("(definition of secret)")))) { ret = secretXMLParseNode(xml, xmlDocGetRootElement(xml)); xmlFreeDoc(xml); } diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 1e7da69..2279a20 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -505,7 +505,7 @@ virStoragePoolDefParseSourceString(const char *srcSpec, xmlXPathContextPtr xpath_ctxt = NULL; virStoragePoolSourcePtr def = NULL, ret = NULL; - if (!(doc = virXMLParseStringCtxt(srcSpec, "srcSpec.xml", &xpath_ctxt))) { + if (!(doc = virXMLParseStringCtxt(srcSpec, _("(storage source specification)"), &xpath_ctxt))) { goto cleanup; } @@ -765,7 +765,7 @@ virStoragePoolDefParse(const char *xmlStr, virStoragePoolDefPtr ret = NULL; xmlDocPtr xml; - if ((xml = virXMLParse(filename, xmlStr, "storage.xml"))) { + if ((xml = virXMLParse(filename, xmlStr, _("(storage pool definition)")))) { ret = virStoragePoolDefParseNode(xml, xmlDocGetRootElement(xml)); xmlFreeDoc(xml); } @@ -1146,7 +1146,7 @@ virStorageVolDefParse(virStoragePoolDefPtr pool, virStorageVolDefPtr ret = NULL; xmlDocPtr xml; - if ((xml = virXMLParse(filename, xmlStr, "storage.xml"))) { + if ((xml = virXMLParse(filename, xmlStr, _("(storage volume definition)")))) { ret = virStorageVolDefParseNode(pool, xml, xmlDocGetRootElement(xml)); xmlFreeDoc(xml); } diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index b47f078..5158bb8 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -76,7 +76,7 @@ cpuCompareXML(virCPUDefPtr host, VIR_DEBUG("host=%p, xml=%s", host, NULLSTR(xml)); - if (!(doc = virXMLParseStringCtxt(xml, "cpu.xml", &ctxt))) + if (!(doc = virXMLParseStringCtxt(xml, _("(CPU definition)"), &ctxt))) goto cleanup; cpu = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_AUTO); @@ -304,7 +304,7 @@ cpuBaselineXML(const char **xmlCPUs, goto no_memory; for (i = 0; i < ncpus; i++) { - if (!(doc = virXMLParseStringCtxt(xmlCPUs[i], "cpu.xml", &ctxt))) + if (!(doc = virXMLParseStringCtxt(xmlCPUs[i], _("(CPU definition)"), &ctxt))) goto error; cpus[i] = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_HOST); diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index f4033eb..2d9890c 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -911,7 +911,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, if ((*response)->responseCode == 500 || (*response)->responseCode == 200) { (*response)->document = virXMLParseStringCtxt((*response)->content, - "esx.xml", + _("(esx execute response)"), &xpathContext); if ((*response)->document == NULL) { diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f849d05..42324b0 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -603,7 +603,7 @@ qemuMigrationCookieXMLParseStr(qemuMigrationCookiePtr mig, VIR_DEBUG("xml=%s", NULLSTR(xml)); - if (!(doc = virXMLParseStringCtxt(xml, "qemumigration.xml", &ctxt))) + if (!(doc = virXMLParseStringCtxt(xml, _("(qemu migration cookie)"), &ctxt))) goto cleanup; ret = qemuMigrationCookieXMLParse(mig, ctxt, flags); -- 1.7.3.4

On Wed, Sep 14, 2011 at 01:42:22PM +0200, Peter Krempa wrote:
Commit 498d783387389bfd74437bf84374583f5a3d3bf6 cleans up some of virtual file names for parsing strings in memory. This patch cleans up (hopefuly) the rest forgotten by the first patch. --- src/conf/domain_conf.c | 4 ++-- src/conf/interface_conf.c | 2 +- src/conf/network_conf.c | 2 +- src/conf/node_device_conf.c | 2 +- src/conf/nwfilter_conf.c | 2 +- src/conf/secret_conf.c | 2 +- src/conf/storage_conf.c | 6 +++--- src/cpu/cpu.c | 4 ++-- src/esx/esx_vi.c | 2 +- src/qemu/qemu_migration.c | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 11755fe..886aa53 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5739,7 +5739,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, xmlXPathContextPtr ctxt = NULL; virDomainDeviceDefPtr dev = NULL;
- if (!(xml = virXMLParseStringCtxt(xmlStr, "device.xml", &ctxt))) { + if (!(xml = virXMLParseStringCtxt(xmlStr, _("(device definition)"), &ctxt))) {
Considering the previous patch this one makes sense, but I realize that the string passed is supposed to be an URI, doesn't have to be absolute but the principle of that argument passed to the parser, beside giving a name for the 'entity' (basically a file in XML terminology) is used to resolve URI-References done from within the XML content. Since we don't use any DTD, this should not affect parsing, but users might be tempted to add this for fun or validation, and that would not be wrong. Simply replacing the spaces by underscore in the string would be sufficient to make them correct URIs (I doubt %escape of the space would be any nicer for the users...) So in one hand, yes this makes sense, but I wonder if we shouldn't clean this up ... Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 09/14/2011 03:55 PM, Daniel Veillard wrote:
Considering the previous patch this one makes sense, but I realize that the string passed is supposed to be an URI, doesn't have to be absolute but the principle of that argument passed to the parser, beside giving a name for the 'entity' (basically a file in XML terminology) is used to resolve URI-References done from within the XML content. Since we don't use any DTD, this should not affect parsing, but users might be tempted to add this for fun or validation, and that would not be wrong. Simply replacing the spaces by underscore in the string would be sufficient to make them correct URIs (I doubt %escape of the space would be any nicer for the users...)
So in one hand, yes this makes sense, but I wonder if we shouldn't clean this up ...
I agree. Making them valid URI's and still telling the user: "I am not a file you should look for!" is a good approach and the underscores are a fine way to do it. v2 incomming. Peter
Daniel
participants (2)
-
Daniel Veillard
-
Peter Krempa