[libvirt] [PATCH v2 RESEND 12/17] conf: Factor out vcpus parsing part from virDomainCachetuneDefParse
John Ferlan
jferlan at redhat.com
Mon Jul 30 22:09:48 UTC 2018
On 07/29/2018 11:12 PM, bing.niu at intel.com wrote:
> From: Bing Niu <bing.niu at intel.com>
>
> Extract vcpus parsing part from virDomainCachetuneDefParse into one
> function called virDomainResctrlParseVcpus. So that vcpus parsing logic
> can be reused by other resource control technologies. Adjust error
> message and use node->name so that the error message can fit to all
> technologies.
>
> Signed-off-by: Bing Niu <bing.niu at intel.com>
> ---
> src/conf/domain_conf.c | 48 +++++++++++++++++++++++++++++++++---------------
> 1 file changed, 33 insertions(+), 15 deletions(-)
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index c1527b2..d6314de 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -18951,6 +18951,38 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
>
>
> static int
> +virDomainResctrlParseVcpus(virDomainDefPtr def,
> + xmlNodePtr node,
> + virBitmapPtr *vcpus)
> +{
> + char *vcpus_str = NULL;
> + int ret = -1;
> +
> + vcpus_str = virXMLPropString(node, "vcpus");
> + if (!vcpus_str) {
> + virReportError(VIR_ERR_XML_ERROR, _("Missing %s attribute 'vcpus'"),
> + node->name);
> + goto cleanup;
> + }
> + if (virBitmapParse(vcpus_str, vcpus, VIR_DOMAIN_CPUMASK_LEN) < 0) {
> + virReportError(VIR_ERR_XML_ERROR,
> + _("Invalid %s attribute 'vcpus' value '%s'"),
> + vcpus_str, node->name);
Arguments reversed - should "Invalid {cputunes|memtunes} attribute
'vcpus' value '$VCPUS_STR'"
> + goto cleanup;
> + }
> +
> + /* We need to limit the bitmap to number of vCPUs. If there's nothing left,
> + * then we can just clean up and return 0 immediately */
> + virBitmapShrink(*vcpus, def->maxvcpus);
> +
> + ret = 0;
> + cleanup:
> + VIR_FREE(vcpus_str);
> + return ret;
> +}
> +
> +
[...]
I'll fix in my branch before pushing.
John
More information about the libvir-list
mailing list