1 # Copyright (c) 2019 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """QEMU utilities library."""
16 from time import sleep
17 from string import Template
20 # Disable due to pylint bug
21 # pylint: disable=no-name-in-module,import-error
22 from distutils.version import StrictVersion
24 from robot.api import logger
25 from resources.libraries.python.ssh import exec_cmd, exec_cmd_no_error
26 from resources.libraries.python.Constants import Constants
27 from resources.libraries.python.DpdkUtil import DpdkUtil
28 from resources.libraries.python.DUTSetup import DUTSetup
29 from resources.libraries.python.topology import NodeType, Topology
30 from resources.libraries.python.VppConfigGenerator import VppConfigGenerator
31 from resources.libraries.python.VPPUtil import VPPUtil
33 __all__ = ["QemuOptions", "QemuUtils"]
36 class QemuOptions(object):
39 The class can handle input parameters that acts as QEMU command line
40 parameters. The only variable is a list of dictionaries where dictionaries
41 can be added multiple times. This emulates the QEMU behavior where one
42 command line parameter can be used multiple times (1..N). Example can be
43 device or object (so it is not an issue to have one memory
44 block of 2G and and second memory block of 512M but from other numa).
46 Class does support get value or string representation that will return
47 space separated, dash prefixed string of key value pairs used for command
51 # Use one instance of class per tests.
52 ROBOT_LIBRARY_SCOPE = 'TEST CASE'
55 self.variables = list()
57 def add(self, variable, value):
58 """Add parameter to the list.
60 :param variable: QEMU parameter name (without dash).
61 :param value: Paired value.
63 :type value: str or int
65 self.variables.append({str(variable): value})
68 """Return space separated string of key value pairs.
70 The format is suitable to be pasted to qemu command line.
72 :returns: Space separated string of key value pairs.
75 return " ".join(["-{k} {v}".format(k=d.keys()[0], v=d.values()[0])
76 for d in self.variables])
79 class QemuUtils(object):
82 # Use one instance of class per tests.
83 ROBOT_LIBRARY_SCOPE = 'TEST CASE'
85 def __init__(self, node, qemu_id=1, smp=1, mem=512, vnf=None,
86 img=Constants.QEMU_VM_IMAGE):
87 """Initialize QemuUtil class.
89 :param node: Node to run QEMU on.
90 :param qemu_id: QEMU identifier.
91 :param smp: Number of virtual SMP units (cores).
92 :param mem: Amount of memory.
93 :param vnf: Network function workload.
94 :param img: QEMU disk image or kernel image path.
105 'host': node['host'],
107 'port': 10021 + qemu_id,
108 'serial': 4555 + qemu_id,
113 if node['port'] != 22:
114 self._vm_info['host_port'] = node['port']
115 self._vm_info['host_username'] = node['username']
116 self._vm_info['host_password'] = node['password']
119 self._opt['qemu_id'] = qemu_id
120 self._opt['mem'] = int(mem)
121 self._opt['smp'] = int(smp)
122 self._opt['img'] = img
123 self._opt['vnf'] = vnf
126 self._temp['pidfile'] = '/var/run/qemu_{id}.pid'.format(id=qemu_id)
127 if '/var/lib/vm/' in img:
128 self._opt['vm_type'] = 'nestedvm'
129 self._temp['qmp'] = '/var/run/qmp_{id}.sock'.format(id=qemu_id)
130 self._temp['qga'] = '/var/run/qga_{id}.sock'.format(id=qemu_id)
131 elif '/opt/boot/vmlinuz' in img:
132 self._opt['vm_type'] = 'kernelvm'
133 self._temp['log'] = '/tmp/serial_{id}.log'.format(id=qemu_id)
134 self._temp['ini'] = '/etc/vm_init_{id}.conf'.format(id=qemu_id)
136 raise RuntimeError('QEMU: Unknown VM image option!')
137 # Computed parameters for QEMU command line.
138 self._params = QemuOptions()
141 def add_params(self):
142 """Set QEMU command line parameters."""
143 self.add_default_params()
144 if self._opt.get('vm_type', '') == 'nestedvm':
145 self.add_nestedvm_params()
146 elif self._opt.get('vm_type', '') == 'kernelvm':
147 self.add_kernelvm_params()
149 raise RuntimeError('QEMU: Unsupported VM type!')
151 def add_default_params(self):
152 """Set default QEMU command line parameters."""
153 self._params.add('daemonize', '')
154 self._params.add('nodefaults', '')
155 self._params.add('name', 'vnf{qemu},debug-threads=on'.
156 format(qemu=self._opt.get('qemu_id')))
157 self._params.add('no-user-config', '')
158 self._params.add('monitor', 'none')
159 self._params.add('display', 'none')
160 self._params.add('vga', 'none')
161 self._params.add('enable-kvm', '')
162 self._params.add('pidfile', '{pidfile}'.
163 format(pidfile=self._temp.get('pidfile')))
164 self._params.add('cpu', 'host')
165 self._params.add('machine', 'pc,accel=kvm,usb=off,mem-merge=off')
166 self._params.add('smp', '{smp},sockets=1,cores={smp},threads=1'.
167 format(smp=self._opt.get('smp')))
168 self._params.add('object',
169 'memory-backend-file,id=mem,size={mem}M,'
170 'mem-path=/dev/hugepages,share=on'.
171 format(mem=self._opt.get('mem')))
172 self._params.add('m', '{mem}M'.
173 format(mem=self._opt.get('mem')))
174 self._params.add('numa', 'node,memdev=mem')
175 self._params.add('balloon', 'none')
177 def add_nestedvm_params(self):
178 """Set NestedVM QEMU parameters."""
179 self._params.add('net', 'nic,macaddr=52:54:00:00:{qemu:02x}:ff'.
180 format(qemu=self._opt.get('qemu_id')))
181 self._params.add('net', 'user,hostfwd=tcp::{info[port]}-:22'.
182 format(info=self._vm_info))
183 # TODO: Remove try except after fully migrated to Bionic or
184 # qemu_set_node is removed.
186 locking = ',file.locking=off'\
187 if self.qemu_version(version='2.10') else ''
188 except AttributeError:
190 self._params.add('drive',
191 'file={img},format=raw,cache=none,if=virtio{locking}'.
192 format(img=self._opt.get('img'), locking=locking))
193 self._params.add('qmp', 'unix:{qmp},server,nowait'.
194 format(qmp=self._temp.get('qmp')))
195 self._params.add('chardev', 'socket,host=127.0.0.1,port={info[serial]},'
196 'id=gnc0,server,nowait'.format(info=self._vm_info))
197 self._params.add('device', 'isa-serial,chardev=gnc0')
198 self._params.add('chardev',
199 'socket,path={qga},server,nowait,id=qga0'.
200 format(qga=self._temp.get('qga')))
201 self._params.add('device', 'isa-serial,chardev=qga0')
203 def add_kernelvm_params(self):
204 """Set KernelVM QEMU parameters."""
205 self._params.add('chardev', 'file,id=char0,path={log}'.
206 format(log=self._temp.get('log')))
207 self._params.add('device', 'isa-serial,chardev=char0')
208 self._params.add('fsdev', 'local,id=root9p,path=/,security_model=none')
209 self._params.add('device',
210 'virtio-9p-pci,fsdev=root9p,mount_tag=/dev/root')
211 self._params.add('kernel', '$(readlink -m {img}* | tail -1)'.
212 format(img=self._opt.get('img')))
213 self._params.add('append',
214 '"ro rootfstype=9p rootflags=trans=virtio '
215 'console=ttyS0 tsc=reliable hugepages=256 '
216 'init={init}"'.format(init=self._temp.get('ini')))
218 def create_kernelvm_config_vpp(self, **kwargs):
219 """Create QEMU VPP config files.
221 :param kwargs: Key-value pairs to replace content of VPP configuration
225 startup = ('/etc/vpp/vm_startup_{id}.conf'.
226 format(id=self._opt.get('qemu_id')))
227 running = ('/etc/vpp/vm_running_{id}.exec'.
228 format(id=self._opt.get('qemu_id')))
230 self._temp['startup'] = startup
231 self._temp['running'] = running
232 self._opt['vnf_bin'] = ('/usr/bin/vpp -c {startup}'.
233 format(startup=startup))
235 # Create VPP startup configuration.
236 vpp_config = VppConfigGenerator()
237 vpp_config.set_node(self._node)
238 vpp_config.add_unix_nodaemon()
239 vpp_config.add_unix_cli_listen()
240 vpp_config.add_unix_exec(running)
241 vpp_config.add_cpu_main_core('0')
242 vpp_config.add_cpu_corelist_workers('1-{smp}'.
243 format(smp=self._opt.get('smp')-1))
244 vpp_config.add_dpdk_dev('0000:00:06.0', '0000:00:07.0')
245 vpp_config.add_dpdk_log_level('debug')
246 if not kwargs['jumbo_frames']:
247 vpp_config.add_dpdk_no_multi_seg()
248 vpp_config.add_dpdk_no_tx_checksum_offload()
249 vpp_config.add_plugin('disable', 'default')
250 vpp_config.add_plugin('enable', 'dpdk_plugin.so')
251 vpp_config.apply_config(startup, restart_vpp=False)
253 # Create VPP running configuration.
254 template = '{res}/{tpl}.exec'.format(res=Constants.RESOURCES_TPL_VM,
255 tpl=self._opt.get('vnf'))
256 exec_cmd_no_error(self._node, 'rm -f {running}'.format(running=running),
259 with open(template, 'r') as src_file:
260 src = Template(src_file.read())
261 exec_cmd_no_error(self._node, "echo '{out}' | sudo tee {running}".
262 format(out=src.safe_substitute(**kwargs),
265 def create_kernelvm_config_testpmd_io(self, **kwargs):
266 """Create QEMU testpmd-io command line.
268 :param kwargs: Key-value pairs to construct command line parameters.
271 testpmd_path = ('{path}/{arch}-native-linuxapp-gcc/app'.
272 format(path=Constants.QEMU_VM_DPDK,
273 arch=Topology.get_node_arch(self._node)))
274 testpmd_cmd = DpdkUtil.get_testpmd_cmdline(
275 eal_corelist='0-{smp}'.format(smp=self._opt.get('smp') - 1),
279 pmd_rxq=kwargs['queues'],
280 pmd_txq=kwargs['queues'],
281 pmd_tx_offloads=False,
282 pmd_disable_hw_vlan=False,
283 pmd_max_pkt_len=9200 if kwargs['jumbo_frames'] else None,
284 pmd_nb_cores=str(self._opt.get('smp') - 1))
286 self._opt['vnf_bin'] = ('{testpmd_path}/{testpmd_cmd}'.
287 format(testpmd_path=testpmd_path,
288 testpmd_cmd=testpmd_cmd))
290 def create_kernelvm_config_testpmd_mac(self, **kwargs):
291 """Create QEMU testpmd-mac command line.
293 :param kwargs: Key-value pairs to construct command line parameters.
296 testpmd_path = ('{path}/{arch}-native-linuxapp-gcc/app'.
297 format(path=Constants.QEMU_VM_DPDK,
298 arch=Topology.get_node_arch(self._node)))
299 testpmd_cmd = DpdkUtil.get_testpmd_cmdline(
300 eal_corelist='0-{smp}'.format(smp=self._opt.get('smp') - 1),
305 pmd_eth_peer_0='0,{mac}'.format(mac=kwargs['vif1_mac']),
306 pmd_eth_peer_1='1,{mac}'.format(mac=kwargs['vif2_mac']),
307 pmd_rxq=kwargs['queues'],
308 pmd_txq=kwargs['queues'],
309 pmd_tx_offloads=False,
310 pmd_disable_hw_vlan=False,
311 pmd_max_pkt_len=9200 if kwargs['jumbo_frames'] else None,
312 pmd_nb_cores=str(self._opt.get('smp') - 1))
314 self._opt['vnf_bin'] = ('{testpmd_path}/{testpmd_cmd}'.
315 format(testpmd_path=testpmd_path,
316 testpmd_cmd=testpmd_cmd))
318 def create_kernelvm_init(self, **kwargs):
319 """Create QEMU init script.
321 :param kwargs: Key-value pairs to replace content of init startup file.
324 template = '{res}/init.sh'.format(res=Constants.RESOURCES_TPL_VM)
325 init = self._temp.get('ini')
326 exec_cmd_no_error(self._node, 'rm -f {init}'.format(init=init),
329 with open(template, 'r') as src_file:
330 src = Template(src_file.read())
331 exec_cmd_no_error(self._node, "echo '{out}' | sudo tee {init}".
332 format(out=src.safe_substitute(**kwargs),
334 exec_cmd_no_error(self._node, "chmod +x {init}".
335 format(init=init), sudo=True)
337 def configure_kernelvm_vnf(self, **kwargs):
338 """Create KernelVM VNF configurations.
340 :param kwargs: Key-value pairs for templating configs.
343 if 'vpp' in self._opt.get('vnf'):
344 self.create_kernelvm_config_vpp(**kwargs)
345 elif 'testpmd_io' in self._opt.get('vnf'):
346 self.create_kernelvm_config_testpmd_io(**kwargs)
347 elif 'testpmd_mac' in self._opt.get('vnf'):
348 self.create_kernelvm_config_testpmd_mac(**kwargs)
350 raise RuntimeError('QEMU: Unsupported VNF!')
351 self.create_kernelvm_init(vnf_bin=self._opt.get('vnf_bin'))
353 def get_qemu_pids(self):
354 """Get QEMU CPU pids.
356 :returns: List of QEMU CPU pids.
359 command = ("grep -rwl 'CPU' /proc/$(sudo cat {pidfile})/task/*/comm ".
360 format(pidfile=self._temp.get('pidfile')))
361 command += (r"| xargs dirname | sed -e 's/\/.*\///g' | uniq")
363 stdout, _ = exec_cmd_no_error(self._node, command)
364 return stdout.splitlines()
366 def qemu_set_affinity(self, *host_cpus):
367 """Set qemu affinity by getting thread PIDs via QMP and taskset to list
368 of CPU cores. Function tries to execute 3 times to avoid race condition
369 in getting thread PIDs.
371 :param host_cpus: List of CPU cores.
372 :type host_cpus: list
376 qemu_cpus = self.get_qemu_pids()
378 if len(qemu_cpus) != len(host_cpus):
381 for qemu_cpu, host_cpu in zip(qemu_cpus, host_cpus):
382 command = ('taskset -pc {host_cpu} {thread}'.
383 format(host_cpu=host_cpu, thread=qemu_cpu))
384 message = ('QEMU: Set affinity failed on {host}!'.
385 format(host=self._node['host']))
386 exec_cmd_no_error(self._node, command, sudo=True,
389 except (RuntimeError, ValueError):
394 raise RuntimeError('Failed to set Qemu threads affinity!')
396 def qemu_set_scheduler_policy(self):
397 """Set scheduler policy to SCHED_RR with priority 1 for all Qemu CPU
400 :raises RuntimeError: Set scheduler policy failed.
403 qemu_cpus = self.get_qemu_pids()
405 for qemu_cpu in qemu_cpus:
406 command = ('chrt -r -p 1 {thread}'.
407 format(thread=qemu_cpu))
408 message = ('QEMU: Set SCHED_RR failed on {host}'.
409 format(host=self._node['host']))
410 exec_cmd_no_error(self._node, command, sudo=True,
412 except (RuntimeError, ValueError):
416 def qemu_add_vhost_user_if(self, socket, server=True, jumbo_frames=False,
417 queue_size=None, queues=1):
418 """Add Vhost-user interface.
420 :param socket: Path of the unix socket.
421 :param server: If True the socket shall be a listening socket.
422 :param jumbo_frames: Set True if jumbo frames are used in the test.
423 :param queue_size: Vring queue size.
424 :param queues: Number of queues.
427 :type jumbo_frames: bool
428 :type queue_size: int
432 self._params.add('chardev',
433 'socket,id=char{vhost},path={socket}{server}'.
434 format(vhost=self._vhost_id, socket=socket,
435 server=',server' if server is True else ''))
436 self._params.add('netdev',
437 'vhost-user,id=vhost{vhost},'
438 'chardev=char{vhost},queues={queues}'.
439 format(vhost=self._vhost_id, queues=queues))
440 mac = ('52:54:00:00:{qemu:02x}:{vhost:02x}'.
441 format(qemu=self._opt.get('qemu_id'), vhost=self._vhost_id))
442 queue_size = ('rx_queue_size={queue_size},tx_queue_size={queue_size}'.
443 format(queue_size=queue_size)) if queue_size else ''
444 mbuf = 'on,host_mtu=9200'
445 self._params.add('device',
446 'virtio-net-pci,netdev=vhost{vhost},'
447 'mac={mac},bus=pci.0,addr={addr}.0,mq=on,'
448 'vectors={vectors},csum=off,gso=off,'
449 'guest_tso4=off,guest_tso6=off,guest_ecn=off,'
450 'mrg_rxbuf={mbuf},{queue_size}'.
451 format(addr=self._vhost_id+5,
452 vhost=self._vhost_id, mac=mac,
453 mbuf=mbuf if jumbo_frames else 'off',
454 queue_size=queue_size,
455 vectors=(2 * queues + 2)))
457 # Add interface MAC and socket to the node dict.
458 if_data = {'mac_address': mac, 'socket': socket}
459 if_name = 'vhost{vhost}'.format(vhost=self._vhost_id)
460 self._vm_info['interfaces'][if_name] = if_data
461 # Add socket to temporary file list.
462 self._temp[if_name] = socket
464 def _qemu_qmp_exec(self, cmd):
465 """Execute QMP command.
467 QMP is JSON based protocol which allows to control QEMU instance.
469 :param cmd: QMP command to execute.
471 :returns: Command output in python representation of JSON format. The
472 { "return": {} } response is QMP's success response. An error
473 response will contain the "error" keyword instead of "return".
475 # To enter command mode, the qmp_capabilities command must be issued.
476 command = ('echo "{{ \\"execute\\": \\"qmp_capabilities\\" }}'
477 '{{ \\"execute\\": \\"{cmd}\\" }}" | '
478 'sudo -S socat - UNIX-CONNECT:{qmp}'.
479 format(cmd=cmd, qmp=self._temp.get('qmp')))
480 message = ('QMP execute "{cmd}" failed on {host}'.
481 format(cmd=cmd, host=self._node['host']))
482 stdout, _ = exec_cmd_no_error(self._node, command, sudo=False,
485 # Skip capabilities negotiation messages.
486 out_list = stdout.splitlines()
487 if len(out_list) < 3:
488 raise RuntimeError('Invalid QMP output on {host}'.
489 format(host=self._node['host']))
490 return json.loads(out_list[2])
492 def _qemu_qga_flush(self):
493 """Flush the QGA parser state."""
494 command = ('(printf "\xFF"; sleep 1) | '
495 'sudo -S socat - UNIX-CONNECT:{qga}'.
496 format(qga=self._temp.get('qga')))
497 message = ('QGA flush failed on {host}'.format(host=self._node['host']))
498 stdout, _ = exec_cmd_no_error(self._node, command, sudo=False,
501 return json.loads(stdout.split('\n', 1)[0]) if stdout else dict()
503 def _qemu_qga_exec(self, cmd):
504 """Execute QGA command.
506 QGA provide access to a system-level agent via standard QMP commands.
508 :param cmd: QGA command to execute.
511 command = ('(echo "{{ \\"execute\\": \\"{cmd}\\" }}"; sleep 1) | '
512 'sudo -S socat - UNIX-CONNECT:{qga}'.
513 format(cmd=cmd, qga=self._temp.get('qga')))
514 message = ('QGA execute "{cmd}" failed on {host}'.
515 format(cmd=cmd, host=self._node['host']))
516 stdout, _ = exec_cmd_no_error(self._node, command, sudo=False,
519 return json.loads(stdout.split('\n', 1)[0]) if stdout else dict()
521 def _wait_until_vm_boot(self):
522 """Wait until QEMU with NestedVM is booted."""
523 if self._opt.get('vm_type') == 'nestedvm':
524 self._wait_until_nestedvm_boot()
525 self._update_vm_interfaces()
526 elif self._opt.get('vm_type') == 'kernelvm':
527 self._wait_until_kernelvm_boot()
529 raise RuntimeError('QEMU: Unsupported VM type!')
531 def _wait_until_nestedvm_boot(self, retries=12):
532 """Wait until QEMU with NestedVM is booted.
534 First try to flush qga until there is output.
535 Then ping QEMU guest agent each 5s until VM booted or timeout.
537 :param retries: Number of retries with 5s between trials.
540 for _ in range(retries):
543 out = self._qemu_qga_flush()
545 logger.trace('QGA qga flush unexpected output {out}'.
547 # Empty output - VM not booted yet
553 raise RuntimeError('QEMU: Timeout, VM not booted on {host}!'.
554 format(host=self._node['host']))
555 for _ in range(retries):
558 out = self._qemu_qga_exec('guest-ping')
560 logger.trace('QGA guest-ping unexpected output {out}'.
562 # Empty output - VM not booted yet.
565 # Non-error return - VM booted.
566 elif out.get('return') is not None:
568 # Skip error and wait.
569 elif out.get('error') is not None:
572 # If there is an unexpected output from QGA guest-info, try
573 # again until timeout.
574 logger.trace('QGA guest-ping unexpected output {out}'.
577 raise RuntimeError('QEMU: Timeout, VM not booted on {host}!'.
578 format(host=self._node['host']))
580 def _wait_until_kernelvm_boot(self, retries=60):
581 """Wait until QEMU KernelVM is booted.
583 :param retries: Number of retries.
586 vpp_ver = VPPUtil.vpp_show_version(self._node)
588 for _ in range(retries):
589 command = ('tail -1 {log}'.format(log=self._temp.get('log')))
592 stdout, _ = exec_cmd_no_error(self._node, command, sudo=True)
596 if vpp_ver in stdout or 'Press enter to exit' in stdout:
598 if 'reboot: Power down' in stdout:
599 raise RuntimeError('QEMU: NF failed to run on {host}!'.
600 format(host=self._node['host']))
602 raise RuntimeError('QEMU: Timeout, VM not booted on {host}!'.
603 format(host=self._node['host']))
605 def _update_vm_interfaces(self):
606 """Update interface names in VM node dict."""
607 # Send guest-network-get-interfaces command via QGA, output example:
608 # {"return": [{"name": "eth0", "hardware-address": "52:54:00:00:04:01"},
609 # {"name": "eth1", "hardware-address": "52:54:00:00:04:02"}]}.
610 out = self._qemu_qga_exec('guest-network-get-interfaces')
611 interfaces = out.get('return')
614 raise RuntimeError('Get VM interface list failed on {host}'.
615 format(host=self._node['host']))
616 # Create MAC-name dict.
617 for interface in interfaces:
618 if 'hardware-address' not in interface:
620 mac_name[interface['hardware-address']] = interface['name']
621 # Match interface by MAC and save interface name.
622 for interface in self._vm_info['interfaces'].values():
623 mac = interface.get('mac_address')
624 if_name = mac_name.get(mac)
626 logger.trace('Interface name for MAC {mac} not found'.
629 interface['name'] = if_name
631 def qemu_start(self):
632 """Start QEMU and wait until VM boot.
634 :returns: VM node info.
637 command = ('{bin_path}/qemu-system-{arch} {params}'.
638 format(bin_path=Constants.QEMU_BIN_PATH,
639 arch=Topology.get_node_arch(self._node),
640 params=self._params))
641 message = ('QEMU: Start failed on {host}!'.
642 format(host=self._node['host']))
644 DUTSetup.check_huge_page(self._node, '/dev/hugepages',
645 self._opt.get('mem'))
647 exec_cmd_no_error(self._node, command, timeout=300, sudo=True,
649 self._wait_until_vm_boot()
656 """Kill qemu process."""
657 exec_cmd(self._node, 'chmod +r {pidfile}'.
658 format(pidfile=self._temp.get('pidfile')), sudo=True)
659 exec_cmd(self._node, 'kill -SIGKILL $(cat {pidfile})'.
660 format(pidfile=self._temp.get('pidfile')), sudo=True)
662 for value in self._temp.values():
663 exec_cmd(self._node, 'cat {value}'.format(value=value), sudo=True)
664 exec_cmd(self._node, 'rm -f {value}'.format(value=value), sudo=True)
666 def qemu_kill_all(self):
667 """Kill all qemu processes on DUT node if specified."""
668 exec_cmd(self._node, 'pkill -SIGKILL qemu', sudo=True)
670 for value in self._temp.values():
671 exec_cmd(self._node, 'cat {value}'.format(value=value), sudo=True)
672 exec_cmd(self._node, 'rm -f {value}'.format(value=value), sudo=True)
674 def qemu_version(self, version=None):
675 """Return Qemu version or compare if version is higher than parameter.
677 :param version: Version to compare.
679 :returns: Qemu version or Boolean if version is higher than parameter.
682 command = ('{bin_path}/qemu-system-{arch} --version'.
683 format(bin_path=Constants.QEMU_BIN_PATH,
684 arch=Topology.get_node_arch(self._node)))
686 stdout, _ = exec_cmd_no_error(self._node, command, sudo=True)
687 ver = match(r'QEMU emulator version ([\d.]*)', stdout).group(1)
688 return StrictVersion(ver) > StrictVersion(version) \