[libvirt] [PATCH v2 1/6] lxc: Rebase lxcNetworkParseData struct to support indexes.

John Ferlan jferlan at redhat.com
Sun Mar 17 14:03:47 UTC 2019



On 3/4/19 8:54 PM, Julio Faracco wrote:
> The current logic of lxcNetworkParseData uses one single structure to
> record data over the network definitions inside config files. The logic
> consider the entry 'type' as a new network definition, every time that
> algorithm find this tag.
> 
> This new structure was designed to consider network definitions as an
> array of network structures.
> 
> Signed-off-by: Julio Faracco <jcfaracco at gmail.com>
> ---
>  src/lxc/lxc_native.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 

This fails to build alone...

> diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
> index 2fd349ac1d..bf82cd1e98 100644
> --- a/src/lxc/lxc_native.c
> +++ b/src/lxc/lxc_native.c
> @@ -423,8 +423,9 @@ lxcCreateHostdevDef(int mode, int type, const char *data)
>      return hostdev;
>  }
>  
> -typedef struct {
> -    virDomainDefPtr def;

Removing @def causes build failure

> +typedef struct _lxcNetworkParseData lxcNetworkParseData;
> +typedef lxcNetworkParseData *lxcNetworkParseDataPtr;
> +struct _lxcNetworkParseData {

I do think there is value in just adding the *Ptr value and then using
within the code rather than "lxcNetworkParseData *data".

That is introduce the lxcNetworkParseDataPtr in the same patch as you
change anything that uses "lxcNetworkParseData *data" to use
"lxcNetworkParseDataPtr data" instead.

>      char *type;
>      char *link;
>      char *mac;
> @@ -436,9 +437,14 @@ typedef struct {
>      size_t nips;
>      char *gateway_ipv4;
>      char *gateway_ipv6;
> -    bool privnet;
> -    size_t networks;

In order to compile these 2 would need to be restored and the subsequent
index removed.  These would be adjusted you 'needed to' adjust them in
the patch that makes them obsolete.

> -} lxcNetworkParseData;
> +    size_t index;
> +};
> +

The following should be separated into its own patch with the similar
format as above using:

typedef struct _lxcNetworkParseArray lxcNetworkParseArray;
typedef lxcNetworkParseArray *lxcNetworkParseArrayPtr;
struct _lxcNetworkParseArray {


> +typedef struct {
> +    lxcNetworkParseDataPtr *data;

This should be "networks" not "data" for the normal naming scheme used.

It is also arguably separable since it's new and introducing a new concept.

John

> +    size_t nnetworks;
> +} lxcNetworkParseArray;
> +
>  
>  static int
>  lxcAddNetworkRouteDefinition(const char *address,
> 




More information about the libvir-list mailing list