* [PATCH 0/4] Renaming scripts that we run on guests
@ 2011-01-22 2:03 Lucas Meneghel Rodrigues
2011-01-22 2:03 ` [PATCH 1/4] KVM test: Renaming script bonding_setup.py to nic_bonding_guest.py Lucas Meneghel Rodrigues
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Lucas Meneghel Rodrigues @ 2011-01-22 2:03 UTC (permalink / raw)
To: autotest; +Cc: kvm, Lucas Meneghel Rodrigues
For the sake of clarity, we stablish a convention, scripts copied
to guests and executed there by tests will be called
[test_name]_guest.py. This patchset takes care of renaming
the scripts.
Lucas Meneghel Rodrigues (4):
KVM test: Renaming script bonding_setup.py to nic_bonding_guest.py
KVM test: Renaming join_mcast.py to multicast_guest.py
KVM test: renaming allocator.py to ksm_overcommit_guest.py
KVM test: Rename virtio_guest.py to virtio_console_guest.py
client/tests/kvm/scripts/allocator.py | 237 -------
client/tests/kvm/scripts/bonding_setup.py | 37 --
client/tests/kvm/scripts/join_mcast.py | 37 --
client/tests/kvm/scripts/ksm_overcommit_guest.py | 237 +++++++
client/tests/kvm/scripts/multicast_guest.py | 37 ++
client/tests/kvm/scripts/nic_bonding_guest.py | 37 ++
client/tests/kvm/scripts/virtio_console_guest.py | 715 ++++++++++++++++++++++
client/tests/kvm/scripts/virtio_guest.py | 715 ----------------------
client/tests/kvm/tests/ksm_overcommit.py | 40 +-
client/tests/kvm/tests/multicast.py | 4 +-
client/tests/kvm/tests/nic_bonding.py | 8 +-
client/tests/kvm/tests/virtio_console.py | 20 +-
12 files changed, 1063 insertions(+), 1061 deletions(-)
delete mode 100755 client/tests/kvm/scripts/allocator.py
delete mode 100644 client/tests/kvm/scripts/bonding_setup.py
delete mode 100755 client/tests/kvm/scripts/join_mcast.py
create mode 100755 client/tests/kvm/scripts/ksm_overcommit_guest.py
create mode 100755 client/tests/kvm/scripts/multicast_guest.py
create mode 100644 client/tests/kvm/scripts/nic_bonding_guest.py
create mode 100755 client/tests/kvm/scripts/virtio_console_guest.py
delete mode 100755 client/tests/kvm/scripts/virtio_guest.py
--
1.7.3.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] KVM test: Renaming script bonding_setup.py to nic_bonding_guest.py
2011-01-22 2:03 [PATCH 0/4] Renaming scripts that we run on guests Lucas Meneghel Rodrigues
@ 2011-01-22 2:03 ` Lucas Meneghel Rodrigues
2011-01-22 2:03 ` [PATCH 2/4] KVM test: Renaming join_mcast.py to multicast_guest.py Lucas Meneghel Rodrigues
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Lucas Meneghel Rodrigues @ 2011-01-22 2:03 UTC (permalink / raw)
To: autotest; +Cc: kvm, Lucas Meneghel Rodrigues
We'll stablish a convention (of course, no extremely strict)
about scripts ran in guest: We can call them [test_name]_guest.py.
Let's start by converting bonding_setup to this convention.
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
client/tests/kvm/scripts/bonding_setup.py | 37 -------------------------
client/tests/kvm/scripts/nic_bonding_guest.py | 37 +++++++++++++++++++++++++
client/tests/kvm/tests/nic_bonding.py | 8 +++---
3 files changed, 41 insertions(+), 41 deletions(-)
delete mode 100644 client/tests/kvm/scripts/bonding_setup.py
create mode 100644 client/tests/kvm/scripts/nic_bonding_guest.py
diff --git a/client/tests/kvm/scripts/bonding_setup.py b/client/tests/kvm/scripts/bonding_setup.py
deleted file mode 100644
index f2d4be9..0000000
--- a/client/tests/kvm/scripts/bonding_setup.py
+++ /dev/null
@@ -1,37 +0,0 @@
-import os, re, commands, sys
-"""This script is used to setup bonding, macaddr of bond0 should be assigned by
-argv1"""
-
-if len(sys.argv) != 2:
- sys.exit(1)
-mac = sys.argv[1]
-eth_nums = 0
-ifconfig_output = commands.getoutput("ifconfig")
-re_eth = "eth[0-9]*"
-for ename in re.findall(re_eth, ifconfig_output):
- eth_config_file = "/etc/sysconfig/network-scripts/ifcfg-%s" % ename
- eth_config = """DEVICE=%s
-USERCTL=no
-ONBOOT=yes
-MASTER=bond0
-SLAVE=yes
-BOOTPROTO=none
-""" % ename
- f = file(eth_config_file,'w')
- f.write(eth_config)
- f.close()
-
-bonding_config_file = "/etc/sysconfig/network-scripts/ifcfg-bond0"
-bond_config = """DEVICE=bond0
-BOOTPROTO=dhcp
-NETWORKING_IPV6=no
-ONBOOT=yes
-USERCTL=no
-MACADDR=%s
-""" % mac
-f = file(bonding_config_file, "w")
-f.write(bond_config)
-f.close()
-os.system("modprobe bonding")
-os.system("service NetworkManager stop")
-os.system("service network restart")
diff --git a/client/tests/kvm/scripts/nic_bonding_guest.py b/client/tests/kvm/scripts/nic_bonding_guest.py
new file mode 100644
index 0000000..f2d4be9
--- /dev/null
+++ b/client/tests/kvm/scripts/nic_bonding_guest.py
@@ -0,0 +1,37 @@
+import os, re, commands, sys
+"""This script is used to setup bonding, macaddr of bond0 should be assigned by
+argv1"""
+
+if len(sys.argv) != 2:
+ sys.exit(1)
+mac = sys.argv[1]
+eth_nums = 0
+ifconfig_output = commands.getoutput("ifconfig")
+re_eth = "eth[0-9]*"
+for ename in re.findall(re_eth, ifconfig_output):
+ eth_config_file = "/etc/sysconfig/network-scripts/ifcfg-%s" % ename
+ eth_config = """DEVICE=%s
+USERCTL=no
+ONBOOT=yes
+MASTER=bond0
+SLAVE=yes
+BOOTPROTO=none
+""" % ename
+ f = file(eth_config_file,'w')
+ f.write(eth_config)
+ f.close()
+
+bonding_config_file = "/etc/sysconfig/network-scripts/ifcfg-bond0"
+bond_config = """DEVICE=bond0
+BOOTPROTO=dhcp
+NETWORKING_IPV6=no
+ONBOOT=yes
+USERCTL=no
+MACADDR=%s
+""" % mac
+f = file(bonding_config_file, "w")
+f.write(bond_config)
+f.close()
+os.system("modprobe bonding")
+os.system("service NetworkManager stop")
+os.system("service network restart")
diff --git a/client/tests/kvm/tests/nic_bonding.py b/client/tests/kvm/tests/nic_bonding.py
index ca9d70a..52ce0ae 100644
--- a/client/tests/kvm/tests/nic_bonding.py
+++ b/client/tests/kvm/tests/nic_bonding.py
@@ -8,7 +8,7 @@ def run_nic_bonding(test, params, env):
Nic bonding test in guest.
1) Start guest with four nic models.
- 2) Setup bond0 in guest by script bonding_setup.py.
+ 2) Setup bond0 in guest by script nic_bonding_guest.py.
3) Execute file transfer test between guest and host.
4) Repeatedly put down/up interfaces by set_link
5) Execute file transfer test between guest and host.
@@ -34,9 +34,9 @@ def run_nic_bonding(test, params, env):
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
session_serial = vm.wait_for_serial_login(timeout=timeout)
- script_path = kvm_utils.get_path(test.bindir, "scripts/bonding_setup.py")
- vm.copy_files_to(script_path, "/tmp/bonding_setup.py")
- cmd = "python /tmp/bonding_setup.py %s" % vm.get_mac_address()
+ script_path = kvm_utils.get_path(test.bindir, "scripts/nic_bonding_guest.py")
+ vm.copy_files_to(script_path, "/tmp/nic_bonding_guest.py")
+ cmd = "python /tmp/nic_bonding_guest.py %s" % vm.get_mac_address()
session_serial.cmd(cmd)
termination_event = threading.Event()
--
1.7.3.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] KVM test: Renaming join_mcast.py to multicast_guest.py
2011-01-22 2:03 [PATCH 0/4] Renaming scripts that we run on guests Lucas Meneghel Rodrigues
2011-01-22 2:03 ` [PATCH 1/4] KVM test: Renaming script bonding_setup.py to nic_bonding_guest.py Lucas Meneghel Rodrigues
@ 2011-01-22 2:03 ` Lucas Meneghel Rodrigues
2011-01-22 2:03 ` [PATCH 3/4] KVM test: renaming allocator.py to ksm_overcommit_guest.py Lucas Meneghel Rodrigues
2011-01-22 2:03 ` [PATCH 4/4] KVM test: Rename virtio_guest.py to virtio_console_guest.py Lucas Meneghel Rodrigues
3 siblings, 0 replies; 5+ messages in thread
From: Lucas Meneghel Rodrigues @ 2011-01-22 2:03 UTC (permalink / raw)
To: autotest; +Cc: kvm
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
client/tests/kvm/scripts/join_mcast.py | 37 ---------------------------
client/tests/kvm/scripts/multicast_guest.py | 37 +++++++++++++++++++++++++++
client/tests/kvm/tests/multicast.py | 4 +-
3 files changed, 39 insertions(+), 39 deletions(-)
delete mode 100755 client/tests/kvm/scripts/join_mcast.py
create mode 100755 client/tests/kvm/scripts/multicast_guest.py
diff --git a/client/tests/kvm/scripts/join_mcast.py b/client/tests/kvm/scripts/join_mcast.py
deleted file mode 100755
index 350cd5f..0000000
--- a/client/tests/kvm/scripts/join_mcast.py
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/python
-import socket, struct, os, signal, sys
-# -*- coding: utf-8 -*-
-
-"""
-Script used to join machine into multicast groups.
-
-@author Amos Kong <akong@redhat.com>
-"""
-
-if __name__ == "__main__":
- if len(sys.argv) < 4:
- print """%s [mgroup_count] [prefix] [suffix]
- mgroup_count: count of multicast addresses
- prefix: multicast address prefix
- suffix: multicast address suffix""" % sys.argv[0]
- sys.exit()
-
- mgroup_count = int(sys.argv[1])
- prefix = sys.argv[2]
- suffix = int(sys.argv[3])
-
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- for i in range(mgroup_count):
- mcast = prefix + "." + str(suffix + i)
- try:
- mreq = struct.pack("4sl", socket.inet_aton(mcast),
- socket.INADDR_ANY)
- s.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
- except:
- s.close()
- print "Could not join multicast: %s" % mcast
- raise
-
- print "join_mcast_pid:%s" % os.getpid()
- os.kill(os.getpid(), signal.SIGSTOP)
- s.close()
diff --git a/client/tests/kvm/scripts/multicast_guest.py b/client/tests/kvm/scripts/multicast_guest.py
new file mode 100755
index 0000000..350cd5f
--- /dev/null
+++ b/client/tests/kvm/scripts/multicast_guest.py
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+import socket, struct, os, signal, sys
+# -*- coding: utf-8 -*-
+
+"""
+Script used to join machine into multicast groups.
+
+@author Amos Kong <akong@redhat.com>
+"""
+
+if __name__ == "__main__":
+ if len(sys.argv) < 4:
+ print """%s [mgroup_count] [prefix] [suffix]
+ mgroup_count: count of multicast addresses
+ prefix: multicast address prefix
+ suffix: multicast address suffix""" % sys.argv[0]
+ sys.exit()
+
+ mgroup_count = int(sys.argv[1])
+ prefix = sys.argv[2]
+ suffix = int(sys.argv[3])
+
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ for i in range(mgroup_count):
+ mcast = prefix + "." + str(suffix + i)
+ try:
+ mreq = struct.pack("4sl", socket.inet_aton(mcast),
+ socket.INADDR_ANY)
+ s.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
+ except:
+ s.close()
+ print "Could not join multicast: %s" % mcast
+ raise
+
+ print "join_mcast_pid:%s" % os.getpid()
+ os.kill(os.getpid(), signal.SIGSTOP)
+ s.close()
diff --git a/client/tests/kvm/tests/multicast.py b/client/tests/kvm/tests/multicast.py
index ddb7807..5dfecbc 100644
--- a/client/tests/kvm/tests/multicast.py
+++ b/client/tests/kvm/tests/multicast.py
@@ -53,9 +53,9 @@ def run_multicast(test, params, env):
prefix = re.findall("\d+.\d+.\d+", mcast)[0]
suffix = int(re.findall("\d+", mcast)[-1])
# copy python script to guest for joining guest to multicast groups
- mcast_path = os.path.join(test.bindir, "scripts/join_mcast.py")
+ mcast_path = os.path.join(test.bindir, "scripts/multicast_guest.py")
vm.copy_files_to(mcast_path, "/tmp")
- output = session.cmd_output("python /tmp/join_mcast.py %d %s %d" %
+ output = session.cmd_output("python /tmp/multicast_guest.py %d %s %d" %
(mgroup_count, prefix, suffix))
# if success to join multicast, the process will be paused, and return PID.
--
1.7.3.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] KVM test: renaming allocator.py to ksm_overcommit_guest.py
2011-01-22 2:03 [PATCH 0/4] Renaming scripts that we run on guests Lucas Meneghel Rodrigues
2011-01-22 2:03 ` [PATCH 1/4] KVM test: Renaming script bonding_setup.py to nic_bonding_guest.py Lucas Meneghel Rodrigues
2011-01-22 2:03 ` [PATCH 2/4] KVM test: Renaming join_mcast.py to multicast_guest.py Lucas Meneghel Rodrigues
@ 2011-01-22 2:03 ` Lucas Meneghel Rodrigues
2011-01-22 2:03 ` [PATCH 4/4] KVM test: Rename virtio_guest.py to virtio_console_guest.py Lucas Meneghel Rodrigues
3 siblings, 0 replies; 5+ messages in thread
From: Lucas Meneghel Rodrigues @ 2011-01-22 2:03 UTC (permalink / raw)
To: autotest; +Cc: kvm
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
client/tests/kvm/scripts/allocator.py | 237 ----------------------
client/tests/kvm/scripts/ksm_overcommit_guest.py | 237 ++++++++++++++++++++++
client/tests/kvm/tests/ksm_overcommit.py | 40 ++--
3 files changed, 258 insertions(+), 256 deletions(-)
delete mode 100755 client/tests/kvm/scripts/allocator.py
create mode 100755 client/tests/kvm/scripts/ksm_overcommit_guest.py
diff --git a/client/tests/kvm/scripts/allocator.py b/client/tests/kvm/scripts/allocator.py
deleted file mode 100755
index 09dc004..0000000
--- a/client/tests/kvm/scripts/allocator.py
+++ /dev/null
@@ -1,237 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-"""
-Auxiliary script used to allocate memory on guests.
-
-@copyright: 2008-2009 Red Hat Inc.
-@author: Jiri Zupka (jzupka@redhat.com)
-"""
-
-
-import os, array, sys, struct, random, copy, inspect, tempfile, datetime, math
-
-PAGE_SIZE = 4096 # machine page size
-
-TMPFS_OVERHEAD = 0.0022 # overhead on 1MB of write data
-
-
-class MemFill(object):
- """
- Fills guest memory according to certain patterns.
- """
- def __init__(self, mem, static_value, random_key):
- """
- Constructor of MemFill class.
-
- @param mem: Amount of test memory in MB.
- @param random_key: Seed of random series used for fill up memory.
- @param static_value: Value used to fill all memory.
- """
- if (static_value < 0 or static_value > 255):
- print ("FAIL: Initialization static value"
- "can be only in range (0..255)")
- return
-
- self.tmpdp = tempfile.mkdtemp()
- ret_code = os.system("mount -o size=%dM tmpfs %s -t tmpfs" %
- ((mem+math.ceil(mem*TMPFS_OVERHEAD)),
- self.tmpdp))
- if ret_code != 0:
- if os.getuid() != 0:
- print ("FAIL: Unable to mount tmpfs "
- "(likely cause: you are not root)")
- else:
- print "FAIL: Unable to mount tmpfs"
- else:
- self.f = tempfile.TemporaryFile(prefix='mem', dir=self.tmpdp)
- self.allocate_by = 'L'
- self.npages = ((mem * 1024 * 1024) / PAGE_SIZE)
- self.random_key = random_key
- self.static_value = static_value
- print "PASS: Initialization"
-
-
- def __del__(self):
- if os.path.ismount(self.tmpdp):
- self.f.close()
- os.system("umount %s" % (self.tmpdp))
-
-
- def compare_page(self, original, inmem):
- """
- Compare pages of memory and print the differences found.
-
- @param original: Data that was expected to be in memory.
- @param inmem: Data in memory.
- """
- for ip in range(PAGE_SIZE / original.itemsize):
- if (not original[ip] == inmem[ip]): # find which item is wrong
- originalp = array.array("B")
- inmemp = array.array("B")
- originalp.fromstring(original[ip:ip+1].tostring())
- inmemp.fromstring(inmem[ip:ip+1].tostring())
- for ib in range(len(originalp)): # find wrong byte in item
- if not (originalp[ib] == inmemp[ib]):
- position = (self.f.tell() - PAGE_SIZE + ip *
- original.itemsize + ib)
- print ("Mem error on position %d wanted 0x%Lx and is "
- "0x%Lx" % (position, originalp[ib], inmemp[ib]))
-
-
- def value_page(self, value):
- """
- Create page filled by value.
-
- @param value: String we want to fill the page with.
- @return: return array of bytes size PAGE_SIZE.
- """
- a = array.array("B")
- for i in range((PAGE_SIZE / a.itemsize)):
- try:
- a.append(value)
- except:
- print "FAIL: Value can be only in range (0..255)"
- return a
-
-
- def random_page(self, seed):
- """
- Create page filled by static random series.
-
- @param seed: Seed of random series.
- @return: Static random array series.
- """
- random.seed(seed)
- a = array.array(self.allocate_by)
- for i in range(PAGE_SIZE / a.itemsize):
- a.append(random.randrange(0, sys.maxint))
- return a
-
-
- def value_fill(self, value=None):
- """
- Fill memory page by page, with value generated with value_page.
-
- @param value: Parameter to be passed to value_page. None to just use
- what's on the attribute static_value.
- """
- self.f.seek(0)
- if value is None:
- value = self.static_value
- page = self.value_page(value)
- for pages in range(self.npages):
- page.tofile(self.f)
- print "PASS: Mem value fill"
-
-
- def value_check(self, value=None):
- """
- Check memory to see if data is correct.
-
- @param value: Parameter to be passed to value_page. None to just use
- what's on the attribute static_value.
- @return: if data in memory is correct return PASS
- else print some wrong data and return FAIL
- """
- self.f.seek(0)
- e = 2
- failure = False
- if value is None:
- value = self.static_value
- page = self.value_page(value)
- for pages in range(self.npages):
- pf = array.array("B")
- pf.fromfile(self.f, PAGE_SIZE / pf.itemsize)
- if not (page == pf):
- failure = True
- self.compare_page(page, pf)
- e = e - 1
- if e == 0:
- break
- if failure:
- print "FAIL: value verification"
- else:
- print "PASS: value verification"
-
-
- def static_random_fill(self, n_bytes_on_end=PAGE_SIZE):
- """
- Fill memory by page with static random series with added special value
- on random place in pages.
-
- @param n_bytes_on_end: how many bytes on the end of page can be changed.
- @return: PASS.
- """
- self.f.seek(0)
- page = self.random_page(self.random_key)
- random.seed(self.random_key)
- p = copy.copy(page)
-
- t_start = datetime.datetime.now()
- for pages in range(self.npages):
- rand = random.randint(((PAGE_SIZE / page.itemsize) - 1) -
- (n_bytes_on_end / page.itemsize),
- (PAGE_SIZE/page.itemsize) - 1)
- p[rand] = pages
- p.tofile(self.f)
- p[rand] = page[rand]
-
- t_end = datetime.datetime.now()
- delta = t_end - t_start
- milisec = delta.microseconds / 1e3 + delta.seconds * 1e3
- print "PASS: filling duration = %Ld ms" % milisec
-
-
- def static_random_verify(self, n_bytes_on_end=PAGE_SIZE):
- """
- Check memory to see if it contains correct contents.
-
- @return: if data in memory is correct return PASS
- else print some wrong data and return FAIL.
- """
- self.f.seek(0)
- e = 2
- page = self.random_page(self.random_key)
- random.seed(self.random_key)
- p = copy.copy(page)
- failure = False
- for pages in range(self.npages):
- rand = random.randint(((PAGE_SIZE/page.itemsize) - 1) -
- (n_bytes_on_end/page.itemsize),
- (PAGE_SIZE/page.itemsize) - 1)
- p[rand] = pages
- pf = array.array(self.allocate_by)
- pf.fromfile(self.f, PAGE_SIZE / pf.itemsize)
- if not (p == pf):
- failure = True
- self.compare_page(p, pf)
- e = e - 1
- if e == 0:
- break
- p[rand] = page[rand]
- if failure:
- print "FAIL: Random series verification"
- else:
- print "PASS: Random series verification"
-
-
-def die():
- """
- Quit allocator.
- """
- exit(0)
-
-
-def main():
- """
- Main (infinite) loop of allocator.
- """
- print "PASS: Start"
- end = False
- while not end:
- str = raw_input()
- exec str
-
-
-if __name__ == "__main__":
- main()
diff --git a/client/tests/kvm/scripts/ksm_overcommit_guest.py b/client/tests/kvm/scripts/ksm_overcommit_guest.py
new file mode 100755
index 0000000..09dc004
--- /dev/null
+++ b/client/tests/kvm/scripts/ksm_overcommit_guest.py
@@ -0,0 +1,237 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+"""
+Auxiliary script used to allocate memory on guests.
+
+@copyright: 2008-2009 Red Hat Inc.
+@author: Jiri Zupka (jzupka@redhat.com)
+"""
+
+
+import os, array, sys, struct, random, copy, inspect, tempfile, datetime, math
+
+PAGE_SIZE = 4096 # machine page size
+
+TMPFS_OVERHEAD = 0.0022 # overhead on 1MB of write data
+
+
+class MemFill(object):
+ """
+ Fills guest memory according to certain patterns.
+ """
+ def __init__(self, mem, static_value, random_key):
+ """
+ Constructor of MemFill class.
+
+ @param mem: Amount of test memory in MB.
+ @param random_key: Seed of random series used for fill up memory.
+ @param static_value: Value used to fill all memory.
+ """
+ if (static_value < 0 or static_value > 255):
+ print ("FAIL: Initialization static value"
+ "can be only in range (0..255)")
+ return
+
+ self.tmpdp = tempfile.mkdtemp()
+ ret_code = os.system("mount -o size=%dM tmpfs %s -t tmpfs" %
+ ((mem+math.ceil(mem*TMPFS_OVERHEAD)),
+ self.tmpdp))
+ if ret_code != 0:
+ if os.getuid() != 0:
+ print ("FAIL: Unable to mount tmpfs "
+ "(likely cause: you are not root)")
+ else:
+ print "FAIL: Unable to mount tmpfs"
+ else:
+ self.f = tempfile.TemporaryFile(prefix='mem', dir=self.tmpdp)
+ self.allocate_by = 'L'
+ self.npages = ((mem * 1024 * 1024) / PAGE_SIZE)
+ self.random_key = random_key
+ self.static_value = static_value
+ print "PASS: Initialization"
+
+
+ def __del__(self):
+ if os.path.ismount(self.tmpdp):
+ self.f.close()
+ os.system("umount %s" % (self.tmpdp))
+
+
+ def compare_page(self, original, inmem):
+ """
+ Compare pages of memory and print the differences found.
+
+ @param original: Data that was expected to be in memory.
+ @param inmem: Data in memory.
+ """
+ for ip in range(PAGE_SIZE / original.itemsize):
+ if (not original[ip] == inmem[ip]): # find which item is wrong
+ originalp = array.array("B")
+ inmemp = array.array("B")
+ originalp.fromstring(original[ip:ip+1].tostring())
+ inmemp.fromstring(inmem[ip:ip+1].tostring())
+ for ib in range(len(originalp)): # find wrong byte in item
+ if not (originalp[ib] == inmemp[ib]):
+ position = (self.f.tell() - PAGE_SIZE + ip *
+ original.itemsize + ib)
+ print ("Mem error on position %d wanted 0x%Lx and is "
+ "0x%Lx" % (position, originalp[ib], inmemp[ib]))
+
+
+ def value_page(self, value):
+ """
+ Create page filled by value.
+
+ @param value: String we want to fill the page with.
+ @return: return array of bytes size PAGE_SIZE.
+ """
+ a = array.array("B")
+ for i in range((PAGE_SIZE / a.itemsize)):
+ try:
+ a.append(value)
+ except:
+ print "FAIL: Value can be only in range (0..255)"
+ return a
+
+
+ def random_page(self, seed):
+ """
+ Create page filled by static random series.
+
+ @param seed: Seed of random series.
+ @return: Static random array series.
+ """
+ random.seed(seed)
+ a = array.array(self.allocate_by)
+ for i in range(PAGE_SIZE / a.itemsize):
+ a.append(random.randrange(0, sys.maxint))
+ return a
+
+
+ def value_fill(self, value=None):
+ """
+ Fill memory page by page, with value generated with value_page.
+
+ @param value: Parameter to be passed to value_page. None to just use
+ what's on the attribute static_value.
+ """
+ self.f.seek(0)
+ if value is None:
+ value = self.static_value
+ page = self.value_page(value)
+ for pages in range(self.npages):
+ page.tofile(self.f)
+ print "PASS: Mem value fill"
+
+
+ def value_check(self, value=None):
+ """
+ Check memory to see if data is correct.
+
+ @param value: Parameter to be passed to value_page. None to just use
+ what's on the attribute static_value.
+ @return: if data in memory is correct return PASS
+ else print some wrong data and return FAIL
+ """
+ self.f.seek(0)
+ e = 2
+ failure = False
+ if value is None:
+ value = self.static_value
+ page = self.value_page(value)
+ for pages in range(self.npages):
+ pf = array.array("B")
+ pf.fromfile(self.f, PAGE_SIZE / pf.itemsize)
+ if not (page == pf):
+ failure = True
+ self.compare_page(page, pf)
+ e = e - 1
+ if e == 0:
+ break
+ if failure:
+ print "FAIL: value verification"
+ else:
+ print "PASS: value verification"
+
+
+ def static_random_fill(self, n_bytes_on_end=PAGE_SIZE):
+ """
+ Fill memory by page with static random series with added special value
+ on random place in pages.
+
+ @param n_bytes_on_end: how many bytes on the end of page can be changed.
+ @return: PASS.
+ """
+ self.f.seek(0)
+ page = self.random_page(self.random_key)
+ random.seed(self.random_key)
+ p = copy.copy(page)
+
+ t_start = datetime.datetime.now()
+ for pages in range(self.npages):
+ rand = random.randint(((PAGE_SIZE / page.itemsize) - 1) -
+ (n_bytes_on_end / page.itemsize),
+ (PAGE_SIZE/page.itemsize) - 1)
+ p[rand] = pages
+ p.tofile(self.f)
+ p[rand] = page[rand]
+
+ t_end = datetime.datetime.now()
+ delta = t_end - t_start
+ milisec = delta.microseconds / 1e3 + delta.seconds * 1e3
+ print "PASS: filling duration = %Ld ms" % milisec
+
+
+ def static_random_verify(self, n_bytes_on_end=PAGE_SIZE):
+ """
+ Check memory to see if it contains correct contents.
+
+ @return: if data in memory is correct return PASS
+ else print some wrong data and return FAIL.
+ """
+ self.f.seek(0)
+ e = 2
+ page = self.random_page(self.random_key)
+ random.seed(self.random_key)
+ p = copy.copy(page)
+ failure = False
+ for pages in range(self.npages):
+ rand = random.randint(((PAGE_SIZE/page.itemsize) - 1) -
+ (n_bytes_on_end/page.itemsize),
+ (PAGE_SIZE/page.itemsize) - 1)
+ p[rand] = pages
+ pf = array.array(self.allocate_by)
+ pf.fromfile(self.f, PAGE_SIZE / pf.itemsize)
+ if not (p == pf):
+ failure = True
+ self.compare_page(p, pf)
+ e = e - 1
+ if e == 0:
+ break
+ p[rand] = page[rand]
+ if failure:
+ print "FAIL: Random series verification"
+ else:
+ print "PASS: Random series verification"
+
+
+def die():
+ """
+ Quit allocator.
+ """
+ exit(0)
+
+
+def main():
+ """
+ Main (infinite) loop of allocator.
+ """
+ print "PASS: Start"
+ end = False
+ while not end:
+ str = raw_input()
+ exec str
+
+
+if __name__ == "__main__":
+ main()
diff --git a/client/tests/kvm/tests/ksm_overcommit.py b/client/tests/kvm/tests/ksm_overcommit.py
index a3c52ef..76ad3b0 100644
--- a/client/tests/kvm/tests/ksm_overcommit.py
+++ b/client/tests/kvm/tests/ksm_overcommit.py
@@ -18,28 +18,29 @@ def run_ksm_overcommit(test, params, env):
def _start_allocator(vm, session, timeout):
"""
- Execute allocator.py on a guest, wait until it is initialized.
+ Execute ksm_overcommit_guest.py on a guest, wait until it is initialized.
@param vm: VM object.
@param session: Remote session to a VM object.
- @param timeout: Timeout that will be used to verify if allocator.py
- started properly.
+ @param timeout: Timeout that will be used to verify if
+ ksm_overcommit_guest.py started properly.
"""
- logging.debug("Starting allocator.py on guest %s", vm.name)
- session.sendline("python /tmp/allocator.py")
+ logging.debug("Starting ksm_overcommit_guest.py on guest %s", vm.name)
+ session.sendline("python /tmp/ksm_overcommit_guest.py")
try:
(match, data) = session.read_until_last_line_matches(
["PASS:", "FAIL:"],
timeout)
except kvm_subprocess.ExpectProcessTerminatedError, e:
- raise error.TestFail("Command allocator.py on vm '%s' failed: %s" %
- (vm.name, str(e)))
+ e_msg = ("Command ksm_overcommit_guest.py on vm '%s' failed: %s" %
+ (vm.name, str(e)))
+ raise error.TestFail(e_msg)
def _execute_allocator(command, vm, session, timeout):
"""
- Execute a given command on allocator.py main loop, indicating the vm
- the command was executed on.
+ Execute a given command on ksm_overcommit_guest.py main loop,
+ indicating the vm the command was executed on.
@param command: Command that will be executed.
@param vm: VM object.
@@ -48,17 +49,18 @@ def run_ksm_overcommit(test, params, env):
@return: Tuple (match index, data)
"""
- logging.debug("Executing '%s' on allocator.py loop, vm: %s, timeout: %s",
- command, vm.name, timeout)
+ logging.debug("Executing '%s' on ksm_overcommit_guest.py loop, "
+ "vm: %s, timeout: %s", command, vm.name, timeout)
session.sendline(command)
try:
(match, data) = session.read_until_last_line_matches(
["PASS:","FAIL:"],
timeout)
except kvm_subprocess.ExpectProcessTerminatedError, e:
- e_str = ("Failed to execute command '%s' on allocator.py, "
- "vm '%s': %s" % (command, vm.name, str(e)))
- raise error.TestFail(e_str)
+ e_msg = ("Failed to execute command '%s' on "
+ "ksm_overcommit_guest.py, vm '%s': %s" %
+ (command, vm.name, str(e)))
+ raise error.TestFail(e_msg)
return (match, data)
@@ -98,7 +100,7 @@ def run_ksm_overcommit(test, params, env):
a_cmd = "mem.value_fill(%d)" % skeys[0]
_execute_allocator(a_cmd, vm, lsessions[i], 120 * perf_ratio)
- # Let allocator.py do its job
+ # Let ksm_overcommit_guest.py do its job
# (until shared mem reaches expected value)
shm = 0
j = 0
@@ -168,7 +170,7 @@ def run_ksm_overcommit(test, params, env):
vm = lvms[i]
session = lsessions[i]
a_cmd = "mem.static_random_fill()"
- logging.debug("Executing %s on allocator.py loop, vm: %s",
+ logging.debug("Executing %s on ksm_overcommit_guest.py loop, vm: %s",
a_cmd, vm.name)
session.sendline(a_cmd)
@@ -271,7 +273,7 @@ def run_ksm_overcommit(test, params, env):
a_cmd = "mem.value_fill(%d)" % (skeys[0])
_execute_allocator(a_cmd, vm, lsessions[i], 90 * perf_ratio)
- # Wait until allocator.py merges the pages (3 * ksm_size / 3)
+ # Wait until ksm_overcommit_guest.py merges the pages (3 * ksm_size / 3)
shm = 0
i = 0
logging.debug("Target shared memory size: %s", ksm_size)
@@ -592,9 +594,9 @@ def run_ksm_overcommit(test, params, env):
time.sleep(vmsc * 2 * perf_ratio)
logging.debug(kvm_test_utils.get_memory_info(lvms))
- # Copy allocator.py into guests
+ # Copy ksm_overcommit_guest.py into guests
pwd = os.path.join(os.environ['AUTODIR'],'tests/kvm')
- vksmd_src = os.path.join(pwd, "scripts/allocator.py")
+ vksmd_src = os.path.join(pwd, "scripts/ksm_overcommit_guest.py")
dst_dir = "/tmp"
for vm in lvms:
vm.copy_files_to(vksmd_src, dst_dir)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] KVM test: Rename virtio_guest.py to virtio_console_guest.py
2011-01-22 2:03 [PATCH 0/4] Renaming scripts that we run on guests Lucas Meneghel Rodrigues
` (2 preceding siblings ...)
2011-01-22 2:03 ` [PATCH 3/4] KVM test: renaming allocator.py to ksm_overcommit_guest.py Lucas Meneghel Rodrigues
@ 2011-01-22 2:03 ` Lucas Meneghel Rodrigues
3 siblings, 0 replies; 5+ messages in thread
From: Lucas Meneghel Rodrigues @ 2011-01-22 2:03 UTC (permalink / raw)
To: autotest; +Cc: kvm
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
client/tests/kvm/scripts/virtio_console_guest.py | 715 ++++++++++++++++++++++
client/tests/kvm/scripts/virtio_guest.py | 715 ----------------------
client/tests/kvm/tests/virtio_console.py | 20 +-
3 files changed, 725 insertions(+), 725 deletions(-)
create mode 100755 client/tests/kvm/scripts/virtio_console_guest.py
delete mode 100755 client/tests/kvm/scripts/virtio_guest.py
diff --git a/client/tests/kvm/scripts/virtio_console_guest.py b/client/tests/kvm/scripts/virtio_console_guest.py
new file mode 100755
index 0000000..35efb7d
--- /dev/null
+++ b/client/tests/kvm/scripts/virtio_console_guest.py
@@ -0,0 +1,715 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+"""
+Auxiliary script used to send data between ports on guests.
+
+@copyright: 2010 Red Hat, Inc.
+@author: Jiri Zupka (jzupka@redhat.com)
+@author: Lukas Doktor (ldoktor@redhat.com)
+"""
+import threading
+from threading import Thread
+import os, time, select, re, random, sys, array
+import fcntl, subprocess, traceback, signal
+
+DEBUGPATH = "/sys/kernel/debug"
+SYSFSPATH = "/sys/class/virtio-ports/"
+
+exiting = False
+
+class VirtioGuest:
+ """
+ Test tools of virtio_ports.
+ """
+ LOOP_NONE = 0
+ LOOP_POLL = 1
+ LOOP_SELECT = 2
+
+ def __init__(self):
+ self.files = {}
+ self.exit_thread = threading.Event()
+ self.threads = []
+ self.ports = {}
+ self.poll_fds = {}
+ self.catch_signal = None
+ self.use_config = threading.Event()
+
+
+ def _readfile(self, name):
+ """
+ Read file and return content as string
+
+ @param name: Name of file
+ @return: Content of file as string
+ """
+ out = ""
+ try:
+ f = open(name, "r")
+ out = f.read()
+ f.close()
+ except:
+ print "FAIL: Cannot open file %s" % (name)
+
+ return out
+
+
+ def _get_port_status(self):
+ """
+ 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:
+ open_db_file = "%s/virtio-ports/%s" % (DEBUGPATH, name)
+ f = open(open_db_file, 'r')
+ port = {}
+ file = []
+ for line in iter(f):
+ file.append(line)
+ try:
+ for line in file:
+ 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
+
+ if (not os.path.exists(port['path'])):
+ print "FAIL: %s not exist" % port['path']
+
+ sysfspath = SYSFSPATH + name
+ if (not os.path.isdir(sysfspath)):
+ print "FAIL: %s not exist" % (sysfspath)
+
+ info_name = sysfspath + "/name"
+ port_name = self._readfile(info_name).strip()
+ if (port_name != port["name"]):
+ print ("FAIL: Port info not match \n%s - %s\n%s - %s" %
+ (info_name , port_name,
+ "%s/virtio-ports/%s" % (DEBUGPATH, name),
+ port["name"]))
+ except AttributeError:
+ print ("In file " + open_db_file +
+ " are bad data\n"+ "".join(file).strip())
+ print ("FAIL: Fail file data.")
+ return
+
+ ports[port['name']] = port
+ f.close()
+
+ return ports
+
+
+ def init(self, in_files):
+ """
+ Init and check port properties.
+ """
+ self.ports = self._get_port_status()
+
+ if self.ports == None:
+ return
+ for item in in_files:
+ if (item[1] != self.ports[item[0]]["is_console"]):
+ print self.ports
+ print "FAIL: Host console is not like console on guest side\n"
+ print "PASS: Init and check virtioconsole files in system."
+
+
+ class Switch(Thread):
+ """
+ Thread that sends data between ports.
+ """
+ def __init__ (self, in_files, out_files, event,
+ cachesize=1024, method=0):
+ """
+ @param in_files: Array of input files.
+ @param out_files: Array of output files.
+ @param method: Method of read/write access.
+ @param cachesize: Block to receive and send.
+ """
+ Thread.__init__(self, name="Switch")
+
+ self.in_files = in_files
+ self.out_files = out_files
+ self.exit_thread = event
+ self.method = method
+
+ self.cachesize = cachesize
+
+
+ def _none_mode(self):
+ """
+ Read and write to device in blocking mode
+ """
+ data = ""
+ while not self.exit_thread.isSet():
+ data = ""
+ for desc in self.in_files:
+ data += os.read(desc, self.cachesize)
+ if data != "":
+ for desc in self.out_files:
+ os.write(desc, data)
+
+
+ def _poll_mode(self):
+ """
+ Read and write to device in polling mode.
+ """
+
+ pi = select.poll()
+ po = select.poll()
+
+ for fd in self.in_files:
+ pi.register(fd, select.POLLIN)
+
+ for fd in self.out_files:
+ po.register(fd, select.POLLOUT)
+
+ while not self.exit_thread.isSet():
+ data = ""
+ t_out = self.out_files
+
+ readyf = pi.poll(1.0)
+ for i in readyf:
+ data += os.read(i[0], self.cachesize)
+
+ if data != "":
+ while ((len(t_out) != len(readyf)) and not
+ self.exit_thread.isSet()):
+ readyf = po.poll(1.0)
+ for desc in t_out:
+ os.write(desc, data)
+
+
+ def _select_mode(self):
+ """
+ Read and write to device in selecting mode.
+ """
+ while not self.exit_thread.isSet():
+ ret = select.select(self.in_files, [], [], 1.0)
+ data = ""
+ if ret[0] != []:
+ for desc in ret[0]:
+ data += os.read(desc, self.cachesize)
+ if data != "":
+ ret = select.select([], self.out_files, [], 1.0)
+ while ((len(self.out_files) != len(ret[1])) and not
+ self.exit_thread.isSet()):
+ ret = select.select([], self.out_files, [], 1.0)
+ for desc in ret[1]:
+ os.write(desc, data)
+
+
+ def run(self):
+ if (self.method == VirtioGuest.LOOP_POLL):
+ self._poll_mode()
+ elif (self.method == VirtioGuest.LOOP_SELECT):
+ self._select_mode()
+ else:
+ self._none_mode()
+
+
+ class Sender(Thread):
+ """
+ Creates a thread which sends random blocks of data to dst port.
+ """
+ def __init__(self, port, event, length):
+ """
+ @param port: Destination port
+ @param length: Length of the random data block
+ """
+ Thread.__init__(self, name="Sender")
+ self.port = port
+ self.exit_thread = event
+ 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 not self.exit_thread.isSet():
+ os.write(self.port, self.data)
+
+
+ def _open(self, in_files):
+ """
+ Open devices and return array of descriptors
+
+ @param in_files: Files array
+ @return: Array of descriptor
+ """
+ f = []
+
+ for item in in_files:
+ name = self.ports[item]["path"]
+ if (name in self.files):
+ f.append(self.files[name])
+ else:
+ try:
+ self.files[name] = os.open(name, os.O_RDWR)
+ if (self.ports[item]["is_console"] == "yes"):
+ print os.system("stty -F %s raw -echo" % (name))
+ print os.system("stty -F %s -a" % (name))
+ f.append(self.files[name])
+ except Exception, inst:
+ print "FAIL: Failed to open file %s" % (name)
+ raise inst
+ return f
+
+ @staticmethod
+ def pollmask_to_str(mask):
+ """
+ Conver pool mast to string
+
+ @param mask: poll return mask
+ """
+ str = ""
+ if (mask & select.POLLIN):
+ str += "IN "
+ if (mask & select.POLLPRI):
+ str += "PRI IN "
+ if (mask & select.POLLOUT):
+ str += "OUT "
+ if (mask & select.POLLERR):
+ str += "ERR "
+ if (mask & select.POLLHUP):
+ str += "HUP "
+ if (mask & select.POLLMSG):
+ str += "MSG "
+ return str
+
+
+ def poll(self, port, expected, timeout=500):
+ """
+ Pool event from device and print event like text.
+
+ @param file: Device.
+ """
+ in_f = self._open([port])
+
+ p = select.poll()
+ p.register(in_f[0])
+
+ mask = p.poll(timeout)
+
+ maskstr = VirtioGuest.pollmask_to_str(mask[0][1])
+ if (mask[0][1] & expected) == expected:
+ print "PASS: Events: " + maskstr
+ else:
+ emaskstr = VirtioGuest.pollmask_to_str(expected)
+ print "FAIL: Events: " + maskstr + " Expected: " + emaskstr
+
+
+ def lseek(self, port, pos, how):
+ """
+ Use lseek on the device. The device is unseekable so PASS is returned
+ when lseek command fails and vice versa.
+
+ @param port: Name of the port
+ @param pos: Offset
+ @param how: Relativ offset os.SEEK_{SET,CUR,END}
+ """
+ fd = self._open([port])[0]
+
+ try:
+ os.lseek(fd, pos, how)
+ except Exception, inst:
+ if inst.errno == 29:
+ print "PASS: the lseek failed as expected"
+ else:
+ print inst
+ print "FAIL: unknown error"
+ else:
+ print "FAIL: the lseek unexpectedly passed"
+
+
+ def blocking(self, port, mode=False):
+ """
+ Set port function mode blocking/nonblocking
+
+ @param port: port to set mode
+ @param mode: False to set nonblock mode, True for block mode
+ """
+ fd = self._open([port])[0]
+
+ try:
+ fl = fcntl.fcntl(fd, fcntl.F_GETFL)
+ if not mode:
+ fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
+ else:
+ fcntl.fcntl(fd, fcntl.F_SETFL, fl & ~os.O_NONBLOCK)
+
+ except Exception, inst:
+ print "FAIL: Setting (non)blocking mode: " + str(inst)
+ return
+
+ if mode:
+ print "PASS: set to blocking mode"
+ else:
+ print "PASS: set to nonblocking mode"
+
+
+ def __call__(self, sig, frame):
+ """
+ Call function. Used for signal handle.
+ """
+ if (sig == signal.SIGIO):
+ self.sigio_handler(sig, frame)
+
+
+ def sigio_handler(self, sig, frame):
+ """
+ Handler for sigio operation.
+
+ @param sig: signal which call handler.
+ @param frame: frame of caller
+ """
+ if self.poll_fds:
+ p = select.poll()
+ map(p.register, self.poll_fds.keys())
+
+ masks = p.poll(1)
+ print masks
+ for mask in masks:
+ self.poll_fds[mask[0]][1] |= mask[1]
+
+
+ def get_sigio_poll_return(self, port):
+ """
+ Return PASS, FAIL and poll walue in string format.
+
+ @param port: Port to check poll information.
+ """
+ fd = self._open([port])[0]
+
+ maskstr = VirtioGuest.pollmask_to_str(self.poll_fds[fd][1])
+ if (self.poll_fds[fd][0] ^ self.poll_fds[fd][1]):
+ emaskstr = VirtioGuest.pollmask_to_str(self.poll_fds[fd][0])
+ print "FAIL: Events: " + maskstr + " Expected: " + emaskstr
+ else:
+ print "PASS: Events: " + maskstr
+ self.poll_fds[fd][1] = 0
+
+
+ def set_pool_want_return(self, port, poll_value):
+ """
+ Set value to static variable.
+
+ @param port: Port which should be set excepted mask
+ @param poll_value: Value to check sigio signal.
+ """
+ fd = self._open([port])[0]
+ self.poll_fds[fd] = [poll_value, 0]
+ print "PASS: Events: " + VirtioGuest.pollmask_to_str(poll_value)
+
+
+ def catching_signal(self):
+ """
+ return: True if should set catch signal, False if ignore signal and
+ none when configuration is not changed.
+ """
+ ret = self.catch_signal
+ self.catch_signal = None
+ return ret
+
+
+ def async(self, port, mode=True, exp_val = 0):
+ """
+ Set port function mode async/sync.
+
+ @param port: port which should be pooled.
+ @param mode: False to set sync mode, True for sync mode.
+ @param exp_val: Value which should be pooled.
+ """
+ fd = self._open([port])[0]
+
+ try:
+ fcntl.fcntl(fd, fcntl.F_SETOWN, os.getpid())
+ fl = fcntl.fcntl(fd, fcntl.F_GETFL)
+
+ self.use_config.clear()
+ if mode:
+ fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_ASYNC)
+ self.poll_fds[fd] = [exp_val, 0]
+ self.catch_signal = True
+ else:
+ del self.poll_fds[fd]
+ fcntl.fcntl(fd, fcntl.F_SETFL, fl & ~os.O_ASYNC)
+ self.catch_signal = False
+
+ os.kill(os.getpid(), signal.SIGUSR1)
+ self.use_config.wait()
+
+ except Exception, inst:
+ print "FAIL: Setting (a)sync mode: " + str(inst)
+ return
+
+ if mode:
+ print "PASS: Set to async mode"
+ else:
+ print "PASS: Set to sync mode"
+
+
+ def close(self, file):
+ """
+ Close open port.
+
+ @param file: File to close.
+ """
+ descriptor = None
+ path = self.ports[file]["path"]
+ if path != None:
+ if path in self.files.keys():
+ descriptor = self.files[path]
+ del self.files[path]
+ if descriptor != None:
+ try:
+ os.close(descriptor)
+ except Exception, inst:
+ print "FAIL: Closing the file: " + str(inst)
+ return
+ print "PASS: Close"
+
+
+ def open(self, in_file):
+ """
+ Direct open devices.
+
+ @param in_file: Array of files.
+ @return: Array of descriptors.
+ """
+ name = self.ports[in_file]["path"]
+ try:
+ self.files[name] = os.open(name, os.O_RDWR)
+ if (self.ports[in_file]["is_console"] == "yes"):
+ print os.system("stty -F %s raw -echo" % (name))
+ print "PASS: Open all filles correctly."
+ except Exception, inst:
+ print "%s\nFAIL: Failed open file %s" % (str(inst), name)
+
+
+ def loopback(self, in_files, out_files, cachesize=1024, mode=LOOP_NONE):
+ """
+ Start a switch thread.
+
+ (There is a problem with multiple opens of a single file).
+
+ @param in_files: Array of input files.
+ @param out_files: Array of output files.
+ @param cachesize: Cachesize.
+ """
+ self.ports = self._get_port_status()
+
+ in_f = self._open(in_files)
+ out_f = self._open(out_files)
+
+ s = self.Switch(in_f, out_f, self.exit_thread, cachesize, mode)
+ s.start()
+ self.threads.append(s)
+ print "PASS: Start switch"
+
+
+ def exit_threads(self):
+ """
+ Function end all running data switch.
+ """
+ self.exit_thread.set()
+ for th in self.threads:
+ print "join"
+ th.join()
+ self.exit_thread.clear()
+
+ del self.threads[:]
+ for desc in self.files.itervalues():
+ os.close(desc)
+ self.files.clear()
+ print "PASS: All threads finished."
+
+
+ def die(self):
+ """
+ Quit consoleswitch.
+ """
+ self.exit_threads()
+ exit()
+
+
+ def send_loop_init(self, port, length):
+ """
+ Prepares the sender thread. Requires clean thread structure.
+ """
+ self.ports = self._get_port_status()
+ in_f = self._open([port])
+
+ self.threads.append(self.Sender(in_f[0], self.exit_thread, length))
+ print "PASS: Sender prepare"
+
+
+ def send_loop(self):
+ """
+ Start sender data transfer. Requires senderprepare run first.
+ """
+ self.threads[0].start()
+ print "PASS: Sender start"
+
+
+ def send(self, port, length=1, mode=True):
+ """
+ Send a data of some length
+
+ @param port: Port to write data
+ @param length: Length of data
+ @param mode: True = loop mode, False = one shoot mode
+ """
+ in_f = self._open([port])
+
+ data = ""
+ while len(data) < length:
+ data += "%c" % random.randrange(255)
+ try:
+ writes = os.write(in_f[0], data)
+ except Exception, inst:
+ print inst
+ if not writes:
+ writes = 0
+ if mode:
+ while (writes < length):
+ try:
+ writes += os.write(in_f[0], data)
+ except Exception, inst:
+ print inst
+ if writes >= length:
+ print "PASS: Send data length %d" % writes
+ else:
+ print ("FAIL: Partial send: desired %d, transfered %d" %
+ (length, writes))
+
+
+ def recv(self, port, length=1, buffer=1024, mode=True):
+ """
+ Recv a data of some length
+
+ @param port: Port to write data
+ @param length: Length of data
+ @param mode: True = loop mode, False = one shoot mode
+ """
+ in_f = self._open([port])
+
+ recvs = ""
+ try:
+ recvs = os.read(in_f[0], buffer)
+ except Exception, inst:
+ print inst
+ if mode:
+ while (len(recvs) < length):
+ try:
+ recvs += os.read(in_f[0], buffer)
+ except Exception, inst:
+ print inst
+ if len(recvs) >= length:
+ print "PASS: Recv data length %d" % len(recvs)
+ else:
+ print ("FAIL: Partial recv: desired %d, transfered %d" %
+ (length, len(recvs)))
+
+
+ def clean_port(self, port, buffer=1024):
+ in_f = self._open([port])
+ ret = select.select([in_f[0]], [], [], 1.0)
+ buf = ""
+ if ret[0]:
+ buf = os.read(in_f[0], buffer)
+ print ("PASS: Rest in socket: ") + str(buf[10])
+
+
+def is_alive():
+ """
+ Check is only main thread is alive and if guest react.
+ """
+ if threading.activeCount() == 2:
+ print ("PASS: Guest is ok no thread alive")
+ else:
+ threads = ""
+ for thread in threading.enumerate():
+ threads += thread.name + ", "
+ print ("FAIL: On guest run thread. Active thread:" + threads)
+
+
+def compile():
+ """
+ Compile virtio_console_guest.py to speed up.
+ """
+ import py_compile
+ py_compile.compile(sys.path[0] + "/virtio_console_guest.py")
+ print "PASS: compile"
+ sys.exit()
+
+
+def guest_exit():
+ global exiting
+ exiting = True
+ os.kill(os.getpid(), signal.SIGUSR1)
+
+
+def worker(virt):
+ """
+ Worker thread (infinite) loop of virtio_guest.
+ """
+ global exiting
+ print "PASS: Start"
+
+ while not exiting:
+ str = raw_input()
+ try:
+ exec str
+ except:
+ exc_type, exc_value, exc_traceback = sys.exc_info()
+ print "On Guest exception from: \n" + "".join(
+ traceback.format_exception(exc_type,
+ exc_value,
+ exc_traceback))
+
+
+def sigusr_handler(sig, frame):
+ pass
+
+
+def main():
+ """
+ Main function with infinite loop to catch signal from system.
+ """
+ if (len(sys.argv) > 1) and (sys.argv[1] == "-c"):
+ compile()
+
+ global exiting
+ virt = VirtioGuest()
+ slave = Thread(target=worker, args=(virt, ))
+ slave.start()
+ signal.signal(signal.SIGUSR1, sigusr_handler)
+ while not exiting:
+ signal.pause()
+ catch = virt.catching_signal()
+ if catch:
+ signal.signal(signal.SIGIO, virt)
+ elif catch == False:
+ signal.signal(signal.SIGIO, signal.SIG_DFL)
+ if (catch != None):
+ virt.use_config.set()
+ print "PASS: guest_exit"
+
+
+if __name__ == "__main__":
+ main()
diff --git a/client/tests/kvm/scripts/virtio_guest.py b/client/tests/kvm/scripts/virtio_guest.py
deleted file mode 100755
index 498bf6a..0000000
--- a/client/tests/kvm/scripts/virtio_guest.py
+++ /dev/null
@@ -1,715 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-"""
-Auxiliary script used to send data between ports on guests.
-
-@copyright: 2010 Red Hat, Inc.
-@author: Jiri Zupka (jzupka@redhat.com)
-@author: Lukas Doktor (ldoktor@redhat.com)
-"""
-import threading
-from threading import Thread
-import os, time, select, re, random, sys, array
-import fcntl, subprocess, traceback, signal
-
-DEBUGPATH = "/sys/kernel/debug"
-SYSFSPATH = "/sys/class/virtio-ports/"
-
-exiting = False
-
-class VirtioGuest:
- """
- Test tools of virtio_ports.
- """
- LOOP_NONE = 0
- LOOP_POLL = 1
- LOOP_SELECT = 2
-
- def __init__(self):
- self.files = {}
- self.exit_thread = threading.Event()
- self.threads = []
- self.ports = {}
- self.poll_fds = {}
- self.catch_signal = None
- self.use_config = threading.Event()
-
-
- def _readfile(self, name):
- """
- Read file and return content as string
-
- @param name: Name of file
- @return: Content of file as string
- """
- out = ""
- try:
- f = open(name, "r")
- out = f.read()
- f.close()
- except:
- print "FAIL: Cannot open file %s" % (name)
-
- return out
-
-
- def _get_port_status(self):
- """
- 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:
- open_db_file = "%s/virtio-ports/%s" % (DEBUGPATH, name)
- f = open(open_db_file, 'r')
- port = {}
- file = []
- for line in iter(f):
- file.append(line)
- try:
- for line in file:
- 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
-
- if (not os.path.exists(port['path'])):
- print "FAIL: %s not exist" % port['path']
-
- sysfspath = SYSFSPATH + name
- if (not os.path.isdir(sysfspath)):
- print "FAIL: %s not exist" % (sysfspath)
-
- info_name = sysfspath + "/name"
- port_name = self._readfile(info_name).strip()
- if (port_name != port["name"]):
- print ("FAIL: Port info not match \n%s - %s\n%s - %s" %
- (info_name , port_name,
- "%s/virtio-ports/%s" % (DEBUGPATH, name),
- port["name"]))
- except AttributeError:
- print ("In file " + open_db_file +
- " are bad data\n"+ "".join(file).strip())
- print ("FAIL: Fail file data.")
- return
-
- ports[port['name']] = port
- f.close()
-
- return ports
-
-
- def init(self, in_files):
- """
- Init and check port properties.
- """
- self.ports = self._get_port_status()
-
- if self.ports == None:
- return
- for item in in_files:
- if (item[1] != self.ports[item[0]]["is_console"]):
- print self.ports
- print "FAIL: Host console is not like console on guest side\n"
- print "PASS: Init and check virtioconsole files in system."
-
-
- class Switch(Thread):
- """
- Thread that sends data between ports.
- """
- def __init__ (self, in_files, out_files, event,
- cachesize=1024, method=0):
- """
- @param in_files: Array of input files.
- @param out_files: Array of output files.
- @param method: Method of read/write access.
- @param cachesize: Block to receive and send.
- """
- Thread.__init__(self, name="Switch")
-
- self.in_files = in_files
- self.out_files = out_files
- self.exit_thread = event
- self.method = method
-
- self.cachesize = cachesize
-
-
- def _none_mode(self):
- """
- Read and write to device in blocking mode
- """
- data = ""
- while not self.exit_thread.isSet():
- data = ""
- for desc in self.in_files:
- data += os.read(desc, self.cachesize)
- if data != "":
- for desc in self.out_files:
- os.write(desc, data)
-
-
- def _poll_mode(self):
- """
- Read and write to device in polling mode.
- """
-
- pi = select.poll()
- po = select.poll()
-
- for fd in self.in_files:
- pi.register(fd, select.POLLIN)
-
- for fd in self.out_files:
- po.register(fd, select.POLLOUT)
-
- while not self.exit_thread.isSet():
- data = ""
- t_out = self.out_files
-
- readyf = pi.poll(1.0)
- for i in readyf:
- data += os.read(i[0], self.cachesize)
-
- if data != "":
- while ((len(t_out) != len(readyf)) and not
- self.exit_thread.isSet()):
- readyf = po.poll(1.0)
- for desc in t_out:
- os.write(desc, data)
-
-
- def _select_mode(self):
- """
- Read and write to device in selecting mode.
- """
- while not self.exit_thread.isSet():
- ret = select.select(self.in_files, [], [], 1.0)
- data = ""
- if ret[0] != []:
- for desc in ret[0]:
- data += os.read(desc, self.cachesize)
- if data != "":
- ret = select.select([], self.out_files, [], 1.0)
- while ((len(self.out_files) != len(ret[1])) and not
- self.exit_thread.isSet()):
- ret = select.select([], self.out_files, [], 1.0)
- for desc in ret[1]:
- os.write(desc, data)
-
-
- def run(self):
- if (self.method == VirtioGuest.LOOP_POLL):
- self._poll_mode()
- elif (self.method == VirtioGuest.LOOP_SELECT):
- self._select_mode()
- else:
- self._none_mode()
-
-
- class Sender(Thread):
- """
- Creates a thread which sends random blocks of data to dst port.
- """
- def __init__(self, port, event, length):
- """
- @param port: Destination port
- @param length: Length of the random data block
- """
- Thread.__init__(self, name="Sender")
- self.port = port
- self.exit_thread = event
- 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 not self.exit_thread.isSet():
- os.write(self.port, self.data)
-
-
- def _open(self, in_files):
- """
- Open devices and return array of descriptors
-
- @param in_files: Files array
- @return: Array of descriptor
- """
- f = []
-
- for item in in_files:
- name = self.ports[item]["path"]
- if (name in self.files):
- f.append(self.files[name])
- else:
- try:
- self.files[name] = os.open(name, os.O_RDWR)
- if (self.ports[item]["is_console"] == "yes"):
- print os.system("stty -F %s raw -echo" % (name))
- print os.system("stty -F %s -a" % (name))
- f.append(self.files[name])
- except Exception, inst:
- print "FAIL: Failed to open file %s" % (name)
- raise inst
- return f
-
- @staticmethod
- def pollmask_to_str(mask):
- """
- Conver pool mast to string
-
- @param mask: poll return mask
- """
- str = ""
- if (mask & select.POLLIN):
- str += "IN "
- if (mask & select.POLLPRI):
- str += "PRI IN "
- if (mask & select.POLLOUT):
- str += "OUT "
- if (mask & select.POLLERR):
- str += "ERR "
- if (mask & select.POLLHUP):
- str += "HUP "
- if (mask & select.POLLMSG):
- str += "MSG "
- return str
-
-
- def poll(self, port, expected, timeout=500):
- """
- Pool event from device and print event like text.
-
- @param file: Device.
- """
- in_f = self._open([port])
-
- p = select.poll()
- p.register(in_f[0])
-
- mask = p.poll(timeout)
-
- maskstr = VirtioGuest.pollmask_to_str(mask[0][1])
- if (mask[0][1] & expected) == expected:
- print "PASS: Events: " + maskstr
- else:
- emaskstr = VirtioGuest.pollmask_to_str(expected)
- print "FAIL: Events: " + maskstr + " Expected: " + emaskstr
-
-
- def lseek(self, port, pos, how):
- """
- Use lseek on the device. The device is unseekable so PASS is returned
- when lseek command fails and vice versa.
-
- @param port: Name of the port
- @param pos: Offset
- @param how: Relativ offset os.SEEK_{SET,CUR,END}
- """
- fd = self._open([port])[0]
-
- try:
- os.lseek(fd, pos, how)
- except Exception, inst:
- if inst.errno == 29:
- print "PASS: the lseek failed as expected"
- else:
- print inst
- print "FAIL: unknown error"
- else:
- print "FAIL: the lseek unexpectedly passed"
-
-
- def blocking(self, port, mode=False):
- """
- Set port function mode blocking/nonblocking
-
- @param port: port to set mode
- @param mode: False to set nonblock mode, True for block mode
- """
- fd = self._open([port])[0]
-
- try:
- fl = fcntl.fcntl(fd, fcntl.F_GETFL)
- if not mode:
- fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
- else:
- fcntl.fcntl(fd, fcntl.F_SETFL, fl & ~os.O_NONBLOCK)
-
- except Exception, inst:
- print "FAIL: Setting (non)blocking mode: " + str(inst)
- return
-
- if mode:
- print "PASS: set to blocking mode"
- else:
- print "PASS: set to nonblocking mode"
-
-
- def __call__(self, sig, frame):
- """
- Call function. Used for signal handle.
- """
- if (sig == signal.SIGIO):
- self.sigio_handler(sig, frame)
-
-
- def sigio_handler(self, sig, frame):
- """
- Handler for sigio operation.
-
- @param sig: signal which call handler.
- @param frame: frame of caller
- """
- if self.poll_fds:
- p = select.poll()
- map(p.register, self.poll_fds.keys())
-
- masks = p.poll(1)
- print masks
- for mask in masks:
- self.poll_fds[mask[0]][1] |= mask[1]
-
-
- def get_sigio_poll_return(self, port):
- """
- Return PASS, FAIL and poll walue in string format.
-
- @param port: Port to check poll information.
- """
- fd = self._open([port])[0]
-
- maskstr = VirtioGuest.pollmask_to_str(self.poll_fds[fd][1])
- if (self.poll_fds[fd][0] ^ self.poll_fds[fd][1]):
- emaskstr = VirtioGuest.pollmask_to_str(self.poll_fds[fd][0])
- print "FAIL: Events: " + maskstr + " Expected: " + emaskstr
- else:
- print "PASS: Events: " + maskstr
- self.poll_fds[fd][1] = 0
-
-
- def set_pool_want_return(self, port, poll_value):
- """
- Set value to static variable.
-
- @param port: Port which should be set excepted mask
- @param poll_value: Value to check sigio signal.
- """
- fd = self._open([port])[0]
- self.poll_fds[fd] = [poll_value, 0]
- print "PASS: Events: " + VirtioGuest.pollmask_to_str(poll_value)
-
-
- def catching_signal(self):
- """
- return: True if should set catch signal, False if ignore signal and
- none when configuration is not changed.
- """
- ret = self.catch_signal
- self.catch_signal = None
- return ret
-
-
- def async(self, port, mode=True, exp_val = 0):
- """
- Set port function mode async/sync.
-
- @param port: port which should be pooled.
- @param mode: False to set sync mode, True for sync mode.
- @param exp_val: Value which should be pooled.
- """
- fd = self._open([port])[0]
-
- try:
- fcntl.fcntl(fd, fcntl.F_SETOWN, os.getpid())
- fl = fcntl.fcntl(fd, fcntl.F_GETFL)
-
- self.use_config.clear()
- if mode:
- fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_ASYNC)
- self.poll_fds[fd] = [exp_val, 0]
- self.catch_signal = True
- else:
- del self.poll_fds[fd]
- fcntl.fcntl(fd, fcntl.F_SETFL, fl & ~os.O_ASYNC)
- self.catch_signal = False
-
- os.kill(os.getpid(), signal.SIGUSR1)
- self.use_config.wait()
-
- except Exception, inst:
- print "FAIL: Setting (a)sync mode: " + str(inst)
- return
-
- if mode:
- print "PASS: Set to async mode"
- else:
- print "PASS: Set to sync mode"
-
-
- def close(self, file):
- """
- Close open port.
-
- @param file: File to close.
- """
- descriptor = None
- path = self.ports[file]["path"]
- if path != None:
- if path in self.files.keys():
- descriptor = self.files[path]
- del self.files[path]
- if descriptor != None:
- try:
- os.close(descriptor)
- except Exception, inst:
- print "FAIL: Closing the file: " + str(inst)
- return
- print "PASS: Close"
-
-
- def open(self, in_file):
- """
- Direct open devices.
-
- @param in_file: Array of files.
- @return: Array of descriptors.
- """
- name = self.ports[in_file]["path"]
- try:
- self.files[name] = os.open(name, os.O_RDWR)
- if (self.ports[in_file]["is_console"] == "yes"):
- print os.system("stty -F %s raw -echo" % (name))
- print "PASS: Open all filles correctly."
- except Exception, inst:
- print "%s\nFAIL: Failed open file %s" % (str(inst), name)
-
-
- def loopback(self, in_files, out_files, cachesize=1024, mode=LOOP_NONE):
- """
- Start a switch thread.
-
- (There is a problem with multiple opens of a single file).
-
- @param in_files: Array of input files.
- @param out_files: Array of output files.
- @param cachesize: Cachesize.
- """
- self.ports = self._get_port_status()
-
- in_f = self._open(in_files)
- out_f = self._open(out_files)
-
- s = self.Switch(in_f, out_f, self.exit_thread, cachesize, mode)
- s.start()
- self.threads.append(s)
- print "PASS: Start switch"
-
-
- def exit_threads(self):
- """
- Function end all running data switch.
- """
- self.exit_thread.set()
- for th in self.threads:
- print "join"
- th.join()
- self.exit_thread.clear()
-
- del self.threads[:]
- for desc in self.files.itervalues():
- os.close(desc)
- self.files.clear()
- print "PASS: All threads finished."
-
-
- def die(self):
- """
- Quit consoleswitch.
- """
- self.exit_threads()
- exit()
-
-
- def send_loop_init(self, port, length):
- """
- Prepares the sender thread. Requires clean thread structure.
- """
- self.ports = self._get_port_status()
- in_f = self._open([port])
-
- self.threads.append(self.Sender(in_f[0], self.exit_thread, length))
- print "PASS: Sender prepare"
-
-
- def send_loop(self):
- """
- Start sender data transfer. Requires senderprepare run first.
- """
- self.threads[0].start()
- print "PASS: Sender start"
-
-
- def send(self, port, length=1, mode=True):
- """
- Send a data of some length
-
- @param port: Port to write data
- @param length: Length of data
- @param mode: True = loop mode, False = one shoot mode
- """
- in_f = self._open([port])
-
- data = ""
- while len(data) < length:
- data += "%c" % random.randrange(255)
- try:
- writes = os.write(in_f[0], data)
- except Exception, inst:
- print inst
- if not writes:
- writes = 0
- if mode:
- while (writes < length):
- try:
- writes += os.write(in_f[0], data)
- except Exception, inst:
- print inst
- if writes >= length:
- print "PASS: Send data length %d" % writes
- else:
- print ("FAIL: Partial send: desired %d, transfered %d" %
- (length, writes))
-
-
- def recv(self, port, length=1, buffer=1024, mode=True):
- """
- Recv a data of some length
-
- @param port: Port to write data
- @param length: Length of data
- @param mode: True = loop mode, False = one shoot mode
- """
- in_f = self._open([port])
-
- recvs = ""
- try:
- recvs = os.read(in_f[0], buffer)
- except Exception, inst:
- print inst
- if mode:
- while (len(recvs) < length):
- try:
- recvs += os.read(in_f[0], buffer)
- except Exception, inst:
- print inst
- if len(recvs) >= length:
- print "PASS: Recv data length %d" % len(recvs)
- else:
- print ("FAIL: Partial recv: desired %d, transfered %d" %
- (length, len(recvs)))
-
-
- def clean_port(self, port, buffer=1024):
- in_f = self._open([port])
- ret = select.select([in_f[0]], [], [], 1.0)
- buf = ""
- if ret[0]:
- buf = os.read(in_f[0], buffer)
- print ("PASS: Rest in socket: ") + str(buf[10])
-
-
-def is_alive():
- """
- Check is only main thread is alive and if guest react.
- """
- if threading.activeCount() == 2:
- print ("PASS: Guest is ok no thread alive")
- else:
- threads = ""
- for thread in threading.enumerate():
- threads += thread.name + ", "
- print ("FAIL: On guest run thread. Active thread:" + threads)
-
-
-def compile():
- """
- Compile virtio_guest.py to speed up.
- """
- import py_compile
- py_compile.compile(sys.path[0] + "/virtio_guest.py")
- print "PASS: compile"
- sys.exit()
-
-
-def guest_exit():
- global exiting
- exiting = True
- os.kill(os.getpid(), signal.SIGUSR1)
-
-
-def worker(virt):
- """
- Worker thread (infinite) loop of virtio_guest.
- """
- global exiting
- print "PASS: Start"
-
- while not exiting:
- str = raw_input()
- try:
- exec str
- except:
- exc_type, exc_value, exc_traceback = sys.exc_info()
- print "On Guest exception from: \n" + "".join(
- traceback.format_exception(exc_type,
- exc_value,
- exc_traceback))
-
-
-def sigusr_handler(sig, frame):
- pass
-
-
-def main():
- """
- Main function with infinite loop to catch signal from system.
- """
- if (len(sys.argv) > 1) and (sys.argv[1] == "-c"):
- compile()
-
- global exiting
- virt = VirtioGuest()
- slave = Thread(target=worker, args=(virt, ))
- slave.start()
- signal.signal(signal.SIGUSR1, sigusr_handler)
- while not exiting:
- signal.pause()
- catch = virt.catching_signal()
- if catch:
- signal.signal(signal.SIGIO, virt)
- elif catch == False:
- signal.signal(signal.SIGIO, signal.SIG_DFL)
- if (catch != None):
- virt.use_config.set()
- print "PASS: guest_exit"
-
-
-if __name__ == "__main__":
- main()
diff --git a/client/tests/kvm/tests/virtio_console.py b/client/tests/kvm/tests/virtio_console.py
index 9e0611f..b1e8bc6 100644
--- a/client/tests/kvm/tests/virtio_console.py
+++ b/client/tests/kvm/tests/virtio_console.py
@@ -433,15 +433,15 @@ def run_virtio_console(test, params, env):
def _init_guest(vm, timeout=2):
"""
- Execute virtio_guest.py on guest, wait until it is initialized.
+ Execute virtio_console_guest.py on guest, wait until it is initialized.
@param vm: Informations about the guest.
@param timeout: Timeout that will be used to verify if the script
started properly.
"""
- logging.debug("compile virtio_guest.py on guest %s", vm[0].name)
+ logging.debug("compile virtio_console_guest.py on guest %s", vm[0].name)
- (match, data) = _on_guest("python -OO /tmp/virtio_guest.py -c &&"
+ (match, data) = _on_guest("python -OO /tmp/virtio_console_guest.py -c &&"
"echo -n 'PASS: Compile virtio_guest finished' ||"
"echo -n 'FAIL: Compile virtio_guest failed'",
vm, timeout)
@@ -450,9 +450,9 @@ def run_virtio_console(test, params, env):
raise error.TestFail("Command console_switch.py on guest %s failed."
"\nreturn code: %s\n output:\n%s" %
(vm[0].name, match, data))
- logging.debug("Starting virtio_guest.py on guest %s", vm[0].name)
+ logging.debug("Starting virtio_console_guest.py on guest %s", vm[0].name)
vm[1].sendline()
- (match, data) = _on_guest("python /tmp/virtio_guest.pyo &&"
+ (match, data) = _on_guest("python /tmp/virtio_console_guest.pyo &&"
"echo -n 'PASS: virtio_guest finished' ||"
"echo -n 'FAIL: virtio_guest failed'",
vm, timeout)
@@ -466,7 +466,7 @@ def run_virtio_console(test, params, env):
def init_guest(vm, consoles):
"""
- Prepares guest, executes virtio_guest.py and initialize for testing
+ Prepares guest, executes virtio_console_guest.py and initialize for testing
@param vm: Informations about the guest.
@param consoles: Informations about consoles
@@ -516,7 +516,7 @@ def run_virtio_console(test, params, env):
@return: Tuple (match index, data)
"""
- logging.debug("Executing '%s' on virtio_guest.py loop, vm: %s," +
+ logging.debug("Executing '%s' on virtio_console_guest.py loop, vm: %s," +
"timeout: %s", command, vm[0].name, timeout)
vm[1].sendline(command)
try:
@@ -550,7 +550,7 @@ def run_virtio_console(test, params, env):
"""
match, data = _on_guest(command, vm, timeout)
if match == 1 or match is None:
- raise error.TestFail("Failed to execute '%s' on virtio_guest.py, "
+ raise error.TestFail("Failed to execute '%s' on virtio_console_guest.py, "
"vm: %s, output:\n%s" %
(command, vm[0].name, data))
@@ -1290,9 +1290,9 @@ def run_virtio_console(test, params, env):
vm, consoles = _vm_create(no_consoles, no_serialports)
- # Copy allocator.py into guests
+ # Copy virtio_console_guest.py into guests
pwd = os.path.join(os.environ['AUTODIR'], 'tests/kvm')
- vksmd_src = os.path.join(pwd, "scripts/virtio_guest.py")
+ vksmd_src = os.path.join(pwd, "scripts/virtio_console_guest.py")
dst_dir = "/tmp"
vm[0].copy_files_to(vksmd_src, dst_dir)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-01-22 2:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-22 2:03 [PATCH 0/4] Renaming scripts that we run on guests Lucas Meneghel Rodrigues
2011-01-22 2:03 ` [PATCH 1/4] KVM test: Renaming script bonding_setup.py to nic_bonding_guest.py Lucas Meneghel Rodrigues
2011-01-22 2:03 ` [PATCH 2/4] KVM test: Renaming join_mcast.py to multicast_guest.py Lucas Meneghel Rodrigues
2011-01-22 2:03 ` [PATCH 3/4] KVM test: renaming allocator.py to ksm_overcommit_guest.py Lucas Meneghel Rodrigues
2011-01-22 2:03 ` [PATCH 4/4] KVM test: Rename virtio_guest.py to virtio_console_guest.py Lucas Meneghel Rodrigues
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.