qemu: open serial log with O_APPEND via chardev#209
Merged
sjmiller609 merged 1 commit intomainfrom May 8, 2026
Merged
Conversation
Use -chardev file,append=on for the serial console instead of -serial file:. The latter opens the path with plain O_WRONLY|O_CREAT, so QEMU writes at its internal fd offset. When a copytruncate-style log rotation truncates the file out from under it, the next write lands at the stale offset, leaving a sparse hole of NUL bytes from byte 0 onward. With append=on QEMU uses O_APPEND, so every write atomically seeks to EOF and post-truncate writes correctly resume at byte 0.
|
Firetiger deploy monitoring skipped This PR didn't match the auto-monitor filter configured on your GitHub connection:
Reason: PR modifies QEMU hypervisor configuration, not kernel API endpoints or Temporal workflows; unclear if this touches packages/api/cmd/api/ or packages/api/lib/temporal. To monitor this PR anyway, reply with |
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
Switch the QEMU serial console from
-serial file:<path>to a chardev withappend=on:-serial file:opens the path with plainO_WRONLY|O_CREAT, so QEMU writes at its internal fd offset. If the file is externally truncated (e.g. byrotateLogIfNeeded's copytruncate), the next write lands at the stale offset, creating a sparse hole of NUL bytes from byte 0 to that offset. Downstream log readers chunk those NULs and choke.append=onmakes QEMU passO_APPEND, so every write atomically seeks to EOF — post-truncate writes correctly resume at byte 0.This only addresses QEMU. Cloud Hypervisor's
serial.mode=Filedoes not expose an append flag and needs a separate fix (likely switching toSocket/Pipemode with hypeman owning the file fd).Test plan
go test ./lib/hypervisor/qemu/...passesTestBuildArgs_SerialLogto assert the new chardev argsrotateLogIfNeeded, verify the post-rotationapp.loghas no sparse NUL holeNote
Low Risk
Low risk: changes only QEMU CLI argument construction for serial logging and updates unit tests; main risk is QEMU arg compatibility/behavior differences across versions.
Overview
Switches QEMU serial logging from
-serial file:<path>to a-chardev file,...,append=onplus-serial chardev:serial0, ensuring writes useO_APPENDand don’t create sparse NUL holes after external log truncation/rotation.Updates
TestBuildArgs_SerialLogto assert the new-chardevandchardev:serial0arguments.Reviewed by Cursor Bugbot for commit d90aac8. Bugbot is set up for automated code reviews on this repo. Configure here.