| 1 | #include <ndjson.h> |
| 2 | |
| 3 | #include "internal.h" |
| 4 | |
| 5 | static bool cmdline_test_exit_flag = false; |
| 6 | CMDLINE_DECLARE_VAR( |
| 7 | cmdline_test_exit, cmdline_test_exit_flag, |
| 8 | .desc = "Exit QEMU immediately after command-line parsing for unit testing" , |
| 9 | .flags = CMDLINE_ENTRY_HIDDEN); |
| 10 | |
| 11 | void cmdline_debug_hook(void) { |
| 12 | #ifdef DEBUG_CMDLINE |
| 13 | size_t static_count = |
| 14 | (size_t) (__ekernel_cmdline_entries - __skernel_cmdline_entries); |
| 15 | size_t schema_count = |
| 16 | (size_t) (__ekernel_cmdline_schemas - __skernel_cmdline_schemas); |
| 17 | |
| 18 | log_msg(LOG_INFO, "%zu static entries" , static_count); |
| 19 | log_msg(LOG_INFO, "%zu schema namespaces" , schema_count); |
| 20 | |
| 21 | for (struct cmdline_schema *s = __skernel_cmdline_schemas; |
| 22 | s < __ekernel_cmdline_schemas; s++) { |
| 23 | log_msg(LOG_INFO, "Schema [%s]: %zu properties (hint: %s)" , s->prefix, |
| 24 | s->prop_count, s->path_hint ? s->path_hint : "<path>" ); |
| 25 | for (size_t i = 0; i < s->prop_count; i++) { |
| 26 | const struct cmdline_schema_prop *p = &s->props[i]; |
| 27 | log_msg(LOG_INFO, " prop: %s (offset: %zu, type: %s)" , p->name, |
| 28 | p->offset, type_enum_str(p->c_type)); |
| 29 | } |
| 30 | } |
| 31 | #endif |
| 32 | |
| 33 | if (cmdline_test_exit_flag) { |
| 34 | log_msg(LOG_INFO, "cmdline_test_exit active: exiting QEMU now" ); |
| 35 | ndjson_bye(code: QEMU_EXIT_OK, reason: "cmdline test exit" ); |
| 36 | qemu_exit(code: QEMU_EXIT_OK); |
| 37 | } |
| 38 | } |
| 39 | |