[libvirt] [PATCH 1/4] Fix error messages codes when TypeFromString fails

--- src/conf/cpu_conf.c | 4 +- src/conf/domain_conf.c | 100 ++++++++++++++++++----------------- src/conf/interface_conf.c | 2 +- src/conf/network_conf.c | 2 +- src/conf/node_device_conf.c | 4 +- src/conf/nwfilter_conf.c | 6 +- src/conf/secret_conf.c | 2 +- src/conf/storage_conf.c | 2 +- src/conf/storage_encryption_conf.c | 4 +- 9 files changed, 64 insertions(+), 62 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 98d598a..5b7b363 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -156,7 +156,7 @@ virCPUDefParseXML(const xmlNodePtr node, VIR_FREE(match); if (def->match < 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, + virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Invalid match attribute for CPU specification")); goto error; } @@ -257,7 +257,7 @@ virCPUDefParseXML(const xmlNodePtr node, VIR_FREE(strpolicy); if (policy < 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, + virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Invalid CPU feature policy")); goto error; } diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3298c80..e7e265c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1707,7 +1707,7 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, if (type) { if ((info->type = virDomainDeviceAddressTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown address type '%s'"), type); goto cleanup; } @@ -1914,7 +1914,7 @@ virDomainDiskDefParseXML(virCapsPtr caps, type = virXMLPropString(node, "type"); if (type) { if ((def->type = virDomainDiskTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk type '%s'"), type); goto error; } @@ -1947,7 +1947,7 @@ virDomainDiskDefParseXML(virCapsPtr caps, } def->protocol = virDomainDiskProtocolTypeFromString(protocol); if (def->protocol < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown protocol type '%s'"), protocol); goto error; @@ -2046,7 +2046,7 @@ virDomainDiskDefParseXML(virCapsPtr caps, device = virXMLPropString(node, "device"); if (device) { if ((def->device = virDomainDiskDeviceTypeFromString(device)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk device '%s'"), device); goto error; } @@ -2094,7 +2094,7 @@ virDomainDiskDefParseXML(virCapsPtr caps, if (bus) { if ((def->bus = virDomainDiskBusTypeFromString(bus)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk bus type '%s'"), bus); goto error; } @@ -2132,14 +2132,14 @@ virDomainDiskDefParseXML(virCapsPtr caps, if (cachetag && (def->cachemode = virDomainDiskCacheTypeFromString(cachetag)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk cache mode '%s'"), cachetag); goto error; } if (error_policy && (def->error_policy = virDomainDiskErrorPolicyTypeFromString(error_policy)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk error policy '%s'"), error_policy); goto error; } @@ -2147,7 +2147,7 @@ virDomainDiskDefParseXML(virCapsPtr caps, if (iotag) { if ((def->iomode = virDomainDiskIoTypeFromString(iotag)) < 0 || def->iomode == VIR_DOMAIN_DISK_IO_DEFAULT) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk io mode '%s'"), iotag); goto error; } @@ -2251,7 +2251,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, type = virXMLPropString(node, "type"); if (type) { if ((def->type = virDomainControllerTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown controller type '%s'"), type); goto error; } @@ -2269,7 +2269,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, model = virXMLPropString(node, "model"); if (model) { if ((def->model = virDomainControllerModelTypeFromString(model)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown model type '%s'"), model); goto error; } @@ -2359,7 +2359,7 @@ virDomainFSDefParseXML(xmlNodePtr node, type = virXMLPropString(node, "type"); if (type) { if ((def->type = virDomainFSTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown filesystem type '%s'"), type); goto error; } @@ -2370,7 +2370,7 @@ virDomainFSDefParseXML(xmlNodePtr node, accessmode = virXMLPropString(node, "accessmode"); if (accessmode) { if ((def->accessmode = virDomainFSAccessModeTypeFromString(accessmode)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown accessmode '%s'"), accessmode); goto error; } @@ -2622,7 +2622,7 @@ virDomainNetDefParseXML(virCapsPtr caps, type = virXMLPropString(node, "type"); if (type != NULL) { if ((int)(def->type = virDomainNetTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown interface type '%s'"), type); goto error; } @@ -2834,7 +2834,7 @@ virDomainNetDefParseXML(virCapsPtr caps, if (mode != NULL) { int m; if ((m = virDomainNetdevMacvtapTypeFromString(mode)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Unkown mode has been specified")); goto error; } @@ -2887,7 +2887,7 @@ virDomainNetDefParseXML(virCapsPtr caps, int name; if (((name = virDomainNetBackendTypeFromString(backend)) < 0) || (name == VIR_DOMAIN_NET_BACKEND_TYPE_DEFAULT)) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown interface <driver name='%s'> " "has been specified"), backend); @@ -2899,7 +2899,7 @@ virDomainNetDefParseXML(virCapsPtr caps, int m; if (((m = virDomainNetVirtioTxModeTypeFromString(txmode)) < 0) || (m == VIR_DOMAIN_NET_VIRTIO_TX_MODE_DEFAULT)) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown interface <driver txmode='%s'> " "has been specified"), txmode); @@ -3037,6 +3037,8 @@ virDomainChrDefParseTargetXML(virCapsPtr caps, if ((def->targetType = virDomainChrTargetTypeFromString(caps, def->deviceType, targetType)) < 0) { + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown type %s"), targetType); goto error; } @@ -3259,7 +3261,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, def->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW; else if ((def->data.tcp.protocol = virDomainChrTcpProtocolTypeFromString(protocol)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown protocol '%s'"), protocol); goto error; } @@ -3386,7 +3388,7 @@ virDomainChrDefParseXML(virCapsPtr caps, if (type == NULL) { def->source.type = VIR_DOMAIN_CHR_TYPE_PTY; } else if ((def->source.type = virDomainChrTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown type presented to host for character device: %s"), type); goto error; @@ -3394,7 +3396,7 @@ virDomainChrDefParseXML(virCapsPtr caps, nodeName = (const char *) node->name; if ((def->deviceType = virDomainChrDeviceTypeFromString(nodeName)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown character device type: %s"), nodeName); } @@ -3464,7 +3466,7 @@ virDomainSmartcardDefParseXML(xmlNodePtr node, goto error; } if ((def->type = virDomainSmartcardTypeFromString(mode)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown smartcard device mode: %s"), mode); goto error; @@ -3526,7 +3528,7 @@ virDomainSmartcardDefParseXML(xmlNodePtr node, goto error; } if ((def->data.passthru.type = virDomainChrTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown type presented to host for " "character device: %s"), type); goto error; @@ -3594,14 +3596,14 @@ virDomainInputDefParseXML(const char *ostype, } if ((def->type = virDomainInputTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown input device type '%s'"), type); goto error; } if (bus) { if ((def->bus = virDomainInputBusTypeFromString(bus)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown input bus type '%s'"), bus); goto error; } @@ -3691,7 +3693,7 @@ virDomainTimerDefParseXML(const xmlNodePtr node, goto error; } if ((def->name = virDomainTimerNameTypeFromString(name)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer name '%s'"), name); goto error; } @@ -3713,7 +3715,7 @@ virDomainTimerDefParseXML(const xmlNodePtr node, tickpolicy = virXMLPropString(node, "tickpolicy"); if (tickpolicy != NULL) { if ((def->tickpolicy = virDomainTimerTickpolicyTypeFromString(tickpolicy)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer tickpolicy '%s'"), tickpolicy); goto error; } @@ -3723,7 +3725,7 @@ virDomainTimerDefParseXML(const xmlNodePtr node, track = virXMLPropString(node, "track"); if (track != NULL) { if ((def->track = virDomainTimerTrackTypeFromString(track)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer track '%s'"), track); goto error; } @@ -3742,7 +3744,7 @@ virDomainTimerDefParseXML(const xmlNodePtr node, mode = virXMLPropString(node, "mode"); if (mode != NULL) { if ((def->mode = virDomainTimerModeTypeFromString(mode)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer mode '%s'"), mode); goto error; } @@ -3863,7 +3865,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) { } if ((def->type = virDomainGraphicsTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown graphics device type '%s'"), type); goto error; } @@ -4052,7 +4054,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) { } if ((nameval = virDomainGraphicsSpiceChannelNameTypeFromString(name)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown spice channel name %s"), name); VIR_FREE(name); @@ -4060,7 +4062,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) { goto error; } if ((modeval = virDomainGraphicsSpiceChannelModeTypeFromString(mode)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown spice channel mode %s"), mode); VIR_FREE(name); @@ -4187,7 +4189,7 @@ virDomainSoundDefParseXML(const xmlNodePtr node, model = virXMLPropString(node, "model"); if ((def->model = virDomainSoundModelTypeFromString(model)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown sound model '%s'"), model); goto error; } @@ -4229,7 +4231,7 @@ virDomainWatchdogDefParseXML(const xmlNodePtr node, } def->model = virDomainWatchdogModelTypeFromString (model); if (def->model < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown watchdog model '%s'"), model); goto error; } @@ -4240,7 +4242,7 @@ virDomainWatchdogDefParseXML(const xmlNodePtr node, else { def->action = virDomainWatchdogActionTypeFromString (action); if (def->action < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown watchdog action '%s'"), action); goto error; } @@ -4281,7 +4283,7 @@ virDomainMemballoonDefParseXML(const xmlNodePtr node, goto error; } if ((def->model = virDomainMemballoonModelTypeFromString(model)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown memory balloon model '%s'"), model); goto error; } @@ -4325,7 +4327,7 @@ virSysinfoParseXML(const xmlNodePtr node, goto error; } if ((def->type = virDomainSysinfoTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown sysinfo type '%s'"), type); goto error; } @@ -4502,13 +4504,13 @@ virDomainVideoDefParseXML(const xmlNodePtr node, if (type) { if ((def->type = virDomainVideoTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown video model '%s'"), type); goto error; } } else { if ((def->type = virDomainVideoDefaultType(dom)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("missing video model and cannot determine default")); goto error; } @@ -4516,7 +4518,7 @@ virDomainVideoDefParseXML(const xmlNodePtr node, if (vram) { if (virStrToLong_ui(vram, NULL, 10, &def->vram) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("cannot parse video ram '%s'"), vram); goto error; } @@ -4526,7 +4528,7 @@ virDomainVideoDefParseXML(const xmlNodePtr node, if (heads) { if (virStrToLong_ui(heads, NULL, 10, &def->heads) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("cannot parse video heads '%s'"), heads); goto error; } @@ -4739,7 +4741,7 @@ virDomainHostdevDefParseXML(const xmlNodePtr node, mode = virXMLPropString(node, "mode"); if (mode) { if ((def->mode=virDomainHostdevModeTypeFromString(mode)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown hostdev mode '%s'"), mode); goto error; } @@ -4750,7 +4752,7 @@ virDomainHostdevDefParseXML(const xmlNodePtr node, type = virXMLPropString(node, "type"); if (type) { if ((def->source.subsys.type = virDomainHostdevSubsysTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown host device type '%s'"), type); goto error; } @@ -4869,7 +4871,7 @@ virSecurityLabelDefParseXML(const virDomainDefPtr def, def->seclabel.type = virDomainSeclabelTypeFromString(p); VIR_FREE(p); if (def->seclabel.type < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("invalid security type")); goto error; } @@ -5290,7 +5292,7 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, goto cleanup; } if ((val = virDomainBootTypeFromString(dev)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown boot device '%s'"), dev); VIR_FREE(dev); @@ -5425,7 +5427,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, } if ((def->virtType = virDomainVirtTypeFromString(tmp)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid domain type %s"), tmp); goto error; } @@ -5597,7 +5599,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, for (i = 0 ; i < n ; i++) { int val = virDomainFeatureTypeFromString((const char *)nodes[i]->name); if (val < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unexpected feature %s"), nodes[i]->name); goto error; @@ -6239,7 +6241,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, int mode; if ((mode = virDomainSmbiosModeTypeFromString(tmp)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown smbios mode '%s'"), tmp); goto error; } @@ -6318,7 +6320,7 @@ static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps, goto error; } if ((state = virDomainStateTypeFromString(tmp)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid domain state '%s'"), tmp); VIR_FREE(tmp); goto error; @@ -9170,7 +9172,7 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr, } def->state = virDomainStateTypeFromString(state); if (def->state < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid state '%s' in domain snapshot XML"), state); goto cleanup; @@ -9521,7 +9523,7 @@ int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk, formatStr = "raw"; /* Xen compat */ if ((format = virStorageFileFormatTypeFromString(formatStr)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown disk format '%s' for %s"), disk->driverType, disk->src); return -1; diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index f3848bd..7e9c78f 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -689,7 +689,7 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) { } type = virInterfaceTypeFromString(tmp); if (type == -1) { - virInterfaceReportError(VIR_ERR_XML_ERROR, + virInterfaceReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown interface type %s"), tmp); VIR_FREE(tmp); return(NULL); diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index e4765ea..598d01f 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -674,7 +674,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) tmp = virXPathString("string(./forward[1]/@mode)", ctxt); if (tmp) { if ((def->forwardType = virNetworkForwardTypeFromString(tmp)) < 0) { - virNetworkReportError(VIR_ERR_INTERNAL_ERROR, + virNetworkReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown forwarding type '%s'"), tmp); VIR_FREE(tmp); goto error; diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index dde2921..1675631 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -826,7 +826,7 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt, int val = virNodeDevNetCapTypeFromString(tmp); VIR_FREE(tmp); if (val < 0) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, + virNodeDeviceReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid network type supplied for '%s'"), def->name); goto out; @@ -1076,7 +1076,7 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, } if ((val = virNodeDevCapTypeFromString(tmp)) < 0) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, + virNodeDeviceReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown capability type '%s'"), tmp); VIR_FREE(tmp); goto error; diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index a32bdb3..d493c77 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -1891,7 +1891,7 @@ virNWFilterRuleParse(xmlNodePtr node) } if ((ret->action = virNWFilterRuleActionTypeFromString(action)) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, + virNWFilterReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unknown rule action attribute value")); goto err_exit; @@ -1905,7 +1905,7 @@ virNWFilterRuleParse(xmlNodePtr node) } if ((ret->tt = virNWFilterRuleDirectionTypeFromString(direction)) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, + virNWFilterReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unknown rule direction attribute value")); goto err_exit; @@ -2004,7 +2004,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) { if (chain) { if ((ret->chainsuffix = virNWFilterChainSuffixTypeFromString(chain)) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, + virNWFilterReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown chain suffix '%s'"), chain); goto cleanup; } diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 105afbe..c8a8b85 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -74,7 +74,7 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt, } type = virSecretUsageTypeTypeFromString(type_str); if (type < 0) { - virSecretReportError(VIR_ERR_XML_ERROR, + virSecretReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown secret usage type %s"), type_str); VIR_FREE(type_str); return -1; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index ca86f19..5f94c01 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -627,7 +627,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) { type = virXPathString("string(./@type)", ctxt); if ((ret->type = virStoragePoolTypeFromString((const char *)type)) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, + virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown storage pool type %s"), (const char*)type); goto cleanup; } diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c index 545efad..0a4d8ba 100644 --- a/src/conf/storage_encryption_conf.c +++ b/src/conf/storage_encryption_conf.c @@ -94,7 +94,7 @@ virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt, } type = virStorageEncryptionSecretTypeTypeFromString(type_str); if (type < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, + virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown volume encryption secret type %s"), type_str); VIR_FREE(type_str); @@ -148,7 +148,7 @@ virStorageEncryptionParseXML(xmlXPathContextPtr ctxt) } format = virStorageEncryptionFormatTypeFromString(format_str); if (format < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, + virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown volume encryption format type %s"), format_str); VIR_FREE(format_str); -- 1.7.5.rc3

Up to now developers didn't know which error code to use, when invalid attribute/element value was given (e.g. string when expecting integer), something was missing, etc. This patch creates a new error code for cases like that. VIR_ERR_XML_ERROR should really be used when given XML is invalid, meaning bad syntax, or not well formed. --- include/libvirt/virterror.h | 1 + src/util/virterror.c | 6 ++++++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 0708e02..2f160c9 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -231,6 +231,7 @@ typedef enum { VIR_ERR_INVALID_DOMAIN_SNAPSHOT = 71,/* invalid domain snapshot */ VIR_ERR_NO_DOMAIN_SNAPSHOT = 72, /* domain snapshot not found */ VIR_ERR_INVALID_STREAM = 73, /* stream pointer not valid */ + VIR_ERR_XML_CONFIG = 74, /* invalid or not well formed input XML*/ } virErrorNumber; /** diff --git a/src/util/virterror.c b/src/util/virterror.c index 2d7309a..f044dc1 100644 --- a/src/util/virterror.c +++ b/src/util/virterror.c @@ -1205,6 +1205,12 @@ virErrorMsg(virErrorNumber error, const char *info) else errmsg = _("invalid stream pointer in %s"); break; + case VIR_ERR_XML_CONFIG: + if (info == NULL) + errmsg = _("XML parsing error: document not well formed or invalid"); + else + errmsg = _("XML parsing error: %s"); + break; } return (errmsg); } -- 1.7.5.rc3

--- src/conf/cpu_conf.c | 7 ++++--- src/conf/domain_conf.c | 12 ++++++++---- src/conf/interface_conf.c | 6 ++++-- src/conf/network_conf.c | 6 ++++-- src/conf/node_device_conf.c | 6 ++++-- src/conf/secret_conf.c | 6 ++++-- src/conf/storage_conf.c | 12 ++++++++---- src/security/virt-aa-helper.c | 3 ++- src/test/test_driver.c | 13 ++++++++++--- src/util/xml.c | 2 +- 10 files changed, 49 insertions(+), 24 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 5b7b363..56e1dd5 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -118,9 +118,10 @@ virCPUDefParseXML(const xmlNodePtr node, unsigned int i; if (!xmlStrEqual(node->name, BAD_CAST "cpu")) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", - _("XML does not contain expected 'cpu' element")); + virCPUReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s> " + "expecting to see <cpu>"), + node->name); return NULL; } diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e7e265c..2e620d6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6419,8 +6419,10 @@ virDomainDefPtr virDomainDefParseNode(virCapsPtr caps, virDomainDefPtr def = NULL; if (!xmlStrEqual(root->name, BAD_CAST "domain")) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("incorrect root element")); + virDomainReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s>, " + "expecting to see <domain>"), + root->name); goto cleanup; } @@ -6448,8 +6450,10 @@ virDomainObjParseNode(virCapsPtr caps, virDomainObjPtr obj = NULL; if (!xmlStrEqual(root->name, BAD_CAST "domstatus")) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("incorrect root element")); + virDomainReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s>, " + "expecting to see <domstatus>"), + root->name); goto cleanup; } diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 7e9c78f..ef8c9d4 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -838,8 +838,10 @@ virInterfaceDefPtr virInterfaceDefParseNode(xmlDocPtr xml, virInterfaceDefPtr def = NULL; if (!xmlStrEqual(root->name, BAD_CAST "interface")) { - virInterfaceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("incorrect root element")); + virInterfaceReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s>, " + "expecting to see <interface>"), + root->name); return NULL; } diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 598d01f..a79391d 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -731,8 +731,10 @@ virNetworkDefPtr virNetworkDefParseNode(xmlDocPtr xml, virNetworkDefPtr def = NULL; if (!xmlStrEqual(root->name, BAD_CAST "network")) { - virNetworkReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("incorrect root element")); + virNetworkReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s>, " + "expecting to see <network>"), + root->name); return NULL; } diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 1675631..aeca749 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1203,8 +1203,10 @@ virNodeDeviceDefParseNode(xmlDocPtr xml, virNodeDeviceDefPtr def = NULL; if (!xmlStrEqual(root->name, BAD_CAST "device")) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("incorrect root element")); + virNodeDeviceReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s>, " + "expecting to see <device>"), + root->name); return NULL; } diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index c8a8b85..407666a 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -112,8 +112,10 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) char *uuidstr = NULL; if (!xmlStrEqual(root->name, BAD_CAST "secret")) { - virSecretReportError(VIR_ERR_XML_ERROR, "%s", - _("incorrect root element")); + virSecretReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s>, " + "expecting to see <secret>"), + root->name); goto cleanup; } diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 5f94c01..da18350 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -747,8 +747,10 @@ virStoragePoolDefParseNode(xmlDocPtr xml, virStoragePoolDefPtr def = NULL; if (STRNEQ((const char *)root->name, "pool")) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("unknown root element for storage pool")); + virStorageReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s> " + "expecting to see <pool>"), + root->name); goto cleanup; } @@ -1127,8 +1129,10 @@ virStorageVolDefParseNode(virStoragePoolDefPtr pool, virStorageVolDefPtr def = NULL; if (STRNEQ((const char *)root->name, "volume")) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("unknown root element for storage vol")); + virStorageReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s> " + "expecting to see <volume>"), + root->name); goto cleanup; } diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 41ba4a3..994f83c 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -647,7 +647,8 @@ caps_mockup(vahControl * ctl, const char *xmlStr) root = xmlDocGetRootElement(xml); if (!xmlStrEqual(root->name, BAD_CAST "domain")) { - vah_error(NULL, 0, _("incorrect root element")); + vah_error(NULL, 0, _("unexpected root element <%s>, expecting to see " + "<domain>"), root->name)); goto cleanup; } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index eadd587..4524230 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -781,9 +781,16 @@ static int testOpenFromFile(virConnectPtr conn, } root = xmlDocGetRootElement(xml); - if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "node"))) { - testError(VIR_ERR_XML_ERROR, "%s", - _("Root element is not 'node'")); + if (root == NULL) { + testError(VIR_ERR_XML_CONFIG, "%s", + _("missing root element")); + goto error; + } + if (!xmlStrEqual(root->name, BAD_CAST "node")) { + testError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s> " + "expecting to see <node>"), + root->name); goto error; } diff --git a/src/util/xml.c b/src/util/xml.c index 05317ea..828bf00 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -700,7 +700,7 @@ virXMLParseHelper(int domcode, goto error; if (xmlDocGetRootElement(xml) == NULL) { - virGenericReportError(domcode, VIR_ERR_INTERNAL_ERROR, + virGenericReportError(domcode, VIR_ERR_XML_CONFIG, "%s", _("missing root element")); goto error; } -- 1.7.5.rc3

On 05/18/2011 11:47 AM, Michal Privoznik wrote:
--- src/conf/cpu_conf.c | 7 ++++--- src/conf/domain_conf.c | 12 ++++++++---- src/conf/interface_conf.c | 6 ++++-- src/conf/network_conf.c | 6 ++++-- src/conf/node_device_conf.c | 6 ++++-- src/conf/secret_conf.c | 6 ++++-- src/conf/storage_conf.c | 12 ++++++++---- src/security/virt-aa-helper.c | 3 ++- src/test/test_driver.c | 13 ++++++++++--- src/util/xml.c | 2 +- 10 files changed, 49 insertions(+), 24 deletions(-)
I think most of these error messages as well can be consolidated in virXMLParseFile. The caller can pass in the root element name, and virXMLParseFile can just do all this validation, and return a XPathContext pointer. If any caller needs the xmlDocPtr, it's stored in ctxt->doc. Thanks, Cole

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

On 05/18/2011 11:46 AM, Michal Privoznik wrote:
--- src/conf/cpu_conf.c | 4 +- src/conf/domain_conf.c | 100 ++++++++++++++++++----------------- src/conf/interface_conf.c | 2 +- src/conf/network_conf.c | 2 +- src/conf/node_device_conf.c | 4 +- src/conf/nwfilter_conf.c | 6 +- src/conf/secret_conf.c | 2 +- src/conf/storage_conf.c | 2 +- src/conf/storage_encryption_conf.c | 4 +- 9 files changed, 64 insertions(+), 62 deletions(-)
Maybe we should make ToString raise the error for us? The VIR_ENUM_DECL in domain_conf.h could pass in an error message like _("unknown CPU match value"), and virEnumToString could do the failure checking for us, append " '%s'", type Besides reducing code it would also make the error messages actually consistent. Thanks, Cole
participants (2)
-
Cole Robinson
-
Michal Privoznik