From ea1b06e94edd6d328b6835e17b8c56cad74b4bc1 Mon Sep 17 00:00:00 2001 From: Martin Klozik Date: Mon, 4 Apr 2016 12:50:26 +0100 Subject: bugfix: Graceful shutdown of VMs Cleanup phase of PVVP scenario sometimes causes server reboot. It seems, that forced kill of VMs is the root cause. So graceful shutdown of VMs was introduced. Change-Id: I427404406fd7174d2a034f3cf0b51fe0833f9ecf JIRA: VSPERF-271 Signed-off-by: Martin Klozik Reviewed-by: Maryam Tahhan Reviewed-by: Al Morton Reviewed-by: Christian Trautman Reviewed-by: Brian Castelli --- vnfs/qemu/qemu.py | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'vnfs/qemu') diff --git a/vnfs/qemu/qemu.py b/vnfs/qemu/qemu.py index cb6d9ecc..ec728c5c 100644 --- a/vnfs/qemu/qemu.py +++ b/vnfs/qemu/qemu.py @@ -62,6 +62,10 @@ class IVnfQemu(IVnf): else: self._net2 = self._net2.split(',')[self._number] + # set guest loopback application based on VNF configuration + # cli option take precedence to config file values + self._guest_loopback = S.getValue('GUEST_LOOPBACK')[self._number] + name = 'Client%d' % self._number vnc = ':%d' % self._number @@ -116,6 +120,21 @@ class IVnfQemu(IVnf): if self._timeout: self._config_guest_loopback() + def stop(self): + """ + Stops VNF instance gracefully first. + """ + # exit testpmd if needed + if self._guest_loopback == 'testpmd': + self.execute_and_wait('stop', 120, "Done") + self.execute_and_wait('quit', 120, "bye") + + # turn off VM + self.execute_and_wait('poweroff', 120, "Power down") + + # just for case that graceful shutdown failed + super(IVnfQemu, self).stop() + # helper functions def _login(self, timeout=120): @@ -196,24 +215,20 @@ class IVnfQemu(IVnf): def _config_guest_loopback(self): """ - Configure VM to run VNF (e.g. port forwarding application) + Configure VM to run VNF, e.g. port forwarding application based on the configuration """ - # set guest loopback application based on VNF configuration - # cli option take precedence to config file values - guest_loopback = S.getValue('GUEST_LOOPBACK')[self._number] - - if guest_loopback == 'testpmd': + if self._guest_loopback == 'testpmd': self._login() self._configure_testpmd() - elif guest_loopback == 'l2fwd': + elif self._guest_loopback == 'l2fwd': self._login() self._configure_l2fwd() - elif guest_loopback == 'linux_bridge': + elif self._guest_loopback == 'linux_bridge': self._login() self._configure_linux_bridge() - elif guest_loopback != 'buildin': + elif self._guest_loopback != 'buildin': self._logger.error('Unsupported guest loopback method "%s" was specified. Option' - ' "buildin" will be used as a fallback.', guest_loopback) + ' "buildin" will be used as a fallback.', self._guest_loopback) def wait(self, prompt=S.getValue('GUEST_PROMPT'), timeout=30): super(IVnfQemu, self).wait(prompt=prompt, timeout=timeout) -- cgit 1.2.3-korg