summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Hestness <jthestness@gmail.com>2016-12-23 08:43:18 -0600
committerJoel Hestness <jthestness@gmail.com>2016-12-23 08:43:18 -0600
commit6a49dee3f3994c91c3038752172c24a8a5c05d88 (patch)
treecdb3343efc9d828e2597454163d162146d2370c1
parentc9d933efb04ec8bb167b8405f56283804b12c0fe (diff)
downloadgem5-6a49dee3f3994c91c3038752172c24a8a5c05d88.tar.xz
sim: Fix SE mode checkpoint restore file handling
When restoring from a checkpoint, the simulation used to use file handles from the checkpoint. This disallows multiple separate restore simulations from using separate input and output files and directories, and plays havoc when the checkpointed file locations may have changed. Add handling to allow the command line specified files to be used as input/output for the restored simulation (Note: this is the similar functionality to FS mode for output and error).
-rw-r--r--src/sim/process.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/sim/process.cc b/src/sim/process.cc
index 0ba215511..ef3ab9ecd 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -336,6 +336,18 @@ Process::fixFileOffsets()
// Search through the input options and set fd if match is found;
// otherwise, open an input file and seek to location.
FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
+
+ // Check if user has specified a different input file, and if so, use it
+ // instead of the file specified in the checkpoint. This also resets the
+ // file offset from the checkpointed value
+ string new_in = ((ProcessParams*)params())->input;
+ if (new_in != fde_stdin->filename) {
+ warn("Using new input file (%s) rather than checkpointed (%s)\n",
+ new_in, fde_stdin->filename);
+ fde_stdin->filename = new_in;
+ fde_stdin->fileOffset = 0;
+ }
+
if ((it = imap.find(fde_stdin->filename)) != imap.end()) {
fde_stdin->fd = it->second;
} else {
@@ -346,6 +358,18 @@ Process::fixFileOffsets()
// Search through the output/error options and set fd if match is found;
// otherwise, open an output file and seek to location.
FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
+
+ // Check if user has specified a different output file, and if so, use it
+ // instead of the file specified in the checkpoint. This also resets the
+ // file offset from the checkpointed value
+ string new_out = ((ProcessParams*)params())->output;
+ if (new_out != fde_stdout->filename) {
+ warn("Using new output file (%s) rather than checkpointed (%s)\n",
+ new_out, fde_stdout->filename);
+ fde_stdout->filename = new_out;
+ fde_stdout->fileOffset = 0;
+ }
+
if ((it = oemap.find(fde_stdout->filename)) != oemap.end()) {
fde_stdout->fd = it->second;
} else {
@@ -354,6 +378,18 @@ Process::fixFileOffsets()
}
FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
+
+ // Check if user has specified a different error file, and if so, use it
+ // instead of the file specified in the checkpoint. This also resets the
+ // file offset from the checkpointed value
+ string new_err = ((ProcessParams*)params())->errout;
+ if (new_err != fde_stderr->filename) {
+ warn("Using new error file (%s) rather than checkpointed (%s)\n",
+ new_err, fde_stderr->filename);
+ fde_stderr->filename = new_err;
+ fde_stderr->fileOffset = 0;
+ }
+
if (fde_stdout->filename == fde_stderr->filename) {
// Reuse the same file descriptor if these match.
fde_stderr->fd = fde_stdout->fd;