Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon EC2 jsoncfg #108

Open
edescourtis opened this issue Nov 27, 2017 · 1 comment
Open

Amazon EC2 jsoncfg #108

edescourtis opened this issue Nov 27, 2017 · 1 comment

Comments

@edescourtis
Copy link

edescourtis commented Nov 27, 2017

@anttikantee I am trying to boot my rumpkernel in EC2.
I am following these instructions from https://www.freelists.org/post/rumpkernel-users/EC2-launch-script-feedback-valued,1

I can't figure out where to put the hardcoded_jsoncfg. Where do I put it?

From my rumprun ec2 image I can see a json.cfg file that looks like so (I assumed that this maybe replaced the static config):

 {, 
	"net" :  {, 
		"if":		"xenif0", 
		"cloner":	"true", 
		"type":	"inet", 
		"method":	"dhcp", 
	}, 
	"env": "ERL_INETRC=/opt/erlang/erl_inetrc", 
	"blk" :  {, 
		"source":	"vnd", 
		"path":	"images/erlang.iso", 
		"fstype":	"blk", 
		"mountpoint":	"/opt/erlang", 
	}, 
	"blk" :  {, 
		"source":	"vnd", 
		"path":	"images/app.iso", 
		"fstype":	"blk", 
		"mountpoint":	"/apps/erlang", 
	}, 
	"cmdline": "bin/beam.xen_pv.bin -- -no_epmd -root /opt/erlang/lib/erlang -progname erl -- -home /tmp -noshell -pa /apps/erlang -s echoserver start", 
	"hostname": "rumprun-bin_beam.xen_pv.bin.ec2dir", 
}, 

It appears to be invalid json. Why is that? What am I missing?

Xen Minimal OS!
  start_info: 0xae2000(VA)
    nr_pages: 0x26700
  shared_inf: 0x7dcd5000(MA)
     pt_base: 0xae5000(VA)
nr_pt_frames: 0x9
    mfn_list: 0x9ae000(VA)
   mod_start: 0x0(VA)
     mod_len: 0
       flags: 0x0
    cmd_line: root=/dev/sda1 ro 4
  stack:      0x96d840-0x98d840
MM: Init
      _text: 0x0(VA)
     _etext: 0x7dc7d(VA)
   _erodata: 0x9a000(VA)
     _edata: 0x9fce0(VA)
stack start: 0x96d840(VA)
       _end: 0x9ade40(VA)
  start_pfn: af1
    max_pfn: 26700
Mapping memory range 0xc00000 - 0x26700000
setting 0x0-0x9a000 readonly
skipped 0x1000
MM: Initialise page allocator for c1f000(c1f000)-26700000(26700000)
MM: done
Demand map pfns at 26701000-2026701000.
Heap resides at 2026702000-4026702000.
Initialising timer interface
Initialising console ... done.
gnttab_table mapped at 0x26701000.
Initialising scheduler
Thread "Idle": pointer: 0x2026702050, stack: 0x26660000
Thread "xenstore": pointer: 0x2026702800, stack: 0x26670000
xenbus initialised on irq 1 mfn 0xb366f6
Thread "shutdown": pointer: 0x2026702fb0, stack: 0x26680000
Dummy main: start_info=0x98d940
Thread "main": pointer: 0x2026703760, stack: 0x26690000
"main" "root=/dev/sda1" "ro" "4" 
vbd 2049 is hd0
******************* BLKFRONT for device/vbd/2049 **********


backend at /local/domain/0/backend/vbd/5561/2049
Failed to read /local/domain/0/backend/vbd/5561/2049/feature-barrier.
Failed to read /local/domain/0/backend/vbd/5561/2049/feature-flush-cache.
2097152 sectors of 512 bytes
**************************
vbd 2064 is hd1
******************* BLKFRONT for device/vbd/2064 **********


