diff options
author | Stefan Stanacar <stefanx.stanacar@intel.com> | 2013-08-22 14:47:21 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-08-26 11:42:15 +0100 |
commit | 9de7fe11967576f4a8b24e653c6b9a02e5f6d85b (patch) | |
tree | cffdb2fc6a510be1501a4b854c0fd41f52af4a21 /meta/lib/oeqa/utils/qemurunner.py | |
parent | f6186b4204dcc421b4e616774315c8a2a77fb5c5 (diff) | |
download | openembedded-core-contrib-9de7fe11967576f4a8b24e653c6b9a02e5f6d85b.tar.gz |
lib/oeqa: make it possible to restart the target
Tweak QemuRunner so we can actually restart the
qemu target in a test (if we want more memory for example).
Also add a restart method to the base test class so that tests
can use it.
Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Diffstat (limited to 'meta/lib/oeqa/utils/qemurunner.py')
-rw-r--r-- | meta/lib/oeqa/utils/qemurunner.py | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index 9ae618f4c9..6ee5b8577e 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py @@ -32,6 +32,10 @@ class QemuRunner: self.boottime = boottime self.runqemutime = runqemutime + self.create_socket() + + def create_socket(self): + self.bootlog = '' self.qemusock = None @@ -137,21 +141,31 @@ class QemuRunner: return self.is_alive() def kill(self): + + if self.runqemu: + bb.note("Sending SIGTERM to runqemu") + os.kill(-self.runqemu.pid,signal.SIGTERM) + endtime = time.time() + self.runqemutime + while self.runqemu.poll() is None and time.time() < endtime: + time.sleep(1) + if self.runqemu.poll() is None: + bb.note("Sending SIGKILL to runqemu") + os.kill(-self.runqemu.pid,signal.SIGKILL) + self.runqemu = None if self.server_socket: self.server_socket.close() self.server_socket = None - if self.runqemu.pid: - os.kill(-self.runqemu.pid,signal.SIGTERM) - os.kill(-self.runqemu.pid,signal.SIGKILL) - self.runqemu.pid = None self.qemupid = None self.ip = None def restart(self, qemuparams = None): - if self.is_alive(): + bb.note("Restarting qemu process") + if self.runqemu.poll() is None: self.kill() - bb.note("Qemu Restart required...") - return self.launch(qemuparams) + self.create_socket() + if self.launch(qemuparams): + return True + return False def is_alive(self): qemu_child = self.find_child(str(self.runqemu.pid)) |