Code Review
/
csit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
CSIT-530: Add common setup and teardown to perf tests
[csit.git]
/
resources
/
libraries
/
python
/
QemuUtils.py
diff --git
a/resources/libraries/python/QemuUtils.py
b/resources/libraries/python/QemuUtils.py
index
37a8863
..
2123e42
100644
(file)
--- a/
resources/libraries/python/QemuUtils.py
+++ b/
resources/libraries/python/QemuUtils.py
@@
-18,7
+18,7
@@
import json
from robot.api import logger
from robot.api import logger
-from resources.libraries.python.ssh import SSH
+from resources.libraries.python.ssh import SSH
, SSHTimeout
from resources.libraries.python.constants import Constants
from resources.libraries.python.topology import NodeType
from resources.libraries.python.constants import Constants
from resources.libraries.python.topology import NodeType
@@
-227,9
+227,10
@@
class QemuUtils(object):
response will contain the "error" keyword instead of "return".
"""
# To enter command mode, the qmp_capabilities command must be issued.
response will contain the "error" keyword instead of "return".
"""
# To enter command mode, the qmp_capabilities command must be issued.
- qmp_cmd = 'echo "{ \\"execute\\": \\"qmp_capabilities\\" }' + \
- '{ \\"execute\\": \\"' + cmd + '\\" }" | sudo -S nc -U ' + \
- self.__QMP_SOCK
+ qmp_cmd = 'echo "{ \\"execute\\": \\"qmp_capabilities\\" }' \
+ '{ \\"execute\\": \\"' + cmd + \
+ '\\" }" | sudo -S socat - UNIX-CONNECT:' + self.__QMP_SOCK
+
(ret_code, stdout, stderr) = self._ssh.exec_command(qmp_cmd)
if int(ret_code) != 0:
logger.debug('QMP execute failed {0}'.format(stderr))
(ret_code, stdout, stderr) = self._ssh.exec_command(qmp_cmd)
if int(ret_code) != 0:
logger.debug('QMP execute failed {0}'.format(stderr))
@@
-246,8
+247,9
@@
class QemuUtils(object):
def _qemu_qga_flush(self):
"""Flush the QGA parser state
"""
def _qemu_qga_flush(self):
"""Flush the QGA parser state
"""
- qga_cmd = 'printf "\xFF" | sudo -S nc ' \
- '-q 1 -U ' + self.__QGA_SOCK
+ qga_cmd = '(printf "\xFF"; sleep 1) | sudo -S socat - UNIX-CONNECT:' + \
+ self.__QGA_SOCK
+ #TODO: probably need something else
(ret_code, stdout, stderr) = self._ssh.exec_command(qga_cmd)
if int(ret_code) != 0:
logger.debug('QGA execute failed {0}'.format(stderr))
(ret_code, stdout, stderr) = self._ssh.exec_command(qga_cmd)
if int(ret_code) != 0:
logger.debug('QGA execute failed {0}'.format(stderr))
@@
-267,8
+269,10
@@
class QemuUtils(object):
:param cmd: QGA command to execute.
:type cmd: str
"""
:param cmd: QGA command to execute.
:type cmd: str
"""
- qga_cmd = 'echo "{ \\"execute\\": \\"' + cmd + '\\" }" | sudo -S nc ' \
- '-q 1 -U ' + self.__QGA_SOCK
+ qga_cmd = '(echo "{ \\"execute\\": \\"' + \
+ cmd + \
+ '\\" }"; sleep 1) | sudo -S socat - UNIX-CONNECT:' + \
+ self.__QGA_SOCK
(ret_code, stdout, stderr) = self._ssh.exec_command(qga_cmd)
if int(ret_code) != 0:
logger.debug('QGA execute failed {0}'.format(stderr))
(ret_code, stdout, stderr) = self._ssh.exec_command(qga_cmd)
if int(ret_code) != 0:
logger.debug('QGA execute failed {0}'.format(stderr))
@@
-292,6
+296,7
@@
class QemuUtils(object):
if time() - start > timeout:
raise RuntimeError('timeout, VM {0} not booted on {1}'.format(
self._qemu_opt['disk_image'], self._node['host']))
if time() - start > timeout:
raise RuntimeError('timeout, VM {0} not booted on {1}'.format(
self._qemu_opt['disk_image'], self._node['host']))
+ out = None
try:
self._qemu_qga_flush()
out = self._qemu_qga_exec('guest-ping')
try:
self._qemu_qga_flush()
out = self._qemu_qga_exec('guest-ping')
@@
-494,6
+499,9
@@
class QemuUtils(object):
# If 'huge_allocate' is set to true try to allocate as well.
self._huge_page_check(allocate=self._qemu_opt.get('huge_allocate'))
# If 'huge_allocate' is set to true try to allocate as well.
self._huge_page_check(allocate=self._qemu_opt.get('huge_allocate'))
+ # Disk option
+ drive = '-drive file={},format=raw,cache=none,if=virtio'.format(
+ self._qemu_opt.get('disk_image'))
# Setup QMP via unix socket
qmp = '-qmp unix:{0},server,nowait'.format(self.__QMP_SOCK)
# Setup serial console
# Setup QMP via unix socket
qmp = '-qmp unix:{0},server,nowait'.format(self.__QMP_SOCK)
# Setup serial console
@@
-505,11
+513,12
@@
class QemuUtils(object):
'-device isa-serial,chardev=qga0'
# Graphic setup
graphic = '-monitor none -display none -vga none'
'-device isa-serial,chardev=qga0'
# Graphic setup
graphic = '-monitor none -display none -vga none'
+
# Run QEMU
# Run QEMU
- cmd = '{0} {1} {2} {3} {4}
-hda
{5} {6} {7} {8} {9}'.format(
+ cmd = '{0} {1} {2} {3} {4} {5} {6} {7} {8} {9}'.format(
self.__QEMU_BIN, self._qemu_opt.get('smp'), mem, ssh_fwd,
self._qemu_opt.get('options'),
self.__QEMU_BIN, self._qemu_opt.get('smp'), mem, ssh_fwd,
self._qemu_opt.get('options'),
-
self._qemu_opt.get('disk_image')
, qmp, serial, qga, graphic)
+
drive
, qmp, serial, qga, graphic)
(ret_code, _, stderr) = self._ssh.exec_command_sudo(cmd, timeout=300)
if int(ret_code) != 0:
logger.debug('QEMU start failed {0}'.format(stderr))
(ret_code, _, stderr) = self._ssh.exec_command_sudo(cmd, timeout=300)
if int(ret_code) != 0:
logger.debug('QEMU start failed {0}'.format(stderr))
@@
-519,7
+528,7
@@
class QemuUtils(object):
# Wait until VM boot
try:
self._wait_until_vm_boot()
# Wait until VM boot
try:
self._wait_until_vm_boot()
- except
RuntimeError
:
+ except
(RuntimeError, SSHTimeout)
:
self.qemu_kill()
self.qemu_clear_socks()
raise
self.qemu_kill()
self.qemu_clear_socks()
raise