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

Ján Tomko jtomko at redhat.com
Tue Aug 22 13:19:41 UTC 2017


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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170822/b7076470/attachment-0001.sig>


More information about the libvir-list mailing list