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

Re: [libvirt] [PATCH 05/17] conf: error out for multiple source elements while parsing chardev



On Mon, Aug 21, 2017 at 10:07:05AM +0200, Pavel Hrdina wrote:
Currently we accept and correctly parse this chardev XML:

 ...
 <channel type='tcp'>
   <source mode='connect'/>
   <source mode='bind' host='localhost'/>
   <source service='4567'/>
   <target type='virtio' name='test'/>
 </channel>
 ...

The parsed formatted XML is:

 ...
 <channel type='tcp'>
   <source mode='connect' host='localhost' service='4567'/>
   <target type='virtio' name='test'/>
 </channel>
 ...

That behavior is super wrong and should not be allowed.  If you notice
the current parse takes the first found attribute and uses that value,
so for example from the "<source mode='bind' host='localhost'/>" only
the "host" attribute is used.  It works the same way for all possible
attributes that we are able to parse for source element.

This patch enforces providing only one source element for all character
devices, only for UDP type we allow to provide two source elements
since you can specify both modes.

Signed-off-by: Pavel Hrdina <phrdina redhat com>
---
src/conf/domain_conf.c                             | 17 ++++++++++++++
.../generic-chardev-tcp-multiple-source.xml        | 26 ++++++++++++++++++++++
.../generic-chardev-udp-multiple-source.xml        | 26 ++++++++++++++++++++++
tests/genericxml2xmltest.c                         |  4 ++++
4 files changed, 73 insertions(+)
create mode 100644 tests/genericxml2xmlindata/generic-chardev-tcp-multiple-source.xml
create mode 100644 tests/genericxml2xmlindata/generic-chardev-udp-multiple-source.xml


ACK

Jan

Attachment: signature.asc
Description: Digital signature


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