[libvirt] [libvirt-sandbox PATCH v3] Add filter support.

Ian Main imain at redhat.com
Tue Jan 21 21:43:39 UTC 2014


On Thu, Jan 09, 2014 at 12:25:51PM +0100, Christophe Fergeau wrote:
> Hey,
> 
> Mostly looks good, see below a few small changes I'd squash in.
> The only functional change is the addition of missing calls to
> g_object_notify() in the various setters, and the renaming of
> GVirSandboxConfigFilterref::filter to GVirSandboxConfigFilterref::name to
> match the name of the setter, I think that's what we want (?)
> 
> Christophe

ACK.

	Ian

 
> From 8d7d69a467393fbc8cdc8307dd5a1bb9db472591 Mon Sep 17 00:00:00 2001
> From: Christophe Fergeau <cfergeau at redhat.com>
> Date: Thu, 9 Jan 2014 12:22:13 +0100
> Subject: [libvirt-sandbox] Small cleanups
> 
> ---
>  configure.ac                                       |  2 ++
>  ...rt-sandbox-config-network-filterref-parameter.c | 32 +++++++++-------------
>  ...rt-sandbox-config-network-filterref-parameter.h |  2 +-
>  .../libvirt-sandbox-config-network-filterref.c     | 27 ++++++++----------
>  .../libvirt-sandbox-config-network-filterref.h     |  2 +-
>  5 files changed, 29 insertions(+), 36 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index cae869f..e4e4d99 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -13,6 +13,7 @@ AM_SILENT_RULES([yes])
>  GIO_UNIX_REQUIRED=2.28.0
>  GOBJECT_REQUIRED=2.32.0
>  LIBVIRT_REQUIRED=1.0.2
> +LIBVIRT_GCONFIG_REQUIRED=0.1.8
>  LIBVIRT_GLIB_REQUIRED=0.1.7
>  LIBVIRT_GOBJECT_REQUIRED=0.1.7
>  GOBJECT_INTROSPECTION_REQUIRED=0.10.8
> @@ -76,6 +77,7 @@ PKG_CHECK_MODULES(GOBJECT, gobject-2.0 >= $GOBJECT_REQUIRED)
>  PKG_CHECK_MODULES(LIBVIRT, libvirt >= $LIBVIRT_REQUIRED)
>  PKG_CHECK_MODULES(LIBVIRT_GLIB, libvirt-glib-1.0 >= $LIBVIRT_GOBJECT_REQUIRED)
>  PKG_CHECK_MODULES(LIBVIRT_GOBJECT, libvirt-gobject-1.0 >= $LIBVIRT_GOBJECT_REQUIRED)
> +PKG_CHECK_MODULES(LIBVIRT_GCONFIG, libvirt-gconfig-1.0 >= $LIBVIRT_GCONFIG_REQUIRED)
>  
>  LIBVIRT_SANDBOX_CAPNG
>  LIBVIRT_SANDBOX_GETTEXT
> diff --git a/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.c b/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.c
> index fabed90..5086ac6 100644
> --- a/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.c
> +++ b/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.c
> @@ -1,7 +1,7 @@
>  /*
>   * libvirt-sandbox-config-network-filterref-parameter.c: libvirt sandbox configuration
>   *
> - * Copyright (C) 2013 Red Hat, Inc.
> + * Copyright (C) 2014 Red Hat, Inc.
>   *
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
> @@ -170,39 +170,33 @@ GVirSandboxConfigNetworkFilterrefParameter *gvir_sandbox_config_network_filterre
>  void gvir_sandbox_config_network_filterref_parameter_set_name(GVirSandboxConfigNetworkFilterrefParameter *param,
>                                                                const gchar *name)
>  {
> -    GVirSandboxConfigNetworkFilterrefParameterPrivate *priv;
> -
>      g_return_if_fail(GVIR_SANDBOX_IS_CONFIG_NETWORK_FILTERREF_PARAMETER(param));
> -    priv = param->priv;
> -    g_free(priv->name);
> -    priv->name = g_strdup(name);
> +
> +    g_free(param->priv->name);
> +    param->priv->name = g_strdup(name);
> +    g_object_notify(G_OBJECT(param), "name");
>  }
>  
>  const gchar *gvir_sandbox_config_network_filterref_parameter_get_name(GVirSandboxConfigNetworkFilterrefParameter *param)
>  {
> -    GVirSandboxConfigNetworkFilterrefParameterPrivate *priv;
> -
>      g_return_val_if_fail(GVIR_SANDBOX_IS_CONFIG_NETWORK_FILTERREF_PARAMETER(param), NULL);
> -    priv = param->priv;
> -    return priv->name;
> +
> +    return param->priv->name;
>  }
>  
>  void gvir_sandbox_config_network_filterref_parameter_set_value(GVirSandboxConfigNetworkFilterrefParameter *param,
>                                                                 const gchar *value)
>  {
> -    GVirSandboxConfigNetworkFilterrefParameterPrivate *priv;
> -
>      g_return_if_fail(GVIR_SANDBOX_IS_CONFIG_NETWORK_FILTERREF_PARAMETER(param));
> -    priv = param->priv;
> -    g_free(priv->value);
> -    priv->value = g_strdup(value);
> +
> +    g_free(param->priv->value);
> +    param->priv->value = g_strdup(value);
> +    g_object_notify(G_OBJECT(value), "value");
>  }
>  
>  const gchar *gvir_sandbox_config_network_filterref_parameter_get_value(GVirSandboxConfigNetworkFilterrefParameter *param)
>  {
> -    GVirSandboxConfigNetworkFilterrefParameterPrivate *priv;
> -
>      g_return_val_if_fail(GVIR_SANDBOX_IS_CONFIG_NETWORK_FILTERREF_PARAMETER(param), NULL);
> -    priv = param->priv;
> -    return priv->value;
> +
> +    return param->priv->value;
>  }
> diff --git a/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.h b/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.h
> index 9544539..335d22c 100644
> --- a/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.h
> +++ b/libvirt-sandbox/libvirt-sandbox-config-network-filterref-parameter.h
> @@ -1,7 +1,7 @@
>  /*
>   * libvirt-sandbox-config-network-filterref-parameter.h: libvirt sandbox configuration
>   *
> - * Copyright (C) 2013 Red Hat, Inc.
> + * Copyright (C) 2014 Red Hat, Inc.
>   *
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
> diff --git a/libvirt-sandbox/libvirt-sandbox-config-network-filterref.c b/libvirt-sandbox/libvirt-sandbox-config-network-filterref.c
> index 85b41ae..c0c8e01 100644
> --- a/libvirt-sandbox/libvirt-sandbox-config-network-filterref.c
> +++ b/libvirt-sandbox/libvirt-sandbox-config-network-filterref.c
> @@ -2,7 +2,7 @@
>   * libvirt-sandbox-config-network-filterref.c: libvirt sandbox filterr reference
>   * configuration
>   *
> - * Copyright (C) 2013 Red Hat, Inc.
> + * Copyright (C) 2014 Red Hat, Inc.
>   *
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
> @@ -52,7 +52,7 @@ G_DEFINE_TYPE(GVirSandboxConfigNetworkFilterref, gvir_sandbox_config_network_fil
>  
>  enum {
>      PROP_0,
> -    PROP_FILTER
> +    PROP_NAME
>  };
>  
>  enum {
> @@ -70,7 +70,7 @@ static void gvir_sandbox_config_network_filterref_get_property(GObject *object,
>      GVirSandboxConfigNetworkFilterrefPrivate *priv = config->priv;
>  
>      switch (prop_id) {
> -    case PROP_FILTER:
> +    case PROP_NAME:
>          g_value_set_string(value, priv->filter);
>          break;
>  
> @@ -88,7 +88,7 @@ static void gvir_sandbox_config_network_filterref_set_property(GObject *object,
>      GVirSandboxConfigNetworkFilterref *filterref = GVIR_SANDBOX_CONFIG_NETWORK_FILTERREF(object);
>  
>      switch (prop_id) {
> -    case PROP_FILTER:
> +    case PROP_NAME:
>          gvir_sandbox_config_network_filterref_set_name(filterref, g_value_get_string(value));
>          break;
>  
> @@ -121,8 +121,8 @@ static void gvir_sandbox_config_network_filterref_class_init(GVirSandboxConfigNe
>      object_class->set_property = gvir_sandbox_config_network_filterref_set_property;
>  
>      g_object_class_install_property(object_class,
> -                                    PROP_FILTER,
> -                                    g_param_spec_string("filter",
> +                                    PROP_NAME,
> +                                    g_param_spec_string("name",
>                                                          "Filter name",
>                                                          "The filter reference name",
>                                                          NULL,
> @@ -162,22 +162,19 @@ static void gvir_sandbox_config_network_filterref_init(GVirSandboxConfigNetworkF
>   */
>  const gchar *gvir_sandbox_config_network_filterref_get_name(GVirSandboxConfigNetworkFilterref *filterref)
>  {
> -    GVirSandboxConfigNetworkFilterrefPrivate *priv;
> -
>      g_return_val_if_fail(GVIR_SANDBOX_IS_CONFIG_NETWORK_FILTERREF(filterref), NULL);
> -    priv = filterref->priv;
> -    return priv->filter;
> +
> +    return filterref->priv->filter;
>  }
>  
>  void gvir_sandbox_config_network_filterref_set_name(GVirSandboxConfigNetworkFilterref *filterref,
>                                                      const gchar *name)
>  {
> -    GVirSandboxConfigNetworkFilterrefPrivate *priv;
> -
>      g_return_if_fail(GVIR_SANDBOX_IS_CONFIG_NETWORK_FILTERREF(filterref));
> -    priv = filterref->priv;
> -    g_free(priv->filter);
> -    priv->filter = g_strdup(name);
> +
> +    g_free(filterref->priv->filter);
> +    filterref->priv->filter = g_strdup(name);
> +    g_object_notify(G_OBJECT(filterref), "name");
>  }
>  
>  /**
> diff --git a/libvirt-sandbox/libvirt-sandbox-config-network-filterref.h b/libvirt-sandbox/libvirt-sandbox-config-network-filterref.h
> index e036a93..22d361c 100644
> --- a/libvirt-sandbox/libvirt-sandbox-config-network-filterref.h
> +++ b/libvirt-sandbox/libvirt-sandbox-config-network-filterref.h
> @@ -2,7 +2,7 @@
>   * libvirt-sandbox-config-network-filterref.h: libvirt sandbox filter reference
>   * configuration
>   *
> - * Copyright (C) 2013 Red Hat, Inc.
> + * Copyright (C) 2014 Red Hat, Inc.
>   *
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
> -- 
> 1.8.4.2
> 





More information about the libvir-list mailing list