[libvirt] [PATCH 0/4] Unify error messages

As libvirt error codes evolved over time, it was more unclear to know, which code should be use in what cases. This patch series tries to correct those places, so we don't say it is internal error, when in fact incorrect XML was given. Also some error messages were changed to give more hints. Michal Privoznik (4): Fix error messages codes when TypeFromString fails New error code VIR_ERR_XML_CONFIG Improve incorrect root element error messages Change XML parsing error codes when details are presented. include/libvirt/virterror.h | 1 + src/conf/cpu_conf.c | 13 ++-- src/conf/domain_conf.c | 165 +++++++++++++++++++----------------- src/conf/interface_conf.c | 56 ++++++------ src/conf/network_conf.c | 20 +++-- src/conf/node_device_conf.c | 10 ++- src/conf/nwfilter_conf.c | 16 ++-- src/conf/secret_conf.c | 14 ++-- src/conf/storage_conf.c | 66 ++++++++------- src/conf/storage_encryption_conf.c | 14 ++-- src/security/virt-aa-helper.c | 3 +- src/test/test_driver.c | 13 ++- src/util/virterror.c | 6 ++ src/util/xml.c | 2 +- 14 files changed, 218 insertions(+), 181 deletions(-) -- 1.7.4.4

--- 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 ad49916..db8b4bb 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 0e7aeb5..7fba385 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1634,7 +1634,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; } @@ -1841,7 +1841,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; } @@ -1874,7 +1874,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; @@ -1973,7 +1973,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; } @@ -2021,7 +2021,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; } @@ -2059,14 +2059,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; } @@ -2074,7 +2074,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; } @@ -2178,7 +2178,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; } @@ -2196,7 +2196,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; } @@ -2286,7 +2286,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; } @@ -2297,7 +2297,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; } @@ -2549,7 +2549,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; } @@ -2761,7 +2761,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; } @@ -2814,7 +2814,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); @@ -2826,7 +2826,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); @@ -2964,6 +2964,8 @@ virDomainChrDefParseTargetXML(virCapsPtr caps, if ((def->targetType = virDomainChrTargetTypeFromString(caps, def->deviceType, targetType)) < 0) { + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown type %s"), targetType); goto error; } @@ -3186,7 +3188,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; } @@ -3313,7 +3315,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; @@ -3321,7 +3323,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); } @@ -3391,7 +3393,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; @@ -3453,7 +3455,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; @@ -3521,14 +3523,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; } @@ -3618,7 +3620,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; } @@ -3640,7 +3642,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; } @@ -3650,7 +3652,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; } @@ -3669,7 +3671,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; } @@ -3790,7 +3792,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; } @@ -3979,7 +3981,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); @@ -3987,7 +3989,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); @@ -4114,7 +4116,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; } @@ -4156,7 +4158,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; } @@ -4167,7 +4169,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; } @@ -4208,7 +4210,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; } @@ -4252,7 +4254,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; } @@ -4429,13 +4431,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; } @@ -4443,7 +4445,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; } @@ -4453,7 +4455,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; } @@ -4666,7 +4668,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; } @@ -4677,7 +4679,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; } @@ -4796,7 +4798,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; } @@ -5206,7 +5208,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); @@ -5341,7 +5343,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; } @@ -5515,7 +5517,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; @@ -6177,7 +6179,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; } @@ -6252,7 +6254,7 @@ static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps, goto error; } if ((obj->state = virDomainStateTypeFromString(tmp)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid domain state '%s'"), tmp); VIR_FREE(tmp); goto error; @@ -9070,7 +9072,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; @@ -9421,7 +9423,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 2fa2fa0..37b9c7c 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -682,7 +682,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 5738757..7ab2352 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -671,7 +671,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 0b080ce..cc28b2a 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -832,7 +832,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; @@ -1082,7 +1082,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 09dc32b..368aca0 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -1890,7 +1890,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; @@ -1904,7 +1904,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; @@ -2003,7 +2003,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 fc4ae82..30f1a3d 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 116898d..9ccff15 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -630,7 +630,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 20e822c..4414817 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.4.4

