fix qcow2 backing and container status checks#525
Conversation
5e9081b to
2636c09
Compare
|
|
📝 WalkthroughWalkthroughTwo independent fixes address backing-file handling and container state consistency. QCOW2 backing chains now validate candidate files for QCOW2 magic bytes and stop at raw backing files instead of failing to parse them. Container status loading explicitly refreshes stale persisted state before returning status. ChangesQCOW2 Backing-Chain Magic Validation
Container Status Refresh
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/guest/src/container/start.rs (1)
304-310: ⚡ Quick winTest uses
Stoppedstatus but PR describesCreatedstate issue.The PR summary explains the fix prevents "stale
Createdstate from being treated as a failed init," but this test creates a State withContainerStatus::Stopped. Consider adding a second test case withContainerStatus::Createdto cover the exact regression scenario described in the PR.📋 Additional test case for Created status
#[test] fn load_container_status_refreshes_stale_created_status() { let dir = tempfile::TempDir::new().expect("create temp dir"); let state = State::new( "test-container-created", ContainerStatus::Created, Some(i32::try_from(std::process::id()).expect("current pid fits in i32")), dir.path().to_path_buf(), ); state.save(dir.path()).expect("save libcontainer state"); let status = load_container_status(dir.path()).expect("load container status"); assert_eq!(status, ContainerStatus::Running); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/guest/src/container/start.rs` around lines 304 - 310, Add a new test that mirrors the existing Stopped-case but uses ContainerStatus::Created to reproduce the regression described; create a temp dir, construct a State via State::new with ContainerStatus::Created (and the current pid), call state.save(...), then call load_container_status(dir.path()) and assert the returned status equals ContainerStatus::Running. Name the test to reflect behavior (e.g., load_container_status_refreshes_stale_created_status) and reference State::new, ContainerStatus::Created, state.save, and load_container_status when locating where to add it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/guest/src/container/start.rs`:
- Around line 304-310: Add a new test that mirrors the existing Stopped-case but
uses ContainerStatus::Created to reproduce the regression described; create a
temp dir, construct a State via State::new with ContainerStatus::Created (and
the current pid), call state.save(...), then call
load_container_status(dir.path()) and assert the returned status equals
ContainerStatus::Running. Name the test to reflect behavior (e.g.,
load_container_status_refreshes_stale_created_status) and reference State::new,
ContainerStatus::Created, state.save, and load_container_status when locating
where to add it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 36bd0b07-6747-4c07-98ee-7c34529071bf
📒 Files selected for processing (2)
src/boxlite/src/disk/qcow2.rssrc/guest/src/container/start.rs
Summary
Root Cause
Raw backing files are valid terminal nodes for qcow2 COW children, but the backing-chain walker tried to parse every backing file as qcow2. Separately, the container init health check read the persisted libcontainer state immediately after start without refreshing it from the process state, which could treat a stale
Createdstate as a failed init.Validation
make fmtgit diff --checkenv BOXLITE_DEPS_STUB=1 make test:unit:rusttest:unit:rustran the full unit suite with native dependency stubs. The boxlite crate had one environment failure unrelated to this change:jailer::tests::test_jailer_full_flow_with_real_tempdirfailed because AppArmor disallows bwrap unprivileged user namespaces on this host. All other boxlite tests passed, including the new qcow2 tests;boxlite-sharedpassed 36/36.Summary by CodeRabbit
Release Notes