zipl/src: Introduce verbosity levels of zipl session

Introduce verbosity levels of zipl session and verbosity classes of
messages. This is used by the next patches in the series to suppress
information not corresponding the default output of zipl tool that
could be confusing for user.

Add a new option "--debug" of zipl tool to set up verbosity level 2
(and higher) of zipl session.

Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Eduard Shishkin
2024-08-26 14:10:41 +02:00
committed by Jan Höppner
parent dc42460d82
commit a902fd9afe
4 changed files with 41 additions and 2 deletions

View File

@@ -66,4 +66,24 @@ extern int verbose;
extern int interactive;
extern int dry_run;
/* Verbosity levels/classes */
#define VERBOSITY_STANDARD 0
#define VERBOSITY_EXTENDED 1
#define VERBOSITY_DEBUG 2
/*
* Macro for messages with assigned verbosity classes
*
* NOTE: Verbosity levels/classes 3 and higher are "reserved". To implement
* them, make "--debug" zipl option accept arguments.
*/
#define pr_class(class_id, ...) \
do { \
if (verbose >= (class_id)) \
printf(__VA_ARGS__); \
} while (0)
#define pr_verbose(...) pr_class(VERBOSITY_EXTENDED, __VA_ARGS__)
#define pr_debug(...) pr_class(VERBOSITY_DEBUG, __VA_ARGS__)
#endif /* not ZIPL_H */

View File

@@ -351,6 +351,10 @@ interaction is possible.
.BR "\-V" " or " "\-\-verbose"
Provide more verbose output.
.TP
.B "\-\-debug"
Provide output debugging information.
.TP
.BR "\-a" " or " "\-\-add-files"
Copy all specified files to the bootmap file instead of just referencing them.

View File

@@ -60,6 +60,7 @@ static struct option options[] = {
{ "noninteractive", no_argument, NULL, 'n'},
{ "version", no_argument, NULL, 'v'},
{ "verbose", no_argument, NULL, 'V'},
{ "debug", no_argument, NULL, 0xb2},
{ "add-files", no_argument, NULL, 'a'},
{ "tape", required_argument, NULL, 'T'},
{ "dry-run", no_argument, NULL, '0'},
@@ -131,6 +132,16 @@ set_secure_ipl(char *keyword, int *is_secure)
return 0;
}
static void set_verbosity_level(struct command_line *cmdline, int level)
{
/*
* In case of multiple verbosity levels specified by user
* the highest one will take place
*/
if (cmdline->verbose < level)
cmdline->verbose = level;
}
static int
get_command_line(int argc, char* argv[], struct command_line* line)
{
@@ -278,7 +289,7 @@ get_command_line(int argc, char* argv[], struct command_line* line)
cmdline.version = 1;
break;
case 'V':
cmdline.verbose = 1;
set_verbosity_level(&cmdline, VERBOSITY_EXTENDED);
break;
case 'a':
cmdline.add_files = 1;
@@ -295,6 +306,9 @@ get_command_line(int argc, char* argv[], struct command_line* line)
case 0xb1:
cmdline.no_compress = 1;
break;
case 0xb2:
set_verbosity_level(&cmdline, VERBOSITY_DEBUG);
break;
case 1:
/* Non-option is interpreted as section name */
if (cmdline.section != NULL) {

View File

@@ -30,7 +30,7 @@
/* Flag deciding the level of verbosity */
int verbose = 0;
int verbose = VERBOSITY_STANDARD;
/* Flag deciding whether confirmation questions are asked */
int interactive = 1;
@@ -81,6 +81,7 @@ static const char* usage_text[] = {
"-m, --menu MENU Install multi-boot configuration MENU",
"-n, --noninteractive Answer all confirmation questions with 'yes'",
"-V, --verbose Provide more verbose output",
" --debug Provide output debugging information",
"-a, --add-files Add all referenced files to bootmap file",
" --dry-run Simulate run but don't modify IPL records",
"-S, --secure SWITCH Control the zIPL secure boot support.",