Revision 6530a97b
b/vl.c | ||
---|---|---|
4658 | 4658 |
return 0; |
4659 | 4659 |
} |
4660 | 4660 |
|
4661 |
static const QEMUOption *lookup_opt(int argc, char **argv, |
|
4662 |
const char **poptarg, int *poptind) |
|
4663 |
{ |
|
4664 |
const QEMUOption *popt; |
|
4665 |
int optind = *poptind; |
|
4666 |
char *r = argv[optind]; |
|
4667 |
const char *optarg; |
|
4668 |
|
|
4669 |
optind++; |
|
4670 |
/* Treat --foo the same as -foo. */ |
|
4671 |
if (r[1] == '-') |
|
4672 |
r++; |
|
4673 |
popt = qemu_options; |
|
4674 |
for(;;) { |
|
4675 |
if (!popt->name) { |
|
4676 |
fprintf(stderr, "%s: invalid option -- '%s'\n", |
|
4677 |
argv[0], r); |
|
4678 |
exit(1); |
|
4679 |
} |
|
4680 |
if (!strcmp(popt->name, r + 1)) |
|
4681 |
break; |
|
4682 |
popt++; |
|
4683 |
} |
|
4684 |
if (popt->flags & HAS_ARG) { |
|
4685 |
if (optind >= argc) { |
|
4686 |
fprintf(stderr, "%s: option '%s' requires an argument\n", |
|
4687 |
argv[0], r); |
|
4688 |
exit(1); |
|
4689 |
} |
|
4690 |
optarg = argv[optind++]; |
|
4691 |
} else { |
|
4692 |
optarg = NULL; |
|
4693 |
} |
|
4694 |
|
|
4695 |
*poptarg = optarg; |
|
4696 |
*poptind = optind; |
|
4697 |
|
|
4698 |
return popt; |
|
4699 |
} |
|
4700 |
|
|
4661 | 4701 |
int main(int argc, char **argv, char **envp) |
4662 | 4702 |
{ |
4663 | 4703 |
const char *gdbstub_dev = NULL; |
... | ... | |
4672 | 4712 |
int cyls, heads, secs, translation; |
4673 | 4713 |
QemuOpts *hda_opts = NULL, *opts; |
4674 | 4714 |
int optind; |
4675 |
const char *r, *optarg;
|
|
4715 |
const char *optarg; |
|
4676 | 4716 |
const char *loadvm = NULL; |
4677 | 4717 |
QEMUMachine *machine; |
4678 | 4718 |
const char *cpu_model; |
... | ... | |
4753 | 4793 |
for(;;) { |
4754 | 4794 |
if (optind >= argc) |
4755 | 4795 |
break; |
4756 |
r = argv[optind]; |
|
4757 |
if (r[0] != '-') { |
|
4796 |
if (argv[optind][0] != '-') { |
|
4758 | 4797 |
hda_opts = drive_add(argv[optind++], HD_ALIAS, 0); |
4759 | 4798 |
} else { |
4760 | 4799 |
const QEMUOption *popt; |
4761 | 4800 |
|
4762 |
optind++; |
|
4763 |
/* Treat --foo the same as -foo. */ |
|
4764 |
if (r[1] == '-') |
|
4765 |
r++; |
|
4766 |
popt = qemu_options; |
|
4767 |
for(;;) { |
|
4768 |
if (!popt->name) { |
|
4769 |
fprintf(stderr, "%s: invalid option -- '%s'\n", |
|
4770 |
argv[0], r); |
|
4771 |
exit(1); |
|
4772 |
} |
|
4773 |
if (!strcmp(popt->name, r + 1)) |
|
4774 |
break; |
|
4775 |
popt++; |
|
4776 |
} |
|
4777 |
if (popt->flags & HAS_ARG) { |
|
4778 |
if (optind >= argc) { |
|
4779 |
fprintf(stderr, "%s: option '%s' requires an argument\n", |
|
4780 |
argv[0], r); |
|
4781 |
exit(1); |
|
4782 |
} |
|
4783 |
optarg = argv[optind++]; |
|
4784 |
} else { |
|
4785 |
optarg = NULL; |
|
4786 |
} |
|
4787 |
|
|
4801 |
popt = lookup_opt(argc, argv, &optarg, &optind); |
|
4788 | 4802 |
switch(popt->index) { |
4789 | 4803 |
case QEMU_OPTION_M: |
4790 | 4804 |
machine = find_machine(optarg); |
Also available in: Unified diff