Add support for freezing filesystems before taking snapshots - #1022
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The fsfreeze executable path is not provisioned, cancellation handling is inconsistent, and thaw failures can leave filesystems frozen without diagnosis.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds VM filesystem quiescing around LXD snapshots, improves execution-output synchronization, and hardens readiness signaling.
Changes:
- Adds filesystem freeze/thaw implementation and tests.
- Integrates freezing into snapshot creation and workshopctl.
- Safely handles execution output and D-Bus readiness signals.
File summaries
| File | Description |
|---|---|
cmd/workshopctl/main.go |
Adds fsfreeze multicall entry point. |
internal/dirs/dirs.go |
Defines the guest fsfreeze path. |
internal/fsfreeze/export_test.go |
Exposes test hooks. |
internal/fsfreeze/fsfreeze.go |
Implements mount discovery and freeze/thaw behavior. |
internal/fsfreeze/fsfreeze_test.go |
Tests filesystem handling and lifecycle behavior. |
internal/fsfreeze/sys/generate.sh |
Generates ioctl constants. |
internal/fsfreeze/sys/syscall_linux.go |
Wraps freeze/thaw ioctls. |
internal/fsfreeze/sys/sysnum_linux.go |
Defines cgo generation input. |
internal/fsfreeze/sys/zsysnum_linux.go |
Provides generated architecture constants. |
internal/waitready/waitready.go |
Filters D-Bus readiness signals safely. |
internal/workshop/lxd/lxd_backend_project.go |
Avoids unsafe stderr reads. |
internal/workshop/lxd/lxd_backend_snapshots.go |
Freezes running VMs during snapshot copying. |
internal/workshop/lxd/tests/helper/helper.go |
Supports fsfreeze in integration helpers. |
Review details
Files not reviewed (1)
- internal/fsfreeze/sys/zsysnum_linux.go: Generated file
Suppressed comments (1)
internal/fsfreeze/fsfreeze.go:215
- Rollback silently ignores
FITHAWfailures after a later filesystem fails to freeze. In that case an earlier filesystem can remain frozen indefinitely while the process reports only the later freeze error. Collect rollback thaw errors and return them together with the triggering error, as the normalthawpath does.
rev.Add(func() {
for _, f := range slices.Backward(frozen) {
_ = fsThaw(f)
f.Close()
}
- Files reviewed: 12/13 changed files
- Comments generated: 3
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
8cdb637 to
ea7f340
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Deferred rollback can leave filesystems frozen, and four malformed reusable-workflow paths prevent CI workflows from loading.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Files not reviewed (1)
- internal/fsfreeze/sys/zsysnum_linux.go: Generated file
Suppressed comments (1)
.github/workflows/automatic-tests.yaml:35
- This local reusable-workflow reference must begin with
./; the$/.github/...path is invalid and prevents the automatic-tests workflow from loading the unit-test job.
uses: $/.github/workflows/unit-tests.yaml
- Files reviewed: 18/19 changed files
- Comments generated: 4
- Review effort level: Balanced
ea7f340 to
7750e46
Compare
This looks like a longstanding oversight; if checkPartialSnapshot returns an error it means GetInstance failed or the snapshot is complete. In the first case, deleting the snapshot will probably also fail. In the second, the snapshot might already be in use. On the other hand, returning nil means the snapshot doesn't exist (and it can't be recreated while we hold the lock) or it was partially complete; in either case it's OK (but not necessary) to delete it.
7750e46 to
c229bb6
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The implementation has coherent freeze/thaw cleanup, focused unit coverage, and no unresolved correctness issues.
Review details
Files not reviewed (1)
- internal/fsfreeze/sys/zsysnum_linux.go: Generated file
- Files reviewed: 11/12 changed files
- Comments generated: 0 new
- Review effort level: Balanced
e1e3f37 to
2a945e8
Compare
Description
This doesn't really do much at the moment, but is needed in order to take consistent snapshots of VM filesystems.
Also fixes a potential race when running
findmnton/project;WaitExecutiononly waits onDataDonewhen theexecsucceeded (but potentially had a nonzero exit status). With any error other thanErrExecthere might not be synchronization between LXD writing toerrbufand us reading from it.Self-review quick check
Docs
Procedure:
Content:
tutorial/andhow-to/sections).docs/.coverage.yamlupdated, coverage tags added (.. artefact).Or: