@@ -13,18 +13,16 @@ static error_t list_parser(int, char *, struct argp_state *);
13
13
const struct argp list_usage = {
14
14
(const struct argp_option []){
15
15
{NULL , 0 , NULL , 0 , "Options:" , -1 },
16
- {"info" , 'i' , NULL , 0 , "List driver version information" , -1 },
17
16
{"device" , 'd' , "ID" , 0 , "Device UUID(s) or index(es) to list" , -1 },
18
- {"compute" , 'c' , NULL , 0 , "List compute components" , -1 },
19
- {"utility" , 'u' , NULL , 0 , "List utility components" , -1 },
20
- {"video" , 'v' , NULL , 0 , "List video components" , -1 },
21
- {"graphics" , 'g' , NULL , 0 , "List graphics components" , -1 },
22
- {"compat32" , 0x80 , NULL , 0 , "List 32bits components" , -1 },
17
+ {"libraries" , 'l' , NULL , 0 , "List driver libraries" , -1 },
18
+ {"binaries" , 'b' , NULL , 0 , "List driver binaries" , -1 },
19
+ {"ipcs" , 'i' , NULL , 0 , "List driver ipcs" , -1 },
20
+ {"compat32" , 0x80 , NULL , 0 , "Enable 32bits compatibility" , -1 },
23
21
{0 },
24
22
},
25
23
list_parser ,
26
24
NULL ,
27
- "Query the host driver and list the components required in order to configure a container with GPU support." ,
25
+ "Query the driver and list the components required in order to configure a container with GPU support." ,
28
26
NULL ,
29
27
NULL ,
30
28
NULL ,
@@ -37,32 +35,31 @@ list_parser(int key, char *arg, struct argp_state *state)
37
35
struct error err = {0 };
38
36
39
37
switch (key ) {
40
- case 'i' :
41
- ctx -> list_info = true;
42
- break ;
43
38
case 'd' :
44
39
if (strjoin (& err , & ctx -> devices , arg , "," ) < 0 )
45
40
goto fatal ;
46
41
break ;
47
- case 'c' :
48
- if (strjoin (& err , & ctx -> container_flags , "compute" , " " ) < 0 )
49
- goto fatal ;
42
+ case 'l' :
43
+ ctx -> list_libs = true;
50
44
break ;
51
- case 'u' :
52
- if (strjoin (& err , & ctx -> container_flags , "utility" , " " ) < 0 )
53
- goto fatal ;
45
+ case 'b' :
46
+ ctx -> list_bins = true;
54
47
break ;
55
- case 'v' :
56
- if (strjoin (& err , & ctx -> container_flags , "video" , " " ) < 0 )
57
- goto fatal ;
58
- break ;
59
- case 'g' :
60
- if (strjoin (& err , & ctx -> container_flags , "graphics" , " " ) < 0 )
61
- goto fatal ;
48
+ case 'i' :
49
+ ctx -> list_ipcs = true;
62
50
break ;
63
51
case 0x80 :
64
- if (strjoin (& err , & ctx -> container_flags , "compat32" , " " ) < 0 )
65
- goto fatal ;
52
+ ctx -> compat32 = true;
53
+ break ;
54
+ case ARGP_KEY_END :
55
+ if (state -> argc == 1 ) {
56
+ if ((ctx -> devices = xstrdup (& err , "all" )) == NULL )
57
+ goto fatal ;
58
+ ctx -> compat32 = true;
59
+ ctx -> list_libs = true;
60
+ ctx -> list_bins = true;
61
+ ctx -> list_ipcs = true;
62
+ }
66
63
break ;
67
64
default :
68
65
return (ARGP_ERR_UNKNOWN );
@@ -128,18 +125,12 @@ list_command(const struct context *ctx)
128
125
warnx ("permission error: %s" , err .msg );
129
126
goto fail ;
130
127
}
131
- if ((drv = nvc_driver_info_new (nvc , ctx -> driver_flags )) == NULL ||
132
- (dev = nvc_device_info_new (nvc , ctx -> device_flags )) == NULL ) {
128
+ if ((drv = nvc_driver_info_new (nvc , NULL )) == NULL ||
129
+ (dev = nvc_device_info_new (nvc , NULL )) == NULL ) {
133
130
warnx ("detection error: %s" , nvc_error (nvc ));
134
131
goto fail ;
135
132
}
136
133
137
- /* List the driver information. */
138
- if (ctx -> list_info ) {
139
- printf ("NVRM version: %s\n" , drv -> nvrm_version );
140
- printf ("CUDA version: %s\n" , drv -> cuda_version );
141
- }
142
-
143
134
/* List the visible GPU devices. */
144
135
if (dev -> ngpus > 0 ) {
145
136
gpus = alloca (dev -> ngpus * sizeof (* gpus ));
@@ -159,14 +150,22 @@ list_command(const struct context *ctx)
159
150
}
160
151
161
152
/* List the driver components */
162
- for (size_t i = 0 ; i < drv -> nbins ; ++ i )
163
- printf ("%s\n" , drv -> bins [i ]);
164
- for (size_t i = 0 ; i < drv -> nlibs ; ++ i )
165
- printf ("%s\n" , drv -> libs [i ]);
166
- for (size_t i = 0 ; i < drv -> nlibs32 ; ++ i )
167
- printf ("%s\n" , drv -> libs32 [i ]);
168
- for (size_t i = 0 ; i < drv -> nipcs ; ++ i )
169
- printf ("%s\n" , drv -> ipcs [i ]);
153
+ if (ctx -> list_bins ) {
154
+ for (size_t i = 0 ; i < drv -> nbins ; ++ i )
155
+ printf ("%s\n" , drv -> bins [i ]);
156
+ }
157
+ if (ctx -> list_libs ) {
158
+ for (size_t i = 0 ; i < drv -> nlibs ; ++ i )
159
+ printf ("%s\n" , drv -> libs [i ]);
160
+ if (ctx -> compat32 ) {
161
+ for (size_t i = 0 ; i < drv -> nlibs32 ; ++ i )
162
+ printf ("%s\n" , drv -> libs32 [i ]);
163
+ }
164
+ }
165
+ if (ctx -> list_ipcs ) {
166
+ for (size_t i = 0 ; i < drv -> nipcs ; ++ i )
167
+ printf ("%s\n" , drv -> ipcs [i ]);
168
+ }
170
169
171
170
if (run_as_root && perm_set_capabilities (& err , CAP_EFFECTIVE , effective_caps [CAPS_SHUTDOWN ], effective_caps_size (CAPS_SHUTDOWN )) < 0 ) {
172
171
warnx ("permission error: %s" , err .msg );
0 commit comments