From: Martin Kletzander Date: Mon, 15 Apr 2019 08:56:03 +0000 (+0200) Subject: conf: Parse common scheduler attributes in separate function X-Git-Tag: v5.3.0-rc1~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0c010cd1039c301059037d323376be0501f18048;p=thirdparty%2Flibvirt.git conf: Parse common scheduler attributes in separate function This will become useful later when parsing emulatorsched parameters which don't need the rest of the current function. Signed-off-by: Martin Kletzander Reviewed-by: Ján Tomko --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b969a9f6e5..15838c2a23 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18441,45 +18441,24 @@ virDomainLoaderDefParseXML(xmlNodePtr node, } -static virBitmapPtr -virDomainSchedulerParse(xmlNodePtr node, - const char *name, - virProcessSchedPolicy *policy, - int *priority) +static int +virDomainSchedulerParseCommonAttrs(xmlNodePtr node, + virProcessSchedPolicy *policy, + int *priority) { - virBitmapPtr ret = NULL; int pol = 0; VIR_AUTOFREE(char *) tmp = NULL; - if (!(tmp = virXMLPropString(node, name))) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing attribute '%s' in element '%sched'"), - name, name); - goto error; - } - - if (virBitmapParse(tmp, &ret, VIR_DOMAIN_CPUMASK_LEN) < 0) - goto error; - - if (virBitmapIsAllClear(ret)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("'%s' scheduler bitmap '%s' is empty"), - name, tmp); - goto error; - } - - VIR_FREE(tmp); - if (!(tmp = virXMLPropString(node, "scheduler"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing scheduler attribute")); - goto error; + return -1; } if ((pol = virProcessSchedPolicyTypeFromString(tmp)) <= 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid scheduler attribute: '%s'"), tmp); - goto error; + return -1; } *policy = pol; @@ -18490,16 +18469,49 @@ virDomainSchedulerParse(xmlNodePtr node, if (!(tmp = virXMLPropString(node, "priority"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing scheduler priority")); - goto error; + return -1; } if (virStrToLong_i(tmp, NULL, 10, priority) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Invalid value for element priority")); - goto error; + return -1; } } + return 0; +} + + +static virBitmapPtr +virDomainSchedulerParse(xmlNodePtr node, + const char *name, + virProcessSchedPolicy *policy, + int *priority) +{ + virBitmapPtr ret = NULL; + VIR_AUTOFREE(char *) tmp = NULL; + + if (!(tmp = virXMLPropString(node, name))) { + virReportError(VIR_ERR_XML_ERROR, + _("Missing attribute '%s' in element '%sched'"), + name, name); + goto error; + } + + if (virBitmapParse(tmp, &ret, VIR_DOMAIN_CPUMASK_LEN) < 0) + goto error; + + if (virBitmapIsAllClear(ret)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("'%s' scheduler bitmap '%s' is empty"), + name, tmp); + goto error; + } + + if (virDomainSchedulerParseCommonAttrs(node, policy, priority) < 0) + goto error; + return ret; error: