]> xenbits.xensource.com Git - osstest/rumprun.git/commitdiff
If Xenstore config isn't available, use cmdline.
authorAntti Kantee <pooka@iki.fi>
Thu, 15 Oct 2015 01:30:25 +0000 (01:30 +0000)
committerAntti Kantee <pooka@iki.fi>
Thu, 15 Oct 2015 01:33:59 +0000 (01:33 +0000)
This change essentially decouples the bmk part of the Xen platform
from the rumprun userspace, essentially fixing "kernonly" mode on
Xen...  or at least making it possible to build a Xen kernonly image.

platform/xen/init.c

index dc16946254858707ccb3a2261045da98f9855250..a62e871dca1690bca6fd00d6ab63c53d2a1ddc2d 100644 (file)
 #include <bmk-core/platform.h>
 #include <bmk-core/printf.h>
 
-#include <rumprun-base/config.h>
-
-static char hardcoded_jsoncfg[] = "";
-
 static char *
-jsonordie(void)
-{
-
-       if (hardcoded_jsoncfg[0] == '\0')
-               bmk_platform_halt("could not get configuration");
-
-       bmk_printf("using hardcoded_jsoncfg\n");
-       return hardcoded_jsoncfg;
-}
-
-static char *
-get_config(char *cmdline)
+get_xenstorecfg(void)
 {
        xenbus_transaction_t txn;
        char *cfg;
        int retry;
 
-       /* XXX: should not be here */
-       cfg = rumprun_config_path(cmdline);
-       if (cfg != NULL)
-               return cfg;
-
        if (xenbus_transaction_start(&txn))
-               return jsonordie();
-       if (xenbus_read(txn, "rumprun/cfg", &cfg) != NULL)
-               cfg = jsonordie();
+               return NULL;
+       xenbus_read(txn, "rumprun/cfg", &cfg);
+       /* XXX: unclear what the "retry" param is supposed to signify */
        xenbus_transaction_end(txn, 0, &retry);
 
        return cfg;
@@ -74,9 +54,20 @@ get_config(char *cmdline)
 int
 app_main(start_info_t *si)
 {
-       void *cmdline;
+       char *cmdline;
+
+       /*
+        * So, what we currently do is:
+        *   1) try to fetch the config from xenstore.  if available, use that
+        *   2) else, just pass the command line to bmk_mainthread
+        *
+        * Not sure if we eventually need to pass both, but we can change
+        * it later.
+        */
+
+       if ((cmdline = get_xenstorecfg()) == NULL)
+               cmdline = (char *)si->cmd_line;
 
-       cmdline = get_config((char *)si->cmd_line);
        bmk_mainthread(cmdline);
        /* NOTREACHED */