[libvirt] [libvirt PATCH v7 5/6] xen_common: Change xenParseVfbs to using virConfGetValueStringList

Fabiano Fidêncio posted 6 patches 7 years, 4 months ago
[libvirt] [libvirt PATCH v7 5/6] xen_common: Change xenParseVfbs to using virConfGetValueStringList
Posted by Fabiano Fidêncio 7 years, 4 months ago
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
---
 src/xenconfig/xen_common.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 9133998cd7..058f35825e 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -618,7 +618,6 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
     int val;
     char *listenAddr = NULL;
     int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
-    virConfValuePtr list;
     virDomainGraphicsDefPtr graphics = NULL;
 
     if (hvm) {
@@ -674,17 +673,17 @@ 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) {
+        VIR_AUTOPTR(virString) vfbs = NULL;
+        int rc;
+
+        if ((rc = virConfGetValueStringList(conf, "vfb", false, &vfbs)) == 1) {
             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;
             }
 
@@ -754,6 +753,11 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
             def->graphics[0] = graphics;
             def->ngraphics = 1;
             graphics = NULL;
+        } else {
+            rc = xenHandleConfGetValueStringListErrors(rc,
+                                                       virGetLastErrorCode());
+            if (rc < 0)
+                goto cleanup;
         }
     }
 
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt PATCH v7 5/6] xen_common: Change xenParseVfbs to using virConfGetValueStringList
Posted by John Ferlan 7 years, 4 months ago

On 09/20/2018 09:28 AM, Fabiano Fidêncio wrote:
> Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
> ---
>  src/xenconfig/xen_common.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
> index 9133998cd7..058f35825e 100644
> --- a/src/xenconfig/xen_common.c
> +++ b/src/xenconfig/xen_common.c
> @@ -618,7 +618,6 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
>      int val;
>      char *listenAddr = NULL;
>      int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
> -    virConfValuePtr list;
>      virDomainGraphicsDefPtr graphics = NULL;
>  
>      if (hvm) {
> @@ -674,17 +673,17 @@ 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) {
> +        VIR_AUTOPTR(virString) vfbs = NULL;
> +        int rc;
> +
> +        if ((rc = virConfGetValueStringList(conf, "vfb", false, &vfbs)) == 1) {
>              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;
>              }
>  
> @@ -754,6 +753,11 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
>              def->graphics[0] = graphics;
>              def->ngraphics = 1;
>              graphics = NULL;
> +        } else {
> +            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@redhat.com>

John

> +                goto cleanup;
>          }
>      }
>  
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt PATCH v7 5/6] xen_common: Change xenParseVfbs to using virConfGetValueStringList
Posted by Fabiano Fidêncio 7 years, 4 months ago
On Thu, Sep 20, 2018 at 10:19 PM, John Ferlan <jferlan@redhat.com> wrote:

>
>
> On 09/20/2018 09:28 AM, Fabiano Fidêncio wrote:
> > Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
> > ---
> >  src/xenconfig/xen_common.c | 18 +++++++++++-------
> >  1 file changed, 11 insertions(+), 7 deletions(-)
> >
> > diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
> > index 9133998cd7..058f35825e 100644
> > --- a/src/xenconfig/xen_common.c
> > +++ b/src/xenconfig/xen_common.c
> > @@ -618,7 +618,6 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
> >      int val;
> >      char *listenAddr = NULL;
> >      int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
> > -    virConfValuePtr list;
> >      virDomainGraphicsDefPtr graphics = NULL;
> >
> >      if (hvm) {
> > @@ -674,17 +673,17 @@ 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) {
> > +        VIR_AUTOPTR(virString) vfbs = NULL;
> > +        int rc;
> > +
> > +        if ((rc = virConfGetValueStringList(conf, "vfb", false,
> &vfbs)) == 1) {
> >              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;
> >              }
> >
> > @@ -754,6 +753,11 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
> >              def->graphics[0] = graphics;
> >              def->ngraphics = 1;
> >              graphics = NULL;
> > +        } else {
> > +            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@redhat.com>
>

Sure!


>
> John
>
> > +                goto cleanup;
> >          }
> >      }
> >
> >
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list