This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Makefile, configuration files and scripts
Update the README with instructions on setting up, configuring, building and running the SQLite app with Unikraft. As part of it, add Makefile files, configuration files and scripts; they are referenced in the `README.md` file. Current instructions cover the use of QEMU/KVM platform (both on x86_64 and on AArch64) and GCC. Firecraker/KVM, Xen, Linux platforms and Clang are not yet documented. Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com>
- Loading branch information
Showing
10 changed files
with
917 additions
and
29 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
UK_ROOT ?= $(PWD)/.unikraft/unikraft | ||
UK_LIBS ?= $(PWD)/.unikraft/libs | ||
LIBS := $(UK_LIBS)/musl:$(UK_LIBS)/sqlite | ||
|
||
all: | ||
@$(MAKE) -C $(UK_ROOT) A=$(PWD) L=$(LIBS) | ||
|
||
$(MAKECMDGOALS): | ||
@$(MAKE) -C $(UK_ROOT) A=$(PWD) L=$(LIBS) $(MAKECMDGOALS) | ||
|
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,2 @@ | ||
$(eval $(call addlib,appsqlite)) | ||
|
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,50 +1,221 @@ | ||
# SQLite on Unikraft | ||
|
||
This application starts a SQLite database. | ||
This application starts an SQLite web server with Unikraft. | ||
Follow the instructions below to set up, configure, build and run SQLite. | ||
|
||
To configure, build and run the application you need to have [kraft](https://github.com/unikraft/kraft) installed. | ||
## Set Up | ||
|
||
To be able to interact with the database, configure the application to run on the KVM platform: | ||
``` | ||
$ kraft configure -p kvm -m x86_64 | ||
The following repositories are required for SQLite: | ||
|
||
* The application repository (this repository): [`app-sqlite`](https://github.com/unikraft/app-sqlite) | ||
* The Unikraft core repository: [`unikraft`](https://github.com/unikraft/unikraft) | ||
* Library repositories: | ||
* The SQLite "library" repository: [`lib-sqlite`](https://github.com/unikraft/lib-sqlite) | ||
* The standard C library: [`lib-musl`](https://github.com/unikraft/lib-musl) | ||
|
||
Follow the steps below for the setup: | ||
|
||
1. First clone the [`app-sqlite` repository](https://github.com/unikraft/app-sqlite) repository in the `sqlite/` directory: | ||
|
||
```console | ||
$ git clone https://github.com/unikraft/app-sqlite sqlite | ||
``` | ||
|
||
Enter the `sqlite/` directory: | ||
|
||
```console | ||
$ cd sqlite/ | ||
|
||
$ ls | ||
fs0/ kraft.yaml Makefile Makefile.uk.default README.md run-aarch64* run-x86_64* | ||
``` | ||
|
||
1. While inside the `sqlite/` directory, create the `.unikraft/` directory: | ||
|
||
```console | ||
$ mkdir .unikraft | ||
``` | ||
|
||
Enter the `.unikraft/` directory: | ||
|
||
```console | ||
$ cd .unikraft/ | ||
``` | ||
|
||
1. While inside the `.unikraft` directory, clone the [`unikraft` repository](): | ||
|
||
```console | ||
$ git clone https://github.com/unikraft/unikraft unikraft | ||
``` | ||
|
||
1. While inside the `.unikraft/` directory, create the `libs/` directory: | ||
|
||
```console | ||
$ mkdir libs | ||
``` | ||
|
||
1. While inside the `.unikraft/` directory, clone the library repositories in the `libs/` directory: | ||
|
||
```console | ||
$ git clone https://github.com/unikraft/lib-sqlite libs/sqlite | ||
|
||
$ git clone https://github.com/unikraft/lib-musl libs/musl | ||
``` | ||
|
||
1. Get back to the application directory: | ||
|
||
```console | ||
$ cd ../ | ||
``` | ||
|
||
Use the `tree` command to inspect the contents of the `.unikraft/` directory. | ||
It should print something like this: | ||
|
||
```console | ||
$ tree -F -L 2 .unikraft/ | ||
.unikraft/ | ||
|-- libs/ | ||
| |-- musl/ | ||
| `-- sqlite/ | ||
`-- unikraft/ | ||
|-- arch/ | ||
|-- Config.uk | ||
|-- CONTRIBUTING.md | ||
|-- COPYING.md | ||
|-- include/ | ||
|-- lib/ | ||
|-- Makefile | ||
|-- Makefile.uk | ||
|-- plat/ | ||
|-- README.md | ||
|-- support/ | ||
`-- version.mk | ||
|
||
10 directories, 7 files | ||
``` | ||
|
||
## Configure | ||
|
||
Configuring, building and running a Unikraft application depends on our choice of platform and architecture. | ||
Currently supported platforms are QEMU (KVM), Xen and linuxu. | ||
QEMU (KVM) is known to be working, so we focus on that. | ||
|
||
Supported architectures are x86_64 and AArch64. | ||
|
||
Use the corresponding the configuration files (`config-...`), according to your choice of platform and architecture. | ||
|
||
### QEMU x86_64 | ||
|
||
Use the `config-qemu-x86_64` configuration file together with `make defconfig` to create the configuration file: | ||
|
||
```console | ||
$ UK_DEFCONFIG=$(pwd)/config-qemu-x84_64 make defconfig | ||
``` | ||
|
||
Build the application: | ||
This results in the creation of the `.config` file: | ||
|
||
```console | ||
$ ls .config | ||
.config | ||
``` | ||
$ kraft build | ||
|
||
This file will be used in the build step. | ||
|
||
### QEMU AArch64 | ||
|
||
Use the `config-qemu-aarch64` configuration file together with `make defconfig` to create the configuration file: | ||
|
||
```console | ||
$ UK_DEFCONFIG=$(pwd)/config-qemu-aarch64 make defconfig | ||
``` | ||
|
||
And, finally, run the application: | ||
Similar to the x86_64 configuration, this results in the creation of the `.config` file that will be used in the build step. | ||
|
||
## Build | ||
|
||
To build the application, just run `make` from the application directory: | ||
|
||
```console | ||
``` | ||
$ kraft run | ||
SQLite version 3.30.1 2019-10-10 20:19:45 | ||
|
||
## Run | ||
|
||
Run the resulting image with the `run-...` scripts. | ||
|
||
### QEMU x86_64 | ||
|
||
To run the QEMU x86_64 build, use `run-qemu-x86_64.sh`: | ||
|
||
```console | ||
$ ./run-qemu-x86_64.sh | ||
SeaBIOS (version rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org) | ||
|
||
iPXE (http://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+06FD0FF0+06F30FF0 CA00 | ||
|
||
Booting from ROM..Powered by | ||
o. .o _ _ __ _ | ||
Oo Oo ___ (_) | __ __ __ _ ' _) :_ | ||
oO oO ' _ `| | |/ / _)' _` | |_| _) | ||
oOo oOO| | | | | (| | | (_) | _) :_ | ||
OoOoO ._, ._:_:_,\_._, .__,_:_, \___) | ||
Atlas 0.13.1~5eb820bd | ||
-- warning: cannot find home directory; cannot read ~/.sqliterc | ||
SQLite version 3.40.1 2022-12-28 14:03:47 | ||
Enter ".help" for usage hints. | ||
Connected to a transient in-memory database. | ||
Use ".open FILENAME" to reopen on a persistent database. | ||
sqlite> | ||
sqlite> | ||
``` | ||
|
||
If you want to have more control you can also configure, build and run the application manually. | ||
There is a filesystem `./fs0/` attached to the SQLite application, you can test it by running: | ||
|
||
To configure it for the KVM platform: | ||
``` | ||
$ make menuconfig | ||
```console | ||
sqlite> .read script.sql | ||
sqlite> .tables | ||
tab | ||
sqlite> select * from tab limit 3; | ||
-8608611554947236596|-3220254456267143868 | ||
-2845343986204829972|-4062591257759034921 | ||
-4925370139073632296|-3631473384244875208 | ||
sqlite> .open chinook.db | ||
sqlite> .tables | ||
Album Employee InvoiceLine PlaylistTrack | ||
Artist Genre MediaType Track | ||
Customer Invoice Playlist tab | ||
sqlite> select * from Album limit 3; | ||
1|For Those About To Rock We Salute You|1 | ||
2|Balls to the Wall|2 | ||
3|Restless and Wild|2 | ||
sqlite> .exit | ||
$ | ||
``` | ||
|
||
Build the application: | ||
``` | ||
$ make | ||
``` | ||
To close the QEMU SQLite application, use the `.exit` command or the `Ctrl+a x` keyboard shortcut; | ||
that is press the `Ctrl` and `a` keys at the same time and then, separately, press the `x` key. | ||
|
||
Run the application: | ||
``` | ||
sudo qemu-system-x86_64 -fsdev local,id=myid,path=$(pwd)/fs0,security_model=none \ | ||
-device virtio-9p-pci,fsdev=myid,mount_tag=fs0,disable-modern=on,disable-legacy=off \ | ||
-kernel "build/app-sqlite_kvm-x86_64" \ | ||
-enable-kvm \ | ||
-nographic | ||
``` | ||
### QEMU AArch64 | ||
|
||
To run the AArch64 build, use `run-qemu-aarch64.sh`: | ||
|
||
```console | ||
$ ./run-qemu-aarch64.sh | ||
[ 0.014936] ERR: [libkvmvirtio] <virtio_bus.c @ 140> Failed to find the driver for the virtio device 0x40338020 (id:1) | ||
[ 0.015707] ERR: [libkvmvirtio] <virtio_pci.c @ 425> Failed to register the virtio device: -14 | ||
[ 0.015890] ERR: [libkvmpci] <pci_bus_arm64.c @ 100> PCI 00:01.00: Failed to initialize device driver | ||
Powered by | ||
o. .o _ _ __ _ | ||
Oo Oo ___ (_) | __ __ __ _ ' _) :_ | ||
oO oO ' _ `| | |/ / _)' _` | |_| _) | ||
oOo oOO| | | | | (| | | (_) | _) :_ | ||
OoOoO ._, ._:_:_,\_._, .__,_:_, \___) | ||
Atlas 0.13.1~5eb820bd | ||
-- warning: cannot find home directory; cannot read ~/.sqliterc | ||
SQLite version 3.40.1 2022-12-28 14:03:47 | ||
Enter ".help" for usage hints. | ||
Connected to a transient in-memory database. | ||
Use ".open FILENAME" to reopen on a persistent database. | ||
sqlite> | ||
``` | ||
|
||
For more information about `kraft` type ```kraft -h``` or read the | ||
[documentation](http://docs.unikraft.org). | ||
You can ignore the errors at the top. | ||
Use the same commands as above to test it, then close the application by running `.exit` or using the `Ctrl+a x` shortcut. |
Oops, something went wrong.