提交 59a6fa6e 编写于 作者: P Peter Maydell 提交者: Blue Swirl

qemu-log: Abstract out "print usage message about valid log categories"

Abstract out the "print a human readable list of all the
valid log categories" functionality which is currently duplicated
in three separate places. (We leave the monitor.c help_cmd()
implementation as-is since it wants to send the message to
the monitor and add its own information.)
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: NAndreas Färber <afaerber@suse.de>
Signed-off-by: NBlue Swirl <blauwirbel@gmail.com>
上级 9a7e5424
......@@ -864,14 +864,10 @@ int main(int argc, char **argv)
qemu_set_log_filename(log_file);
if (log_mask) {
int mask;
const CPULogItem *item;
mask = cpu_str_to_log_mask(log_mask);
if (!mask) {
printf("Log items (comma separated):\n");
for (item = cpu_log_items; item->mask != 0; item++) {
printf("%-10s %s\n", item->name, item->help);
}
qemu_print_log_usage(stdout);
exit(1);
}
cpu_set_log(mask);
......
......@@ -1178,14 +1178,10 @@ void set_numa_modes(void)
void set_cpu_log(const char *optarg)
{
int mask;
const CPULogItem *item;
mask = cpu_str_to_log_mask(optarg);
if (!mask) {
printf("Log items (comma separated):\n");
for (item = cpu_log_items; item->mask != 0; item++) {
printf("%-10s %s\n", item->name, item->help);
}
qemu_print_log_usage(stdout);
exit(1);
}
cpu_set_log(mask);
......
......@@ -157,4 +157,9 @@ static inline void cpu_set_log(int log_flags)
void qemu_set_log_filename(const char *filename);
int cpu_str_to_log_mask(const char *str);
/* Print a usage message listing all the valid logging categories
* to the specified FILE*.
*/
void qemu_print_log_usage(FILE *f);
#endif
......@@ -3098,14 +3098,10 @@ static void handle_arg_help(const char *arg)
static void handle_arg_log(const char *arg)
{
int mask;
const CPULogItem *item;
mask = cpu_str_to_log_mask(arg);
if (!mask) {
printf("Log items (comma separated):\n");
for (item = cpu_log_items; item->mask != 0; item++) {
printf("%-10s %s\n", item->name, item->help);
}
qemu_print_log_usage(stdout);
exit(1);
}
cpu_set_log(mask);
......
......@@ -170,3 +170,12 @@ int cpu_str_to_log_mask(const char *str)
}
return mask;
}
void qemu_print_log_usage(FILE *f)
{
const CPULogItem *item;
fprintf(f, "Log items (comma separated):\n");
for (item = cpu_log_items; item->mask != 0; item++) {
fprintf(f, "%-10s %s\n", item->name, item->help);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册