Skip to content

My first three applications in Toro

Matias Ezequiel Vara Larsen edited this page Jan 13, 2019 · 10 revisions

Introduction

We present how to compile and run three applications in Toro. These are simple examples that show a particular functionality of the kernel. We begin with the classic Hello World and then we continue by showing more advanced functionalities like Networking and Filesystem. We encourage to start with the first one and then continue with the next one and so on. Let's first install the minimal set of tools to compile and run Toro.

NOTE: Examples can be found in examples directory. Each example contains

Windows Users

On Windows, examples can be compiled by using Lazarus IDE. To install it, please follow the wiki here. Once installed, you need to install QEMU to run the examples. This can be downloaded from here.

Linux Users

On Linux, you need first to install Lazarus by doing:

apt-get install lazarus

To run the example, you need to install KVM so let's install it by doing:

sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils virtinst

We are ready to go through the examples.

Hello World Example

This is a simple application that prints HelloWorld in the screen. This application is compiled together with the kernel. After the kernel is loaded and initialized, the user application is executed. In our example, this application just prints something to the screen. To start, first clone the code of torokernel by doing:

git clone https://github.com/MatiasVara/torokernel.git

Windows Users

From Lazarus, open the project HelloWorld.lpi which is located in torokernel/examples/HelloWorld. This is a simple example that only prints something in the screen, however, it is enough to show how compilation and running work. To compile HelloWorld.pas once opened it, you only need to go to Run > Compile or just pressing CTRL+F9. If everything works well we will get the following screen:

If it fails, it would be necessary to use the whole path of the tools to compile correctly. Please go to Project > Project Options, and then select Compiler Commands. There, complete the path of fpc and build.exe command with the full path. Note that build.exe will be generated in Execute before, and it should be located in torokernel/builder directory.

To run the example in Lazarus, you have to check the box On run project execute Run File command instruction which is located in Run > Configure Build and Run File. If everything is correctly set up, we can run the application by pressing F9 or going to Project > Run. We will get the following screen:

Note

If Lazarus fails to execute QEMU, please set up the full path of QEMU. This can be done by going to Run > Configure Build and Run File. And then, in Run tab, edit the Run command by setting up the full path. For example, if QEMU is located in Program Files, the path will result:

`{%RunCommand "C:\Program Files\qemu\qemu-system-x86_64.exe" -m 512 -smp 2 -drive format=raw,file=HelloWorld.img}

Linux Users

To try this example in Linux, please follow the instructions here.

If you face the issue could not open disk image : Permission denied, edit /etc/libvirt/qemu.conf and uncomment user/group to work as root, then restart libvirtd by doing systemctl restart libvirtd . For more details see https://github.com/jedi4ever/veewee/issues/996.

If you want to make the VNC to listen in all interfaces, edit /etc/libvirt/qemu.conf, uncomment vnc_listen = "0.0.0.0" and then restart libvirtd. This makes possible to get the guest's console from a remote host by using the ip of the host:

Hello World Microservice Example

In the next example, we focus on the using of Networking. This example is very similar to the Hello World example but this time Toro will send it over the Network by using sockets. We first need to configure the access to the network. This mechanism varies from Windows to Linux.

Windows Users

To run the examples that use networking we need first to install a TAP vpn device and name it TAP2. To do so, download openvpn from here. After installed, it is need to set up the adapter properties as follows:

This configures the host IP as 192.100.200.10. The IP of Toro VM is static to 192.100.200.100. It could be possible that the Firewall blocks the ICMP packets to host. In that case, it is needed to disable the Firewall to make the example works.

Once everything is installed, go to Lazarus and open the project HelloWorldMicroservice.lpi which is located in torokernel/examples/HelloWorldMicroservice. To compile HelloWorldMicroservice.pas once opened it, you only need to go to Run > Compile or just pressing CTRL+F9. To run the example in Lazarus, you have to check the box On run project execute Run File command instruction which is located in Run > Configure Build and Run File. If everything is correctly set up, we can run the application by pressing F9 or going to Project > Run.

To check that Toro is alive you can open your web browser and go to http://192.100.200.100:8080. You will get something like:

Linux Users

In Linux, you have just to follow the instructions here.

Simple WebServer Example

In this example, we use the Filesystem API to build a static web server. The example reads a file named index.html and sends it each time a client requests it. The file index.html is located in torokernel/examples/StaticWebServer/StaticWebServerFiles. This example uses the FAT driver.

Windows Users

In Windows, just compile and run the example as it is explained above. If you try to browse to the guest you will get the content of the file index.html which is located in `torokernel/examples/StaticWebServer/StaticWebServerFiles. If everything went well you will get the following output.

Linux Users

In Linux, you have just to follow the instructions here.

You can’t perform that action at this time.