[libvirt] [libvirt-glib PATCH] Add filterref and filterref parameter support.

Daniel P. Berrange berrange at redhat.com
Tue Oct 22 08:32:58 UTC 2013


On Wed, Oct 16, 2013 at 11:12:46AM +0200, Christophe Fergeau wrote:
> On Tue, Oct 15, 2013 at 12:05:02PM -0700, Ian Main wrote:
> > This patch adds support for setting filterref's on interfaces.  Also
> > supported are parameters to the filterref's.
> 
> This mostly looks good, some comments below.
> 

> > +GVirConfigDomainInterfaceFilterref *gvir_config_domain_interface_filterref_new_from_xml(const gchar *xml,
> > +                                                                                        GError **error)
> > +{
> > +    GVirConfigObject *object;
> > +
> > +    object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_FILTERREF,
> > +                                             "filterref", NULL, xml, error);
> > +    if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "type"), "filterref") != 0) {
> 
> Is this test correct? I don't see a 'type' attribute on 'filterref' nodes
> in http://libvirt.org/formatnwfilter.html
> 
> > +        g_object_unref(G_OBJECT(object));
> > +        return NULL;
> > +    }
> > +    return GVIR_CONFIG_DOMAIN_INTERFACE_FILTERREF(object);
> > +}
> > +
> > +void gvir_config_domain_interface_filterref_set_filter(GVirConfigDomainInterfaceFilterref *filterref,
> > +                                                       const char *filter)
> 
> I'm wondering if we should call that method
> gvir_config_domain_interface_filterref_set_filter_name()

I'd go one step simpler and call it

   gvir_config_domain_interface_filterref_set_name()

> so that in the future we can have
> gvir_config_domain_interface_filterref_set_filter(GVirConfigDomainInterfaceFilterref *ref,
>                                                   GVirConfigNwFilter *filter);

I don't think we'll need such a method, since in the context of domains, we only
really care about the name, not the whole object config.

> > +{
> > +    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF(filterref));
> > +
> > +    gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(filterref),
> > +                                     "filter", filter, NULL);
> > +}
> > +
> > +const char *gvir_config_domain_interface_filterref_get_filter(GVirConfigDomainInterfaceFilterref *filterref)
> > +{

And call this one  'get_name'

> 
> I'd add a
> g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE_FILTERREF(filterref), NULL);
> here.
> 

Regards,
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 :|




More information about the libvir-list mailing list