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

Re: [libvirt] [PATCH V3 3/4] Extend NWFilter parameter parser to cope with lists of values



On 10/24/2011 12:31 PM, Matthias Bolte wrote:
2011/10/24 Stefan Berger<stefanb linux vnet ibm com>:
This patch modifies the NWFilter parameter parser to support multiple
elements with the same name and to internally build a list of items.
An example of the XML looks like this:

        <parameter name='TEST' value='10.1.2.3'/>
        <parameter name='TEST' value='10.2.3.4'/>
        <parameter name='TEST' value='10.1.1.1'/>

The list of values is then stored in the newly introduced data type
virNWFilterVarValue.

The XML formatter is also adapted to print out all items in alphabetical
order sorted by 'name'.

This patch als fixes a bug in the XML schema on the way.

v3:
  - Follow Daniel Berrange's suggestion of parsing a list as shown above
  - Rewrote XML formatter to print out parameters in alphabetical order
The parameters are stored in a hash and their name is used as key.
This means that the parameters aren't guaranteed to be printed to XML
again in the same order as they where parsed from XML, doesn't it?

This might be no problem when all parameters have a unique name. But
now with multiple parameters having the same name this might be an
issue, assuming that a given element order has a meaning attached to
it. If

        <parameter name='TEST' value='10.1.2.3'/>
        <parameter name='TEST' value='10.2.3.4'/>
        <parameter name='TEST' value='10.1.1.1'/>

and

        <parameter name='TEST' value='10.1.1.1'/>
        <parameter name='TEST' value='10.1.2.3'/>
        <parameter name='TEST' value='10.2.3.4'/>

aren't the same from the NWFilter's point-of-view then this needs to
be fixed to have NWFilter preserve the exact order of elements.

If it's the same then there's no problem here.

Internally there's an entry TEST in the hash table that holds the values in the order they were parsed (increasing index in a string array, char**). In the XML formatter the list is then printed in that same order. So the order is preserved and maybe some time in the future one could select a single value using $TEST[1] and be sure to always get that same value.

   Stefan


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