Skip to content

Conversation

@ValentaTomas
Copy link
Member

@ValentaTomas ValentaTomas commented Dec 10, 2025

Note

Exports VM memory by reading Firecracker process memory using memory mappings, replacing tmp memfile snapshots and refactoring UFFD/diff pipeline with new API endpoints.

  • Memory export/diff pipeline:
    • Read FC process memory directly into block.Cache via process_vm_readv using new uffd/memory.Mapping and block.Range utilities; add IOV_MAX handling and extensive tests.
    • Replace memfile-based snapshotting: fc.Process.CreateSnapshot no longer takes memfilePath; Sandbox.Pause builds memfile diff from FC process memory; MemoryBackend.DiffMetadata added; NoopMemory derives dirty/empty via FC.
    • UFFD refactor: expose DiffMetadata; adjust fd helpers and copy API; remove unregister usage.
  • FC client/API:
    • Add GET /memory and GET /memory/mappings with generated models (MemoryResponse, MemoryMappingsResponse, GuestMemoryRegionMapping) and client methods; fc.Process exposes MemoryInfo/ExportMemory.
  • Block cache/build:
    • block.Cache supports zero-size caches and exporting diffs when unmapped; add NewCacheFromProcessMemory, address helpers.
    • Introduce GenerateDiffCachePath; localDiff wraps an existing block.Cache; storage diff uses generator.
  • Versioning/deps:
    • Bump kernel to vmlinux-6.1.158, FC to v1.12.1_717921c; update default FC versions; add github.com/tklauser/go-sysconf.
  • Swagger/models:
    • Update Firecracker Swagger (v1.10.1); regenerate clients/models to include new endpoints and fields.

Written by Cursor Bugbot for commit 518e4ee. This will update automatically on new commits. Configure here.

@ValentaTomas
Copy link
Member Author

@codex review

@ValentaTomas
Copy link
Member Author

@cursor review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
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 pull request implements a major refactoring of Firecracker memory handling during snapshot creation, eliminating the temporary memfile approach in favor of direct memory copying via process_vm_readv syscall. The changes support an upgrade to Firecracker v1.12.2.

Key Changes:

  • Replace temporary memfile-based snapshot creation with direct memory export via process_vm_readv
  • Update Firecracker API to v1.12.2 with new memory-related endpoints (/memory and /memory/mappings)
  • Refactor memory backend interface from Disable() to Dirty() to better reflect the new workflow
  • Remove temporary memfile management infrastructure

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/shared/pkg/storage/temporary_memfile.go Removed - temporary memfile infrastructure no longer needed
packages/shared/pkg/fc/firecracker.yml Updated Firecracker API version from 1.7.0-dev to 1.12.2
packages/shared/pkg/fc/models/snapshot_create_params.go Made MemFilePath optional (no longer required)
packages/shared/pkg/fc/models/snapshot_load_params.go Added NetworkOverrides field for network interface restoration
packages/shared/pkg/fc/models/network_override.go New model for network device overrides during snapshot load
packages/shared/pkg/fc/models/memory_response.go New model for memory info (resident/empty pages)
packages/shared/pkg/fc/models/memory_mappings_response.go New model for memory region mappings
packages/shared/pkg/fc/models/guest_memory_region_mapping.go New model for individual memory region details
packages/shared/pkg/fc/models/cpu_config.go Changed from string type to structured object with CPU configuration fields
packages/shared/pkg/fc/models/full_vm_configuration.go Added CPUConfig and Entropy device support
packages/shared/pkg/fc/client/operations/operations_client.go Added GetMemory and GetMemoryMappings client methods
packages/shared/pkg/fc/client/operations/get_memory_*.go New client implementation for memory API endpoints
packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd.go Refactored parameter order in handleMissing and removed Unregister method
packages/orchestrator/internal/sandbox/uffd/userfaultfd/fd.go Renamed uffdFd to Fd, removed unregister method, adjusted parameter order in copy
packages/orchestrator/internal/sandbox/uffd/userfaultfd/fd_helpers_test.go New test helpers extracted from production code
packages/orchestrator/internal/sandbox/uffd/memory/region.go Added helper methods for region offset calculations and iteration
packages/orchestrator/internal/sandbox/uffd/memory/mapping.go Added reverse mapping functions and FC model integration
packages/orchestrator/internal/sandbox/uffd/memory/mapping_*_test.go Comprehensive test coverage for new mapping functionality
packages/orchestrator/internal/sandbox/uffd/uffd.go Changed interface from Disable to Dirty method
packages/orchestrator/internal/sandbox/uffd/noop.go Updated to match new Dirty interface
packages/orchestrator/internal/sandbox/uffd/memory_backend.go Changed interface from Disable to Dirty
packages/orchestrator/internal/sandbox/sandbox.go Integrated direct memory export, removed temporary memfile handling
packages/orchestrator/internal/sandbox/fc/process.go Removed memfilePath parameter from CreateSnapshot
packages/orchestrator/internal/sandbox/fc/memory.go New implementation for direct memory export via process_vm_readv
packages/orchestrator/internal/sandbox/fc/client.go Added memory mapping and info API client methods
packages/orchestrator/internal/sandbox/diffcreator.go Removed MemoryDiffCreator class
packages/orchestrator/internal/sandbox/build/diff.go Added GenerateDiffCachePath helper function
packages/orchestrator/internal/sandbox/build/local_diff.go Refactored to use Cache directly, added NewLocalDiffFromCache
packages/orchestrator/internal/sandbox/build/storage_diff.go Updated to use centralized cache path generation
packages/orchestrator/internal/sandbox/block/tracker.go Changed BitSet() to return internal reference without cloning (concurrency implications)
packages/orchestrator/internal/sandbox/block/range.go New range abstraction for memory/block operations
packages/orchestrator/internal/sandbox/block/cache.go Added helper methods for address access and metadata
packages/orchestrator/go.mod Moved tklauser/go-sysconf from indirect to direct dependency
packages/api/internal/cfg/model.go Updated default Firecracker version to v1.12.2_g1133bd6cd

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ValentaTomas ValentaTomas merged commit ed5827f into main Dec 22, 2025
28 checks passed
@ValentaTomas ValentaTomas deleted the process-read branch December 22, 2025 16:24
@ValentaTomas ValentaTomas removed the request for review from dobrac December 22, 2025 16:25
@ValentaTomas ValentaTomas assigned dobrac and jakubno and unassigned djeebus and dobrac Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants