From 0c010cd1039c301059037d323376be0501f18048 Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Mon, 15 Apr 2019 10:56:03 +0200 Subject: [PATCH] conf: Parse common scheduler attributes in separate function MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/conf/domain_conf.c | 70 +++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 29 deletions(-) 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: -- 2.47.2