From 9e45d65c949911ff2519f4c93f5e22e42f864777 Mon Sep 17 00:00:00 2001 From: Sascha Bischoff Date: Thu, 7 Jun 2018 13:35:50 +0100 Subject: [PATCH] gem5: Unmount the VirtIO device at the end of the run We explicitly unmount the VirtIO device (used to transfer files into the simulated system) at the end of a run (when the connection is closed) in order to make checkpointing the simulated system easier. gem5 supports checkpointing the state of the simulation when it is terminated, and future simulations are able to resume from this snapshot. However, for the checkpoint to work correctly, we need to make sure that there is no shared state between the simulated system and the host. This mandates that we disconnect the VirtIO device prior to taking a checkpoint. --- devlib/utils/ssh.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/devlib/utils/ssh.py b/devlib/utils/ssh.py index 8391ed2..c6db81f 100644 --- a/devlib/utils/ssh.py +++ b/devlib/utils/ssh.py @@ -536,6 +536,10 @@ class Gem5Connection(TelnetConnection): """ gem5_logger.info("Gracefully terminating the gem5 simulation.") try: + # Unmount the virtio device BEFORE we kill the + # simulation. This is done to simplify checkpointing at + # the end of a simulation! + self._unmount_virtio() self._gem5_util("exit") self.gem5simulation.wait() except EOF: @@ -793,6 +797,15 @@ class Gem5Connection(TelnetConnection): mount_command = "mount -t 9p -o trans=virtio,version=9p2000.L,aname={} gem5 {}".format(self.gem5_interact_dir, self.gem5_input_dir) self._gem5_shell(mount_command, as_root=True) + def _unmount_virtio(self): + """ + Unmount the VirtIO device in the simulated system. + """ + gem5_logger.info("Unmounting VirtIO device in simulated system") + + unmount_command = "umount {}".format(self.gem5_input_dir) + self._gem5_shell(unmount_command, as_root=True) + def _move_to_temp_dir(self, source): """ Move a file to the temporary directory on the host for copying to the