Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Vagrant workflow and documentation
The project previously did not include suggested development workflows or environments. The one workflow script included (`bin/rebuild-and-deploy`) was tightly coupled to my own local environment. This PR: - adds a Vagrantfile for a Ubuntu virtual machine running Xen - turns my existing (undocumented) workflows into helper scripts - adds a tutorial for building and running a program with AtmanOS - starts a document for developing AtmanOS itself
- Loading branch information
1 parent
dc39160
commit 056092b
Showing
13 changed files
with
203 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/build | ||
/.vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
Vagrant.configure(2) do |config| | ||
config.vm.box = "ubuntu/trusty64" | ||
|
||
# Disable the default shared folder, because we can't use VirtualBox shared | ||
# folders when running under Xen. | ||
config.vm.synced_folder ".", "/vagrant", disabled: true | ||
|
||
# Run vagrant rsync to update the shared images. | ||
config.vm.synced_folder "vagrant/", "/home/vagrant/atman", type: "rsync" | ||
|
||
# Install xen hypervisor | ||
config.vm.provision "shell", inline: <<-SHELL | ||
sudo apt-get update | ||
sudo apt-get install -y xen-hypervisor-4.4-amd64 gdb | ||
sed -i '1s|^|export PATH=$HOME/atman/bin:$PATH\\n|' .bashrc | ||
sudo reboot | ||
SHELL | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
GOROOT=build/go | ||
|
||
GOOS=atman exec "$GOROOT"/bin/go "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Developing AtmanOS | ||
|
||
## Build AtmanOS | ||
|
||
If you've just downloaded the AtmanOS project, run `bin/setup` to download the | ||
required dependencies and build AtmanOS. | ||
|
||
Once you've run `bin/setup`, rebuilding AtmanOS can be done with `make build`. | ||
|
||
## Testing changes | ||
|
||
You can test changes using basic workflow outlined in [Running locally with | ||
Vagrant](./running-locally-with-vagrant.md). | ||
|
||
There's also a helper script which automates the process of rebuilding AtmanOS | ||
and deploying a test program: | ||
|
||
``` | ||
$ bin/rebuild-and-deploy github.com/atmanos/example/hello | ||
``` | ||
|
||
It may be useful to automatically build and deploy whenever changes are made, | ||
which can be done with [entr](http://entrproject.org/): | ||
|
||
``` | ||
$ find src -type f | | ||
entr bin/rebuild-and-deploy github.com/atmanos/example/hello | ||
``` | ||
|
||
## Debug an AtmanOS kernel | ||
|
||
You can get a GDB session for a running (or crashed) kernel with: | ||
|
||
``` | ||
$ vagrant ssh -- debugvm hello | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Running locally with Vagrant | ||
|
||
The AtmanOS includes a Vagrantfile whch describes a development Xen | ||
environment. To use this development environment, you'll need: | ||
|
||
* Vagrant: https://www.vagrantup.com/ | ||
* VirtualBox: https://www.virtualbox.org/ | ||
|
||
If you're on OS X and use Homebrew, you can get these with: | ||
|
||
``` | ||
$ brew cask install vagrant virtualbox | ||
``` | ||
|
||
## Build AtmanOS | ||
|
||
If you've just downloaded the AtmanOS project, run `bin/setup` to download the | ||
required dependencies and build AtmanOS. | ||
|
||
Once you've run `bin/setup`, rebuilding AtmanOS can be done with `make build`. | ||
|
||
## Provision the virtual machine | ||
|
||
From the root directory of the AtmanOS project, run: | ||
|
||
``` | ||
$ vagrant up | ||
``` | ||
|
||
The first time you run this, it will take a while, as it needs to install Xen | ||
and reboot the virtual machine. | ||
|
||
Once the command completes, you should be able to connect to the machine by | ||
running `vagrant ssh`. | ||
|
||
At any time you can use `vagrant halt` to shut down the virtual machine, or | ||
`vagrant pause` to pause it for faster boot later. | ||
|
||
## Run an AtmanOS kernel | ||
|
||
For this section, we'll be using the hello program from the [repository of | ||
AtmanOS example programs][example]. | ||
|
||
[example]: github.com/atmanos/example | ||
|
||
Download the program with: | ||
|
||
``` | ||
$ go get github.com/atmanos/example/hello | ||
``` | ||
|
||
You can run `hello` locally to see that it first prints "Hello, world", and | ||
then prints the current time every few seconds. | ||
|
||
But we want to run the `hello` program on Xen! | ||
|
||
To do that, we'll first need to build a kernel image with `atman`: | ||
|
||
``` | ||
$ bin/atman build -o vagrant/images/hello \ | ||
github.com/atmanos/example/hello | ||
``` | ||
|
||
We told `atman` to put the built image in `vagrant/images`. That allows up to | ||
transfer the image to the Vagrant environment with: | ||
|
||
``` | ||
$ vagrant rsync | ||
``` | ||
|
||
Finally, we can run our `hello` kernel with: | ||
|
||
``` | ||
$ vagrant ssh -- startvm hello | ||
``` | ||
|
||
The [`startvm` command](../vagrant/bin/startvm) is a wrapper for a few Xen | ||
commands, stopping any existing machine with the same name, and then starting a | ||
new machine with the [default template](../vagrant/template.xl). | ||
|
||
To see the output of `hello`, attach to the console with [another Xen | ||
wrapper](../vagrant/bin/console): | ||
|
||
``` | ||
$ vagrant ssh -- console hello | ||
Hello, world | ||
The current time is 2016-04-23 23:53:05.651799283 +0000 UTC | ||
The current time is 2016-04-23 23:53:10.651806585 +0000 UTC | ||
The current time is 2016-04-23 23:53:15.651807123 +0000 UTC | ||
``` | ||
|
||
Success! | ||
|
||
Now we can stop the `hello` machine with: | ||
|
||
``` | ||
$ vagrant ssh -- sudo xl destroy hello | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
VMNAME=$1 | ||
|
||
sudo xl console $VMNAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
VMNAME=$1 | ||
domid=$(sudo xl domid $VMNAME) | ||
|
||
sudo /usr/lib/xen-4.4/bin/gdbsx -a $domid 64 9999 & | ||
sleep 1 | ||
gdb -ex "target remote localhost:9999" $HOME/atman/images/$VMNAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
VMNAME=$1 | ||
|
||
sudo xl destroy $VMNAME 2>/dev/null | ||
sudo xl dmesg -c &>/dev/null | ||
sudo xl create -e $HOME/atman/template.xl \ | ||
"name = '$VMNAME'" \ | ||
"kernel = '$HOME/atman/images/$VMNAME'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
vcpus = 1 | ||
memory = 16 | ||
|
||
on_crash = 'preserve' |