Repository navigation
Conversation
Contributor
Author
|
friendly ping |
milantracy
requested changes
Oct 23, 2026
hugelgupf
force-pushed
the
pr/restore-fifo-statefile
branch
from
October 23, 2026 06:21
6618b2e to
257bccb
Compare
Contributor
Author
|
ptal @milantracy |
hugelgupf
force-pushed
the
pr/restore-fifo-statefile
branch
from
November 4, 2026 22:47
257bccb to
d9afd7c
Compare
Contributor
Author
|
Rebased onto current master. PTAL @milantracy |
Contributor
Author
|
@milantracy friendly ping: all three of your comments are addressed (both |
ayushr2
approved these changes
Nov 9, 2026
hugelgupf
force-pushed
the
pr/restore-fifo-statefile
branch
from
November 19, 2026 20:02
d9afd7c to
bc3639a
Compare
Contributor
Author
|
ping @milantracy |
Contributor
Author
|
@milantracy friendly ping: ayushr2 approved this on 11-09, and it's signed off for DCO now. Is anything left from your review, or could you clear the change request? 🤖 Posted by an AI agent (Cursor · skill |
hugelgupf
force-pushed
the
pr/restore-fifo-statefile
branch
from
November 20, 2026 06:13
bc3639a to
eac6adb
Compare
Restore rejected a statefile whose fstat st_size is 0, so a FIFO at <image-path>/checkpoint.img never worked: pipes always report st_size 0. Only apply the empty check to regular files. An empty stream still fails when the statefile header is read. This applies to single-file checkpoints only, because the pages file is read at offsets. A read from a pipe can return fewer bytes than asked for. The statefile reader read the 8-byte magic header with one Read, so a short read gave ErrBadMagic. Read the header with io.ReadFull, like the metadata length, metadata, and hash that follow it. The compressio readers already read their fixed-size chunk headers and hashes in full. A stream that ends inside the header now gives io.ErrUnexpectedEOF instead of ErrBadMagic. Linux: generic_fillattr() reports i_size_read(inode), and fs/pipe.c never sets i_size, so st_size is 0 for every pipe. pipe_read() returns as soon as any data is available. POSIX only defines st_size for regular files and symlinks. Tests: - TestStatefileShortReads (pkg/state/statefile) writes a statefile into an io.Pipe 1-3 bytes at a time, so every read is short, and reads it back with and without an integrity key, uncompressed and flate. With the header read reverted to one Read, every subtest fails with "bad magic header". - TestRestoreReadersFromFIFO (runsc/boot) streams a statefile through a FIFO 1-3 bytes at a time, waiting for the FIFO to drain (FIONREAD) before each write, and reads it back through the restore path. It fails with "statefile cannot be empty" with the old size check, and with "bad magic header" with the old header read. - TestRestoreReadersRejectEmptyRegularStateFile checks that an empty regular file is still rejected. - //pkg/state/statefile:statefile_test, //runsc/boot:boot_test (FIFO tests 30 runs) and //pkg/compressio:compressio_test pass, as do TestCheckpointRestore and TestCheckpointResume in //runsc/container:container_test on systrap. Assisted-by: Cortex Code Signed-off-by: Chris Koch <[email protected]>
hugelgupf
force-pushed
the
pr/restore-fifo-statefile
branch
from
November 20, 2026 17:38
eac6adb to
8b433ed
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow restoring from a FIFO at
<image-path>/checkpoint.img. Restore only rejects an empty state file if the file is a regular file, and the state file header is now read in full, so a pipe that returns the header in short reads no longer fails withbad magic header.Linux Fidelity
fs/stat.c:generic_fillattr()reportsi_size_read(inode), andfs/pipe.cnever setsi_size, so every pipe reportsst_size == 0. POSIX only definesst_sizefor regular files and symlinks.fs/pipe.c:pipe_read()returns as soon as it has copied any data once the pipe is empty, so a read can return less than asked for.Details
io.ReadFull; only the 8-byte magic header used a single read.io.ErrUnexpectedEOFinstead ofbad magic header.