From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X42WD-0004iT-7j for qemu-devel@nongnu.org; Mon, 07 Jul 2014 02:35:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X42W5-0008Nd-2o for qemu-devel@nongnu.org; Mon, 07 Jul 2014 02:35:17 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:42930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X42W4-0008Ml-Sf for qemu-devel@nongnu.org; Mon, 07 Jul 2014 02:35:09 -0400 From: Chunyan Liu Date: Mon, 7 Jul 2014 14:34:34 +0800 Message-Id: <1404714875-24362-3-git-send-email-cyliu@suse.com> In-Reply-To: <1404714875-24362-1-git-send-email-cyliu@suse.com> References: <1404714875-24362-1-git-send-email-cyliu@suse.com> Subject: [Qemu-devel] [RFC PATCH V5 2/3] xl.cfg: add 'cmdline' in config file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: xen-devel@lists.xensource.com, qemu-devel@nongnu.org Cc: Chunyan Liu , Ian.Jackson@eu.citrix.com, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com Currently in xl.cfg, use 'root' and 'extra' to generate the command line. 'cmdline' could be a more generic equivalent. So, add 'cmdline' in xl.cfg and let it be preferred. 'root' and 'extra' still works. But when 'cmdline' is specified, 'root' and 'extra' will be ignored. [HVM config example] [snip] builder="hvm" device_model_override="/home/cyliu/git/qemu/x86_64-softmmu/qemu-system-x86_64" kernel="/mnt/vmlinuz-3.0.13-0.27-default" ramdisk="/mnt/initrd-3.0.13-0.27-default" root="/dev/hda2" extra="console=tty0 console=ttyS0" [snip] or: [snip] builder="hvm" device_model_override="/home/cyliu/git/qemu/x86_64-softmmu/qemu-system-x86_64" kernel="/mnt/vmlinuz-3.0.13-0.27-default" ramdisk="/mnt/initrd-3.0.13-0.27-default" cmdline="root=/dev/hda2 console=tty0 console=ttyS0" [snip] Signed-off-by: Chunyan Liu --- Changes: - add back the 'cmdline' in xl.cfg, but as separate patch docs/man/xl.cfg.pod.5 | 7 +++++++ tools/libxl/xl_cmdimpl.c | 20 ++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5 index c4a6589..cb5b76b 100644 --- a/docs/man/xl.cfg.pod.5 +++ b/docs/man/xl.cfg.pod.5 @@ -323,6 +323,13 @@ Load the specified file as the kernel image. Load the specified file as the ramdisk. +=item B + +Append B to the kernel command line. (Note: it is +guest specific what meaning this has). It can replace B +plus B and is preferred. When B is set, +B and B will be ignored. + =item B Append B to the kernel command line (Note: it is guest diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index d4cd50b..cfe13e3 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -693,19 +693,27 @@ static void parse_top_level_sdl_options(XLU_Config *config, static char *parse_cmdline(XLU_Config *config) { char *cmdline = NULL; - const char *root = NULL, *extra = ""; + const char *root = NULL, *extra = NULL, *buf = NULL; + xlu_cfg_get_string (config, "cmdline", &buf, 0); xlu_cfg_get_string (config, "root", &root, 0); xlu_cfg_get_string (config, "extra", &extra, 0); - if (root) { - if (asprintf(&cmdline, "root=%s %s", root, extra) == -1) - cmdline = NULL; + if (buf) { + cmdline = strdup(buf); + if (root || extra) + fprintf(stderr, "Warning: ignoring root= and extra= " + "in favour of cmdline=\n"); } else { - cmdline = strdup(extra); + if (root) { + if (asprintf(&cmdline, "root=%s %s", root, extra) == -1) + cmdline = NULL; + } else if (extra) { + cmdline = strdup(extra); + } } - if ((root || extra) && !cmdline) { + if ((buf || root || extra) && !cmdline) { fprintf(stderr, "Failed to allocate memory for cmdline\n"); exit(1); } -- 1.8.4.5