[libvirt] [libvirt PATCH v6 14/15] xen_common: Change xenParseVfbs to using virConfGetValueStringList

John Ferlan jferlan at redhat.com
Wed Sep 19 22:06:34 UTC 2018



On 09/18/2018 02:48 PM, Fabiano Fidêncio wrote:
> Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
> ---
>  src/xenconfig/xen_common.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
> index 9ad081e56b..a6e77a9250 100644
> --- a/src/xenconfig/xen_common.c
> +++ b/src/xenconfig/xen_common.c
> @@ -605,8 +605,10 @@ xenParseCPUFeatures(virConfPtr conf,
>  static int
>  xenParseVfb(virConfPtr conf, virDomainDefPtr def)
>  {
> +    int ret = -1;
>      int val;
>      char *listenAddr = NULL;
> +    char **vfbs = NULL;
>      int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
>      virConfValuePtr list;
>      virDomainGraphicsDefPtr graphics = NULL;
> @@ -664,17 +666,14 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
>      }
>  
>      if (!hvm && def->graphics == NULL) { /* New PV guests use this format */
> -        list = virConfGetValue(conf, "vfb");
> -        if (list && list->type == VIR_CONF_LIST &&
> -            list->list && list->list->type == VIR_CONF_STRING &&
> -            list->list->str) {
> +        if (virConfGetValueStringList(conf, "vfb", false, &vfbs) == 1) {

There needs to be an else that will do some of the similar checking
described in the previous patch...

At the very least if return < 0, then virResetLastError... In fact now
that I see the same pattern, the code described in the last patch should
be a some common local/static function used by the 3 consumers to handle
the case where rc is not 1.

John

>              char vfb[MAX_VFB];
>              char *key = vfb;
>  
> -            if (virStrcpyStatic(vfb, list->list->str) < 0) {
> +            if (virStrcpyStatic(vfb, *vfbs) < 0) {
>                  virReportError(VIR_ERR_INTERNAL_ERROR,
>                                 _("VFB %s too big for destination"),
> -                               list->list->str);
> +                               *vfbs);
>                  goto cleanup;
>              }
>  
> @@ -747,12 +746,13 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
>          }
>      }
>  
> -    return 0;
> +    ret = 0;
>  
>   cleanup:
>      virDomainGraphicsDefFree(graphics);
>      VIR_FREE(listenAddr);
> -    return -1;
> +    virStringListFree(vfbs);
> +    return ret;
>  }
>  
>  
> 




More information about the libvir-list mailing list