-
Notifications
You must be signed in to change notification settings - Fork 57
feat(library): Introduce SQLite 3.44 as library #163
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
Open
prasoon054
wants to merge
1
commit into
unikraft:main
Choose a base branch
from
prasoon054:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,12 @@ | ||
FROM keinos/sqlite3 as build | ||
FROM scratch | ||
|
||
COPY --from=build /usr/bin/sqlite3 /usr/bin/sqlite3 | ||
|
||
COPY --from=build /lib/ld-musl-x86_64.so.1 /lib/ld-musl-x86_64.so.1 | ||
COPY --from=build /usr/lib/libz.so.1 /usr/lib/libz.so.1 | ||
COPY --from=build /lib/ld-musl-x86_64.so.1 /lib/ld-musl-x86_64.so.1 | ||
|
||
COPY ./build.sql build.sql | ||
COPY ./query.sql query.sql | ||
COPY ./init.sql init.sql |
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,146 @@ | ||
spec: v0.6 | ||
|
||
name: sqlite | ||
|
||
# Use the Dockerfile we just created as the root filesystem description | ||
rootfs: ./Dockerfile | ||
|
||
# The command to run the sqlite3 application inside the unikernel | ||
cmd: ["/usr/bin/sqlite3", "sales.db", "--init", "init.sql"] | ||
|
||
template: | ||
source: https://github.com/unikraft/app-elfloader.git | ||
version: staging | ||
|
||
unikraft: | ||
source: https://github.com/unikraft/unikraft.git | ||
version: staging | ||
kconfig: | ||
# Configurations options for app-elfloader | ||
# (they can't be part of the template atm) | ||
CONFIG_APPELFLOADER_ARCH_PRCTL: 'y' | ||
CONFIG_APPELFLOADER_BRK: 'y' | ||
CONFIG_APPELFLOADER_CUSTOMAPPNAME: 'y' | ||
CONFIG_APPELFLOADER_STACK_NBPAGES: 128 | ||
CONFIG_APPELFLOADER_VFSEXEC_EXECBIT: 'n' | ||
CONFIG_APPELFLOADER_VFSEXEC: 'y' | ||
CONFIG_APPELFLOADER_HFS: 'y' | ||
CONFIG_APPELFLOADER_HFS_ETCRESOLVCONF: 'y' | ||
CONFIG_APPELFLOADER_HFS_ETCHOSTS: 'y' | ||
CONFIG_APPELFLOADER_HFS_ETCHOSTNAME: 'y' | ||
CONFIG_APPELFLOADER_HFS_REPLACEEXIST: 'y' | ||
# Unikraft options | ||
CONFIG_HAVE_PAGING_DIRECTMAP: 'y' | ||
CONFIG_HAVE_PAGING: 'y' | ||
CONFIG_I8042: 'y' | ||
CONFIG_LIBDEVFS_AUTOMOUNT: 'y' | ||
CONFIG_LIBDEVFS_DEV_NULL: 'y' | ||
CONFIG_LIBDEVFS_DEV_STDOUT: 'y' | ||
CONFIG_LIBDEVFS_DEV_ZERO: 'y' | ||
CONFIG_LIBDEVFS: 'y' | ||
CONFIG_LIBPOSIX_ENVIRON_ENVP0: "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | ||
CONFIG_LIBPOSIX_ENVIRON_ENVP1: "LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib" | ||
CONFIG_LIBPOSIX_ENVIRON_ENVP2: "HOME=/" | ||
CONFIG_LIBPOSIX_ENVIRON: 'y' | ||
CONFIG_LIBPOSIX_ENVIRON_LIBPARAM: 'y' | ||
CONFIG_LIBPOSIX_ENVIRON_LIBPARAM_MAXCOUNT: '64' | ||
CONFIG_LIBPOSIX_EVENTFD: 'y' | ||
CONFIG_LIBPOSIX_FDIO: 'y' | ||
CONFIG_LIBPOSIX_FDTAB: 'y' | ||
CONFIG_LIBPOSIX_FUTEX: 'y' | ||
CONFIG_LIBPOSIX_MMAP: 'y' | ||
CONFIG_LIBPOSIX_NETLINK: 'y' | ||
CONFIG_LIBPOSIX_PIPE: 'y' | ||
CONFIG_LIBPOSIX_POLL: 'y' | ||
CONFIG_LIBPOSIX_PROCESS_CLONE: 'y' | ||
CONFIG_LIBPOSIX_SOCKET: 'y' | ||
CONFIG_LIBPOSIX_SYSINFO: 'y' | ||
CONFIG_LIBPOSIX_TIME: 'y' | ||
CONFIG_LIBPOSIX_TIMERFD: 'y' | ||
CONFIG_LIBPOSIX_UNIXSOCKET: 'y' | ||
CONFIG_LIBPOSIX_USER_GID: 0 | ||
CONFIG_LIBPOSIX_USER_GROUPNAME: "root" | ||
CONFIG_LIBPOSIX_USER_UID: 0 | ||
CONFIG_LIBPOSIX_USER_USERNAME: "root" | ||
CONFIG_LIBPOSIX_USER: 'y' | ||
CONFIG_LIBRAMFS: 'y' | ||
CONFIG_LIBSYSCALL_SHIM_HANDLER_ULTLS: 'y' | ||
CONFIG_LIBSYSCALL_SHIM_HANDLER: 'y' | ||
CONFIG_LIBSYSCALL_SHIM_LEGACY_VERBOSE: 'y' | ||
CONFIG_LIBSYSCALL_SHIM: 'y' | ||
CONFIG_LIBUKALLOCPOOL: 'y' | ||
CONFIG_LIBUKBLKDEV_MAXNBQUEUES: '1' | ||
CONFIG_LIBUKBLKDEV_DISPATCHERTHREADS: 'y' | ||
CONFIG_LIBUKBLKDEV_SYNC_IO_BLOCKED_WAITING: 'y' | ||
CONFIG_LIBUKBLKDEV: 'y' | ||
CONFIG_LIBUKBOOT_BANNER_MINIMAL: 'y' | ||
CONFIG_LIBUKBOOT_HEAP_BASE: '0x400000000' | ||
CONFIG_LIBUKBOOT_MAINTHREAD: 'y' | ||
CONFIG_LIBUKBOOT_SHUTDOWNREQ_HANDLER: 'y' | ||
CONFIG_LIBUKCPIO: 'y' | ||
CONFIG_LIBUKDEBUG_CRASH_SCREEN: 'y' | ||
CONFIG_LIBUKDEBUG_ENABLE_ASSERT: 'y' | ||
CONFIG_LIBUKDEBUG_PRINT_SRCNAME: 'n' | ||
CONFIG_LIBUKDEBUG_PRINT_TIME: 'y' | ||
CONFIG_LIBUKDEBUG_PRINTK_ERR: 'y' | ||
CONFIG_LIBUKDEBUG_PRINTK: 'y' | ||
CONFIG_LIBUKDEBUG: 'y' | ||
CONFIG_LIBUKFALLOC: 'y' | ||
CONFIG_LIBUKMPI: 'n' | ||
CONFIG_LIBUKSIGNAL: 'y' | ||
CONFIG_LIBUKRANDOM_DEVFS: 'y' | ||
CONFIG_LIBUKRANDOM: 'y' | ||
CONFIG_LIBUKRANDOM_GETRANDOM: 'y' | ||
CONFIG_LIBUKVMEM_DEFAULT_BASE: '0x0000001000000000' | ||
CONFIG_LIBUKVMEM_DEMAND_PAGE_IN_SIZE: 12 | ||
CONFIG_LIBUKVMEM_PAGEFAULT_HANDLER_PRIO: 4 | ||
CONFIG_LIBUKVMEM: 'y' | ||
CONFIG_LIBVFSCORE_AUTOMOUNT_CI: 'y' | ||
CONFIG_LIBVFSCORE_AUTOMOUNT_CI_EINITRD: 'y' | ||
CONFIG_LIBVFSCORE_AUTOMOUNT_UP: 'y' | ||
CONFIG_LIBVFSCORE_AUTOMOUNT: 'y' | ||
CONFIG_LIBVFSCORE_NONLARGEFILE: 'y' | ||
CONFIG_LIBVFSCORE: 'y' | ||
CONFIG_LIBUK9P: 'y' | ||
CONFIG_OPTIMIZE_DEADELIM: 'y' | ||
CONFIG_OPTIMIZE_LTO: 'y' | ||
CONFIG_PAGING: 'y' | ||
CONFIG_STACK_SIZE_PAGE_ORDER: 4 # 128 * 4K = 512K | ||
CONFIG_UKPLAT_MEMREGION_MAX_COUNT: 64 | ||
CONFIG_LIBUKNETDEV_EINFO_LIBPARAM: 'y' | ||
# Debug options | ||
# CONFIG_LIBUKDEBUG_PRINTD: 'y' | ||
# CONFIG_LIBUKDEBUG_PRINTK_INFO: 'y' | ||
# CONFIG_LIBSYSCALL_SHIM_STRACE: 'y' | ||
# CONFIG_LIBSYSCALL_SHIM_DEBUG: 'y' | ||
|
||
libraries: | ||
lwip: | ||
source: https://github.com/unikraft/lib-lwip.git | ||
version: staging | ||
kconfig: | ||
CONFIG_LWIP_LOOPIF: 'y' | ||
CONFIG_LWIP_UKNETDEV: 'y' | ||
CONFIG_LWIP_LOOPBACK: 'y' | ||
CONFIG_LWIP_TCP: 'y' | ||
CONFIG_LWIP_UDP: 'y' | ||
CONFIG_LWIP_RAW: 'y' | ||
CONFIG_LWIP_WND_SCALE: 'y' | ||
CONFIG_LWIP_TCP_KEEPALIVE: 'y' | ||
CONFIG_LWIP_THREADS: 'y' | ||
CONFIG_LWIP_HEAP: 'y' | ||
CONFIG_LWIP_SOCKET: 'y' | ||
CONFIG_LWIP_AUTOIFACE: 'y' | ||
CONFIG_LWIP_IPV4: 'y' | ||
CONFIG_LWIP_DHCP: 'y' | ||
CONFIG_LWIP_DNS: 'y' | ||
CONFIG_LWIP_NUM_TCPCON: 64 | ||
CONFIG_LWIP_NUM_TCPLISTENERS: 64 | ||
CONFIG_LWIP_ICMP: 'y' | ||
libelf: | ||
source: https://github.com/unikraft/lib-libelf.git | ||
version: staging | ||
|
||
targets: | ||
- fc/x86_64 | ||
- qemu/x86_64 |
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,16 @@ | ||
# SQLite 3.44 Image | ||
|
||
This directory contains the example for `sqlite:3.44` image. | ||
|
||
To run this image, [install Unikraft's companion command-line toolchain `kraft`](https://unikraft.org/docs/cli) and then you can run: | ||
|
||
``` | ||
kraft build . | ||
kraft run . | ||
``` | ||
|
||
Once executed you will be get the output of an SQL script. | ||
|
||
## See also | ||
|
||
- [How to run unikernels locally in Unikraft's Documentation](https://unikraft.org/docs/cli/running). |
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,55 @@ | ||
-- Drop tables if they exist | ||
DROP TABLE IF EXISTS OrderDetail; | ||
DROP TABLE IF EXISTS [Order]; | ||
DROP TABLE IF EXISTS Product; | ||
DROP TABLE IF EXISTS Customer; | ||
|
||
-- Create Customer table | ||
CREATE TABLE Customer ( | ||
CustomerID INTEGER NOT NULL PRIMARY KEY, | ||
Name TEXT NOT NULL, | ||
Email TEXT | ||
); | ||
|
||
-- Create Product table | ||
CREATE TABLE Product ( | ||
ProductID INTEGER NOT NULL PRIMARY KEY, | ||
ProductName TEXT NOT NULL, | ||
Price REAL NOT NULL | ||
); | ||
|
||
-- Create Order table | ||
CREATE TABLE [Order] ( | ||
OrderID INTEGER NOT NULL PRIMARY KEY, | ||
CustomerID INTEGER NOT NULL, | ||
OrderDate TEXT NOT NULL, | ||
FOREIGN KEY (CustomerID) REFERENCES Customer(CustomerID) | ||
); | ||
|
||
-- Create OrderDetail table | ||
CREATE TABLE OrderDetail ( | ||
OrderDetailID INTEGER NOT NULL PRIMARY KEY, | ||
OrderID INTEGER NOT NULL, | ||
ProductID INTEGER NOT NULL, | ||
Quantity INTEGER NOT NULL, | ||
FOREIGN KEY (OrderID) REFERENCES [Order](OrderID), | ||
FOREIGN KEY (ProductID) REFERENCES Product(ProductID) | ||
); | ||
|
||
-- Populate Customer table | ||
INSERT INTO Customer (CustomerID, Name, Email) VALUES (1, 'Alice Smith', 'alice@example.com'); | ||
INSERT INTO Customer (CustomerID, Name, Email) VALUES (2, 'Bob Johnson', 'bob@example.com'); | ||
|
||
-- Populate Product table | ||
INSERT INTO Product (ProductID, ProductName, Price) VALUES (1, 'Laptop', 999.99); | ||
INSERT INTO Product (ProductID, ProductName, Price) VALUES (2, 'Smartphone', 499.99); | ||
INSERT INTO Product (ProductID, ProductName, Price) VALUES (3, 'Headphones', 89.99); | ||
|
||
-- Populate Order table | ||
INSERT INTO [Order] (OrderID, CustomerID, OrderDate) VALUES (1, 1, '2025-03-20'); | ||
INSERT INTO [Order] (OrderID, CustomerID, OrderDate) VALUES (2, 2, '2025-03-21'); | ||
|
||
-- Populate OrderDetail table | ||
INSERT INTO OrderDetail (OrderDetailID, OrderID, ProductID, Quantity) VALUES (1, 1, 1, 1); | ||
INSERT INTO OrderDetail (OrderDetailID, OrderID, ProductID, Quantity) VALUES (2, 1, 3, 2); | ||
INSERT INTO OrderDetail (OrderDetailID, OrderID, ProductID, Quantity) VALUES (3, 2, 2, 1); |
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 @@ | ||
.read build.sql | ||
.read query.sql |
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,17 @@ | ||
.headers on | ||
.mode column | ||
|
||
-- List all customers | ||
SELECT * FROM Customer; | ||
|
||
-- List orders with customer names and order dates | ||
SELECT O.OrderID, C.Name AS Customer, O.OrderDate | ||
FROM [Order] O | ||
JOIN Customer C ON O.CustomerID = C.CustomerID; | ||
|
||
-- List order details with product names, quantities, and prices | ||
SELECT O.OrderID, C.Name AS Customer, P.ProductName, OD.Quantity, P.Price | ||
FROM OrderDetail OD | ||
JOIN [Order] O ON OD.OrderID = O.OrderID | ||
JOIN Customer C ON O.CustomerID = C.CustomerID | ||
JOIN Product P ON OD.ProductID = P.ProductID; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.