Skip to content

js: reject more disks than the kernel takes, instead of dropping them - #184

Open
mannlohchab wants to merge 1 commit into
pithings:mainfrom
mannlohchab:disk-limit-error
Open

mannlohchab wants to merge 1 commit into
pithings:mainfrom
mannlohchab:disk-limit-error

Conversation

@mannlohchab

Copy link
Copy Markdown

Fixes #182.

The kernel's kwblk driver takes 16 disks (KWBLK_MAX_DEVS, /dev/wda to /dev/wdp), and BlockHost kept the first 16 of what it was given (disks.slice(0, MAX_DEVS)), so createKernel() with more booted without a word and the guest found the rest missing.

  • createKernel() counts the disks after building them (the distro image included, optional specs that were left out not counted) and rejects more than 16 with a BootError, e.g. disks: 31 disks (the distro image included), and the kernel takes at most 16. It closes the disks it opened first; the caller's own BlockDevice objects are left alone. Worker mode goes through the same path.
  • MAX_DEVS is exported from block.ts for this; the slice stays as a backstop for direct Kernel users.
  • The README ("Add disks") and the SDK's Disks page state the limit.

Testing

  • New test in test/api.test.ts: 17 BlockDevice objects inline and 17 file specs in a worker both reject with the BootError, the caller's disks are not closed, and 16 file disks boot with 16 wd* devices in /sys/block. Without the change the 17-disk kernels boot and the test does not settle.
  • pnpm typecheck passes.
  • pnpm test:api against the v0.3.0-261202-b033dc7 release bundle (UNKERNEL_TEST_KERNEL, concurrency 2): 142 pass, 27 skipped, 1 fail. The failure is "worker mode rejects device objects", which loads js/unkernel.wasm, a bundle I have not built locally.
  • pnpm test:block passes. One HTTP read-ahead timing test failed once while the API suite was loading the machine; on its own it passes, with and without this change.

The kernel's kwblk driver takes 16 disks (/dev/wda to /dev/wdp), and
BlockHost kept the first 16 of what it was given, so createKernel() with
more booted without a word and the guest found the rest missing.
createKernel() now rejects that with a BootError that gives the count and
the limit, after closing the disks it opened, and the README and the SDK's
disks page state the limit.

Fixes pithings#182
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disks beyond the 16th are dropped without an error

1 participant