[libvirt] [PATCH 5/5] tests: add qemu chardev srouce reconnect tests

Pavel Hrdina posted 5 patches 7 years, 8 months ago
[libvirt] [PATCH 5/5] tests: add qemu chardev srouce reconnect tests
Posted by Pavel Hrdina 7 years, 8 months ago
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 .../qemuxml2argv-channel-reconnect.args            | 31 +++++++++++++++
 ...uxml2argv-chardev-reconnect-invalid-timeout.xml | 23 +++++++++++
 .../qemuxml2argv-chardev-reconnect.args            | 40 +++++++++++++++++++
 .../qemuxml2argv-chardev-reconnect.xml             | 46 ++++++++++++++++++++++
 tests/qemuxml2argvtest.c                           | 11 ++++++
 5 files changed, 151 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-invalid-timeout.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args
new file mode 100644
index 0000000000..43a5d5bb3e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args
@@ -0,0 +1,31 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefconfig \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline \
+-no-acpi \
+-boot c \
+-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
+-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 \
+-usb \
+-chardev socket,id=charchannel0,host=localhost,port=1234,reconnect=10 \
+-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\
+id=channel0,name=asdf \
+-chardev socket,id=charchannel1,path=/tmp/channel/domain--1-QEMUGuest1/fdsa,\
+server,nowait,reconnect=10 \
+-device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,\
+id=channel1,name=fdsa
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-invalid-timeout.xml b/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-invalid-timeout.xml
new file mode 100644
index 0000000000..73dac66816
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-invalid-timeout.xml
@@ -0,0 +1,23 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <controller type='virtio-serial' index='1'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
+    </controller>
+    <channel type='tcp'>
+      <source host='localhost' service='1234'>
+        <reconnect enabled='yes' timeout='0'/>
+      </source>
+      <target type='virtio' name='asdf'/>
+    </channel>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.args b/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.args
new file mode 100644
index 0000000000..133a2c6039
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.args
@@ -0,0 +1,40 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefconfig \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline \
+-no-acpi \
+-boot c \
+-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
+-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 \
+-device usb-ccid,id=ccid0,bus=usb.0,port=1 \
+-usb \
+-chardev socket,id=charsmartcard0,path=/tmp/channel/domain-oldname/asdf,\
+reconnect=20 \
+-device ccid-card-passthru,chardev=charsmartcard0,id=smartcard0,bus=ccid0.0 \
+-chardev socket,id=charchannel0,host=localhost,port=1234,reconnect=10 \
+-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\
+id=channel0,name=asdf \
+-chardev socket,id=charchannel1,path=/tmp/channel/domain--1-QEMUGuest1/fdsa,\
+server,nowait,reconnect=0 \
+-device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,\
+id=channel1,name=fdsa \
+-chardev socket,id=charredir0,host=localhost,port=3456,reconnect=15 \
+-device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=2 \
+-chardev socket,id=charrng0,host=localhost,port=2345,reconnect=5 \
+-object rng-egd,id=objrng0,chardev=charrng0 \
+-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.xml b/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.xml
new file mode 100644
index 0000000000..e0664b2a95
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.xml
@@ -0,0 +1,46 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <controller type='virtio-serial' index='1'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
+    </controller>
+    <redirdev bus='usb' type='tcp'>
+      <source mode='connect' host='localhost' service='3456'>
+        <reconnect enabled='yes' timeout='15'/>
+      </source>
+    </redirdev>
+    <smartcard mode='passthrough' type='unix'>
+      <source mode='connect' path='/tmp/channel/domain-oldname/asdf'>
+        <reconnect enabled='yes' timeout='20'/>
+      </source>
+    </smartcard>
+    <channel type='tcp'>
+      <source mode='connect' host='localhost' service='1234'>
+        <reconnect enabled='yes' timeout='10'/>
+      </source>
+      <target type='virtio' name='asdf'/>
+    </channel>
+    <channel type='unix'>
+      <source mode='connect' path='/tmp/channel/domain-oldname/fdsa'>
+        <reconnect enabled='no'/>
+      </source>
+      <target type='virtio' name='fdsa'/>
+    </channel>
+    <memballoon model='none'/>
+    <rng model='virtio'>
+      <backend model='egd' type='tcp'>
+        <source mode='connect' host='localhost' service='2345'>
+          <reconnect enabled='yes' timeout='5'/>
+        </source>
+      </backend>
+    </rng>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 5cdbc78eb8..39f8d66c04 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1341,6 +1341,17 @@ mymain(void)
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_CCID_EMULATED);
 
