virtio_console test v3.0
Cheers,
we are back with new version of virtio_console. This version is more similar to upstream C virtio_console test so it will be easier to maintain. Also we moved the scripts/console_switch.py to more sensible scripts/virtio_guest.py
the patch with explanation follows.
Best regards,
Lukas and Jiri
New version of virtio_console test is more similar to upstream C virtio_console test so it will be easier to maintain. Also we moved the scripts/console_switch.py to more sensible scripts/virtio_guest.py
There are still some virtio_console bugs which restricts some usage (mostly with console). We have created workarounds which enables us to run the tests. They are marked as FIXME comments.
It tests more virtio_console features:
[preparation]:
* Prepare for testing
* test parameters '$console_type:$data;...'
1) creates GUEST machine with virtio_ports (serialport/consoles)
2) Initiate connection; defines and verifies the virtio_ports on GUEST side.
[test_smoke]:
* Tests the basic capabilities of virtio_consoles.
* test parameters, multiple recievers allowe. '$source_console_type@$buffer_length:$destination_console_type1@buffer_length:...:$loopback_buffer_length;...'
1) POLL test (IN,OUT,HUP)
2) Read/write without connected host
3) Read in nonblocking and blocking mode
4) Basic loopback test (different from test_loopback test)
[test_loopback]:
*Creates a loopback between sender port and receiving port, send data through this connection, verify data correctness.
* test parameters '$console_type@$buffer_length:$test_duration;...'
* link checking mode is configurable by virtio_check_mode = {none, poll, select}
1) GUEST: creates loopback between specified ports
2) HOST: creates thread for sending data and storing them into verification buffer
3) HOST: creates threads for receiving data and comparing them with verification buffer
4) let it work for 60 seconds
5) Exit threads and loopback
[test_perf]:
* Measure performance for the virtio console tunnel
---< Host->Guest >---
1) GUEST: creates loopback between the port and nothing (read and forget)
2) HOST: prepare for data send (sending thread, stats, cpu loads)
3) HOST: starts sending the data in loop for specified period of time
4) HOST: stop the sending and process stats/cpu loads
5) Exit threads and loopback
---< Guest->Host >---
1) GUEST: inits sender thread
2) HOST: prepare for receiving data (recv thread, stats, cpu loads)
3) GUEST: starts sending the data
4) HOST: stop logging stats
5) GUEST: exit sending thread
6) HOST: finish receiving
--- client/tests/kvm/scripts/console_switch.py | 219 --------- client/tests/kvm/scripts/virtio_guest.py | 571 ++++++++++++++++++++++ client/tests/kvm/tests/virtio_console.py | 730 +++++++++++++++++----------- client/tests/kvm/tests_base.cfg.sample | 8 +- 4 files changed, 1022 insertions(+), 506 deletions(-) delete mode 100644 client/tests/kvm/scripts/console_switch.py create mode 100644 client/tests/kvm/scripts/virtio_guest.py
client/tests/kvm/scripts/console_switch.py deleted +0 -219
@@ -1,219 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -""" -Auxiliary script used to send data between ports on guests. - -@copyright: 2008-2009 Red Hat Inc. -@author: Jiri Zupka ([email protected]) -@author: Lukas Doktor ([email protected]) -""" -import threading -from threading import Thread -import os,time,select,re,random,sys,array - -files = {} -ev = threading.Event() -threads = [] - -DEBUGPATH="/sys/kernel/debug" - - -class Switch(Thread): - """ - Create a thread which sends data between ports. - """ - def __init__(self, exitevent, in_files, out_files, cachesize=1): - """ - @param exitevent: Event to end switch. - @param in_files: Array of input files. - @param out_files: Array of output files. - @param cachesize: Block to receive and send. - """ - Thread.__init__(self) - - self.in_files = in_files - self.out_files = out_files - - self.cachesize = cachesize - self.exitevent = exitevent - - - def run(self): - while not self.exitevent.isSet(): - #TODO: Why select causes trouble? :-( - #ret = select.select(self.in_files,[],[],1.0) - data = "" - #if not ret[0] == []: - for desc in self.in_files: - data += os.read(desc, self.cachesize) - for desc in self.out_files: - os.write(desc, data) - - -class Sender(Thread): - """ - Creates thread which sends random blocks of data to the destination port. - """ - def __init__(self, port, length): - """ - @param port: Destination port. - @param length: Length of the random data block. - """ - Thread.__init__(self) - self.port = port - self.data = array.array('L') - for i in range(max(length/self.data.itemsize, 1)): - self.data.append(random.randrange(sys.maxint)) - - - def run(self): - while True: - os.write(self.port, self.data) - del threads[:] - - -def get_port_status(): - """ - Get info about ports from kernel debugfs. - - @return: ports dictionary of port properties - """ - ports = {} - - not_present_msg = "FAIL: There's no virtio-ports dir in debugfs" - if not os.path.ismount(DEBUGPATH): - os.system('mount -t debugfs none %s' % DEBUGPATH) - try: - if not os.path.isdir('%s/virtio-ports' % DEBUGPATH): - print not_present_msg - except: - print not_present_msg - else: - viop_names = os.listdir('%s/virtio-ports' % DEBUGPATH) - for name in viop_names: - f = open("%s/virtio-ports/%s" % (DEBUGPATH, name), 'r') - port = {} - for line in iter(f): - m = re.match("(\S+): (\S+)",line) - port[m.group(1)] = m.group(2) - - if (port['is_console'] == "yes"): - port["path"] = "/dev/hvc%s" % port["console_vtermno"] - # Console works like a serialport - else: - port["path"] = "/dev/%s" % name - ports[port['name']] = port - f.close() - - return ports - - -def open_device(in_files, ports): - """ - Open devices and return an array of descriptors. - - @param in_files: files array - @return: array of descriptors - """ - f = [] - - for item in in_files: - name = ports[item[0]]["path"] - if (not item[1] == ports[item[0]]["is_console"]): - print ports - print "FAIL: Host console is not like console on guest side\n" - - if (name in files): - f.append(files[name]) - else: - try: - files[name] = os.open(name, os.O_RDWR) - if (ports[item[0]]["is_console"] == "yes"): - print os.system("stty -F %s raw -echo" % - (ports[item[0]]["path"])) - print os.system("stty -F %s -a" % ports[item[0]]["path"]) - f.append(files[name]) - except Exception as inst: - print "FAIL: Failed to open file %s" % name - raise inst - return f - - -def start_switch(in_files,out_files,cachesize=1): - """ - Start a switch thread - (because there is a problem with opening one file multiple times). - - @param in_files: array of input files - @param out_files: array of output files - @param cachesize: cachesize - """ - ports = get_port_status() - - in_f = open_device(in_files, ports) - out_f = open_device(out_files, ports) - - s = Switch(ev, in_f, out_f, cachesize) - s.start() - threads.append(s) - - print "PASS: Start switch" - - -def end_switches(): - """ - End all running data switches. - """ - ev.set() - for th in threads: - print "join" - th.join(3.0) - ev.clear() - - del threads[:] - print "PASS: End switch" - - -def die(): - """ - Quit consoleswitch. - """ - for desc in files.itervalues(): - os.close(desc) - current_pid = os.getpid() - os.kill(current_pid, 15) - - -def sender_prepare(port, length): - """ - Prepares the sender thread. Requires a clean thread structure. - """ - del threads[:] - ports = get_port_status() - in_f = open_device([port], ports) - - threads.append(Sender(in_f[0], length)) - print "PASS: Sender prepare" - - -def sender_start(): - """ - Start sender data transfer. Requires sender_prepare to run first. - """ - threads[0].start() - print "PASS: Sender start" - - -def main(): - """ - Main (infinite) loop of console_switch. - """ - print "PASS: Start" - end = False - while not end: - str = raw_input() - exec str - - -if __name__ == "__main__": - main()
client/tests/kvm/scripts/virtio_guest.py new file +571 -0
571 lines not on this page · raw message
client/tests/kvm/tests/virtio_console.py +445 -285
1,073 lines not on this page · raw message
client/tests/kvm/tests_base.cfg.sample +6 -2
@@ -502,11 +502,15 @@ variants: vms = '' type = virtio_console # smoke params - $console_type:data_string - virtio_console_smoke = "serialport;console:Custom data" + # FIXME: test_smoke doesn't work with console yet (virtio_console bug) + # "serialport;console:Custom data" + virtio_console_smoke = "serialport" # loopback params - '$source_console_type@buffer_length:$destination_console_type1@buffer_length:...:$loopback_buffer_length;...' virtio_console_loopback = "serialport:serialport;serialport@1024:serialport@32:console@1024:console@8:16" # perf params - $console_type@buffer_length:$test_duration - virtio_console_perf = "serialport;serialport@1000000:120;console@1024:60" + # FIXME: test_perf doesn't work with console yet (virtio_console bug) + # virtio_console_perf = "serialport;serialport@1000000:120;console@1024:60" + virtio_console_perf = "serialport;serialport@1000000:120" # This unit test module is for older branches of KVM that use the # kvmctl test harness (such as the code shipped with RHEL 5.x)
Signature · 1 line
1.7.2.2
Quoted 3 lines · Lukas Doktor
New version of
virtio_consoletest is more similar to upstream Cvirtio_consoletest so it will be easier to maintain. Also we moved thescripts/console_switch.pyto more sensiblescripts/virtio_guest.pyThere are still some
virtio_consolebugs which restricts some usage (mostly with console). We have created workarounds which enables us to run the tests. They are marked as FIXME comments.
I'm guessing you're seeing those bugs because you try open/close/etc. calls on the hvc devices. That's not how they're supposed to be used. As I mentioned previously, you should spawn a terminal on hvc and use it for console IO.
I'll take a look at the rest in a bit.
Amit