Revert "vl: fix -hdachs/-hda argument order parsing issues"

This reverts commit 7764ae9671.

Signed-off-by: malc <av1474@comtv.ru>
This commit is contained in:
malc 2012-08-27 18:33:22 +04:00
parent e4558dcae8
commit 9f227bc358

39
vl.c
View File

@ -2352,9 +2352,8 @@ int main(int argc, char **argv, char **envp)
char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */ char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */
DisplayState *ds; DisplayState *ds;
DisplayChangeListener *dcl; DisplayChangeListener *dcl;
char hdachs_params[512]; /* save -hdachs to apply to later -hda */ int cyls, heads, secs, translation;
QemuOpts *hda_opts = NULL; /* save -hda to be modified by later -hdachs */ QemuOpts *hda_opts = NULL, *opts, *machine_opts;
QemuOpts *opts, *machine_opts;
QemuOptsList *olist; QemuOptsList *olist;
int optind; int optind;
const char *optarg; const char *optarg;
@ -2409,7 +2408,8 @@ int main(int argc, char **argv, char **envp)
cpu_model = NULL; cpu_model = NULL;
ram_size = 0; ram_size = 0;
snapshot = 0; snapshot = 0;
snprintf(hdachs_params, sizeof(hdachs_params), "%s", HD_OPTS); cyls = heads = secs = 0;
translation = BIOS_ATA_TRANSLATION_AUTO;
for (i = 0; i < MAX_NODES; i++) { for (i = 0; i < MAX_NODES; i++) {
node_mem[i] = 0; node_mem[i] = 0;
@ -2457,7 +2457,7 @@ int main(int argc, char **argv, char **envp)
if (optind >= argc) if (optind >= argc)
break; break;
if (argv[optind][0] != '-') { if (argv[optind][0] != '-') {
hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], hdachs_params); hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
} else { } else {
const QEMUOption *popt; const QEMUOption *popt;
@ -2475,8 +2475,21 @@ int main(int argc, char **argv, char **envp)
cpu_model = optarg; cpu_model = optarg;
break; break;
case QEMU_OPTION_hda: case QEMU_OPTION_hda:
hda_opts = drive_add(IF_DEFAULT, 0, optarg, hdachs_params); {
break; char buf[256];
if (cyls == 0)
snprintf(buf, sizeof(buf), "%s", HD_OPTS);
else
snprintf(buf, sizeof(buf),
"%s,cyls=%d,heads=%d,secs=%d%s",
HD_OPTS , cyls, heads, secs,
translation == BIOS_ATA_TRANSLATION_LBA ?
",trans=lba" :
translation == BIOS_ATA_TRANSLATION_NONE ?
",trans=none" : "");
drive_add(IF_DEFAULT, 0, optarg, buf);
break;
}
case QEMU_OPTION_hdb: case QEMU_OPTION_hdb:
case QEMU_OPTION_hdc: case QEMU_OPTION_hdc:
case QEMU_OPTION_hdd: case QEMU_OPTION_hdd:
@ -2510,10 +2523,7 @@ int main(int argc, char **argv, char **envp)
break; break;
case QEMU_OPTION_hdachs: case QEMU_OPTION_hdachs:
{ {
int cyls, heads, secs, translation;
const char *p; const char *p;
cyls = heads = secs = 0;
translation = BIOS_ATA_TRANSLATION_AUTO;
p = optarg; p = optarg;
cyls = strtol(p, (char **)&p, 0); cyls = strtol(p, (char **)&p, 0);
if (cyls < 1 || cyls > 16383) if (cyls < 1 || cyls > 16383)
@ -2545,14 +2555,7 @@ int main(int argc, char **argv, char **envp)
fprintf(stderr, "qemu: invalid physical CHS format\n"); fprintf(stderr, "qemu: invalid physical CHS format\n");
exit(1); exit(1);
} }
snprintf(hdachs_params, sizeof(hdachs_params), if (hda_opts != NULL) {
"%s,cyls=%d,heads=%d,secs=%d%s",
HD_OPTS , cyls, heads, secs,
translation == BIOS_ATA_TRANSLATION_LBA ?
",trans=lba" :
translation == BIOS_ATA_TRANSLATION_NONE ?
",trans=none" : "");
if (hda_opts != NULL) {
char num[16]; char num[16];
snprintf(num, sizeof(num), "%d", cyls); snprintf(num, sizeof(num), "%d", cyls);
qemu_opt_set(hda_opts, "cyls", num); qemu_opt_set(hda_opts, "cyls", num);