提交 9b73290f 编写于 作者: C Christophe Fergeau

conf: Always use VIR_ERR_CONFIG_UNSUPPORTED on enumFromString() failures

Currently, during XML parsing, when a call to a FromString() function to
get an enum value fails, the error which is reported is either
VIR_ERR_CONFIG_UNSUPPORTED, VIR_ERR_INTERNAL_ERROR or VIR_ERR_XML_ERROR.

This commit makes such conversion failures consistently return
VIR_ERR_CONFIG_UNSUPPORTED.
上级 f902734b
......@@ -221,7 +221,7 @@ virCPUDefParseXML(xmlNodePtr node,
def->mode = virCPUModeTypeFromString(cpuMode);
if (def->mode < 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Invalid mode attribute '%s'"),
cpuMode);
VIR_FREE(cpuMode);
......@@ -249,7 +249,7 @@ virCPUDefParseXML(xmlNodePtr node,
VIR_FREE(match);
if (def->match < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Invalid match attribute for CPU "
"specification"));
goto error;
......@@ -265,7 +265,7 @@ virCPUDefParseXML(xmlNodePtr node,
goto error;
}
if ((def->arch = virArchFromString(arch)) == VIR_ARCH_NONE) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unknown architecture %s"), arch);
VIR_FREE(arch);
goto error;
......@@ -285,7 +285,7 @@ virCPUDefParseXML(xmlNodePtr node,
if ((fallback = virXPathString("string(./model[1]/@fallback)", ctxt))) {
if ((def->fallback = virCPUFallbackTypeFromString(fallback)) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Invalid fallback attribute"));
goto error;
}
......@@ -391,7 +391,7 @@ virCPUDefParseXML(xmlNodePtr node,
VIR_FREE(strpolicy);
if (policy < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Invalid CPU feature policy"));
goto error;
}
......
此差异已折叠。
......@@ -662,7 +662,7 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) {
}
type = virInterfaceTypeFromString(tmp);
if (type == -1) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown interface type %s"), tmp);
VIR_FREE(tmp);
return NULL;
......
......@@ -82,7 +82,7 @@ virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr ctxt, virNetDevVlanPtr de
}
if ((def->nativeMode
= virNativeVlanModeTypeFromString(nativeMode)) <= 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Invalid \"nativeMode='%s'\" "
"in vlan <tag> element"),
nativeMode);
......
......@@ -48,7 +48,7 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
if ((virtPortType = virXMLPropString(node, "type")) &&
(virtPort->virtPortType = virNetDevVPortTypeFromString(virtPortType)) <= 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown virtualport type %s"), virtPortType);
goto error;
}
......
......@@ -1728,7 +1728,7 @@ virNetworkForwardDefParseXML(const char *networkName,
def->type = VIR_NETWORK_FORWARD_NAT;
} else {
if ((def->type = virNetworkForwardTypeFromString(type)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown forwarding type '%s'"), type);
goto cleanup;
}
......@@ -1747,7 +1747,7 @@ virNetworkForwardDefParseXML(const char *networkName,
= virNetworkForwardDriverNameTypeFromString(forwardDriverName);
if (driverName <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unknown forward <driver name='%s'/> "
"in network %s"),
forwardDriverName, networkName);
......@@ -1873,7 +1873,7 @@ virNetworkForwardDefParseXML(const char *networkName,
}
if ((def->ifs[i].type = virNetworkForwardHostdevDeviceTypeFromString(type)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown address type '%s' in network %s"),
type, networkName);
goto cleanup;
......
......@@ -854,7 +854,7 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt,
int val = virNodeDevNetCapTypeFromString(tmp);
VIR_FREE(tmp);
if (val < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("invalid network type supplied for '%s'"),
def->name);
goto out;
......@@ -1166,7 +1166,7 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
}
if ((val = virNodeDevCapTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown capability type '%s'"), tmp);
VIR_FREE(tmp);
goto error;
......
......@@ -2319,7 +2319,7 @@ virNWFilterRuleParse(xmlNodePtr node)
}
if ((ret->action = virNWFilterRuleActionTypeFromString(action)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s",
_("unknown rule action attribute value"));
goto err_exit;
......@@ -2333,7 +2333,7 @@ virNWFilterRuleParse(xmlNodePtr node)
}
if ((ret->tt = virNWFilterRuleDirectionTypeFromString(direction)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s",
_("unknown rule direction attribute value"));
goto err_exit;
......
......@@ -82,7 +82,7 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt,
}
type = virSecretUsageTypeTypeFromString(type_str);
if (type < 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown secret usage type %s"), type_str);
VIR_FREE(type_str);
return -1;
......
......@@ -121,7 +121,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
if (snapshot) {
def->snapshot = virDomainSnapshotLocationTypeFromString(snapshot);
if (def->snapshot <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk snapshot setting '%s'"),
snapshot);
goto cleanup;
......@@ -157,7 +157,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
if (driver) {
def->format = virStorageFileFormatTypeFromString(driver);
if (def->format <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk snapshot driver '%s'"),
driver);
VIR_FREE(driver);
......@@ -242,7 +242,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
}
def->state = virDomainSnapshotStateTypeFromString(state);
if (def->state < 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Invalid state '%s' in domain snapshot XML"),
state);
goto cleanup;
......@@ -282,7 +282,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
if (memorySnapshot) {
def->memory = virDomainSnapshotLocationTypeFromString(memorySnapshot);
if (def->memory <= 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown memory snapshot setting '%s'"),
memorySnapshot);
goto cleanup;
......
......@@ -527,7 +527,7 @@ virStoragePoolDefParseAuth(xmlXPathContextPtr ctxt,
if ((source->authType =
virStoragePoolAuthTypeTypeFromString(authType)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown auth type '%s'"),
authType);
goto cleanup;
......@@ -601,7 +601,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
source->format = options->formatFromString(format);
if (source->format < 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown pool format type %s"), format);
VIR_FREE(format);
goto cleanup;
......@@ -673,7 +673,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
if ((adapter_type = virXPathString("string(./adapter/@type)", ctxt))) {
if ((source->adapter.type =
virStoragePoolSourceAdapterTypeTypeFromString(adapter_type)) <= 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unknown pool adapter type '%s'"),
adapter_type);
goto cleanup;
......@@ -871,7 +871,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
}
if ((ret->type = virStoragePoolTypeFromString(type)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown storage pool type %s"), type);
goto error;
}
......@@ -1305,7 +1305,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
type = virXPathString("string(./@type)", ctxt);
if (type) {
if ((ret->type = virStorageVolTypeFromString(type)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown volume type '%s'"), type);
goto error;
}
......@@ -1340,7 +1340,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
ret->target.format = (options->formatFromString)(format);
if (ret->target.format < 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown volume format type %s"), format);
VIR_FREE(format);
goto error;
......@@ -1370,7 +1370,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
ret->backingStore.format = (options->formatFromString)(format);
if (ret->backingStore.format < 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown volume format type %s"), format);
VIR_FREE(format);
goto error;
......@@ -1408,7 +1408,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
int f = options->featureFromString((const char*)nodes[i]->name);
if (f < 0) {
virReportError(VIR_ERR_XML_ERROR, _("unsupported feature %s"),
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported feature %s"),
(const char*)nodes[i]->name);
goto error;
}
......
......@@ -91,7 +91,7 @@ virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt,
}
type = virStorageEncryptionSecretTypeTypeFromString(type_str);
if (type < 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown volume encryption secret type %s"),
type_str);
VIR_FREE(type_str);
......@@ -144,7 +144,7 @@ virStorageEncryptionParseXML(xmlXPathContextPtr ctxt)
}
format = virStorageEncryptionFormatTypeFromString(format_str);
if (format < 0) {
virReportError(VIR_ERR_XML_ERROR,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown volume encryption format type %s"),
format_str);
VIR_FREE(format_str);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册