+    DO_TEST("chardev-reconnect",
+            QEMU_CAPS_NODEFCONFIG,
+            QEMU_CAPS_CHARDEV_RECONNECT,
+            QEMU_CAPS_USB_REDIR,
+            QEMU_CAPS_DEVICE_VIRTIO_RNG,
+            QEMU_CAPS_OBJECT_RNG_EGD,
+            QEMU_CAPS_CCID_PASSTHRU);
+    DO_TEST_PARSE_ERROR("chardev-reconnect-invalid-timeout",
+                        QEMU_CAPS_NODEFCONFIG,
+                        QEMU_CAPS_CHARDEV_RECONNECT);
+
     DO_TEST("usb-controller",
             QEMU_CAPS_NODEFCONFIG);
     DO_TEST("usb-piix3-controller",
-- 
2.13.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/5] tests: add qemu chardev srouce reconnect tests
Posted by Ján Tomko 7 years, 8 months ago
s/srouce/source/

Jan
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/5] tests: add qemu chardev srouce reconnect tests
Posted by Michal Privoznik 7 years, 8 months ago
On 08/28/2017 02:56 PM, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  .../qemuxml2argv-channel-reconnect.args            | 31 +++++++++++++++
>  ...uxml2argv-chardev-reconnect-invalid-timeout.xml | 23 +++++++++++
>  .../qemuxml2argv-chardev-reconnect.args            | 40 +++++++++++++++++++
>  .../qemuxml2argv-chardev-reconnect.xml             | 46 ++++++++++++++++++++++
>  tests/qemuxml2argvtest.c                           | 11 ++++++
>  5 files changed, 151 insertions(+)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-invalid-timeout.xml
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.args
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.xml
> 
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args
> new file mode 100644
> index 0000000000..43a5d5bb3e
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args
> @@ -0,0 +1,31 @@
> +LC_ALL=C \
> +PATH=/bin \
> +HOME=/home/test \
> +USER=test \
> +LOGNAME=test \
> +QEMU_AUDIO_DRV=none \
> +/usr/bin/qemu-system-i686 \
> +-name QEMUGuest1 \
> +-S \
> +-M pc \
> +-m 214 \
> +-smp 1,sockets=1,cores=1,threads=1 \
> +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
> +-nographic \
> +-nodefconfig \
> +-nodefaults \
> +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
> +server,nowait \
> +-mon chardev=charmonitor,id=monitor,mode=readline \
> +-no-acpi \
> +-boot c \
> +-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
> +-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 \
> +-usb \
> +-chardev socket,id=charchannel0,host=localhost,port=1234,reconnect=10 \
> +-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\
> +id=channel0,name=asdf \
> +-chardev socket,id=charchannel1,path=/tmp/channel/domain--1-QEMUGuest1/fdsa,\
> +server,nowait,reconnect=10 \

This doesn't look right. How come a server can have reconnect at the
same time?

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/5] tests: add qemu chardev srouce reconnect tests
Posted by Pavel Hrdina 7 years, 8 months ago
On Tue, Aug 29, 2017 at 11:17:13AM +0200, Michal Privoznik wrote:
> On 08/28/2017 02:56 PM, Pavel Hrdina wrote:
> > Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> > ---
> >  .../qemuxml2argv-channel-reconnect.args            | 31 +++++++++++++++
> >  ...uxml2argv-chardev-reconnect-invalid-timeout.xml | 23 +++++++++++
> >  .../qemuxml2argv-chardev-reconnect.args            | 40 +++++++++++++++++++
> >  .../qemuxml2argv-chardev-reconnect.xml             | 46 ++++++++++++++++++++++
> >  tests/qemuxml2argvtest.c                           | 11 ++++++
> >  5 files changed, 151 insertions(+)
> >  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args
> >  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-invalid-timeout.xml
> >  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.args
> >  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.xml
> > 
> > diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args
> > new file mode 100644
> > index 0000000000..43a5d5bb3e
> > --- /dev/null
> > +++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args
> > @@ -0,0 +1,31 @@
> > +LC_ALL=C \
> > +PATH=/bin \
> > +HOME=/home/test \
> > +USER=test \
> > +LOGNAME=test \
> > +QEMU_AUDIO_DRV=none \
> > +/usr/bin/qemu-system-i686 \
> > +-name QEMUGuest1 \
> > +-S \
> > +-M pc \
> > +-m 214 \
> > +-smp 1,sockets=1,cores=1,threads=1 \
> > +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
> > +-nographic \
> > +-nodefconfig \
> > +-nodefaults \
> > +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
> > +server,nowait \
> > +-mon chardev=charmonitor,id=monitor,mode=readline \
> > +-no-acpi \
> > +-boot c \
> > +-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
> > +-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 \
> > +-usb \
> > +-chardev socket,id=charchannel0,host=localhost,port=1234,reconnect=10 \
> > +-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\
> > +id=channel0,name=asdf \
> > +-chardev socket,id=charchannel1,path=/tmp/channel/domain--1-QEMUGuest1/fdsa,\
> > +server,nowait,reconnect=10 \
> 
> This doesn't look right. How come a server can have reconnect at the
> same time?

