[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] xl.cfg: add 'cmdline' in config file



commit 986aea7fbe3c6ff3c4d2312ca8a4365930401e40
Author:     Chunyan Liu <cyliu@xxxxxxxx>
AuthorDate: Mon Jul 7 14:34:34 2014 +0800
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Tue Aug 26 21:18:51 2014 +0100

    xl.cfg: add 'cmdline' in config file
    
    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 <cyliu@xxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 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 9ab0ad6..f1fc906 100644
--- a/docs/man/xl.cfg.pod.5
+++ b/docs/man/xl.cfg.pod.5
@@ -345,6 +345,13 @@ Load the specified file as the kernel image.
 
 Load the specified file as the ramdisk.
 
+=item B<cmdline="STRING">
+
+Append B<cmdline="STRING"> to the kernel command line. (Note: it is
+guest specific what meaning this has). It can replace B<root="STRING">
+plus B<extra="STRING"> and is preferred. When B<cmdline="STRING"> is set,
+B<root="STRING"> and B<extra="STRING"> will be ignored.
+
 =item B<root="STRING">
 
 Append B<root="STRING"> to the kernel command line (Note: it is guest
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 9120c1e..409a795 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -694,19 +694,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);
     }
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.