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).
This commit is contained in:
Joel Hestness 2016-12-23 08:43:18 -06:00
parent c9d933efb0
commit 6a49dee3f3
1 changed files with 36 additions and 0 deletions

View File

@ -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;