vl: fix -hdachs/-hda argument order parsing issues
Without this patch, the -hdachs argument had to occur either BEFORE the corresponding "-hda" option, or AFTER the plain disk image name (if neither -hda nor -drive is used). Otherwise it would effectively be ignored. Option -hdachs still has no effect on -drive, but that seems best. Signed-off-by: Matthew Ogilvie <mmogilvi_qemu@miniinfo.net> Signed-off-by: malc <av1474@comtv.ru>
This commit is contained in:
parent
5c73b757e3
commit
7764ae9671
35
vl.c
35
vl.c
|
@ -2352,8 +2352,9 @@ 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;
|
||||||
int cyls, heads, secs, translation;
|
char hdachs_params[512]; /* save -hdachs to apply to later -hda */
|
||||||
QemuOpts *hda_opts = NULL, *opts, *machine_opts;
|
QemuOpts *hda_opts = NULL; /* save -hda to be modified by later -hdachs */
|
||||||
|
QemuOpts *opts, *machine_opts;
|
||||||
QemuOptsList *olist;
|
QemuOptsList *olist;
|
||||||
int optind;
|
int optind;
|
||||||
const char *optarg;
|
const char *optarg;
|
||||||
|
@ -2408,8 +2409,7 @@ int main(int argc, char **argv, char **envp)
|
||||||
cpu_model = NULL;
|
cpu_model = NULL;
|
||||||
ram_size = 0;
|
ram_size = 0;
|
||||||
snapshot = 0;
|
snapshot = 0;
|
||||||
cyls = heads = secs = 0;
|
snprintf(hdachs_params, sizeof(hdachs_params), "%s", HD_OPTS);
|
||||||
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++], HD_OPTS);
|
hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], hdachs_params);
|
||||||
} else {
|
} else {
|
||||||
const QEMUOption *popt;
|
const QEMUOption *popt;
|
||||||
|
|
||||||
|
@ -2475,21 +2475,8 @@ 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);
|
||||||
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;
|
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:
|
||||||
|
@ -2523,7 +2510,10 @@ 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)
|
||||||
|
@ -2555,6 +2545,13 @@ 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),
|
||||||
|
"%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) {
|
if (hda_opts != NULL) {
|
||||||
char num[16];
|
char num[16];
|
||||||
snprintf(num, sizeof(num), "%d", cyls);
|
snprintf(num, sizeof(num), "%d", cyls);
|
||||||
|
|
Loading…
Reference in a new issue