Re: [libvirt PATCH v7 6/6] xen_common: Change xenParseCharDev to using virConfGetValueStringList

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

 




On 09/20/2018 09:28 AM, Fabiano Fidêncio wrote:
> Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
> ---
>  src/xenconfig/xen_common.c | 27 +++++++++++++--------------
>  1 file changed, 13 insertions(+), 14 deletions(-)
> 
> diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
> index 058f35825e..21f1f4a24c 100644
> --- a/src/xenconfig/xen_common.c
> +++ b/src/xenconfig/xen_common.c
> @@ -773,11 +773,13 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
>  static int
>  xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
>  {
> -    virConfValuePtr value = NULL;
> +    VIR_AUTOPTR(virString) serials = NULL;
>      virDomainChrDefPtr chr = NULL;
>  
>      if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
>          VIR_AUTOFREE(char *) parallel = NULL;
> +        int rc;
> +
>          if (xenConfigGetString(conf, "parallel", &parallel, NULL) < 0)
>              goto cleanup;
>          if (parallel && STRNEQ(parallel, "none") &&
> @@ -795,8 +797,8 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
>          }
>  
>          /* Try to get the list of values to support multiple serial ports */
> -        value = virConfGetValue(conf, "serial");
> -        if (value && value->type == VIR_CONF_LIST) {
> +        if ((rc = virConfGetValueStringList(conf, "serial", false, &serials)) == 1) {
> +            virString *entries;
>              int portnum = -1;
>  
>              if (STREQ(nativeFormat, XEN_CONFIG_FORMAT_XM)) {
> @@ -805,18 +807,12 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
>                  goto cleanup;
>              }
>  
> -            value = value->list;
> -            while (value) {
> -                char *port = NULL;
> +            for (entries = serials; *entries; entries++) {
> +                virString port = *entries;
>  
> -                if ((value->type != VIR_CONF_STRING) || (value->str == NULL))
> -                    goto cleanup;
> -                port = value->str;
>                  portnum++;
> -                if (STREQ(port, "none")) {
> -                    value = value->next;
> +                if (STREQ(port, "none"))
>                      continue;
> -                }
>  
>                  if (!(chr = xenParseSxprChar(port, NULL)))
>                      goto cleanup;
> @@ -824,11 +820,14 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
>                  chr->target.port = portnum;
>                  if (VIR_APPEND_ELEMENT(def->serials, def->nserials, chr) < 0)
>                      goto cleanup;
> -
> -                value = value->next;
>              }
>          } else {
>              VIR_AUTOFREE(char *) serial = NULL;
> +
> +            rc = xenHandleConfGetValueStringListErrors(rc, virGetLastErrorCode());
> +            if (rc < 0)

Based on patch4 change, this is simplified to just:


            if (xenHandleConfGetValueStringListErrors(rc) < 0)

I can alter before pushing if you're fine with that.

Reviewed-by: John Ferlan <jferlan@xxxxxxxxxx>

John

Logic is sooo much nicer with these VIR_AUTOFREE and VIR_AUTOPTR!

> +                goto cleanup;
> +
>              /* If domain is not using multiple serial ports we parse data old way */
>              if (xenConfigGetString(conf, "serial", &serial, NULL) < 0)
>                  goto cleanup;
> 

--
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]

  Powered by Linux