Skip to content

FIxed --restartdir flag#1208

Merged
xuyao0127 merged 2 commits intodmtcp:mainfrom
xuyao0127:restartdir_fix
Jun 3, 2025
Merged

FIxed --restartdir flag#1208
xuyao0127 merged 2 commits intodmtcp:mainfrom
xuyao0127:restartdir_fix

Conversation

@xuyao0127
Copy link
Copy Markdown
Collaborator

PR #1207 needs to be merged before this PR.

@xuyao0127 xuyao0127 requested review from gc00 and karya0 May 31, 2025 05:30
@xuyao0127 xuyao0127 added the bug label May 31, 2025
@karya0 karya0 requested a review from Copilot May 31, 2025 07:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for the new --restartdir flag by updating the test harness and internal restart logic, and adjusts the filesystem layer to handle 64-bit directory entries on additional architectures.

  • Extend testRestart() to detect and pass a checkpoint directory via --restartdir and add a corresponding test invocation.
  • Restructure DmtcpRestart so it either consumes explicit checkpoint image arguments or lists a directory for images.
  • Enhance jalib::Filesystem to define linux_dirent for 64-bit architectures and call SYS_getdents64 where appropriate.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/autotest.py Add --restartdir branch inside testRestart() and invoke it.
src/dmtcprestartinternal.cpp Enforce mutual exclusion of image args vs. --restartdir and list directory on that flag.
jalib/jfilesystem.h Define a 64-bit linux_dirent struct for __aarch64__, __riscv, and __x86_64__.
jalib/jfilesystem.cpp Switch to SYS_getdents64 on architectures with 64-bit dirents.
Comments suppressed due to low confidence (2)

test/autotest.py:645

  • The variable name is not defined within testRestart(), which will raise a NameError at runtime. Consider passing name as an argument to testRestart or deriving it from the test framework context.
if name == "restartdir":

test/autotest.py:645

  • [nitpick] Indentation here uses 4 spaces but the project standard is 2 spaces. Please align the new block to match existing indentation.
if name == "restartdir":

Comment on lines 813 to +842
// Can't specify ckpt images with --restartdir flag.
if (restartDir.empty() ^ (ckptImages.size() > 0)) {
JASSERT_STDERR << theUsage;
exit(DMTCP_FAIL_RC);
}

if (ckptImages.size() > 0) { // Explicit ckpt images are provided
for (; argc > 0; shift) {
Copy link

Copilot AI May 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This XOR check runs before ckptImages is populated, causing valid explicit-image invocations to be rejected. Either move this validation after the image-listing logic or invert the condition so it only errors when both or neither option is specified.

Suggested change
// Can't specify ckpt images with --restartdir flag.
if (restartDir.empty() ^ (ckptImages.size() > 0)) {
JASSERT_STDERR << theUsage;
exit(DMTCP_FAIL_RC);
}
if (ckptImages.size() > 0) { // Explicit ckpt images are provided
for (; argc > 0; shift) {
if (ckptImages.size() > 0) { // Explicit ckpt images are provided
for (; argc > 0; shift) {
string restorename(argv[0]);
struct stat buf;
JASSERT(stat(restorename.c_str(), &buf) != -1);
if (Util::strEndsWith(restorename.c_str(), "_files")) {
continue;
} else if (!Util::strEndsWith(restorename.c_str(), ".dmtcp")) {
JNOTE("File doesn't have .dmtcp extension. Check Usage.") (restorename);
// Don't test for --quiet here. We're aborting. We need to say why.
JASSERT_STDERR << theUsage;
exit(DMTCP_FAIL_RC);
} else if (buf.st_uid != getuid() && !noStrictChecking) {
/*Could also run if geteuid() matches*/
JASSERT(false) (getuid()) (buf.st_uid) (restorename)
.Text("Process uid doesn't match uid of checkpoint image.\n" \
"This is dangerous. Aborting for security reasons.\n" \
"If you still want to do this, then re-run dmtcp_restart\n" \
" with the --no-strict-checking flag.\n");
}
JTRACE("Will restart ckpt image") (argv[0]);
ckptImages.push_back(argv[0]);
}
} else { // --restartdir is provided
// Additional logic for --restartdir
}
// Can't specify ckpt images with --restartdir flag.
if (restartDir.empty() ^ (ckptImages.size() > 0)) {
JASSERT_STDERR << theUsage;
exit(DMTCP_FAIL_RC);
}

Copilot uses AI. Check for mistakes.
@xuyao0127 xuyao0127 merged commit ee7cecf into dmtcp:main Jun 3, 2025
1 check passed
@xuyao0127 xuyao0127 deleted the restartdir_fix branch June 3, 2025 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants