error: Track locations on command line
New LOC_CMDLINE. Use it for tracking option with argument in
lookup_opt(). We now report errors like this
qemu: -device smbus-eeprom: Did not find I2C bus for smbus-eeprom
diff --git a/vl.c b/vl.c
index a83ed55..45214ee 100644
--- a/vl.c
+++ b/vl.c
@@ -4796,6 +4796,7 @@
char *r = argv[optind];
const char *optarg;
+ loc_set_cmdline(argv, optind, 1);
optind++;
/* Treat --foo the same as -foo. */
if (r[1] == '-')
@@ -4803,8 +4804,7 @@
popt = qemu_options;
for(;;) {
if (!popt->name) {
- fprintf(stderr, "%s: invalid option -- '%s'\n",
- argv[0], r);
+ error_report("invalid option");
exit(1);
}
if (!strcmp(popt->name, r + 1))
@@ -4813,11 +4813,11 @@
}
if (popt->flags & HAS_ARG) {
if (optind >= argc) {
- fprintf(stderr, "%s: option '%s' requires an argument\n",
- argv[0], r);
+ error_report("requires an argument");
exit(1);
}
optarg = argv[optind++];
+ loc_set_cmdline(argv, optind - 2, 2);
} else {
optarg = NULL;
}
@@ -5662,6 +5662,7 @@
}
}
}
+ loc_set_none();
/* If no data_dir is specified then try to find it relative to the
executable path. */