redirect_path patch for restoring cpt (#221)

Modify the FDArray::unserialize function to perform a checkPathRedirect
if a Process pointer is passed in.
Currently when restoring a checkpoint, it doesn't perform
checkPathRedirect for files that were opened during checkpointing. This
patch adds a checkPathRedirect in the FDArray::unserialize to redirect
app path for restoring checkpoints.
This commit is contained in:
Jason Lowe-Power
2023-09-08 15:30:53 -07:00
committed by GitHub
3 changed files with 25 additions and 5 deletions

View File

@@ -42,6 +42,7 @@
#include "base/output.hh"
#include "params/Process.hh"
#include "sim/fd_entry.hh"
#include "sim/process.hh"
namespace gem5
{
@@ -367,7 +368,7 @@ FDArray::serialize(CheckpointOut &cp) const {
}
void
FDArray::unserialize(CheckpointIn &cp) {
FDArray::unserialize(CheckpointIn &cp, Process* process_ptr) {
ScopedCheckpointSection sec(cp, "fdarray");
uint64_t size;
paramIn(cp, "size", size);
@@ -418,11 +419,24 @@ FDArray::unserialize(CheckpointIn &cp) {
setFDEntry(tgt_fd, fdep);
mode_t mode = this_ffd->getFileMode();
std::string const& path = this_ffd->getFileName();
std::string path;
if (process_ptr) {
// Check if it is needed to redirect the app path to another host
// path
path = process_ptr->checkPathRedirect(this_ffd->getFileName());
}
else {
path = this_ffd->getFileName();
}
int flags = this_ffd->getFlags();
// Re-open the file and assign a new sim_fd
int sim_fd = openFile(path, flags, mode);
int sim_fd;
sim_fd = openFile(path, flags, mode);
this_ffd->setSimFD(sim_fd);
// Restore the file offset to the proper value

View File

@@ -43,6 +43,8 @@
namespace gem5
{
class Process;
class FDArray : public Serializable
{
public:
@@ -117,7 +119,11 @@ class FDArray : public Serializable
* Serialization methods for file descriptors
*/
void serialize(CheckpointOut &cp) const override;
void unserialize(CheckpointIn &cp) override;
void unserialize(CheckpointIn &cp, Process* process_ptr );
void unserialize(CheckpointIn &cp) override {
unserialize(cp, nullptr);
};
private:
/**

View File

@@ -387,7 +387,7 @@ Process::unserialize(CheckpointIn &cp)
{
memState->unserialize(cp);
pTable->unserialize(cp);
fds->unserialize(cp);
fds->unserialize(cp, this);
/**
* Checkpoints for pipes, device drivers or sockets currently