backend at /local/domain/0/backend/vbd/5561/2064
Failed to read /local/domain/0/backend/vbd/5561/2064/feature-barrier.
Failed to read /local/domain/0/backend/vbd/5561/2064/feature-flush-cache.
2097152 sectors of 512 bytes
**************************
�[H�[J

    GNU GRUB  version 0.97  (629760K lower / 0K upper memory)



�[m�[4;2H+-------------------------------------------------------------------------+�[5;2H|�[5;76H|�[6;2H|�[6;76H|�[7;2H|�[7;76H|�[8;2H|�[8;76H|�[9;2H|�[9;76H|�[10;2H|�[10;76H|�[11;2H|�[11;76H|�[12;2H|�[12;76H|�[13;2H|�[13;76H|�[14;2H|�[14;76H|�[15;2H|�[15;76H|�[16;2H|�[16;76H|�[17;2H+-------------------------------------------------------------------------+�[m

    Use the ^ and v keys to select which entry is highlighted.

    Press enter to boot the selected OS, 'e' to edit the

    commands before booting, or 'c' for a command-line.�[5;78H �[m�[7m�[5;3H Rump                                                                    �[5;75H�[m�[m�[6;3H                                                                         �[6;75H�[m�[m�[7;3H                                                                         �[7;75H�[m�[m�[8;3H                                                                         �[8;75H�[m�[m�[9;3H                                                                         �[9;75H�[m�[m�[10;3H                                                                         �[10;75H�[m�[m�[11;3H                                                                         �[11;75H�[m�[m�[12;3H                                                                         �[12;75H�[m�[m�[13;3H                                                                         �[13;75H�[m�[m�[14;3H                                                                         �[14;75H�[m�[m�[15;3H                                                                         �[15;75H�[m�[m�[16;3H                                                                         �[16;75H�[m�[16;78H �[5;75H�[23;4H The highlighted entry will be booted automatically in 1 seconds.   �[5;75H�[H�[J  Booting 'Rump'



root (hd0)

 Filesystem type is ext2fs, using whole disk

kernel /boot/rump-os.gz



============= Init TPM Front ================
Tpmfront:Error Unable to read device/vtpm/0/backend-id during tpmfront initialization! error = ENOENT
Tpmfront:Info Shutting down tpmfront
close blk: backend=/local/domain/0/backend/vbd/5561/2049 node=device/vbd/2049
close blk: backend=/local/domain/0/backend/vbd/5561/2064 node=device/vbd/2064
  start_info: 0x8f4000(VA)
    nr_pages: 0x26700
  shared_inf: 0x7dcd5000(MA)
     pt_base: 0x8f7000(VA)
nr_pt_frames: 0x9
    mfn_list: 0x7c0000(VA)
   mod_start: 0x0(VA)
     mod_len: 0
       flags: 0x0
    cmd_line: 
  stack:      0x7328c0-0x7b28c0
MM: Init
      _text: 0x0(VA)
     _etext: 0x44ef77(VA)
   _erodata: 0x5b2000(VA)
     _edata: 0x62bdd8(VA)
stack start: 0x7328c0(VA)
       _end: 0x7bf1a8(VA)
  start_pfn: 903
    max_pfn: 26700
Mapping memory range 0x903000 - 0x26700000
setting 0x0-0x5b2000 readonly
skipped 0x1000
MM: Initialise page allocator for a31000(a31000)-26700000(26700000)
MM: done
Demand map pfns at 26701000-2026701000.
Initialising timer interface
Initialising console ... done.
gnttab_table mapped at 0x26701000.
xenbus initialised on irq 1 mfn 0xb366f6
Failed to read device/pci/0/backend-id.
no backend
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 7.99.34 (RUMP-ROAST)
total memory = 302 MB
timecounter: Timecounters tick every 10.000 msec
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
cpu0 at thinair0: rump virtual cpu
root file system type: rumpfs
kern.module.path=/stand/amd64/7.99.34/modules
mainbus0 (root)
timecounter: Timecounter "bmktc" frequency 1000000000 Hz quality 100
mounted tmpfs on /tmp
rumprun: could not find start of json.  no config?

=== calling "rumprun" main() ===

rumprun: call to ``sigaction'' ignored
rumprun: call to ``_sys___sigprocmask14'' ignored
{"init terminating in do_boot",'no -root flag'}



Crash dump is being written to: erl_crash.dump...done

init terminating in do_boot (no -root flag)


=== ERROR: _exit(1) called ===
rump kernel halting...
syncing disks... done
unmounting file systems...
unmounted tmpfs on /tmp type tmpfs
unmounted rumpfs on / type rumpfs
unmounting done
minios: halting, reason=0
@edescourtis
Copy link
Author

edescourtis commented Nov 28, 2017

I also tried to hardcode rumprun/platform/xen/init.c like so:

/*-
 * Copyright (c) 2015 Antti Kantee.  All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include <bmk-rumpuser/core_types.h> /* XXX */

#include <mini-os/types.h>
#include <mini-os/hypervisor.h>
#include <mini-os/kernel.h>
#include <mini-os/xenbus.h>
#include <xen/xen.h>

#include <bmk-core/mainthread.h>
#include <bmk-core/platform.h>
#include <bmk-core/printf.h>
static char hardcoded_jsoncfg[] = "{\"net\":{\"if\":\"xenif0\",\"cloner\":\"true\",\"type\":\"inet\",\"method\":\"dhcp\"},\"env\":\"ERL_INETRC=/opt/erlang/erl_inetrc\",\"blk\":{\"source\":\"vnd\",\"path\":\"images/erlang.iso\",\"fstype\":\"blk\",\"mountpoint\":\"/opt/erlang\"},\"blk\":{\"source\":\"vnd\",\"path\":\"images/app.iso\",\"fstype\":\"blk\",\"mountpoint\":\"/apps/erlang\"},\"cmdline\":\"bin/beam.xen_pv.bin -- -no_epmd -root /opt/erlang/lib/erlang -progname erl -- -home /tmp -noshell -pa /apps/erlang -s echoserver start\",\"hostname\":\"rumprun-bin-beam.xen_pv.bin.ec2dir\"}";

static char *
get_xenstorecfg(void)
{
	xenbus_transaction_t txn;
	char *cfg;
	int retry;

	if (xenbus_transaction_start(&txn))
		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;
}

int
app_main(start_info_t *si)
{
	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 = hardcoded_jsoncfg;

	bmk_mainthread(cmdline);
	/* NOTREACHED */

	return 0;
}

But I still get the same error...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant