virtio_console test
Hi,
This patch adds new test for virtio_console. It supports booth, serialport and console, virtio_console types and it contains three tests:
1) smoke
2) loopback
3) perf
Before any tests are executed it starts the machine with required number of virtio_consoles. Than it allows user to run all three tests. Using the parameters user can control which tests are executed and what setting is used. All tests supports multiple run using ';' separated list of settings. Most of the settings are optional only. The mandatory ones are written in CAPITALS.
ad1) virtio_console_smoke format:
$VIRTIO_CONSOLE_TYPE:$custom_data
It creates a loopback via $VIRTIO_CONSOLE_TYPE console and sends $custom_data. If the received data match the original test pass
ad2) virtio_console_loopback format:
$SOURCE_CONSOLE_TYPE@$buffer_length:$DESTINATION_CONSOLE1_TYPE@$buffer_length:...:$DESTINATION_CONSOLEx_TYPE@$buffer_length:$loopback_buffer_length
Creates loopback between the $SOURCE_CONSOLE_TYPE console and all following $DESTINATION_CONSOLEn_TYPE consoles. Than it sends data by $buffer_length to the source port. The loopback resends the data by $loopback_buffer_length to all destination consoles. The test listens on the destination consoles and controls the received data.
NOTE: in the debug mode you can see the send/received data's buffers in every second during the test.
ad3) virtio_console_perf format:
$VIRTIO_CONSOLE_TYPE@$buffer_size:$test_duration
First it sends the prepared data in a loop over $VIRTIO_CONSOLE_TYPE console from host to guest. Guest only reads all the data and throw them away. This part runs $test_duration seconds. Second it does the same from guest to host.
For booth runs it provides information of minimum/median/maximum throughput and guest/host average loads.
Best regards,
Lukas Doktor
PATCH 1/1 NEW virtio_console test
--- client/tests/kvm/scripts/consoleSwitch.py | 217 +++++++++ client/tests/kvm/tests/virtio_console.py | 730 +++++++++++++++++++++++++++++ client/tests/kvm/tests_base.cfg.sample | 7 + 3 files changed, 954 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/scripts/consoleSwitch.py create mode 100644 client/tests/kvm/tests/virtio_console.py
client/tests/kvm/scripts/consoleSwitch.py new file +217 -0
@@ -0,0 +1,217 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +""" +Auxiliary script used to send data betwen 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 = dict() +ev = threading.Event() +threads = [] + +DEBUGPATH="/sys/kernel/debug" + + + +class switch(Thread): + """ + Class create thread which send 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): + """ + Class creates thread which sends random block 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 getPortStatus(): + """ + Function get info about ports from kernel debugfs. + + @return: ports dictionary of port properties + """ + ports = dict() + + 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 "FAIL: Not exist virtio-ports in debug fs" + except: + print "FAIL: virtio-ports not exist" + else: + viop_names = os.listdir('%s/virtio-ports' % (DEBUGPATH)) + for name in viop_names: + f = open("%s/virtio-ports/%s" % (DEBUGPATH,name),'r') + port = dict() + 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 work like serialport + else: + port["path"] = "/dev/%s" % (name) + ports[port['name']] = port + f.close() + + return ports + + +def opendevice(in_files,ports): + """ + Open devices and return array of descriptors + + @param in_files: files array + @return: array of descriptor + """ + + 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 open file %s" % (name) + raise inst + return f + + +def startswitch(in_files,out_files,cachesize=1): + """ + Function starts switch thread (because there is problem with multiple open + of one files). + + @param in_files: array of input files + @param out_files: array of output files + @param cachesize: cachesize + """ + + + ports = getPortStatus() + + in_f = opendevice(in_files,ports) + out_f = opendevice(out_files,ports) + + + s = switch(ev,in_f,out_f,cachesize) + s.start() + threads.append(s) + print "PASS: Start switch" + +def endswitchs(): + """ + Function end all running data switch. + """ + 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) + exit(0) + +def senderprepare(port, length): + """ + Prepares the sender thread. Requires clean thread structure. + """ + del threads[:] + ports = getPortStatus() + in_f = opendevice([port],ports) + + threads.append(sender(in_f[0], length)) + print "PASS: Sender prepare" + +def senderstart(): + """ + Start sender data transfer. Requires senderprepare run firs. + """ + threads[0].start() + print "PASS: Sender start" + +def main(): + """ + Main (infinite) loop of consoleswitch. + """ + print "PASS: Start" + end = False + while not end: + str = raw_input() + exec str + + + +if __name__ == "__main__": + main()
client/tests/kvm/tests/virtio_console.py new file +730 -0
730 lines not on this page · raw message
client/tests/kvm/tests_base.cfg.sample +7 -0
@@ -380,6 +380,13 @@ variants: ksm_mode = "parallel" - iofuzz: type = iofuzz + + - virtio_console: + vms = '' + type = virtio_console + virtio_console_smoke = "serialport;console:Custom data" + virtio_console_loopback = "serialport:serialport;serialport@1024:serialport@32:console@1024:console@8:16" + virtio_console_perf = "serialport;serialport@1000000:120;console@1024:60" # 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.1
Dne 20.8.2010 15:40, Lukas Doktor napsal(a):
Quoted 31 lines
Hi,
This patch adds new test for
virtio_console. It supports booth, serialport and console,virtio_consoletypes and it contains three tests:
1) smoke
2) loopback
3) perfBefore any tests are executed it starts the machine with required number of
virtio_consoles. Than it allows user to run all three tests. Using the parameters user can control which tests are executed and what setting is used. All tests supports multiple run using ';' separated list of settings. Most of the settings are optional only. The mandatory ones are written in CAPITALS.ad1)
virtio_console_smokeformat:
$VIRTIO_CONSOLE_TYPE:$custom_dataIt creates a loopback via $VIRTIO_CONSOLE_TYPE console and sends $custom_data. If the received data match the original test pass
ad2)
virtio_console_loopbackformat:
$SOURCE_CONSOLE_TYPE@$buffer_length:$DESTINATION_CONSOLE1_TYPE@$buffer_length:...:$DESTINATION_CONSOLEx_TYPE@$buffer_length:$loopback_buffer_lengthCreates loopback between the $SOURCE_CONSOLE_TYPE console and all following $DESTINATION_CONSOLEn_TYPE consoles. Than it sends data by $buffer_length to the source port. The loopback resends the data by $loopback_buffer_length to all destination consoles. The test listens on the destination consoles and controls the received data.
NOTE: in the debug mode you can see the send/received data's buffers in every second during the test.
ad3)
virtio_console_perfformat:
$VIRTIO_CONSOLE_TYPE@$buffer_size:$test_durationFirst it sends the prepared data in a loop over $VIRTIO_CONSOLE_TYPE console from host to guest. Guest only reads all the data and throw them away. This part runs $test_duration seconds. Second it does the same from guest to host.
For booth runs it provides information of minimum/median/maximum throughput and guest/host average loads.
Quoted 6 lines
Best regards,
Lukas Doktor
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Just a note about kernels:
serialport works great but console have big issues. Use kernels >= 2.6.35 for testing.
Quoted 7 lines · Lukáš Doktor
Dne 20.8.2010 15:40, Lukas Doktor napsal(a):
Quoted 6 lines
Hi,
This patch adds new test for
virtio_console. It supports booth, serialport and console,virtio_consoletypes and it contains three tests:
1) smoke
2) loopback
3) perf
This is great, thanks for the tests.
I was working with Lucas at the KVM Forum to get my virtio-console tests integrated upstream. I have a few micro tests that test correctness of various bits in the virtio_console code:
http://fedorapeople.org/gitweb?p=amitshah/public_git/test-virtserial.git
It would be great to sync up with Lucas and add those tests to autotest as well.
Eventually, I'd also like to adapt the C code to python so that it integrates with KVM-autotest.
Quoted 3 lines
Just a note about kernels:
serialport works great but console have big issues. Use kernels >= 2.6.35 for testing.
Can you tell me what the issues are? I test console io in the testsuite mentioned above and it's been passing fine.
Amit
Hi Amit,
Dne 23.8.2010 09:53, Amit Shah napsal(a):
Quoted 9 lines · Lukáš Doktor
Quoted 7 lines
Dne 20.8.2010 15:40, Lukas Doktor napsal(a):
Quoted 6 lines
Hi,
This patch adds new test for
virtio_console. It supports booth, serialport and console,virtio_consoletypes and it contains three tests:
1) smoke
2) loopback
3) perf
Quoted 7 lines
This is great, thanks for the tests.
I was working with Lucas at the KVM Forum to get my virtio-console tests integrated upstream. I have a few micro tests that test correctness of various bits in the
virtio_consolecode:http://fedorapeople.org/gitweb?p=amitshah/public_git/test-virtserial.git
yes, I'm aware of your tests and the fedora page about virtio-console. I took an inspiration from them ;-) (thanks)
Quoted 3 lines
It would be great to sync up with Lucas and add those tests to autotest as well.
I went through the code trying to find tests missing in our autotest virtio_console.py test. Correct me if I'm wrong, but the missing tests are:
* variations on opening/writing/reading host/guest closed/open consoles and check the right handling
* guest caching (if necessarily)
Quoted 4 lines
Eventually, I'd also like to adapt the C code to python so that it integrates with KVM-autotest.
Yes, either you or I can do that. I would just need the test-requirement-list.
Quoted 7 lines
Quoted 3 lines
Just a note about kernels:
serialport works great but console have big issues. Use kernels>= 2.6.35 for testing.Can you tell me what the issues are? I test console io in the testsuite mentioned above and it's been passing fine.
Sometimes on F13 there were Oops while booting guests with virtconsoles. Also the sysfs informations about virtconsoles were sometimes mismatched. With vanilla kernel 2.6.35 it worked better with occasional Oops while booting the guest. My colleague was working on that part so when he's back from holiday he can provide more information.
With virtserialport it always worked correctly.
Quoted 1 line
Amit
Lukáš
Quoted 26 lines · Lukáš Doktor
Hi Amit,
Dne 23.8.2010 09:53, Amit Shah napsal(a):
Quoted 9 lines · Lukáš Doktor
Quoted 7 lines
Dne 20.8.2010 15:40, Lukas Doktor napsal(a):
Quoted 6 lines
Hi,
This patch adds new test for
virtio_console. It supports booth, serialport and console,virtio_consoletypes and it contains three tests:
1) smoke
2) loopback
3) perfQuoted 7 lines
This is great, thanks for the tests.
I was working with Lucas at the KVM Forum to get my virtio-console tests integrated upstream. I have a few micro tests that test correctness of various bits in the
virtio_consolecode:http://fedorapeople.org/gitweb?p=amitshah/public_git/test-virtserial.git
yes, I'm aware of your tests and the fedora page about virtio-console. I took an inspiration from them ;-) (thanks)
Quoted 3 lines
It would be great to sync up with Lucas and add those tests to autotest as well.
Quoted 6 lines
I went through the code trying to find tests missing in our autotest
virtio_console.pytest. Correct me if I'm wrong, but the missing tests are:* variations on opening/writing/reading host/guest closed/open consoles and check the right handling
Mostly checking for the open/read/write/close semantics, poll(), a new test that I added today for checking of blocking calls (read) in one thread while doing write in another.
I actually want to add a lot more (and even convert existing ones) to threads, since currently I can't guarantee that the guest commands are processed before any subsequent host commands (this means threading in the host, obviously).
Quoted 1 line
* guest caching (if necessarily)
Yes, guest caching isn't needed in the current code (they're kept around from the previous code where we had such a thing).
Quoted 5 lines
Quoted 2 lines
Eventually, I'd also like to adapt the C code to python so that it integrates with KVM-autotest.
Yes, either you or I can do that. I would just need the test-requirement-list.
I'd much prefer someone else did it, as I'm not familiar with python (yet).
I'll be willing to help you or whoever picks it up.
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines
Just a note about kernels:
serialport works great but console have big issues. Use kernels>= 2.6.35 for testing.Can you tell me what the issues are? I test console io in the testsuite mentioned above and it's been passing fine.
Sometimes on F13 there were Oops while booting guests with virtconsoles. Also the sysfs informations about virtconsoles were sometimes mismatched. With vanilla kernel 2.6.35 it worked better with occasional Oops while booting the guest.
I see. Can you give me any logs / oops messages / traces?
2.6.35 is the first kernel version to officially support the new features and is complete barring a few fixes which I haven't pushed out yet.
There's a chance that the F13 kernel doesn't have some fixes, but I did backport all of them AFAIR.
Quoted 2 lines
My colleague was working on that part so when he's back from holiday he can provide more information.
OK, let me know if you get more info.
Thanks,
Amit