]> git.ipfire.org Git - thirdparty/libvirt.git/commit
conf: error out for multiple source elements while parsing chardev
authorPavel Hrdina <phrdina@redhat.com>
Fri, 18 Aug 2017 15:14:34 +0000 (17:14 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 22 Aug 2017 15:28:40 +0000 (17:28 +0200)
commit21bfd1e9b9dacaca0c92eb14d62e4f643464fc31
treeb442f46247efb07d04f260ba4c9816daf16f2519
parent7d0ff9430bfc03aaad83e28bd608725e0d970ea8
conf: error out for multiple source elements while parsing chardev

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
tests/genericxml2xmlindata/generic-chardev-tcp-multiple-source.xml [new file with mode: 0644]
tests/genericxml2xmlindata/generic-chardev-udp-multiple-source.xml [new file with mode: 0644]
tests/genericxml2xmltest.c