Re: [PATCH 2/5] conf: Split up virDomainVcpuPinDefParseXML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 04/07/2015 02:50 PM, Peter Krempa wrote:
> Extract part that parses iothreads into virDomainIothreadPinDefParseXML
> ---
>  src/conf/domain_conf.c | 112 +++++++++++++++++++++++++++++--------------------
>  1 file changed, 66 insertions(+), 46 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index ec7f9c9..10ec17a 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -13153,30 +13153,19 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt,
>      return idmap;
>  }
> 
> -/* Parse the XML definition for a vcpupin or emulatorpin.
> +/* Parse the XML definition for a vcpupin

[set bikeshed=flog...   technically the above would go in patch 1, but
I'm not concerned due to where this is headed... same in about 4 lines ]

>   *
>   * vcpupin has the form of
>   *   <vcpupin vcpu='0' cpuset='0'/>
> - *
> - * and emulatorpin has the form of
> - *   <emulatorpin cpuset='0'/>
> - *
> - * and an iothreadspin has the form
> - *   <iothreadpin iothread='1' cpuset='2'/>
> - *
> - * A vcpuid of -1 is valid and only valid for emulatorpin. So callers
> - * have to check the returned cpuid for validity.
>   */
>  static virDomainPinDefPtr
>  virDomainVcpuPinDefParseXML(xmlNodePtr node,
>                              xmlXPathContextPtr ctxt,
> -                            int maxvcpus,
> -                            bool iothreads)
> +                            int maxvcpus)
>  {
>      virDomainPinDefPtr def;
>      xmlNodePtr oldnode = ctxt->node;
>      int vcpuid = -1;
> -    unsigned int iothreadid;
>      char *tmp = NULL;
>      int ret;
> 
> @@ -13185,28 +13174,66 @@ virDomainVcpuPinDefParseXML(xmlNodePtr node,
> 
>      ctxt->node = node;
> 
> -    if (!iothreads) {
> -        ret = virXPathInt("string(./@vcpu)", ctxt, &vcpuid);
> -        if ((ret == -2) || (vcpuid < -1)) {
> -            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> -                           _("vcpu id must be an unsigned integer or -1"));
> -            goto error;
> -        } else if (vcpuid == -1) {
> -            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> -                           _("vcpu id value -1 is not allowed for vcpupin"));
> -            goto error;
> -        }
> +    ret = virXPathInt("string(./@vcpu)", ctxt, &vcpuid);
> +    if ((ret == -2) || (vcpuid < -1)) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("vcpu id must be an unsigned integer or -1"));
> +        goto error;
> +    } else if (vcpuid == -1) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("vcpu id value -1 is not allowed for vcpupin"));
> +        goto error;
> +    }
> 
> -        if (vcpuid >= maxvcpus) {
> +    if (vcpuid >= maxvcpus) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("vcpu id must be less than maxvcpus"));
> +        goto error;
> +    }
> +
> +    def->id = vcpuid;
> +
> +    if (!(tmp = virXMLPropString(node, "cpuset"))) {
>              virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> -                           _("vcpu id must be less than maxvcpus"));
> -            goto error;
> -        }
> +                           _("missing cpuset for vcpupin"));
> 
> -        def->id = vcpuid;
> +        goto error;
>      }
> 
> -    if (iothreads && (tmp = virXPathString("string(./@iothread)", ctxt))) {
> +    if (virBitmapParse(tmp, 0, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
> +        goto error;
> +
> + cleanup:
> +    VIR_FREE(tmp);
> +    ctxt->node = oldnode;
> +    return def;
> +
> + error:
> +    VIR_FREE(def);
> +    goto cleanup;
> +}
> +
> +
> +/* Parse the XML definition for a iothreadpin
> + * and an iothreadspin has the form
> + *   <iothreadpin iothread='1' cpuset='2'/>
> + */
> +static virDomainPinDefPtr
> +virDomainIothreadPinDefParseXML(xmlNodePtr node,
> +                                xmlXPathContextPtr ctxt,
> +                                int iothreads)

s/Iothread/IOThread/


ACK with this

John


> +{
> +    virDomainPinDefPtr def;
> +    xmlNodePtr oldnode = ctxt->node;
> +    unsigned int iothreadid;
> +    char *tmp = NULL;
> +
> +    if (VIR_ALLOC(def) < 0)
> +        return NULL;
> +
> +    ctxt->node = node;
> +
> +    if ((tmp = virXPathString("string(./@iothread)", ctxt))) {
>          if (virStrToLong_uip(tmp, NULL, 10, &iothreadid) < 0) {
>              virReportError(VIR_ERR_XML_ERROR,
>                             _("invalid setting for iothread '%s'"), tmp);
> @@ -13220,11 +13247,9 @@ virDomainVcpuPinDefParseXML(xmlNodePtr node,
>              goto error;
>          }
> 
> -        /* NB: maxvcpus is actually def->iothreads
> -         * IOThreads are numbered "iothread1...iothread<n>", where
> -         * "n" is the iothreads value
> -         */
> -        if (iothreadid > maxvcpus) {
> +        /* IOThreads are numbered "iothread1...iothread<n>", where
> +         * "n" is the iothreads value */
> +        if (iothreadid > iothreads) {
>              virReportError(VIR_ERR_XML_ERROR, "%s",
>                             _("iothread id must not exceed iothreads"));
>              goto error;
> @@ -13234,13 +13259,8 @@ virDomainVcpuPinDefParseXML(xmlNodePtr node,
>      }
> 
>      if (!(tmp = virXMLPropString(node, "cpuset"))) {
> -        if (iothreads)
> -            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> -                           _("missing cpuset for iothreadpin"));
> -        else
> -            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> -                           _("missing cpuset for vcpupin"));
> -
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("missing cpuset for iothreadpin"));
>          goto error;
>      }
> 
> @@ -13258,6 +13278,7 @@ virDomainVcpuPinDefParseXML(xmlNodePtr node,
>  }
> 
> 
> +
>  /* Parse the XML definition for emulatorpin.
>   * emulatorpin has the form of
>   *   <emulatorpin cpuset='0'/>
> @@ -13970,7 +13991,7 @@ virDomainDefParseXML(xmlDocPtr xml,
>      for (i = 0; i < n; i++) {
>          virDomainPinDefPtr vcpupin = NULL;
>          vcpupin = virDomainVcpuPinDefParseXML(nodes[i], ctxt,
> -                                              def->maxvcpus, false);
> +                                              def->maxvcpus);
> 
>          if (!vcpupin)
>              goto error;
> @@ -14057,9 +14078,8 @@ virDomainDefParseXML(xmlDocPtr xml,
> 
>      for (i = 0; i < n; i++) {
>          virDomainPinDefPtr iothreadpin = NULL;
> -        iothreadpin = virDomainVcpuPinDefParseXML(nodes[i], ctxt,
> -                                                  def->iothreads,
> -                                                  true);
> +        iothreadpin = virDomainIothreadPinDefParseXML(nodes[i], ctxt,
> +                                                      def->iothreads);
>          if (!iothreadpin)
>              goto error;
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]