Skip to content

Extend cmdline to work with abstractions instead of strings #25

Open
@alxiord

Description

@alxiord

Per @andreeaflorescu's idea, instead of:

let mut kernel_cmdline = "reboot=k panic=1 pci=off nomodules 8250.nr_uarts=0 \
    i8042.noaux i8042.nomux i8042.nopnp i8042.dumbkbd";
if blocks.has_root_block_device() && !blocks.has_partuuid_root() {
    kernel_cmdline.insert_str("root=/dev/vda")?;
    let flags = if blocks.has_read_only_root() {
        "ro"
    } else {
        "rw"
    };
   kernel_cmdline.insert_str(flags)?;
}

(source: firecracker, default cmdline)

we could build the kernel command line using a Rustacean builder:

let kernel_cmdline = Cmdline::default()
    .pci(None)
    .serial(None)
    .root_device(Some(Block { root: true, ro: true, partuuid: partuuid_config }))
    .extra_args("nomodules")?;

(Not its final form, merely demonstrative purposes).

This would make cmdline building simpler and more elegant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions