VM Manager: "Remove VM & Disks" destroys the whole share dataset (e.g. cache/domains) when the VM folder is a plain directory on ZFS
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Read my_rmdir() in emhttp/plugins/dynamix/include/Helpers.php around lines 466–486, then trace its caller domain_delete() in emhttp/plugins/dynamix.vm.manager/include/libvirt.php around lines 1766–1786. Compare the ZFS handling with the my_mkdir() fix in #1968. Done means deleting a VM in a plain directory preserves the containing share dataset, while deleting an empty dataset mountpoint still removes that dataset; an open linked pull request (#2793) already addresses this issue.
索引モデルが issue の本文から書いたものです。
説明
Summary
VMs → Remove VM & Disks destroys the whole share dataset (e.g. cache/domains) when the VM's folder on a ZFS pool is a plain directory rather than its own dataset. Every other file in that share's dataset is destroyed with it, including the vdisks of other VMs that are stopped.
my_rmdir() runs zfs list -H -o name <dir>, which for a plain directory returns the dataset that contains it (the share), and then runs zfs destroy on that name.
Where
domain_delete()deletes the first vdisk, then callsmy_rmdir()on the VM's folder once it is empty: libvirt.php#L1766-L1786my_rmdir(), ZFS case: Helpers.php#L466-L486
case "zfs":
$zfsdataset = trim(shell_exec("zfs list -H -o name ".escapeshellarg($dirname))) ;
$cmdstr = "zfs destroy \"$zfsdataset\" 2>&1 ";
The same assumption was fixed in my_mkdir() in #1968 ("Fix for dir not a dataset"), which now falls back to mkdir when the parent is not a dataset. my_rmdir() has no such check.
What happened (Unraid 7.1.1)
- The pool
cacheis a ZFS mirror, and the sharedomains(primary storagecache, cache only) is the datasetcache/domains. - The VM
Ubuntu-20.04-researchwas created in 2024. Its folder/mnt/cache/domains/Ubuntu-20.04-researchwas a plain directory, not a dataset, and held one vdisk. It was the only VM. - I used Remove VM & Disks (the same
domain-deleterequest with the VM's UUID thatvmmanager.jssends). The response was{"success":true}. - Result:
cache/domainsno longer existed inzfs list, and/mnt/user/domainswas gone. The share'sdomains.cfgwas left behind.
The VM's log shows the destroy of the share's dataset:
delete empty zfs /mnt/user/domains/Ubuntu-20.04-research 0
dataset cache/domains
Command zfs destroy 'cache/domains' 2>&1
Output end
Nothing else was lost here, because this was the only VM in the share. With other stopped VMs in the same dataset, zfs destroy would succeed as well and take their vdisks with it. Only a busy dataset (a running VM) makes it fail.
The lookup behaviour is easy to confirm on any ZFS pool:
# zfs list -H -o name /mnt/cache/appdata/Jellyfin # a plain directory inside the appdata dataset
cache/appdata
Steps to reproduce
- On a ZFS pool, make sure the share
domainsis a dataset, e.g.cache/domains. - Create a plain directory in it (
mkdir /mnt/cache/domains/test), put a small vdisk in it, and define a VM that uses only that vdisk. VM folders created before a pool became ZFS, or by hand, are in this state. - Optionally add a second, stopped VM with its vdisk in another folder of the same share.
- VMs → the test VM → Remove VM & Disks.
zfs list:cache/domainsis gone, and so is the second VM's vdisk.
Expected
Destroy a dataset only if the directory itself is a dataset's mountpoint. Otherwise rmdir() the empty directory. For example:
case "zfs":
[$zfsdataset, $mountpoint] = array_pad(explode("\t", trim(shell_exec("zfs list -H -o name,mountpoint ".escapeshellarg($dirname)))), 2, '');
if ($zfsdataset && realpath($mountpoint) === realpath($dirname)) {
exec("zfs destroy ".escapeshellarg($zfsdataset)." 2>&1", $zfsoutput, $rtncode);
} else {
$rtncode = rmdir($dirname) ? 0 : 1; // a plain directory: never touch the parent dataset
}
Environment
- Unraid 7.1.1 (observed). The code is unchanged on
masterat 26eb1b5. - Cache pool: a 2-device ZFS mirror.
- 主要言語
- PHP
- スター
- 266
- フォーク
- 116
- 平均マージ
- 1日 5時間
- マージ済み PR(30日)
- 4
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
unraid/webgui のほかの issue
-
CPU core labels missing for Low-Power E-cores on hybrid Intel CPUs (Arrow Lake-H) — get_intel_core_types() ignores /sys/devices/cpu_lowpower対応中かも @dgongut が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
unraid/webgui#2785 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
rsyslog_config: "Mirror syslog to flash" rule is appended again on every Apply — each line written to the boot device N times対応中かも @junkerderprovinz が 38 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
メンテナーはふだん 1 日以内に返信
-
Notification e-mails are sent without Date and Message-ID headers対応中かも @nofuturekid が 56 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
unraid/webgui#2781 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Static asset caching misses the Connect plugin's hashed bundle: ~144 JS chunks (8.5 MB) revalidate on every page load対応中かも @davidcoulson が 54 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
area: tests area: user refactoring
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
nplhse/collaborative-ivena-statistics#1845 ·
メンテナーはふだん 1 日以内に返信
-
[Sync EN] filesystem: document the ValueError of fgets(), file_get_contents(), and touch() (#6167)オープンsync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
sync-en
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 2 日以内に返信
-
Перевод устарел
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
Documentation Feature: Events / Calendar
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信