bsdkrun 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4ab49439569d91cb726f6aba3a2aff97bcd5ebae0fcc08daff49386d37493a6
4
- data.tar.gz: 8e5e860d49fab4b63b29254f5e886e16db71e031bd1e35b0f24602e4c619c858
3
+ metadata.gz: b23de4b48a88b521c5909ad2aa610d8557e9b06661e450db3d862292cc3bb296
4
+ data.tar.gz: be6175dd5884c7ec861a57f355c3dff05d01e759355117d8e21e27904b717063
5
5
  SHA512:
6
- metadata.gz: 6e88557a8e9eaa412bd43bcf67d25b8ed63970fbdefb42edfe81ff07b94b4df0013870c8fa1cf98ea1797ca607eb9481839934fea65eb34d0a34be507c1ee267
7
- data.tar.gz: 5980d80cdbc6d908ce8c489a5728699f7ae9fcabeeac325c7043aad8d6f11051091be4631047f1d69c4870546eeda3f902f79e7c2b8ffe1ce06805c509673c71
6
+ metadata.gz: 9b2b575fc9be711c375a053537e8ba687d162c4180c1e7075aaa5e3d27d8992655615c10c28ca5894a066213a3d8382c9f6f7c31fdca7118b8dc72707bddf86f
7
+ data.tar.gz: 38d9ba56709b1b870df9873d70c658e68534fb2eb90fa6c6793a2e87aa80d9fe1f076a6324579f4834a9241554960b35c6501ebc05e3896a781da3166be2c565
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # bsdkrun (Ruby SDK)
2
2
 
