The test case attempts to test as many of the chardev backends as
possible by adding channels with various configs. The idea is to have a
representative sample which will later be used also for QMP schema
testing.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
.../chardev-backends.x86_64-latest.args | 79 ++++++++++
.../chardev-backends.x86_64-latest.xml | 149 ++++++++++++++++++
tests/qemuxmlconfdata/chardev-backends.xml | 111 +++++++++++++
tests/qemuxmlconftest.c | 2 +
4 files changed, 341 insertions(+)
create mode 100644 tests/qemuxmlconfdata/chardev-backends.x86_64-latest.args
create mode 100644 tests/qemuxmlconfdata/chardev-backends.x86_64-latest.xml
create mode 100644 tests/qemuxmlconfdata/chardev-backends.xml
diff --git a/tests/qemuxmlconfdata/chardev-backends.x86_64-latest.args
b/tests/qemuxmlconfdata/chardev-backends.x86_64-latest.args
new file mode 100644
index 0000000000..4e6e17587e
--- /dev/null
+++ b/tests/qemuxmlconfdata/chardev-backends.x86_64-latest.args
@@ -0,0 +1,79 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}'
\
+-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
+-accel tcg \
+-cpu qemu64 \
+-m size=219136k \
+-object
'{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'
\
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-device
'{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}'
\
+-device
'{"driver":"virtio-serial-pci","id":"virtio-serial0","bus":"pci.0","addr":"0x3"}'
\
+-chardev parallel,id=charparallel0,path=/dev/parport0 \
+-device
'{"driver":"isa-parallel","chardev":"charparallel0","id":"parallel0"}'
\
+-add-fd set=0,fd=1751,opaque=channel0-log \
+-chardev null,id=charchannel0,logfile=/dev/fdset/0,logappend=on \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":1,"chardev":"charchannel0","id":"channel0","name":"chardev-null"}'
\
+-add-fd set=1,fd=1751,opaque=channel1-log \
+-chardev vc,id=charchannel1,logfile=/dev/fdset/1,logappend=on \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":2,"chardev":"charchannel1","id":"channel1","name":"chardev-vc"}'
\
+-chardev pty,id=charchannel2 \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":3,"chardev":"charchannel2","id":"channel2","name":"chardev-pty"}'
\
+-chardev stdio,id=charchannel3 \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":4,"chardev":"charchannel3","id":"channel3","name":"chardev-stdio"}'
\
+-add-fd set=2,fd=1750,opaque=channel4-source \
+-chardev file,id=charchannel4,path=/dev/fdset/2,append=on \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":5,"chardev":"charchannel4","id":"channel4","name":"chardev-file"}'
\
+-chardev pipe,id=charchannel5,path=/path/to/pipe \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":6,"chardev":"charchannel5","id":"channel5","name":"chardev-pipe"}'
\
+-chardev serial,id=charchannel6,path=/path/to/device \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":7,"chardev":"charchannel6","id":"channel6","name":"chardev-dev"}'
\
+-chardev socket,id=charchannel7,fd=1729,server=on,wait=off \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":8,"chardev":"charchannel7","id":"channel7","name":"chardev-unix-listen"}'
\
+-chardev socket,id=charchannel8,path=/path/to/unix-listen,reconnect=2 \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":9,"chardev":"charchannel8","id":"channel8","name":"chardev-unix-connect"}'
\
+-chardev socket,id=charchannel9,host=1.2.3.4,port=5678,server=on,wait=off \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":10,"chardev":"charchannel9","id":"channel9","name":"chardev-tcp-listen-raw"}'
\
+-chardev socket,id=charchannel10,host=1.2.3.4,port=5679,telnet=on,server=on,wait=off \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":11,"chardev":"charchannel10","id":"channel10","name":"chardev-tcp-listen-telnet"}'
\
+-object
'{"qom-type":"tls-creds-x509","id":"objcharchannel11_tls0","dir":"/etc/pki/libvirt-chardev","endpoint":"client","verify-peer":true}'
\
+-chardev
socket,id=charchannel11,host=1.2.3.4,port=5678,reconnect=2,tls-creds=objcharchannel11_tls0
\
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":12,"chardev":"charchannel11","id":"channel11","name":"chardev-tcp-connect-raw"}'
\
+-object
'{"qom-type":"tls-creds-x509","id":"objcharchannel12_tls0","dir":"/etc/pki/libvirt-chardev","endpoint":"client","verify-peer":true}'
\
+-chardev
socket,id=charchannel12,host=hostname.global.,port=5679,telnet=on,reconnect=2,tls-creds=objcharchannel12_tls0
\
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":13,"chardev":"charchannel12","id":"channel12","name":"chardev-tcp-connect-telnet"}'
\
+-chardev udp,id=charchannel13,host=127.0.0.1,port=2222,localaddr=,localport=0 \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":14,"chardev":"charchannel13","id":"channel13","name":"chardev-udp-nobind"}'
\
+-chardev udp,id=charchannel14,host=127.0.0.1,port=2222,localaddr=127.0.0.1,localport=1111
\
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":15,"chardev":"charchannel14","id":"channel14","name":"chardev-udp-bind"}'
\
+-chardev spicevmc,id=charchannel15,name=vdagent \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":16,"chardev":"charchannel15","id":"channel15","name":"com.redhat.spice.0"}'
\
+-chardev qemu-vdagent,id=charchannel16,name=vdagent,clipboard=off,mouse=off \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":17,"chardev":"charchannel16","id":"channel16","name":"chardev-vdagent"}'
\
+-chardev dbus,id=charchannel17,name=test.channel.0 \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":18,"chardev":"charchannel17","id":"channel17","name":"chardev-dbus"}'
\
+-chardev spiceport,id=charchannel18,name=test.channel.0 \
+-device
'{"driver":"virtserialport","bus":"virtio-serial0.0","nr":19,"chardev":"charchannel18","id":"channel18","name":"chardev-spiceport"}'
\
+-audiodev
'{"id":"audio1","driver":"spice"}' \
+-spice port=5901,addr=0.0.0.0,seamless-migration=on \
+-device
'{"driver":"cirrus-vga","id":"video0","bus":"pci.0","addr":"0x2"}'
\
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxmlconfdata/chardev-backends.x86_64-latest.xml
b/tests/qemuxmlconfdata/chardev-backends.x86_64-latest.xml
new file mode 100644
index 0000000000..57a16b5b7c
--- /dev/null
+++ b/tests/qemuxmlconfdata/chardev-backends.x86_64-latest.xml
@@ -0,0 +1,149 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu64</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='usb' index='0' model='piix3-uhci'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='virtio-serial' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x03' function='0x0'/>
+ </controller>
+ <parallel type='dev'>
+ <source path='/dev/parport0'/>
+ <target port='0'/>
+ </parallel>
+ <channel type='null'>
+ <log file='/path/to/null.log' append='off'/>
+ <target type='virtio' name='chardev-null'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='1'/>
+ </channel>
+ <channel type='vc'>
+ <log file='/path/to/vc.log' append='on'/>
+ <target type='virtio' name='chardev-vc'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='2'/>
+ </channel>
+ <channel type='pty'>
+ <target type='virtio' name='chardev-pty'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='3'/>
+ </channel>
+ <channel type='stdio'>
+ <target type='virtio' name='chardev-stdio'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='4'/>
+ </channel>
+ <channel type='file'>
+ <source path='/path/to/fileout'/>
+ <target type='virtio' name='chardev-file'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='5'/>
+ </channel>
+ <channel type='pipe'>
+ <source path='/path/to/pipe'/>
+ <target type='virtio' name='chardev-pipe'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='6'/>
+ </channel>
+ <channel type='dev'>
+ <source path='/path/to/device'/>
+ <target type='virtio' name='chardev-dev'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='7'/>
+ </channel>
+ <channel type='unix'>
+ <source mode='bind' path='/path/to/unix-listen'/>
+ <target type='virtio' name='chardev-unix-listen'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='8'/>
+ </channel>
+ <channel type='unix'>
+ <source mode='connect' path='/path/to/unix-listen'>
+ <reconnect enabled='yes' timeout='2'/>
+ </source>
+ <target type='virtio' name='chardev-unix-connect'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='9'/>
+ </channel>
+ <channel type='tcp'>
+ <source mode='bind' host='1.2.3.4' service='5678'/>
+ <protocol type='raw'/>
+ <target type='virtio' name='chardev-tcp-listen-raw'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='10'/>
+ </channel>
+ <channel type='tcp'>
+ <source mode='bind' host='1.2.3.4' service='5679'/>
+ <protocol type='telnet'/>
+ <target type='virtio' name='chardev-tcp-listen-telnet'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='11'/>
+ </channel>
+ <channel type='tcp'>
+ <source mode='connect' host='1.2.3.4' service='5678'
tls='yes'>
+ <reconnect enabled='yes' timeout='2'/>
+ </source>
+ <protocol type='raw'/>
+ <target type='virtio' name='chardev-tcp-connect-raw'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='12'/>
+ </channel>
+ <channel type='tcp'>
+ <source mode='connect' host='hostname.global.'
service='5679' tls='yes'>
+ <reconnect enabled='yes' timeout='2'/>
+ </source>
+ <protocol type='telnet'/>
+ <target type='virtio' name='chardev-tcp-connect-telnet'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='13'/>
+ </channel>
+ <channel type='udp'>
+ <source mode='connect' host='127.0.0.1'
service='2222'/>
+ <target type='virtio' name='chardev-udp-nobind'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='14'/>
+ </channel>
+ <channel type='udp'>
+ <source mode='bind' host='127.0.0.1'
service='1111'/>
+ <source mode='connect' host='127.0.0.1'
service='2222'/>
+ <target type='virtio' name='chardev-udp-bind'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='15'/>
+ </channel>
+ <channel type='spicevmc'>
+ <target type='virtio' name='com.redhat.spice.0'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='16'/>
+ </channel>
+ <channel type='qemu-vdagent'>
+ <source>
+ <clipboard copypaste='no'/>
+ <mouse mode='server'/>
+ </source>
+ <target type='virtio' name='chardev-vdagent'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='17'/>
+ </channel>
+ <channel type='dbus'>
+ <source channel='test.channel.0'/>
+ <target type='virtio' name='chardev-dbus'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='18'/>
+ </channel>
+ <channel type='spiceport'>
+ <source channel='test.channel.0'/>
+ <target type='virtio' name='chardev-spiceport'/>
+ <address type='virtio-serial' controller='0' bus='0'
port='19'/>
+ </channel>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='spice' autoport='yes'
listen='0.0.0.0'>
+ <listen type='address' address='0.0.0.0'/>
+ </graphics>
+ <audio id='1' type='spice'/>
+ <video>
+ <model type='cirrus' vram='16384' heads='1'
primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconfdata/chardev-backends.xml
b/tests/qemuxmlconfdata/chardev-backends.xml
new file mode 100644
index 0000000000..c92489ce4c
--- /dev/null
+++ b/tests/qemuxmlconfdata/chardev-backends.xml
@@ -0,0 +1,111 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <channel type='null'>
+ <target type='virtio' name='chardev-null'/>
+ <log file='/path/to/null.log' append='off'/>
+ </channel>
+ <channel type='vc'>
+ <target type='virtio' name='chardev-vc'/>
+ <log file='/path/to/vc.log' append='on'/>
+ </channel>
+ <channel type='pty'>
+ <target type='virtio' name='chardev-pty'/>
+ </channel>
+ <channel type='stdio'>
+ <target type='virtio' name='chardev-stdio'/>
+ </channel>
+ <channel type='file'>
+ <source path='/path/to/fileout'/>
+ <target type='virtio' name='chardev-file'/>
+ </channel>
+ <channel type='pipe'>
+ <source path='/path/to/pipe'/>
+ <target type='virtio' name='chardev-pipe'/>
+ </channel>
+ <channel type='dev'>
+ <source path='/path/to/device'/>
+ <target type='virtio' name='chardev-dev'/>
+ </channel>
+ <channel type='unix'>
+ <source mode='bind' path='/path/to/unix-listen'/>
+ <target type='virtio' name='chardev-unix-listen'/>
+ </channel>
+ <channel type='unix'>
+ <source mode='connect' path='/path/to/unix-listen'>
+ <reconnect enabled='yes' timeout='2'/>
+ </source>
+ <target type='virtio' name='chardev-unix-connect'/>
+ </channel>
+ <channel type='tcp'>
+ <source mode='bind' host='1.2.3.4' service='5678'/>
+ <protocol type='raw'/>
+ <target type='virtio' name='chardev-tcp-listen-raw'/>
+ </channel>
+ <channel type='tcp'>
+ <source mode='bind' host='1.2.3.4' service='5679'/>
+ <protocol type='telnet'/>
+ <target type='virtio' name='chardev-tcp-listen-telnet'/>
+ </channel>
+ <channel type='tcp'>
+ <source mode='connect' host='1.2.3.4' service='5678'
tls='yes'>
+ <reconnect enabled='yes' timeout='2'/>
+ </source>
+ <protocol type='raw'/>
+ <target type='virtio' name='chardev-tcp-connect-raw'/>
+ </channel>
+ <channel type='tcp'>
+ <source mode='connect' host='hostname.global.'
service='5679' tls='yes'>
+ <reconnect enabled='yes' timeout='2'/>
+ </source>
+ <protocol type='telnet'/>
+ <target type='virtio' name='chardev-tcp-connect-telnet'/>
+ </channel>
+ <channel type='udp'>
+ <source mode='connect' host='127.0.0.1'
service='2222'/>
+ <target type='virtio' name='chardev-udp-nobind'/>
+ </channel>
+ <channel type='udp'>
+ <source mode='bind' host='127.0.0.1'
service='1111'/>
+ <source mode='connect' host='127.0.0.1'
service='2222'/>
+ <target type='virtio' name='chardev-udp-bind'/>
+ </channel>
+ <!-- The commandline formatter requires that the target is strictly
'com.redhat.spice.0',
+ and spice graphics is present. -->
+ <channel type='spicevmc'>
+ <target type='virtio' name='com.redhat.spice.0'/>
+ </channel>
+ <channel type='qemu-vdagent'>
+ <target type='virtio' name='chardev-vdagent'/>
+ <source>
+ <clipboard copypaste='no'/>
+ <mouse mode='server'/>
+ </source>
+ </channel>
+ <channel type='dbus'>
+ <source channel='test.channel.0'/>
+ <target type='virtio' name='chardev-dbus'/>
+ </channel>
+ <channel type='spiceport'>
+ <source channel='test.channel.0'/>
+ <target type='virtio' name='chardev-spiceport'/>
+ </channel>
+ <!-- parallel port with 'dev' type is special as it has a specific backend
in qemu -->
+ <parallel type='dev'>
+ <source path='/dev/parport0'/>
+ <target port='0'/>
+ </parallel>
+ <!-- spice graphics required by some of the spice-transported backends -->
+ <graphics type='spice' autoport='yes'
listen='0.0.0.0'>
+ <listen type='address' address='0.0.0.0'/>
+ </graphics>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index 323fd9d721..6fc8d5eabd 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -1830,6 +1830,8 @@ mymain(void)
DO_TEST_CAPS_LATEST("console-compat-auto");
DO_TEST_CAPS_LATEST("console-compat-crash");
+ DO_TEST_CAPS_LATEST("chardev-backends");
+
DO_TEST_CAPS_LATEST("serial-vc-chardev");
DO_TEST_CAPS_LATEST("serial-pty-chardev");
DO_TEST_CAPS_LATEST("serial-dev-chardev");
--
2.46.0