Commit 9f227bc3 authored by malc's avatar malc
Browse files

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



This reverts commit 7764ae96.

Signed-off-by: default avatarmalc <av1474@comtv.ru>
parent e4558dca
Loading
Loading
Loading
Loading
+21 −18
Original line number Diff line number Diff line
@@ -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);
                {
                    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,13 +2555,6 @@ 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) {
                        char num[16];
                        snprintf(num, sizeof(num), "%d", cyls);