Yes, that is strange.  If you look at the XML the mode is connect so
there is something else going on.  I'll investigate the issue.  Also
I've noticed that one file [1] shouldn't be included in that patch.
I'll send a followup to clean that file.

Pavel

[1] <tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/5] tests: add qemu chardev srouce reconnect tests
Posted by Pavel Hrdina 7 years, 8 months ago
On Tue, Aug 29, 2017 at 11:17:13AM +0200, Michal Privoznik wrote:
> On 08/28/2017 02:56 PM, Pavel Hrdina wrote:
> > Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> > ---
> >  .../qemuxml2argv-channel-reconnect.args            | 31 +++++++++++++++
> >  ...uxml2argv-chardev-reconnect-invalid-timeout.xml | 23 +++++++++++
> >  .../qemuxml2argv-chardev-reconnect.args            | 40 +++++++++++++++++++
> >  .../qemuxml2argv-chardev-reconnect.xml             | 46 ++++++++++++++++++++++
> >  tests/qemuxml2argvtest.c                           | 11 ++++++
> >  5 files changed, 151 insertions(+)
> >  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args
> >  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-invalid-timeout.xml
> >  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.args
> >  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect.xml
> > 
> > diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args
> > new file mode 100644
> > index 0000000000..43a5d5bb3e
> > --- /dev/null
> > +++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-reconnect.args
> > @@ -0,0 +1,31 @@
> > +LC_ALL=C \
> > +PATH=/bin \
> > +HOME=/home/test \
> > +USER=test \
> > +LOGNAME=test \
> > +QEMU_AUDIO_DRV=none \
> > +/usr/bin/qemu-system-i686 \
> > +-name QEMUGuest1 \
> > +-S \
> > +-M pc \
> > +-m 214 \
> > +-smp 1,sockets=1,cores=1,threads=1 \
> > +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
> > +-nographic \
> > +-nodefconfig \
> > +-nodefaults \
> > +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
> > +server,nowait \
> > +-mon chardev=charmonitor,id=monitor,mode=readline \
> > +-no-acpi \
> > +-boot c \
> > +-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
> > +-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 \
> > +-usb \
> > +-chardev socket,id=charchannel0,host=localhost,port=1234,reconnect=10 \
> > +-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\
> > +id=channel0,name=asdf \
> > +-chardev socket,id=charchannel1,path=/tmp/channel/domain--1-QEMUGuest1/fdsa,\
> > +server,nowait,reconnect=10 \
> 
> This doesn't look right. How come a server can have reconnect at the
> same time?

So there are two issues with our code:

1. We successfully parse this configuration:

    ...
    <channel type='unix'>
      <source mode='connect'/>
      <target type='virtio' name='test'/>
    </channel>
    ...

While formatting the XML we ignore the source element if there is no
path and the code starting a domain generates a new path and set's the
mode to 'bind'.  With the reconnect patches if we parse the reconnect
it's unconditionally put to the command line if it was parsed even
though the mode was changed.

2. This test uses a path that matches a pattern of automatically
generated paths by libvirt:

      ...
      <source mode='connect' path='/tmp/channel/domain-oldname/fdsa'>
        <reconnect enabled='no'/>
      </source>
      ...

and our code removes that path in order to get it automatically
generated following new rules and also changes the mode to "bind" and
that leads to the same issue as for the first example.

I'll send a patches to fix it.

Pavel
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list