Virtual machine Management Terminal User Interface
リビジョン | f7c11dcbc54747e375aab66654d9c101669c6996 (tree) |
---|---|
日時 | 2023-04-03 22:53:05 |
作者 | Koine Yuusuke(koinec) <koinec@user...> |
コミッター | Koine Yuusuke(koinec) |
Implemented exec. serial console with external terminal.
@@ -29,6 +29,70 @@ | ||
29 | 29 | #include "vmtui.h" |
30 | 30 | |
31 | 31 | /* ===========================================================================*/ |
32 | +void | |
33 | + LocalExec_Error( | |
34 | + char *pstr_msg, | |
35 | + char *pstr_argv[], | |
36 | + int i_argc, | |
37 | + int i_hvisor, | |
38 | + int i_guest, | |
39 | + int i_err ) | |
40 | +{ | |
41 | + int i_len; | |
42 | + int i_remain; | |
43 | + int i_cnt; | |
44 | + char str_buffer[512]; | |
45 | + char *pstr_now; | |
46 | + char *pstr_temp = NULL; | |
47 | + | |
48 | + memset( str_buffer, 0x00, sizeof( str_buffer ) ); | |
49 | + | |
50 | + pstr_now = str_buffer; | |
51 | + i_remain = sizeof( str_buffer ); | |
52 | + | |
53 | + for( i_cnt = 0; i_cnt < i_argc; i_cnt++ ) { | |
54 | + i_len = strnlen( pstr_argv[i_cnt], sizeof( str_buffer ) ); | |
55 | + | |
56 | + if( (i_cnt + 1) == i_argc ) { | |
57 | + pstr_temp = pstr_argv[i_cnt]; | |
58 | + while(('\0' != *pstr_temp) && (' ' != *pstr_temp)) | |
59 | + { pstr_temp++; } | |
60 | + | |
61 | + if( '\0' != *pstr_temp ) { | |
62 | + *pstr_now++ = '\''; | |
63 | + i_remain--; | |
64 | + | |
65 | + *pstr_now = '\0'; | |
66 | + } | |
67 | + } | |
68 | + | |
69 | + strncat( pstr_now, pstr_argv[i_cnt], i_remain ); | |
70 | + i_remain -= i_len; | |
71 | + pstr_now += i_len; | |
72 | + | |
73 | + if( (i_cnt + 1) < i_argc ) { | |
74 | + *pstr_now++ = ' '; | |
75 | + i_remain--; | |
76 | + | |
77 | + *pstr_now = '\0'; | |
78 | + } | |
79 | + else { | |
80 | + if( '\0' != *pstr_temp ) { | |
81 | + *pstr_now++ = '\''; | |
82 | + i_remain--; | |
83 | + | |
84 | + *pstr_now = '\0'; | |
85 | + } | |
86 | + } | |
87 | + } | |
88 | + | |
89 | + ErrInfo_Error( pstr_msg, i_hvisor, i_guest, REQUEST_ID_NONE, | |
90 | + errno, i_err, 0x00, str_buffer ); | |
91 | + | |
92 | + return; | |
93 | +} | |
94 | + | |
95 | +/* ===========================================================================*/ | |
32 | 96 | int |
33 | 97 | LocalExec_ExecBackgroundCommand( |
34 | 98 | char *pstr_argv[] ) |
@@ -256,10 +320,9 @@ int | ||
256 | 320 | i_remain -= 4; |
257 | 321 | pstr_now += 4; |
258 | 322 | |
259 | - // XXX sudo option | |
260 | - /* | |
261 | - if( 0 < gt_openssh.option.i_len ) { | |
262 | - strncpy( str_option, gt_openssh.option.str_option, VMTUI_CMDINFO_MAXLEN_OPTION ); | |
323 | + // sudo option --- | |
324 | + if( 0 < p_hvisor->sudo.option.i_len ) { | |
325 | + strncpy( str_option, p_hvisor->sudo.option.str_option, VMTUI_CMDINFO_MAXLEN_OPTION ); | |
263 | 326 | |
264 | 327 | pstr_next = str_option; |
265 | 328 | while( NULL != (pstr_val = strsep( &pstr_next, " " ))) { |
@@ -272,7 +335,6 @@ int | ||
272 | 335 | }while( '\0' != *pstr_val++ ); |
273 | 336 | } |
274 | 337 | } |
275 | - */ | |
276 | 338 | } |
277 | 339 | |
278 | 340 | strncpy( pstr_now, VMBHYVE_DEFAULT_PATH, VMBHYVE_DEFAULT_PATH_LEN ); |
@@ -298,16 +360,13 @@ int | ||
298 | 360 | |
299 | 361 | pstr_argv[i_argc] = NULL; |
300 | 362 | |
301 | -ErrInfo_DebugMsg( "================================================" ); | |
302 | - | |
303 | - { | |
304 | - int i_cnt; | |
305 | - for( i_cnt = 0; i_cnt < i_argc; i_cnt++ ) { | |
306 | - ErrInfo_DebugMsg( pstr_argv[i_cnt] ); | |
307 | - } | |
308 | - } | |
309 | - | |
363 | + // Exec. | |
310 | 364 | i_err = LocalExec_ExecBackgroundCommand( pstr_argv ); |
365 | + if( 0x00 != i_err ) { | |
366 | + LocalExec_Error( | |
367 | + "Can't exec external serial-console.", | |
368 | + pstr_argv, i_argc, i_hvisor, i_guest, i_err ); | |
369 | + } | |
311 | 370 | |
312 | 371 | return 0x00; |
313 | 372 | } |
@@ -75,7 +75,7 @@ int | ||
75 | 75 | int i_hvisor, int i_guest, int i_option ) |
76 | 76 | { |
77 | 77 | LocalExec_ExecSerialTerminal_External( i_guest, 0x00 ); |
78 | - ErrInfo_DebugMsg( "Serial Console" ); | |
78 | + | |
79 | 79 | return 0x00; |
80 | 80 | } |
81 | 81 |