You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nvx-rs: split the guest init's boot tokens with one function of protocol::cmdline #905
nvx::protocol::cmdline reads a kernel command line as Linux reads it, for the readers that need the kernel's view of it. The readers of the boot tokens that the guest's init consumes don't use it. Each splits the command line itself, at spaces, tabs, and newlines, without quoting, as guest/common/init splits it, and takes a token's name up to its first =. The same loop is copied four times:
RootLayout::parse, nvx-rs/src/protocol/root.rs:205-213: a layered root's tokens. It already reads the virtio_mmio.device parameters through cmdline::virtio_mmio_devices.
The kernel's rules, cmdline::parameters, cannot replace these copies as they stand. They split at more bytes, honor double quotes, stop at --, and match - with _ in names, so they would read some command lines differently from init. tests/fixtures/export-tokens.json and tests/fixtures/root-tokens.json pin that every reader of those tokens agrees.
Add to protocol::cmdline a function that splits a command line as the guest's init does, at spaces, tabs, and newlines, without quoting, and returns its tokens with their names up to the first = and their values after it. The module's documentation names both sets of rules and the readers that take each.
HostExport::parse, RootLayout::parse, and parse_host_mapping_count read their tokens through it, and drop their own copies of the split.
Tests of the new function in protocol/cmdline/tests.rs: empty tokens, a token without =, a token that starts with =, a value that holds =, and the bytes at which it does not split, such as \r, 0x0b, 0x0c, 0xa0, and ".
Acceptance criteria
No behavior change. The cases of tests/fixtures/export-tokens.json and tests/fixtures/root-tokens.json, host_mapping_count_matches_the_guest_command_line_parser, and the existing tests pass unchanged.
The init's split exists once in nvx-rs/src, in protocol::cmdline.
protocol still needs nothing outside the standard library, so the host, the guest, and test doubles still share it.
Activity