[libvirt] [PATCH 4/4] Change XML parsing error codes when details are presented.

Michal Privoznik mprivozn at redhat.com
Wed May 18 15:47:01 UTC 2011


Error messages which contain any additional info should be using
VIR_ERR_XML_CONFIG instead of VIR_ERR_XML_ERROR.
---
 src/conf/cpu_conf.c                |    2 +-
 src/conf/domain_conf.c             |   42 +++++++++++++++---------------
 src/conf/interface_conf.c          |   46 ++++++++++++++++----------------
 src/conf/network_conf.c            |   12 ++++----
 src/conf/nwfilter_conf.c           |    6 ++--
 src/conf/secret_conf.c             |    6 ++--
 src/conf/storage_conf.c            |   50 ++++++++++++++++++------------------
 src/conf/storage_encryption_conf.c |   10 +++---
 8 files changed, 87 insertions(+), 87 deletions(-)

diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 56e1dd5..1f42652 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -133,7 +133,7 @@ virCPUDefParseXML(const xmlNodePtr node,
     if (mode == VIR_CPU_TYPE_AUTO) {
         if (virXPathBoolean("boolean(./arch)", ctxt)) {
             if (virXPathBoolean("boolean(./@match)", ctxt)) {
-                virCPUReportError(VIR_ERR_XML_ERROR, "%s",
+                virCPUReportError(VIR_ERR_XML_CONFIG, "%s",
                         _("'arch' element element cannot be used inside 'cpu'"
                           " element with 'match' attribute'"));
                 goto error;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2e620d6..799c5b1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2928,7 +2928,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
     if (ret >= 0) {
         def->tune.sndbuf_specified = true;
     } else if (ret == -2) {
-        virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+        virDomainReportError(VIR_ERR_XML_CONFIG, "%s",
                              _("sndbuf must be a positive integer"));
         goto error;
     }
@@ -2968,7 +2968,7 @@ virDomainChrDefaultTargetType(virCapsPtr caps, int devtype) {
 
     switch (devtype) {
     case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL:
-        virDomainReportError(VIR_ERR_XML_ERROR,
+        virDomainReportError(VIR_ERR_XML_CONFIG,
                              _("target type must be specified for %s device"),
                              virDomainChrDeviceTypeToString(devtype));
         break;
@@ -3050,7 +3050,7 @@ virDomainChrDefParseTargetXML(virCapsPtr caps,
             portStr = virXMLPropString(cur, "port");
 
             if (addrStr == NULL) {
-                virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+                virDomainReportError(VIR_ERR_XML_CONFIG, "%s",
                                      _("guestfwd channel does not "
                                        "define a target address"));
                 goto error;
@@ -3072,14 +3072,14 @@ virDomainChrDefParseTargetXML(virCapsPtr caps,
             }
 
             if (portStr == NULL) {
-                virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+                virDomainReportError(VIR_ERR_XML_CONFIG, "%s",
                                      _("guestfwd channel does "
                                        "not define a target port"));
                 goto error;
             }
 
             if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) {
-                virDomainReportError(VIR_ERR_XML_ERROR,
+                virDomainReportError(VIR_ERR_XML_CONFIG,
                                      _("Invalid port number: %s"),
                                      portStr);
                 goto error;
@@ -3103,7 +3103,7 @@ virDomainChrDefParseTargetXML(virCapsPtr caps,
         }
 
         if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) {
-            virDomainReportError(VIR_ERR_XML_ERROR,
+            virDomainReportError(VIR_ERR_XML_CONFIG,
                                  _("Invalid port number: %s"),
                                  portStr);
             goto error;
@@ -3461,7 +3461,7 @@ virDomainSmartcardDefParseXML(xmlNodePtr node,
 
     mode = virXMLPropString(node, "mode");
     if (mode == NULL) {
-        virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+        virDomainReportError(VIR_ERR_XML_CONFIG, "%s",
                              _("missing smartcard device mode"));
         goto error;
     }
@@ -3483,7 +3483,7 @@ virDomainSmartcardDefParseXML(xmlNodePtr node,
             if (cur->type == XML_ELEMENT_NODE &&
                 xmlStrEqual(cur->name, BAD_CAST "certificate")) {
                 if (i == 3) {
-                    virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+                    virDomainReportError(VIR_ERR_XML_CONFIG, "%s",
                                          _("host-certificates mode needs "
                                            "exactly three certificates"));
                     goto error;
@@ -3503,7 +3503,7 @@ virDomainSmartcardDefParseXML(xmlNodePtr node,
                     goto error;
                 }
                 if (*def->data.cert.database != '/') {
-                    virDomainReportError(VIR_ERR_XML_ERROR,
+                    virDomainReportError(VIR_ERR_XML_CONFIG,
                                          _("expecting absolute path: %s"),
                                          def->data.cert.database);
                     goto error;
@@ -3512,7 +3512,7 @@ virDomainSmartcardDefParseXML(xmlNodePtr node,
             cur = cur->next;
         }
         if (i < 3) {
-            virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+            virDomainReportError(VIR_ERR_XML_CONFIG, "%s",
                                  _("host-certificates mode needs "
                                    "exactly three certificates"));
             goto error;
@@ -3522,7 +3522,7 @@ virDomainSmartcardDefParseXML(xmlNodePtr node,
     case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
         type = virXMLPropString(node, "type");
         if (type == NULL) {
-            virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+            virDomainReportError(VIR_ERR_XML_CONFIG, "%s",
                                  _("passthrough mode requires a character "
                                    "device type attribute"));
             goto error;
@@ -4310,7 +4310,7 @@ virSysinfoParseXML(const xmlNodePtr node,
     char *type;
 
     if (!xmlStrEqual(node->name, BAD_CAST "sysinfo")) {
-        virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+        virDomainReportError(VIR_ERR_XML_CONFIG, "%s",
                         _("XML does not contain expected 'sysinfo' element"));
         return(NULL);
     }
@@ -4864,7 +4864,7 @@ virSecurityLabelDefParseXML(const virDomainDefPtr def,
     p = virXPathStringLimit("string(./seclabel/@type)",
                             VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
     if (p == NULL) {
-        virDomainReportError(VIR_ERR_XML_ERROR,
+        virDomainReportError(VIR_ERR_XML_CONFIG,
                              "%s", _("missing security type"));
         goto error;
     }
@@ -4884,7 +4884,7 @@ virSecurityLabelDefParseXML(const virDomainDefPtr def,
         p = virXPathStringLimit("string(./seclabel/@model)",
                                 VIR_SECURITY_MODEL_BUFLEN-1, ctxt);
         if (p == NULL) {
-            virDomainReportError(VIR_ERR_XML_ERROR,
+            virDomainReportError(VIR_ERR_XML_CONFIG,
                                  "%s", _("missing security model"));
             goto error;
         }
@@ -4893,7 +4893,7 @@ virSecurityLabelDefParseXML(const virDomainDefPtr def,
         p = virXPathStringLimit("string(./seclabel/label[1])",
                                 VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
         if (p == NULL) {
-            virDomainReportError(VIR_ERR_XML_ERROR,
+            virDomainReportError(VIR_ERR_XML_CONFIG,
                                  "%s", _("security label is missing"));
             goto error;
         }
@@ -4907,7 +4907,7 @@ virSecurityLabelDefParseXML(const virDomainDefPtr def,
         p = virXPathStringLimit("string(./seclabel/imagelabel[1])",
                                 VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
         if (p == NULL) {
-            virDomainReportError(VIR_ERR_XML_ERROR,
+            virDomainReportError(VIR_ERR_XML_CONFIG,
                                  "%s", _("security imagelabel is missing"));
             goto error;
         }
@@ -4993,7 +4993,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
         if (!(dev->data.graphics = virDomainGraphicsDefParseXML(node, flags)))
             goto error;
     } else {
-        virDomainReportError(VIR_ERR_XML_ERROR,
+        virDomainReportError(VIR_ERR_XML_CONFIG,
                              "%s", _("unknown device type"));
         goto error;
     }
@@ -5502,7 +5502,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
 
     n = virXPathULong("string(./vcpu[1])", ctxt, &count);
     if (n == -2) {
-        virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+        virDomainReportError(VIR_ERR_XML_CONFIG, "%s",
                              _("maximum vcpus must be an integer"));
         goto error;
     } else if (n < 0) {
@@ -5510,7 +5510,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
     } else {
         def->maxvcpus = count;
         if (count == 0) {
-            virDomainReportError(VIR_ERR_XML_ERROR,
+            virDomainReportError(VIR_ERR_XML_CONFIG,
                                  _("invalid maxvcpus %lu"), count);
             goto error;
         }
@@ -5518,7 +5518,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
 
     n = virXPathULong("string(./vcpu[1]/@current)", ctxt, &count);
     if (n == -2) {
-        virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+        virDomainReportError(VIR_ERR_XML_CONFIG, "%s",
                              _("current vcpus must be an integer"));
         goto error;
     } else if (n < 0) {
@@ -5526,7 +5526,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
     } else {
         def->vcpus = count;
         if (count == 0) {
-            virDomainReportError(VIR_ERR_XML_ERROR,
+            virDomainReportError(VIR_ERR_XML_CONFIG,
                                  _("invalid current vcpus %lu"), count);
             goto error;
         }
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index ef8c9d4..b3b8584 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -122,7 +122,7 @@ virInterfaceDefParseName(virInterfaceDefPtr def,
 
     tmp = virXPathString("string(./@name)", ctxt);
     if (tmp == NULL) {
-        virInterfaceReportError(VIR_ERR_XML_ERROR,
+        virInterfaceReportError(VIR_ERR_XML_CONFIG,
                                 "%s",  _("interface has no name"));
         return(-1);
     }
@@ -138,7 +138,7 @@ virInterfaceDefParseMtu(virInterfaceDefPtr def,
 
     ret = virXPathULong("string(./mtu/@size)", ctxt, &mtu);
     if ((ret == -2) || ((ret == 0) && (mtu > 100000))) {
-        virInterfaceReportError(VIR_ERR_XML_ERROR,
+        virInterfaceReportError(VIR_ERR_XML_CONFIG,
                          "%s", _("interface mtu value is improper"));
         return(-1);
     } else if (ret == 0) {
@@ -162,7 +162,7 @@ virInterfaceDefParseStartMode(virInterfaceDefPtr def,
     else if (STREQ(tmp, "none"))
         def->startmode = VIR_INTERFACE_START_NONE;
     else {
-        virInterfaceReportError(VIR_ERR_XML_ERROR,
+        virInterfaceReportError(VIR_ERR_XML_CONFIG,
                                 _("unknown interface startmode %s"), tmp);
         VIR_FREE(tmp);
         return(-1);
@@ -194,7 +194,7 @@ virInterfaceDefParseBondMode(xmlXPathContextPtr ctxt) {
     else if (STREQ(tmp, "balance-alb"))
         ret = VIR_INTERFACE_BOND_BALALB;
     else {
-        virInterfaceReportError(VIR_ERR_XML_ERROR,
+        virInterfaceReportError(VIR_ERR_XML_CONFIG,
                                 _("unknown bonding mode %s"), tmp);
         ret = -1;
     }
@@ -215,7 +215,7 @@ virInterfaceDefParseBondMiiCarrier(xmlXPathContextPtr ctxt) {
     else if (STREQ(tmp, "netif"))
         ret = VIR_INTERFACE_BOND_MII_NETIF;
     else {
-        virInterfaceReportError(VIR_ERR_XML_ERROR,
+        virInterfaceReportError(VIR_ERR_XML_CONFIG,
                                 _("unknown mii bonding carrier %s"), tmp);
         ret = -1;
     }
@@ -238,7 +238,7 @@ virInterfaceDefParseBondArpValid(xmlXPathContextPtr ctxt) {
     else if (STREQ(tmp, "all"))
         ret = VIR_INTERFACE_BOND_ARP_ALL;
     else {
-        virInterfaceReportError(VIR_ERR_XML_ERROR,
+        virInterfaceReportError(VIR_ERR_XML_CONFIG,
                                 _("unknown arp bonding validate %s"), tmp);
         ret = -1;
     }
@@ -264,7 +264,7 @@ virInterfaceDefParseDhcp(virInterfaceProtocolDefPtr def,
         else if (STREQ(tmp, "no"))
             def->peerdns = 0;
         else {
-            virInterfaceReportError(VIR_ERR_XML_ERROR,
+            virInterfaceReportError(VIR_ERR_XML_CONFIG,
                               _("unknown dhcp peerdns value %s"), tmp);
             ret = -1;
         }
@@ -290,7 +290,7 @@ virInterfaceDefParseIp(virInterfaceIpDefPtr def,
         if (ret == 0)
             def->prefix = (int) l;
         else if (ret == -2) {
-            virInterfaceReportError(VIR_ERR_XML_ERROR,
+            virInterfaceReportError(VIR_ERR_XML_CONFIG,
                               "%s", _("Invalid ip address prefix value"));
             return(-1);
         }
@@ -450,7 +450,7 @@ virInterfaceDefParseIfAdressing(virInterfaceDefPtr def,
         ctxt->node = protoNodes[pp];
         tmp = virXPathString("string(./@family)", ctxt);
         if (tmp == NULL) {
-            virInterfaceReportError(VIR_ERR_XML_ERROR,
+            virInterfaceReportError(VIR_ERR_XML_CONFIG,
                                     "%s", _("protocol misses the family attribute"));
             virInterfaceProtocolDefFree(proto);
             goto error;
@@ -469,7 +469,7 @@ virInterfaceDefParseIfAdressing(virInterfaceDefPtr def,
                 goto error;
             }
         } else {
-            virInterfaceReportError(VIR_ERR_XML_ERROR,
+            virInterfaceReportError(VIR_ERR_XML_CONFIG,
                                     _("unsupported protocol family '%s'"), tmp);
             virInterfaceProtocolDefFree(proto);
             goto error;
@@ -592,7 +592,7 @@ virInterfaceDefParseBond(virInterfaceDefPtr def,
 
         ret = virXPathULong("string(./miimon/@freq)", ctxt, &tmp);
         if ((ret == -2) || (ret == -1)) {
-            virInterfaceReportError(VIR_ERR_XML_ERROR,
+            virInterfaceReportError(VIR_ERR_XML_CONFIG,
                      "%s", _("bond interface miimon freq missing or invalid"));
             goto error;
         }
@@ -600,7 +600,7 @@ virInterfaceDefParseBond(virInterfaceDefPtr def,
 
         ret = virXPathULong("string(./miimon/@downdelay)", ctxt, &tmp);
         if (ret == -2) {
-            virInterfaceReportError(VIR_ERR_XML_ERROR,
+            virInterfaceReportError(VIR_ERR_XML_CONFIG,
                      "%s", _("bond interface miimon downdelay invalid"));
             goto error;
         } else if (ret == 0) {
@@ -609,7 +609,7 @@ virInterfaceDefParseBond(virInterfaceDefPtr def,
 
         ret = virXPathULong("string(./miimon/@updelay)", ctxt, &tmp);
         if (ret == -2) {
-            virInterfaceReportError(VIR_ERR_XML_ERROR,
+            virInterfaceReportError(VIR_ERR_XML_CONFIG,
                      "%s", _("bond interface miimon updelay invalid"));
             goto error;
         } else if (ret == 0) {
@@ -628,7 +628,7 @@ virInterfaceDefParseBond(virInterfaceDefPtr def,
 
         ret = virXPathULong("string(./arpmon/@interval)", ctxt, &tmp);
         if ((ret == -2) || (ret == -1)) {
-            virInterfaceReportError(VIR_ERR_XML_ERROR,
+            virInterfaceReportError(VIR_ERR_XML_CONFIG,
                  "%s", _("bond interface arpmon interval missing or invalid"));
             goto error;
         }
@@ -637,7 +637,7 @@ virInterfaceDefParseBond(virInterfaceDefPtr def,
         def->data.bond.target =
             virXPathString("string(./arpmon/@target)", ctxt);
         if (def->data.bond.target == NULL) {
-            virInterfaceReportError(VIR_ERR_XML_ERROR,
+            virInterfaceReportError(VIR_ERR_XML_CONFIG,
                  "%s", _("bond interface arpmon target missing"));
             ret = -1;
             goto error;
@@ -658,7 +658,7 @@ virInterfaceDefParseVlan(virInterfaceDefPtr def,
                          xmlXPathContextPtr ctxt) {
     def->data.vlan.tag = virXPathString("string(./@tag)", ctxt);
     if (def->data.vlan.tag == NULL) {
-        virInterfaceReportError(VIR_ERR_XML_ERROR,
+        virInterfaceReportError(VIR_ERR_XML_CONFIG,
                     "%s", _("vlan interface misses the tag attribute"));
         return(-1);
     }
@@ -666,7 +666,7 @@ virInterfaceDefParseVlan(virInterfaceDefPtr def,
     def->data.vlan.devname =
          virXPathString("string(./interface/@name)", ctxt);
     if (def->data.vlan.devname == NULL) {
-        virInterfaceReportError(VIR_ERR_XML_ERROR,
+        virInterfaceReportError(VIR_ERR_XML_CONFIG,
                     "%s", _("vlan interface misses name attribute"));
         return(-1);
     }
@@ -683,7 +683,7 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) {
     /* check @type */
     tmp = virXPathString("string(./@type)", ctxt);
     if (tmp == NULL) {
-        virInterfaceReportError(VIR_ERR_XML_ERROR,
+        virInterfaceReportError(VIR_ERR_XML_CONFIG,
                                 "%s", _("interface misses the type attribute"));
         return(NULL);
     }
@@ -710,7 +710,7 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) {
         || (parentIfType == VIR_INTERFACE_TYPE_ETHERNET)
         || (parentIfType == VIR_INTERFACE_TYPE_VLAN))
         {
-        virInterfaceReportError(VIR_ERR_XML_ERROR,
+        virInterfaceReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                 _("interface has unsupported type '%s'"),
                                 virInterfaceTypeToString(type));
         goto error;
@@ -747,7 +747,7 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) {
 
             bridge = virXPathNode("./bridge[1]", ctxt);
             if (bridge == NULL) {
-                virInterfaceReportError(VIR_ERR_XML_ERROR,
+                virInterfaceReportError(VIR_ERR_XML_CONFIG,
                                         "%s", _("bridge interface misses the bridge element"));
                 goto error;
             }
@@ -759,7 +759,7 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) {
                 } else if (STREQ(tmp, "off")) {
                     def->data.bridge.stp = 0;
                 } else {
-                    virInterfaceReportError(VIR_ERR_XML_ERROR,
+                    virInterfaceReportError(VIR_ERR_XML_CONFIG,
                           _("bridge interface stp should be on or off got %s"),
                                             tmp);
                     VIR_FREE(tmp);
@@ -789,7 +789,7 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) {
 
             bond = virXPathNode("./bond[1]", ctxt);
             if (bond == NULL) {
-                virInterfaceReportError(VIR_ERR_XML_ERROR,
+                virInterfaceReportError(VIR_ERR_XML_CONFIG,
                             "%s", _("bond interface misses the bond element"));
                 goto error;
             }
@@ -810,7 +810,7 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) {
                 goto error;
             vlan = virXPathNode("./vlan[1]", ctxt);
             if (vlan == NULL) {
-                virInterfaceReportError(VIR_ERR_XML_ERROR,
+                virInterfaceReportError(VIR_ERR_XML_CONFIG,
                             "%s", _("vlan interface misses the vlan element"));
                 goto error;
             }
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index a79391d..aff0e98 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -333,7 +333,7 @@ virNetworkDHCPRangeDefParseXML(const char *networkName,
 
             range = virSocketGetRange(&saddr, &eaddr);
             if (range < 0) {
-                virNetworkReportError(VIR_ERR_XML_ERROR,
+                virNetworkReportError(VIR_ERR_XML_CONFIG,
                                       _("Invalid dhcp range '%s' to '%s' in network '%s'"),
                                       start, end, networkName);
                 VIR_FREE(start);
@@ -375,7 +375,7 @@ virNetworkDHCPRangeDefParseXML(const char *networkName,
              * You need at least one MAC address or one host name
              */
             if ((mac == NULL) && (name == NULL)) {
-                virNetworkReportError(VIR_ERR_XML_ERROR,
+                virNetworkReportError(VIR_ERR_XML_CONFIG,
                                       _("Static host definition in network '%s' must have mac or name attribute"),
                                       networkName);
                 return -1;
@@ -383,7 +383,7 @@ virNetworkDHCPRangeDefParseXML(const char *networkName,
             ip = virXMLPropString(cur, "ip");
             if ((ip == NULL) ||
                 (virSocketParseAddr(ip, &inaddr, AF_UNSPEC) < 0)) {
-                virNetworkReportError(VIR_ERR_XML_ERROR,
+                virNetworkReportError(VIR_ERR_XML_CONFIG,
                                       _("Missing IP address in static host definition for network '%s'"),
                                       networkName);
                 VIR_FREE(ip);
@@ -465,7 +465,7 @@ virNetworkIPParseXML(const char *networkName,
 
     if (address) {
         if (virSocketParseAddr(address, &def->address, AF_UNSPEC) < 0) {
-            virNetworkReportError(VIR_ERR_XML_ERROR,
+            virNetworkReportError(VIR_ERR_XML_CONFIG,
                                   _("Bad address '%s' in definition of network '%s'"),
                                   address, networkName);
             goto error;
@@ -497,7 +497,7 @@ virNetworkIPParseXML(const char *networkName,
             goto error;
         }
     } else {
-        virNetworkReportError(VIR_ERR_XML_ERROR,
+        virNetworkReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                               _("Unrecognized family '%s' in definition of network '%s'"),
                               def->family, networkName);
         goto error;
@@ -631,7 +631,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
     tmp = virXPathString("string(./mac[1]/@address)", ctxt);
     if (tmp) {
         if (virParseMacAddr(tmp, def->mac) < 0) {
-            virNetworkReportError(VIR_ERR_XML_ERROR,
+            virNetworkReportError(VIR_ERR_XML_CONFIG,
                                   _("Invalid bridge mac address '%s' in network '%s'"),
                                   tmp, def->name);
             VIR_FREE(tmp);
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index d493c77..5e9f6d0 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2019,7 +2019,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) {
         }
     } else {
         if (virUUIDParse(uuid, ret->uuid) < 0) {
-            virNWFilterReportError(VIR_ERR_XML_ERROR,
+            virNWFilterReportError(VIR_ERR_XML_CONFIG,
                                   "%s", _("malformed uuid element"));
             goto cleanup;
         }
@@ -2073,7 +2073,7 @@ virNWFilterDefParseNode(xmlDocPtr xml,
     virNWFilterDefPtr def = NULL;
 
     if (STRNEQ((const char *)root->name, "filter")) {
-        virNWFilterReportError(VIR_ERR_XML_ERROR,
+        virNWFilterReportError(VIR_ERR_XML_CONFIG,
                                "%s",
                                _("unknown root element for nw filter"));
         goto cleanup;
@@ -2478,7 +2478,7 @@ virNWFilterObjLoad(virConnectPtr conn,
     }
 
     if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
-        virNWFilterReportError(VIR_ERR_XML_ERROR,
+        virNWFilterReportError(VIR_ERR_XML_CONFIG,
             _("network filter config filename '%s' does not match name '%s'"),
             path, def->name);
         virNWFilterDefFree(def);
diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c
index 407666a..d6df176 100644
--- a/src/conf/secret_conf.c
+++ b/src/conf/secret_conf.c
@@ -68,7 +68,7 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt,
 
     type_str = virXPathString("string(./usage/@type)", ctxt);
     if (type_str == NULL) {
-        virSecretReportError(VIR_ERR_XML_ERROR, "%s",
+        virSecretReportError(VIR_ERR_XML_CONFIG, "%s",
                              _("unknown secret usage type"));
         return -1;
     }
@@ -138,7 +138,7 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root)
         else if (STREQ(prop, "no"))
             def->ephemeral = 0;
         else {
-            virSecretReportError(VIR_ERR_XML_ERROR, "%s",
+            virSecretReportError(VIR_ERR_XML_CONFIG, "%s",
                                  _("invalid value of 'ephemeral'"));
             goto cleanup;
         }
@@ -152,7 +152,7 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root)
         else if (STREQ(prop, "no"))
             def->private = 0;
         else {
-            virSecretReportError(VIR_ERR_XML_ERROR, "%s",
+            virSecretReportError(VIR_ERR_XML_CONFIG, "%s",
                                  _("invalid value of 'private'"));
             goto cleanup;
         }
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index da18350..2c595dd 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -371,14 +371,14 @@ virStoragePoolDefParseAuthChap(xmlXPathContextPtr ctxt,
                                virStoragePoolAuthChapPtr auth) {
     auth->login = virXPathString("string(./auth/@login)", ctxt);
     if (auth->login == NULL) {
-        virStorageReportError(VIR_ERR_XML_ERROR,
+        virStorageReportError(VIR_ERR_XML_CONFIG,
                               "%s", _("missing auth host attribute"));
         return -1;
     }
 
     auth->passwd = virXPathString("string(./auth/@passwd)", ctxt);
     if (auth->passwd == NULL) {
-        virStorageReportError(VIR_ERR_XML_ERROR,
+        virStorageReportError(VIR_ERR_XML_CONFIG,
                               "%s", _("missing auth passwd attribute"));
         return -1;
     }
@@ -415,7 +415,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
             source->format = options->formatFromString(format);
 
         if (source->format < 0) {
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                   _("unknown pool format type %s"), format);
             VIR_FREE(format);
             goto cleanup;
@@ -427,7 +427,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
     port = virXPathString("string(./host/@port)", ctxt);
     if (port) {
         if (virStrToLong_i(port, NULL, 10, &source->host.port) < 0) {
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_XML_CONFIG,
                                   _("Invalid port number: %s"),
                                   port);
             goto cleanup;
@@ -452,7 +452,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
             char *path = virXMLPropString(nodeset[i], "path");
             if (path == NULL) {
                 VIR_FREE(nodeset);
-                virStorageReportError(VIR_ERR_XML_ERROR,
+                virStorageReportError(VIR_ERR_XML_CONFIG,
                         "%s", _("missing storage pool source device path"));
                 goto cleanup;
             }
@@ -471,7 +471,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
         if (STREQ(authType, "chap")) {
             source->authType = VIR_STORAGE_POOL_AUTH_CHAP;
         } else {
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                   _("unknown auth type '%s'"),
                                   (const char *)authType);
             goto cleanup;
@@ -522,7 +522,7 @@ virStoragePoolDefParseSourceString(const char *srcSpec,
 
     node = virXPathNode("/source", xpath_ctxt);
     if (!node) {
-        virStorageReportError(VIR_ERR_XML_ERROR,
+        virStorageReportError(VIR_ERR_XML_CONFIG,
                               "%s", _("root element was not source"));
         goto cleanup;
     }
@@ -573,7 +573,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
         perms->mode = strtol(mode, &end, 8);
         if (*end || perms->mode < 0 || perms->mode > 0777) {
             VIR_FREE(mode);
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_XML_CONFIG,
                                   "%s", _("malformed octal mode"));
             goto error;
         }
@@ -584,7 +584,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
         perms->uid = -1;
     } else {
         if (virXPathLong("number(./owner)", ctxt, &v) < 0) {
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_XML_CONFIG,
                                   "%s", _("malformed owner element"));
             goto error;
         }
@@ -595,7 +595,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
         perms->gid = -1;
     } else {
         if (virXPathLong("number(./group)", ctxt, &v) < 0) {
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_XML_CONFIG,
                                   "%s", _("malformed group element"));
             goto error;
         }
@@ -651,7 +651,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) {
         options->flags & VIR_STORAGE_POOL_SOURCE_NAME)
         ret->name = ret->source.name;
     if (ret->name == NULL) {
-        virStorageReportError(VIR_ERR_XML_ERROR,
+        virStorageReportError(VIR_ERR_XML_CONFIG,
                               "%s", _("missing pool source name element"));
         goto cleanup;
     }
@@ -665,7 +665,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) {
         }
     } else {
         if (virUUIDParse(uuid, ret->uuid) < 0) {
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_XML_CONFIG,
                                   "%s", _("malformed uuid element"));
             goto cleanup;
         }
@@ -674,7 +674,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) {
 
     if (options->flags & VIR_STORAGE_POOL_SOURCE_HOST) {
         if (!ret->source.host.name) {
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_XML_CONFIG,
                                   "%s",
                                   _("missing storage pool source host name"));
             goto cleanup;
@@ -683,7 +683,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) {
 
     if (options->flags & VIR_STORAGE_POOL_SOURCE_DIR) {
         if (!ret->source.dir) {
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_XML_CONFIG,
                                   "%s", _("missing storage pool source path"));
             goto cleanup;
         }
@@ -701,7 +701,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) {
 
     if (options->flags & VIR_STORAGE_POOL_SOURCE_ADAPTER) {
         if (!ret->source.adapter) {
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_XML_CONFIG,
                                   "%s", _("missing storage pool source adapter name"));
             goto cleanup;
         }
@@ -710,14 +710,14 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) {
     /* If DEVICE is the only source type, then its required */
     if (options->flags == VIR_STORAGE_POOL_SOURCE_DEVICE) {
         if (!ret->source.ndevice) {
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_XML_CONFIG,
                                   "%s", _("missing storage pool source device name"));
             goto cleanup;
         }
     }
 
     if ((tmppath = virXPathString("string(./target/path)", ctxt)) == NULL) {
-        virStorageReportError(VIR_ERR_XML_ERROR,
+        virStorageReportError(VIR_ERR_XML_CONFIG,
                               "%s", _("missing storage pool target path"));
         goto cleanup;
     }
@@ -985,19 +985,19 @@ virStorageSize(const char *unit,
             break;
 
         default:
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_XML_CONFIG,
                                   _("unknown size units '%s'"), unit);
             return -1;
         }
     }
 
     if (virStrToLong_ull (val, &end, 10, ret) < 0) {
-        virStorageReportError(VIR_ERR_XML_ERROR,
+        virStorageReportError(VIR_ERR_XML_CONFIG,
                               "%s", _("malformed capacity element"));
         return -1;
     }
     if (*ret > (ULLONG_MAX / mult)) {
-        virStorageReportError(VIR_ERR_XML_ERROR,
+        virStorageReportError(VIR_ERR_XML_CONFIG,
                               "%s", _("capacity element value too large"));
             return -1;
     }
@@ -1028,7 +1028,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
 
     ret->name = virXPathString("string(./name)", ctxt);
     if (ret->name == NULL) {
-        virStorageReportError(VIR_ERR_XML_ERROR,
+        virStorageReportError(VIR_ERR_XML_CONFIG,
                               "%s", _("missing volume name element"));
         goto cleanup;
     }
@@ -1039,7 +1039,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
     capacity = virXPathString("string(./capacity)", ctxt);
     unit = virXPathString("string(./capacity/@unit)", ctxt);
     if (capacity == NULL) {
-        virStorageReportError(VIR_ERR_XML_ERROR,
+        virStorageReportError(VIR_ERR_XML_CONFIG,
                               "%s", _("missing capacity element"));
         goto cleanup;
     }
@@ -1068,7 +1068,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
             ret->target.format = (options->formatFromString)(format);
 
         if (ret->target.format < 0) {
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                   _("unknown volume format type %s"), format);
             VIR_FREE(format);
             goto cleanup;
@@ -1099,7 +1099,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
             ret->backingStore.format = (options->formatFromString)(format);
 
         if (ret->backingStore.format < 0) {
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                   _("unknown volume format type %s"), format);
             VIR_FREE(format);
             goto cleanup;
@@ -1424,7 +1424,7 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools,
     }
 
     if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
-        virStorageReportError(VIR_ERR_XML_ERROR,
+        virStorageReportError(VIR_ERR_XML_CONFIG,
                               _("Storage pool config filename '%s' does not match pool name '%s'"),
                               path, def->name);
         virStoragePoolDefFree(def);
diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c
index 0a4d8ba..ea43683 100644
--- a/src/conf/storage_encryption_conf.c
+++ b/src/conf/storage_encryption_conf.c
@@ -88,7 +88,7 @@ virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt,
 
     type_str = virXPathString("string(./@type)", ctxt);
     if (type_str == NULL) {
-        virStorageReportError(VIR_ERR_XML_ERROR, "%s",
+        virStorageReportError(VIR_ERR_XML_CONFIG, "%s",
                               _("unknown volume encryption secret type"));
         goto cleanup;
     }
@@ -106,14 +106,14 @@ virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt,
     uuidstr = virXPathString("string(./@uuid)", ctxt);
     if (uuidstr) {
         if (virUUIDParse(uuidstr, ret->uuid) < 0) {
-            virStorageReportError(VIR_ERR_XML_ERROR,
+            virStorageReportError(VIR_ERR_XML_CONFIG,
                                   _("malformed volume encryption uuid '%s'"),
                                   uuidstr);
             goto cleanup;
         }
         VIR_FREE(uuidstr);
     } else {
-        virStorageReportError(VIR_ERR_XML_ERROR, "%s",
+        virStorageReportError(VIR_ERR_XML_CONFIG, "%s",
                               _("missing volume encryption uuid"));
         goto cleanup;
     }
@@ -142,7 +142,7 @@ virStorageEncryptionParseXML(xmlXPathContextPtr ctxt)
 
     format_str = virXPathString("string(./@format)", ctxt);
     if (format_str == NULL) {
-        virStorageReportError(VIR_ERR_XML_ERROR, "%s",
+        virStorageReportError(VIR_ERR_XML_CONFIG, "%s",
                               _("unknown volume encryption format"));
         goto cleanup;
     }
@@ -188,7 +188,7 @@ virStorageEncryptionParseNode(xmlDocPtr xml, xmlNodePtr root)
     virStorageEncryptionPtr enc = NULL;
 
     if (STRNEQ((const char *) root->name, "encryption")) {
-        virStorageReportError(VIR_ERR_XML_ERROR,
+        virStorageReportError(VIR_ERR_XML_CONFIG,
                               "%s", _("unknown root element for volume "
                                       "encryption information"));
         goto cleanup;
-- 
1.7.5.rc3




More information about the libvir-list mailing list