fix(oci): a shared host directory is recognised by its filesystem, not its device number

This commit is contained in:
MacRimi
2026-10-09 21:00:33 +02:00
parent 9f09272889
commit c2936d4587
7 changed files with 358 additions and 5 deletions
+9 -1
View File
@@ -58,6 +58,14 @@ def running_pid(vmid):
return int(pid) if result.returncode == 0 and pid.isdigit() else None
def _host_directory_missing(vmid):
"""Whether the container mounts a directory of the host that is not
there. It is not mounted then: Proxmox would leave it locked."""
from oci_host_mounts import missing_sources
result = _run('pct', 'config', str(int(vmid)))
return result.returncode != 0 or bool(missing_sources(result.stdout.encode()))
@contextlib.contextmanager
def container_root(vmid, mount_stopped=True):
"""The root filesystem of the container as the host sees it, or None. A
@@ -67,7 +75,7 @@ def container_root(vmid, mount_stopped=True):
if pid:
yield Path(f'/proc/{pid}/root')
return
if not mount_stopped or _run('pct', 'mount', str(int(vmid))).returncode != 0:
if not mount_stopped or _host_directory_missing(vmid) or _run('pct', 'mount', str(int(vmid))).returncode != 0:
yield None
return
try: