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

Re: [libvirt] [libvirt-designer][PATCH v2 4/4] domain: Introduce interface support



On 09/10/2012 03:58 PM, Michal Privoznik wrote:
> Let users add NICs to domains.
> ---
>  examples/virtxml.c                         |   78 ++++++++++++++++++++++++++
>  libvirt-designer/libvirt-designer-domain.c |   83 ++++++++++++++++++++++++++++
>  libvirt-designer/libvirt-designer-domain.h |    3 +
>  libvirt-designer/libvirt-designer.sym      |    1 +
>  4 files changed, 165 insertions(+), 0 deletions(-)
> 
> diff --git a/examples/virtxml.c b/examples/virtxml.c
> index 20e3f3c..df83f57 100644
> --- a/examples/virtxml.c
> +++ b/examples/virtxml.c
> @@ -35,6 +35,7 @@
>  #include <unistd.h>
>  
>  GList *disk_str_list = NULL;
> +GList *iface_str_list = NULL;
>  
>  #define print_error(...) \
>      print_error_impl(__FUNCTION__, __LINE__, __VA_ARGS__)
> @@ -215,6 +216,79 @@ add_disk_str(const gchar *option_name,
>      return TRUE;
>  }
>  
> +static void
> +add_iface(gpointer data,
> +          gpointer user_data)
> +{
> +    GVirDesignerDomain *domain = (GVirDesignerDomain *) user_data;
> +    char *network = (char *) data;
> +    char *param = NULL;
> +    GVirConfigDomainInterface *iface = NULL;
> +    GError *error = NULL;
> +
> +    param = strchr(network, ',');
> +    if (param) {
> +        *param = '\0';
> +        param++;
> +    }
> +
> +    iface = gvir_designer_domain_add_interface_network(domain, network, &error);
> +    if (error) {
> +        print_error("%s", error->message);
> +        exit(EXIT_FAILURE);
> +    }
> +
> +    while (param && *param) {
> +        char *key = param;
> +        char *val;
> +        GVirConfigDomainInterfaceLinkState link;
> +
> +        /* move to next token */
> +        param = strchr(param, ',');
> +        if (param) {
> +            *param = '\0';
> +            param++;
> +        }
> +
> +        /* parse token */
> +        val = strchr(key, '=');
> +        if (!val) {
> +            print_error("Invalid format: %s", key);
> +            exit(EXIT_FAILURE);
> +        }
> +
> +        *val = '\0';
> +        val++;
> +
> +        if (!strcmp(key, "mac")) {
> +            gvir_config_domain_interface_set_mac(iface, val);
> +        } else if (!strcmp(key, "link")) {
> +            if (!strcmp(val, "up")) {
> +                link = GVIR_CONFIG_DOMAIN_INTERFACE_LINK_STATE_UP;
> +            } else if (!strcmp(val, "down")) {

Change those 4 !strcmp to g_str_equal.

[...]

ACK with that fixed.

Martin


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