From patchwork Mon Oct 1 04:56:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Ogilvie X-Patchwork-Id: 188212 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6F4042C00E3 for ; Mon, 1 Oct 2012 15:02:42 +1000 (EST) Received: from localhost ([::1]:40478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIY9Q-0006PK-9z for incoming@patchwork.ozlabs.org; Mon, 01 Oct 2012 01:02:40 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIY9B-0006P1-91 for qemu-devel@nongnu.org; Mon, 01 Oct 2012 01:02:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TIY99-0007ed-SH for qemu-devel@nongnu.org; Mon, 01 Oct 2012 01:02:25 -0400 Received: from qmta06.emeryville.ca.mail.comcast.net ([76.96.30.56]:48788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIY99-0007dS-JO for qemu-devel@nongnu.org; Mon, 01 Oct 2012 01:02:23 -0400 Received: from omta14.emeryville.ca.mail.comcast.net ([76.96.30.60]) by qmta06.emeryville.ca.mail.comcast.net with comcast id 5guB1k0041HpZEsA6h2PQz; Mon, 01 Oct 2012 05:02:23 +0000 Received: from mmogilvi.homeip.net ([24.9.53.136]) by omta14.emeryville.ca.mail.comcast.net with comcast id 5gxM1k00s2wKXRC8agxNbY; Mon, 01 Oct 2012 04:57:23 +0000 Received: by mmogilvi.homeip.net (Postfix, from userid 501) id BB6081E9601B; Sun, 30 Sep 2012 22:57:21 -0600 (MDT) From: Matthew Ogilvie To: qemu-devel@nongnu.org Date: Sun, 30 Sep 2012 22:56:32 -0600 Message-Id: <1349067398-9578-3-git-send-email-mmogilvi_qemu@miniinfo.net> X-Mailer: git-send-email 1.7.10.2.484.gcd07cc5 In-Reply-To: <1349067398-9578-1-git-send-email-mmogilvi_qemu@miniinfo.net> References: <1349067398-9578-1-git-send-email-mmogilvi_qemu@miniinfo.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 76.96.30.56 Cc: Paolo Bonzini , Jan Kiszka , Matthew Ogilvie , "Maciej W. Rozycki" , Avi Kivity Subject: [Qemu-devel] [PATCH v6 2/8] vl: fix -hdachs/-hda argument order parsing issues X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- vl.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/vl.c b/vl.c index 8d305ca..e1d2f7e 100644 --- a/vl.c +++ b/vl.c @@ -2362,8 +2362,9 @@ int main(int argc, char **argv, char **envp) char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */ DisplayState *ds; DisplayChangeListener *dcl; - int cyls, heads, secs, translation; - QemuOpts *hda_opts = NULL, *opts, *machine_opts; + 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; QemuOptsList *olist; int optind; const char *optarg; @@ -2418,8 +2419,7 @@ int main(int argc, char **argv, char **envp) cpu_model = NULL; ram_size = 0; snapshot = 0; - cyls = heads = secs = 0; - translation = BIOS_ATA_TRANSLATION_AUTO; + snprintf(hdachs_params, sizeof(hdachs_params), "%s", HD_OPTS); for (i = 0; i < MAX_NODES; i++) { node_mem[i] = 0; @@ -2467,7 +2467,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++], HD_OPTS); + hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], hdachs_params); } else { const QEMUOption *popt; @@ -2485,21 +2485,8 @@ int main(int argc, char **argv, char **envp) cpu_model = optarg; break; case QEMU_OPTION_hda: - { - 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; - } + hda_opts = drive_add(IF_DEFAULT, 0, optarg, hdachs_params); + break; case QEMU_OPTION_hdb: case QEMU_OPTION_hdc: case QEMU_OPTION_hdd: @@ -2533,7 +2520,10 @@ 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) @@ -2565,7 +2555,14 @@ int main(int argc, char **argv, char **envp) fprintf(stderr, "qemu: invalid physical CHS format\n"); exit(1); } - if (hda_opts != NULL) { + 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); qemu_opt_set(hda_opts, "cyls", num);