3
- A Ruby SDK for [**bsdkrun**](https://github.com/tsirysndr/bsdkrun) — a Firecracker-style microVM launcher for **BSD and Linux** guests on macOS and
3
+ A Ruby SDK for [**bsdkrun**](https://github.com/tsirysndr/bsdkrun) — a Firecracker-style microVM launcher for **BSD, Linux, and unikernel** guests on macOS and
4
4
  Linux, built on [libkrun](https://github.com/containers/libkrun). Boot and drive microVMs programmatically, inspired by the **Vercel** and **Deno** Sandbox SDKs.
5
5
 
6
6
  The SDK shells out to the `bsdkrun` binary, so it has **zero runtime
@@ -213,10 +213,13 @@ client.stop(id)
213
213
  client.remove([id])
214
214
  ```
215
215
 
216
- `client.run_linux`/`run_bsd`/`run_nanos`/`run_unikraft`/`run_osv`/`run_flavor`
217
- each take the same options as the corresponding GraphQL mutation
216
+ `client.run_linux`/`run_bsd`/`run_nanos`/`run_unikraft`/`run_solo5`/`run_osv`/
217
+ `run_flavor` each take the same options as the corresponding GraphQL mutation
218
218
  (`daemon/src/graphql.rs`) — `run_bsd(os: "freebsd", ...)`, etc. — and return
219
- the new machine's id. `stop`/`start`/`remove`/`update`/`commit` return a
219
+ the new machine's id. `run_solo5` boots a MirageOS unikernel under the
220
+ `solo5-hvt` tender rather than libkrun:
221
+ `run_solo5(path: "dist/hello.hvt", args: ["--ipv4=10.0.0.2/24"])`.
222
+ `stop`/`start`/`remove`/`update`/`commit` return a
220
223
  `CommandResult` (`exit_code`, `stdout`, `stderr`).
221
224
 
222
225
  For a live terminal instead of a one-shot `exec`, use `shell`:
data/lib/bsdkrun/args.rb CHANGED
@@ -66,6 +66,7 @@ module Bsdkrun
66
66
  when "firmware" then firmware_args(opts)
67
67
  when "kernel" then kernel_args(opts)
68
68
  when "unikraft" then unikraft_args(opts)
69
+ when "solo5" then solo5_args(opts)
69
70
  when "nanos" then nanos_args(opts)
70
71
  when "osv" then osv_args(opts)
71
72
  else raise ArgumentError, "unknown os: #{opts[:os].inspect}"
@@ -167,5 +168,24 @@ module Bsdkrun
167
168
  a.concat(net_args(opts[:net])).concat(name_args(opts)).concat(vm_args(opts))
168
169
  a.push((opts[:path] || ".").to_s)
169
170
  end
171
+
172
+ # @!visibility private
173
+ #
174
+ # Solo5 (MirageOS): runs under the +solo5-hvt+ tender rather than libkrun.
175
+ # The unikernel declares its devices in its own MFT1 manifest, so only the
176
+ # +:block+ backing files (+NAME=FILE+) are passed. +:path+ is a +.hvt+
177
+ # binary or a project dir whose +dist/+ holds one; default +.+. Guest
178
+ # +:args+ go last, after a literal +--+ — MirageOS options look like
179
+ # bsdkrun's own (e.g. +--ipv4=...+), so the CLI takes them as trailing
180
+ # args.
181
+ def solo5_args(opts)
182
+ a = ["solo5", "-d"]
183
+ Array(opts[:block]).each { |b| a.push("--block", b) }
184
+ a.concat(net_args(opts[:net])).concat(name_args(opts)).concat(vm_args(opts))
185
+ a.push((opts[:path] || ".").to_s)
186
+ args = Array(opts[:args])
187
+ a.push("--", *args) unless args.empty?
188
+ a
189
+ end
170
190
  end
171
191
  end
@@ -274,10 +274,11 @@ module Bsdkrun
274
274
 
275
275
  # ---- booting ------------------------------------------------------------
276
276
  #
277
- # Six variants, one per daemon mutation — see +daemon/src/graphql.rs+ for
277
+ # Seven variants, one per daemon mutation — see +daemon/src/graphql.rs+ for
278
278
  # the exact input field names this transcribes (RunLinuxInput ~L384,
279
- # RunBsdInput ~L406, RunNanosInput ~L428, RunUnikraftInput ~L449,
280
- # RunOsvInput ~L467, RunFlavorInput ~L506, NetInput ~L360). Each accepts
279
+ # RunBsdInput ~L406, RunNanosInput ~L429, RunUnikraftInput ~L445,
280
+ # RunSolo5Input ~L465, RunOsvInput ~L498, RunFlavorInput ~L541,
281
+ # NetInput ~L360). Each accepts
281
282
  # an options Hash and/or keyword arguments, merged — the same convention
282
283
  # {Sandbox.create} uses — with snake_case Ruby keys mapped 1:1 to the
283
284
  # camelCase GraphQL fields on the wire.
@@ -359,6 +360,26 @@ module Bsdkrun
359
360
  request("mutation($i:RunUnikraftInput!){ runUnikraft(input:$i) }", { i: input })["runUnikraft"]
360
361
  end
361
362
 
363
+ # Solo5 (MirageOS): runs under the +solo5-hvt+ tender rather than libkrun.
364
+ # The unikernel declares its own network and block devices in its +MFT1+
365
+ # manifest note, so only what the host alone can know is asked for —
366
+ # +block:+ backing files (+NAME=FILE+) and the unikernel's own +args:+
367
+ # (e.g. "--ipv4=10.0.0.2/24"). Like Unikraft, no disk and no agent, so no
368
+ # volume/persist/repo/command fields.
369
+ # @return [String] the new machine's id.
370
+ def run_solo5(opts = {}, **kwargs)
371
+ o = merge_opts(opts, kwargs)
372
+ input = {
373
+ path: o[:path],
374
+ cpus: o[:cpus],
375
+ mem: o[:mem],
376
+ net: net_input(o[:net]),
377
+ block: o[:block] || [],
378
+ args: o[:args] || []
379
+ }
380
+ request("mutation($i:RunSolo5Input!){ runSolo5(input:$i) }", { i: input })["runSolo5"]
381
+ end
382
+
362
383
  # Like Nanos, no agent, but it does have a root filesystem, so the disk
363
384
  # options apply — +disk:+ in particular, how an x86_64 guest gets a
364
385
  # filesystem (its loader ELF is kernel only).
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Bsdkrun
4
4
  # The bsdkrun Ruby SDK version.
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.0"
6
6
  end
data/lib/bsdkrun.rb CHANGED
@@ -17,7 +17,7 @@ require_relative "bsdkrun/shell_session"
17
17
  require_relative "bsdkrun/client"
18
18
 
19
19
  # bsdkrun — a Ruby SDK for {https://github.com/tsirysndr/bsdkrun bsdkrun}, a
20
- # Firecracker-style microVM launcher for BSD and Linux guests. A thin wrapper
20
+ # Firecracker-style microVM launcher for BSD, Linux, and unikernel guests. A thin wrapper
21
21
  # around the +bsdkrun+ CLI: it builds argv, shells out, and parses JSON output.
22
22
  #
23
23
  # @example
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bsdkrun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsiry Sandratraina
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '13.0'
40
40
  description: |
41
41
  A thin, dependency-free Ruby wrapper around the `bsdkrun` CLI. Boot and drive
42
- BSD/Linux microVMs programmatically: create sandboxes, exec commands, manage
42
+ BSD/Linux/unikernel microVMs programmatically: create sandboxes, exec commands, manage
43
43
  lifecycle, and wire up global networks, volumes and images.
44
44
  email:
45
45
  - tsiry.sndr@gmail.com
@@ -87,6 +87,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  requirements: []
88
88
  rubygems_version: 4.0.10
89
89
  specification_version: 4
90
- summary: Ruby SDK for bsdkrun — a Firecracker-style microVM launcher for BSD and Linux
91
- guests.
90
+ summary: Ruby SDK for bsdkrun — a Firecracker-style microVM launcher for BSD, Linux,
91
+ and unikernel guests.
92
92
  test_files: []