From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjNMf-0001Ka-UG for qemu-devel@nongnu.org; Thu, 21 Nov 2013 01:03:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjNMZ-0007hi-UM for qemu-devel@nongnu.org; Thu, 21 Nov 2013 01:03:45 -0500 Received: from [222.73.24.84] (port=7930 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjNMY-0007hS-Pd for qemu-devel@nongnu.org; Thu, 21 Nov 2013 01:03:39 -0500 Message-ID: <528DA1C7.5080708@cn.fujitsu.com> Date: Thu, 21 Nov 2013 14:01:43 +0800 From: Li Guang MIME-Version: 1.0 References: <1385001528-12003-1-git-send-email-imammedo@redhat.com> <1385001528-12003-5-git-send-email-imammedo@redhat.com> In-Reply-To: <1385001528-12003-5-git-send-email-imammedo@redhat.com> Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1; format=flowed Subject: Re: [Qemu-devel] [PATCH 04/27] vl: convert -m to qemu_opts_parse() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: peter.maydell@linaro.org, aliguori@amazon.com, stefanb@linux.vnet.ibm.com, armbru@redhat.com, mst@redhat.com, mjt@tls.msk.ru, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, vasilis.liaskovitis@profitbricks.com, quintela@redhat.com, kraxel@redhat.com, stefanha@redhat.com, hutao@cn.fujitsu.com, pbonzini@redhat.com, marcel.a@redhat.com, lcapitulino@redhat.com, chegu_vinod@hp.com, afaerber@suse.de Igor Mammedov wrote: > Along with conversion extend -m option to support following parameters > ... > + if (!opts) { > exit(1); > } > - sz = QEMU_ALIGN_UP((uint64_t)value, 8192); > + > + /* fixup legacy sugffix-less format */ > s/sugffix/suffix > + end = qemu_opt_get(opts, "mem"); > + if (g_ascii_isdigit(end[strlen(end) - 1])) { > + s = g_strconcat(end, "M", NULL); > + qemu_opt_set(opts, "mem", s); > + g_free(s); > + } > + > + sz = QEMU_ALIGN_UP(qemu_opt_get_size(opts, "mem", ram_size), > + 8192); > + /* compatibility behaviour for case "-m 0" */ > + if (sz == 0) { > + sz = DEFAULT_RAM_SIZE * 1024 * 1024; > + } > + > ram_size = sz; > if (ram_size != sz) { > fprintf(stderr, "qemu: ram size too large\n"); > exit(1); > } > + /* store aligned value for future use */ > + qemu_opt_set_number(opts, "mem", ram_size); > + > + sz = qemu_opt_get_size(opts, "maxmem", ram_size); > + if (sz< ram_size) { > + qemu_opt_set_number(opts, "maxmem", ram_size); > + } > break; > } > #ifdef CONFIG_TPM > @@ -4029,11 +4083,6 @@ int main(int argc, char **argv, char **envp) > exit(1); > } > > - /* init the memory */ > - if (ram_size == 0) { > - ram_size = DEFAULT_RAM_SIZE * 1024 * 1024; > - } > - > if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0) > != 0) { > exit(0); >