On Wed, Apr 27, 2011 at 16:57:43 +0200, 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(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index ad49916..db8b4bb 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; } ...
I think all of these errors should really be changed to the new VIR_ERR_XML_CONFIG. This is not the case that a driver doesn't support particular value, it's that the value is not know to libvirt at all, i.e., it is an error in XML configuration file. Jirka

On 04/29/2011 09:07 AM, Jiri Denemark wrote:
On Wed, Apr 27, 2011 at 16:57:43 +0200, 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(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index ad49916..db8b4bb 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; } ...
I think all of these errors should really be changed to the new VIR_ERR_XML_CONFIG. This is not the case that a driver doesn't support particular value, it's that the value is not know to libvirt at all, i.e., it is an error in XML configuration file.
Jirka
I don't agree. If we add support for new value and somebody'll give older libvirt XML with new interface type, I think libvirt should say VIR_ERR_CONFIG_UNSUPPORTED. Michal

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. --- 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 fbb4a45..f597e9b 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.4.4

--- src/conf/cpu_conf.c | 7 ++++--- src/conf/domain_conf.c | 21 ++++++++++++++------- src/conf/interface_conf.c | 6 ++++-- src/conf/network_conf.c | 6 ++++-- src/conf/node_device_conf.c | 6 ++++-- src/conf/nwfilter_conf.c | 2 +- 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 +- 11 files changed, 56 insertions(+), 28 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index db8b4bb..9ea11cb 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 7fba385..ac3d955 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4867,7 +4867,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, node = xmlDocGetRootElement(xml); if (node == NULL) { - virDomainReportError(VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_CONFIG, "%s", _("missing root element")); goto error; } @@ -6322,8 +6322,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; } @@ -6351,8 +6353,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; } @@ -9015,13 +9019,16 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr, } if ((root = xmlDocGetRootElement(xml)) == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, + virDomainReportError(VIR_ERR_XML_CONFIG, "%s", _("missing root element")); goto cleanup; } if (!xmlStrEqual(root->name, BAD_CAST "domainsnapshot")) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("domainsnapshot")); + virDomainReportError(VIR_ERR_XML_CONFIG, + _("unexpected root element <%s> " + "expecting to see <domainsnapshot>"), + root->name); goto cleanup; } diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 37b9c7c..c07ffc8 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -831,8 +831,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 7ab2352..88848ee 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -728,8 +728,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 cc28b2a..8e7c573 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1205,8 +1205,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/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 368aca0..0aee8a4 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2152,7 +2152,7 @@ virNWFilterDefParse(virConnectPtr conn, node = xmlDocGetRootElement(xml); if (node == NULL) { - virNWFilterReportError(VIR_ERR_XML_ERROR, + virNWFilterReportError(VIR_ERR_XML_CONFIG, "%s", _("missing root element")); goto cleanup; } diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 30f1a3d..37a513b 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 9ccff15..76ea103 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -750,8 +750,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; } @@ -1130,8 +1132,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 08ff53c..0b24516 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -684,7 +684,8 @@ caps_mockup(vahControl * ctl, const char *xmlStr) } 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 0978214..6a6f189 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -798,9 +798,16 @@ static int testOpenFromFile(virConnectPtr conn, VIR_FORCE_CLOSE(fd); 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 d2989e2..2ad21cd 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -696,7 +696,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.4.4

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 | 44 +++++++++++++++--------------- src/conf/interface_conf.c | 48 ++++++++++++++++---------------- src/conf/network_conf.c | 12 ++++---- src/conf/nwfilter_conf.c | 8 +++--- src/conf/secret_conf.c | 6 ++-- src/conf/storage_conf.c | 52 ++++++++++++++++++------------------ src/conf/storage_encryption_conf.c | 10 +++--- 8 files changed, 91 insertions(+), 91 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 9ea11cb..b18c2c4 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 ac3d955..66cd07d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2855,7 +2855,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; } @@ -2895,7 +2895,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; @@ -2977,7 +2977,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; @@ -2999,14 +2999,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; @@ -3030,7 +3030,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; @@ -3388,7 +3388,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; } @@ -3410,7 +3410,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; @@ -3430,7 +3430,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; @@ -3439,7 +3439,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; @@ -3449,7 +3449,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; @@ -4237,7 +4237,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); } @@ -4791,7 +4791,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; } @@ -4811,7 +4811,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; } @@ -4820,7 +4820,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; } @@ -4834,7 +4834,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; } @@ -4929,7 +4929,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; } @@ -5418,7 +5418,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) { @@ -5426,7 +5426,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; } @@ -5434,7 +5434,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) { @@ -5442,7 +5442,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; } @@ -9013,7 +9013,7 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr, xml = virXMLParse(NULL, xmlStr, "domainsnapshot.xml"); if (!xml) { - virDomainReportError(VIR_ERR_XML_ERROR, + virDomainReportError(VIR_ERR_XML_CONFIG, "%s",_("failed to parse snapshot xml document")); return NULL; } diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index c07ffc8..6f20843 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); } @@ -447,7 +447,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; @@ -466,7 +466,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; @@ -537,7 +537,7 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def, nbItf = virXPathNodeSet("./interface", ctxt, &interfaces); if (nbItf <= 0) { - virInterfaceReportError(VIR_ERR_XML_ERROR, + virInterfaceReportError(VIR_ERR_XML_CONFIG, "%s", _("bond has no interfaces")); ret = -1; goto error; @@ -585,7 +585,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; } @@ -593,7 +593,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) { @@ -602,7 +602,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) { @@ -621,7 +621,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; } @@ -630,7 +630,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; @@ -651,7 +651,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); } @@ -659,7 +659,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); } @@ -676,7 +676,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); } @@ -703,7 +703,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; @@ -740,7 +740,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; } @@ -752,7 +752,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); @@ -782,7 +782,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; } @@ -803,7 +803,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 88848ee..41c545e 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 0aee8a4..62812b3 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2018,7 +2018,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; } @@ -2094,7 +2094,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; @@ -2145,7 +2145,7 @@ virNWFilterDefParse(virConnectPtr conn, if (!xml) { if (conn && conn->err.code == VIR_ERR_NONE) - virNWFilterReportError(VIR_ERR_XML_ERROR, + virNWFilterReportError(VIR_ERR_XML_CONFIG, "%s",_("failed to parse xml document")); goto cleanup; } @@ -2537,7 +2537,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 37a513b..ffc5a76 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 76ea103..79527ec 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; @@ -449,7 +449,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; } @@ -468,7 +468,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; @@ -507,7 +507,7 @@ virStoragePoolDefParseSourceString(const char *srcSpec, XML_PARSE_NOERROR | XML_PARSE_NOWARNING); if (doc == NULL) { - virStorageReportError(VIR_ERR_XML_ERROR, + virStorageReportError(VIR_ERR_XML_CONFIG, "%s", _("bad <source> spec")); goto cleanup; } @@ -525,7 +525,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; } @@ -576,7 +576,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; } @@ -587,7 +587,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; } @@ -598,7 +598,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; } @@ -654,7 +654,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; } @@ -668,7 +668,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; } @@ -677,7 +677,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; @@ -686,7 +686,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; } @@ -704,7 +704,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; } @@ -713,14 +713,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; } @@ -988,19 +988,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; } @@ -1031,7 +1031,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; } @@ -1042,7 +1042,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; } @@ -1071,7 +1071,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; @@ -1102,7 +1102,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; @@ -1427,7 +1427,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 4414817..dcc16dd 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; } @@ -190,7 +190,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.4.4
participants (3)
-
Jiri Denemark
-
Michal Privoznik
-
Michal Prívozník