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

Re: [libvirt] [PATCH v2 01/18] Improve virConf parse to handle LXC config format



On Thu, Jan 30, 2014 at 10:55:49AM +0100, Cédric Bosdonnat wrote:
> virConf now honours a VIR_CONF_FLAG_LXC_FORMAT flag to handle LXC
> configuration files. The differences are that property names can
> contain '.' character and values are all strings without any bounding
> quotes.
> 
> Provide a new virConfWalk function calling a handler on all non-comment
> values. This function will be used by the LXC conversion code to loop
> over LXC configuration lines.


>  
> +/**
> + * virConfWalk:
> + * @conf: a configuration file handle
> + * @callback: the function to call to process each entry
> + * @data: obscure data passed to callback
> + *
> + * Walk over all entries of the configuration file and run the callback
> + * for each with entry name, value and the obscure data.
> + *
> + * Returns 0 on success, or -1 on failure.
> + */
> +int virConfWalk(virConfPtr conf,
> +                 virConfWalkCallback callback,
> +                 void *data)

Nit-pick:  s/data/opaque/ for more common naming convention
here and in the header file decl later too.

> +{
> +    virConfEntryPtr cur;
> +
> +    if (!conf)
> +        return 0;
> +
> +    cur = conf->entries;
> +    while (cur != NULL) {
> +        if (cur->name && cur->value &&
> +                callback(cur->name, cur->value, data) < 0)
> +            return -1;
> +        cur = cur->next;
> +    }
> +    return 0;
> +}
>  
>  /**
>   * virConfWriteFile:

>  
> +typedef int (*virConfWalkCallback)(const char* name,
> +                                   virConfValuePtr value,
> +                                   void *data);

s/data/opaque/

> +
>  virConfPtr      virConfNew             (void);
>  virConfPtr	virConfReadFile	(const char *filename, unsigned int flags);
>  virConfPtr	virConfReadMem		(const char *memory,
> @@ -91,6 +98,9 @@ virConfValuePtr	virConfGetValue	(virConfPtr conf,
>  int             virConfSetValue        (virConfPtr conf,
>                                           const char *setting,
>                                           virConfValuePtr value);
> +int virConfWalk(virConfPtr conf,
> +                virConfWalkCallback callback,
> +                void *data);

s/data/opaque/

ACK with the nit-pick fixed.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


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