@@ -1,15 +1,15 @@
#if defined(QEMU_OPTIONS_GENERATE_ENUM)
-#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \
+#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask, ...) \
opt_enum,
#define DEFHEADING(text)
#define ARCHHEADING(text, arch_mask)
#elif defined(QEMU_OPTIONS_GENERATE_HELP)
-#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \
- if ((arch_mask) & arch_type) \
+#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask, ...) \
+ if ((arch_mask) & arch_type) \
fputs(opt_help, stdout);
#define ARCHHEADING(text, arch_mask) \
@@ -20,8 +20,8 @@
#elif defined(QEMU_OPTIONS_GENERATE_OPTIONS)
-#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \
- { option, opt_arg, opt_enum, arch_mask },
+#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask, ...) \
+ { option, opt_arg, opt_enum, arch_mask, __VA_ARGS__},
#define DEFHEADING(text)
#define ARCHHEADING(text, arch_mask)
@@ -3352,7 +3352,8 @@ testing of various kernels.
ERST
DEF("kernel", HAS_ARG, QEMU_OPTION_kernel, \
- "-kernel bzImage use 'bzImage' as kernel image\n", QEMU_ARCH_ALL)
+ "-kernel bzImage use 'bzImage' as kernel image\n", QEMU_ARCH_ALL, \
+ parse_linux_boot)
SRST
``-kernel bzImage``
Use bzImage as kernel image. The kernel can be either a Linux kernel
@@ -3360,14 +3361,16 @@ SRST
ERST
DEF("append", HAS_ARG, QEMU_OPTION_append, \
- "-append cmdline use 'cmdline' as kernel command line\n", QEMU_ARCH_ALL)
+ "-append cmdline use 'cmdline' as kernel command line\n", QEMU_ARCH_ALL, \
+ parse_linux_boot)
SRST
``-append cmdline``
Use cmdline as kernel command line
ERST
DEF("initrd", HAS_ARG, QEMU_OPTION_initrd, \
- "-initrd file use 'file' as initial ram disk\n", QEMU_ARCH_ALL)
+ "-initrd file use 'file' as initial ram disk\n", QEMU_ARCH_ALL, \
+ parse_linux_boot)
SRST
``-initrd file``
Use file as initial ram disk.
@@ -3380,7 +3383,8 @@ SRST
ERST
DEF("dtb", HAS_ARG, QEMU_OPTION_dtb, \
- "-dtb file use 'file' as device tree image\n", QEMU_ARCH_ALL)
+ "-dtb file use 'file' as device tree image\n", QEMU_ARCH_ALL, \
+ parse_linux_boot)
SRST
``-dtb file``
Use file as a device tree binary (dtb) image and pass it to the
@@ -1715,8 +1715,16 @@ typedef struct QEMUOption {
int flags;
int index;
uint32_t arch_mask;
+ int (*parser)(const struct QEMUOption *popt, const char* optarg);
} QEMUOption;
+static int parse_linux_boot(const QEMUOption *popt, const char* optarg)
+{
+ qemu_opts_set(qemu_find_opts("machine"), NULL, popt->name, optarg,
+ &error_abort);
+ return 0;
+}
+
static const QEMUOption qemu_options[] = {
{ "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL },
#define QEMU_OPTIONS_GENERATE_OPTIONS
@@ -2981,6 +2989,15 @@ void qemu_init(int argc, char **argv, char **envp)
error_report("Option not supported for this target");
exit(1);
}
+
+ if (popt->parser) {
+ if (popt->parser(popt, optarg)) {
+ error_report("Parser '%s' option error", popt->name);
+ exit(1);
+ }
+ continue;
+ }
+
switch(popt->index) {
case QEMU_OPTION_cpu:
/* hw initialization will check this */
@@ -3075,22 +3092,6 @@ void qemu_init(int argc, char **argv, char **envp)
exit(1);
}
break;
- case QEMU_OPTION_kernel:
- qemu_opts_set(qemu_find_opts("machine"), NULL, "kernel", optarg,
- &error_abort);
- break;
- case QEMU_OPTION_initrd:
- qemu_opts_set(qemu_find_opts("machine"), NULL, "initrd", optarg,
- &error_abort);
- break;
- case QEMU_OPTION_append:
- qemu_opts_set(qemu_find_opts("machine"), NULL, "append", optarg,
- &error_abort);
- break;
- case QEMU_OPTION_dtb:
- qemu_opts_set(qemu_find_opts("machine"), NULL, "dtb", optarg,
- &error_abort);
- break;
case QEMU_OPTION_cdrom:
drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
break;