[libvirt] [PATCH] nwfilter: Add filter schema for nwfilter XML, extend domain XML schema

Stefan Berger stefanb at us.ibm.com
Tue Apr 6 13:21:50 UTC 2010


Daniel Veillard <veillard at redhat.com> wrote on 04/06/2010 09:10:11 AM:


> 
> Please respond to veillard
> 
> On Mon, Apr 05, 2010 at 12:53:19PM -0400, Stefan Berger wrote:
> > This patch adds a relaxng nwfilter schema along with a test that
> > verifies all the test output XML against the schema. The input XMLs
> > contain a lot of intentional out-of-range values that make them fail 
the
> > schema verification, so I am not verifying against those.
> > 
> > Signed-off-by: Stefan Berger <stefanb at us.ibm.com>
> > Signed-off-by: Gerhard Stenzel <gerhard.stenzel at de.ibm.com>
> > 
> > ---
> >  docs/schemas/Makefile.am  |    3 
> >  docs/schemas/domain.rng   |   31 +
> >  docs/schemas/nwfilter.rng |  783
> > ++++++++++++++++++++++++++++++++++++++++++++++
> >  libvirt.spec.in           |    1 
> >  tests/Makefile.am         |    4 
> >  tests/nwfilterschematest  |   11 
> >  6 files changed, 831 insertions(+), 2 deletions(-)
> > 
> [...]
> > +  <define name="addrMAC">
> > +    <choice>
> > +      <!-- variable -->
> > +      <data type="string">
> > +        <param name="pattern">[\\$]{1}[a-zA-Z0-9_]+</param>
> > +      </data>
> > +
> > +      <data type="string">
> > +        <param
> > name="pattern">([a-fA-F0-9]{1,2}:){5}[a-fA-F0-9]{1,2}</param>
> > +      </data>
> > +    </choice>
> > +  </define>
> 
>   Hum, can you explain why you get apparently 2 completely different
> format values ranges here (and in a number of other types), I'm a bit
> lost.

Every item in the network filter xml can be a variable like $MAC or $IP. 
So for the schema to validate a srcmacaddr="$MAC" I needed to add the 
above 'variable' pattern. 
I had a lot of problems finding a way to require a $ as first letter and I 
ended up having to use the [\\$]{1} construct. Also I could not find a 
switch for non-case-sensitive string comparison like other regexes have 
(?i) or \i for example... I suppose there is none.


> 
> [...]
> > Index: libvirt-acl/docs/schemas/domain.rng
> > ===================================================================
> > --- libvirt-acl.orig/docs/schemas/domain.rng
> > +++ libvirt-acl/docs/schemas/domain.rng
> > @@ -894,6 +894,11 @@
> >        <optional>
> >          <ref name="address"/>
> >        </optional>
> > +      <optional>
> > +        <element name="filterref">
> > +          <ref name="filterref-node-attributes"/>
> > +        </element>
> > +      </optional>
> >      </interleave>
> >    </define>
> >    <!--
> @@ -1577,6 +1582,22 @@
> >      </element>
> >    </define>
> > 
> > +  <define name="filterref-node-attributes">
> > +    <attribute name="filter">
> > +      <data type="NCName"/>
> > +    </attribute>
> > +    <optional>
> > +      <element name="parameter">
> > +        <attribute name="name">
> > +          <ref name="parameter-name"/>
> > +        </attribute>
> > +        <attribute name="value">
> > +          <ref name="parameter-value"/>
> > +        </attribute>
> > +      </element>
> > +    </optional>
> > +  </define>
> > +
> >    <!--
>         Type library
> > 
> > @@ -1737,4 +1758,14 @@
> >        <param name="pattern">[a-zA-Z0-9_\.\+\-/]+</param>
> >      </data>
> >    </define>
> > +  <define name="parameter-name">
> > +    <data type="string">
> > +      <param name="pattern">[a-zA-Z0-9_]+</param>
> > +    </data>
> > +  </define>
> > +  <define name="parameter-value">
> > +    <data type="string">
> > +      <param name="pattern">[a-zA-Z0-9_\.:]+</param>
> > +    </data>
> > +  </define>
> >  </grammar>
> 
> I just find parameter-name/parameter-value a bit too generic names,
> if you could make them more specific to the task, like
>    filter-param-name / filter-param-value
> 
> but it's minor, and it's good to have updated schema and augmented
> testing

Ok, so I will rename those two to the names you suggest. Should I post 
again before pushing it to the repository?

   Stefan


> 
> ACK
> 
> Daniel
> 
> -- 
> Daniel Veillard      | libxml Gnome XML XSLT toolkit  
http://xmlsoft.org/
> daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
> http://veillard.com/ | virtualization library  http://libvirt.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100406/a8ebb405/attachment-0001.htm>


More information about the libvir-list mailing list