From fcadde057ead615b3d65084fc6f0be9f4b6e95e2 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 20 Oct 2022 15:00:10 -0400 Subject: [PATCH] Include /proc in chroot mounts --- api-daemon/pvcapid/vmbuilder.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/api-daemon/pvcapid/vmbuilder.py b/api-daemon/pvcapid/vmbuilder.py index 88bc163d..8d599030 100755 --- a/api-daemon/pvcapid/vmbuilder.py +++ b/api-daemon/pvcapid/vmbuilder.py @@ -558,6 +558,15 @@ def create_vm( f"Failed to mount sysfs onto {temp_dir}/sys for chroot: {stderr}" ) + # Bind mount /proc to the chroot location /proc + retcode, stdout, stderr = pvc_common.run_os_command( + f"mount --bind --options rw /proc {temp_dir}/proc" + ) + if retcode: + raise ProvisioningError( + f"Failed to mount procfs onto {temp_dir}/proc for chroot: {stderr}" + ) + print("Chroot environment prepared successfully") def general_cleanup(): @@ -576,6 +585,10 @@ def create_vm( retcode, stdout, stderr = pvc_common.run_os_command( f"umount {temp_dir}/sys" ) + # Unmount bind-mounted procfs on the chroot + retcode, stdout, stderr = pvc_common.run_os_command( + f"umount {temp_dir}/proc" + ) # Unmount bind-mounted tmpfs on the chroot retcode, stdout, stderr = pvc_common.run_os_command( f"umount {temp_dir}/tmp"