Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
Walkthrough
ChangesFilesystem safety and cleanup
Priority: ⬆️ High Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: High Possibly related issues
Merge Risk: ⚪ Minimal · up to
|
🔧 PR Test Plugin AvailableA test plugin has been generated for this PR that includes the modified files. Version: 📥 Installation Instructions:Install via Unraid Web UI:
Alternative: Direct Download
|
Summary
Prevent VM removal from destroying a containing ZFS share dataset, and close the directory handle before removing a VM-owned dataset.
Related to OS-1066.
Fixes #2792.
Why This Exists
Remove VM & Disks checks that the VM folder is empty after deleting its first vdisk. However,
zfs listresolves an ordinary directory to its containing dataset. Destroying that dataset can also erase other stopped VMs' disks.Live QA also found that
is_dir_empty()leaves a directory handle open. This makes ZFS report a VM-owned dataset as busy during deletion.Resolution
Permit
zfs destroyonly when the canonical directory path matches the dataset mountpoint. Usermdir()for ordinary directories. Close the emptiness-check handle infinallyon both return paths before the caller removes the directory or dataset.Reviewer Considerations
realpath()calls must never authorize destruction.Behavior Changes
Ordinary VM folders are removed without destroying their containing dataset. Actual dataset mountpoints remain eligible for
zfs destroy, after the caller closes its directory handle. Failed lookups stop before deletion. Nonempty folders remain intact.Implementation Summary
Helpers.php.Libvirt::is_dir_empty().Verification
php tests/helpers_rmdir_test.php— passed.php tests/libvirt_directory_test.php— passed.git diff --check— passed.Risk
The combined fix passed targeted native PHP/libvirt/ZFS validation. Browser-menu, HTTP-request, and
/mnt/usertranslation coverage remain outside this run. The PR remains in draft pending human review and formal QA approval.Live QAVM validation of the combined fix
Validated commit
567e326f9a6e9eafcf368a65704aeebd746cbe58through the published PR plugin2026.10.21.0841on Unraid7.4.0-beta.3.2. Both installed production files exactly matched the PR source hashes.Using native
Libvirt::domain_delete()and a real ZFS mirror on two fresh disposable disks:zfs destroyreturning zero. The handle leak is resolved.The test exited zero with
QAVM_ZFS_VALIDATION_PASS. The QA VM was restored and released; live read-back confirmed it was shut off with no data disks attached. No formal Linear QA approval is claimed.