aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authormalc <av1474@comtv.ru>2012-08-27 18:33:22 +0400
committermalc <av1474@comtv.ru>2012-08-27 18:33:22 +0400
commit9f227bc3583ea082be7a79c14a5ffdade5844753 (patch)
tree0b5d59a40a45e3777e474fff6ef34b9658cd1543 /vl.c
parente4558dcae8b9fcb2bcc312f1d04071b34adf0781 (diff)
downloadqemu-9f227bc3583ea082be7a79c14a5ffdade5844753.zip
qemu-9f227bc3583ea082be7a79c14a5ffdade5844753.tar.gz
qemu-9f227bc3583ea082be7a79c14a5ffdade5844753.tar.bz2
Revert "vl: fix -hdachs/-hda argument order parsing issues"
This reverts commit 7764ae9671f1cd74227cf4404431dd5213799ef0. Signed-off-by: malc <av1474@comtv.ru>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/vl.c b/vl.c
index febfd62..7c577fa 100644
--- a/vl.c
+++ b/vl.c
@@ -2352,9 +2352,8 @@ int main(int argc, char **argv, char **envp)
char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */
DisplayState *ds;
DisplayChangeListener *dcl;
- char hdachs_params[512]; /* save -hdachs to apply to later -hda */
- QemuOpts *hda_opts = NULL; /* save -hda to be modified by later -hdachs */
- QemuOpts *opts, *machine_opts;
+ int cyls, heads, secs, translation;
+ QemuOpts *hda_opts = NULL, *opts, *machine_opts;
QemuOptsList *olist;
int optind;
const char *optarg;
@@ -2409,7 +2408,8 @@ int main(int argc, char **argv, char **envp)
cpu_model = NULL;
ram_size = 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++) {
node_mem[i] = 0;
@@ -2457,7 +2457,7 @@ int main(int argc, char **argv, char **envp)
if (optind >= argc)
break;
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 {
const QEMUOption *popt;
@@ -2475,8 +2475,21 @@ int main(int argc, char **argv, char **envp)
cpu_model = optarg;
break;
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_hdc:
case QEMU_OPTION_hdd:
@@ -2510,10 +2523,7 @@ int main(int argc, char **argv, char **envp)
break;
case QEMU_OPTION_hdachs:
{
- int cyls, heads, secs, translation;
const char *p;
- cyls = heads = secs = 0;
- translation = BIOS_ATA_TRANSLATION_AUTO;
p = optarg;
cyls = strtol(p, (char **)&p, 0);
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");
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];
snprintf(num, sizeof(num), "%d", cyls);
qemu_opt_set(hda_opts, "cyls", num);