@@ -937,12 +937,8 @@ nvc_mig_config_global_caps_mount(struct nvc_context *ctx, const struct nvc_conta
937937 if (ns_enter (& ctx -> err , cnt -> mnt_ns , CLONE_NEWNS ) < 0 )
938938 return (-1 );
939939
940- // Construct the path to the global MIG 'config' file in '/proc'.
941- if (path_join (& ctx -> err , config , NV_MIG_CAPS_PATH , NV_MIG_CONFIG_FILE ) < 0 )
942- goto fail ;
943-
944- // Mount the 'config' file into the container.
945- if ((proc_mnt = mount_procfs_mig (& ctx -> err , ctx -> cfg .root , cnt , config )) == NULL )
940+ // Mount the entire 'nvidia-capabilities' folder from '/proc' into the container.
941+ if ((proc_mnt = mount_procfs_mig (& ctx -> err , ctx -> cfg .root , cnt , NV_PROC_DRIVER_CAPS )) == NULL )
946942 goto fail ;
947943
948944 // Check if NV_CAPS_MODULE_NAME exists as a major device,
@@ -951,6 +947,9 @@ nvc_mig_config_global_caps_mount(struct nvc_context *ctx, const struct nvc_conta
951947 if ((dev_mnt = mount_directory (& ctx -> err , ctx -> cfg .root , cnt , NV_CAPS_DEVICE_DIR )) == NULL )
952948 goto fail ;
953949
950+ if (path_join (& ctx -> err , config , NV_MIG_CAPS_PATH , NV_MIG_CONFIG_FILE ) < 0 )
951+ goto fail ;
952+
954953 if (nvc_nvcaps_device_from_proc_path (ctx , config , & node ) < 0 )
955954 goto fail ;
956955
@@ -1000,12 +999,8 @@ nvc_mig_monitor_global_caps_mount(struct nvc_context *ctx, const struct nvc_cont
1000999 if (ns_enter (& ctx -> err , cnt -> mnt_ns , CLONE_NEWNS ) < 0 )
10011000 return (-1 );
10021001
1003- // Construct the path to the global MIG 'monitor' file in '/proc'.
1004- if (path_join (& ctx -> err , monitor , NV_MIG_CAPS_PATH , NV_MIG_MONITOR_FILE ) < 0 )
1005- goto fail ;
1006-
1007- // Mount the 'monitor' file into the container.
1008- if ((proc_mnt = mount_procfs_mig (& ctx -> err , ctx -> cfg .root , cnt , monitor )) == NULL )
1002+ // Mount the entire 'nvidia-capabilities' folder from '/proc' into the container.
1003+ if ((proc_mnt = mount_procfs_mig (& ctx -> err , ctx -> cfg .root , cnt , NV_PROC_DRIVER_CAPS )) == NULL )
10091004 goto fail ;
10101005
10111006 // Check if NV_CAPS_MODULE_NAME exists as a major device,
@@ -1014,6 +1009,9 @@ nvc_mig_monitor_global_caps_mount(struct nvc_context *ctx, const struct nvc_cont
10141009 if ((dev_mnt = mount_directory (& ctx -> err , ctx -> cfg .root , cnt , NV_CAPS_DEVICE_DIR )) == NULL )
10151010 goto fail ;
10161011
1012+ if (path_join (& ctx -> err , monitor , NV_MIG_CAPS_PATH , NV_MIG_MONITOR_FILE ) < 0 )
1013+ goto fail ;
1014+
10171015 if (nvc_nvcaps_device_from_proc_path (ctx , monitor , & node ) < 0 )
10181016 goto fail ;
10191017
@@ -1047,7 +1045,6 @@ int
10471045nvc_device_mig_caps_mount (struct nvc_context * ctx , const struct nvc_container * cnt , const struct nvc_device * dev )
10481046{
10491047 // Initialize local variables.
1050- char * proc_mnt = NULL ;
10511048 int nvcaps_major = -1 ;
10521049 int rv = -1 ;
10531050
@@ -1061,10 +1058,6 @@ nvc_device_mig_caps_mount(struct nvc_context *ctx, const struct nvc_container *c
10611058 if (ns_enter (& ctx -> err , cnt -> mnt_ns , CLONE_NEWNS ) < 0 )
10621059 return (-1 );
10631060
1064- // Mount the path to the mig MIG capabilities directory for this device in '/proc'.
1065- if ((proc_mnt = mount_procfs_mig (& ctx -> err , ctx -> cfg .root , cnt , dev -> mig_caps_path )) == NULL )
1066- goto fail ;
1067-
10681061 // Check if NV_CAPS_MODULE_NAME exists as a major device, and if so,
10691062 // mount in the appropriate /dev based capabilities as devices.
10701063 if ((nvcaps_major = nvidia_get_chardev_major (NV_CAPS_MODULE_NAME )) != -1 ) {
@@ -1078,17 +1071,10 @@ nvc_device_mig_caps_mount(struct nvc_context *ctx, const struct nvc_container *c
10781071
10791072 fail :
10801073 if (rv < 0 ) {
1081- // If we failed above for any reason, unmount the 'access' file
1082- // we mounted and exit the mount namespace.
1083- unmount (proc_mnt );
10841074 assert_func (ns_enter_at (NULL , ctx -> mnt_ns , CLONE_NEWNS ));
10851075 } else {
1086- // Otherwise, just exit the mount namespace.
10871076 rv = ns_enter_at (& ctx -> err , ctx -> mnt_ns , CLONE_NEWNS );
10881077 }
10891078
1090- // In all cases, free the string associated with the mounted 'access'
1091- // file and return.
1092- free (proc_mnt );
10931079 return (rv );
10941080}
0 commit comments