Struct linux_loader::cmdline::Cmdline [−][src]
pub struct Cmdline { /* fields omitted */ }Expand description
A builder for a kernel command line string that validates the string as it’s being built.
A CString can be constructed from this directly using CString::new.
Examples
let cl = Cmdline::new(100);
let cl_cstring = CString::new(cl).unwrap();
assert_eq!(cl_cstring.to_str().unwrap(), "");Implementations
Validates and inserts a key-value pair into this command line.
Arguments
key- Key to be inserted in the command line string.val- Value corresponding tokey.
Examples
let mut cl = Cmdline::new(100);
cl.insert("foo", "bar");
let cl_cstring = CString::new(cl).unwrap();
assert_eq!(cl_cstring.to_str().unwrap(), "foo=bar");Validates and inserts a key-value1,…,valueN pair into this command line.
Arguments
key- Key to be inserted in the command line string.vals- Values corresponding tokey.
Examples
let mut cl = Cmdline::new(100);
cl.insert_multiple("foo", &["bar", "baz"]);
let cl_cstring = CString::new(cl).unwrap();
assert_eq!(cl_cstring.to_str().unwrap(), "foo=bar,baz");Returns the string representation of the command line without the nul terminator.
Examples
let mut cl = Cmdline::new(10);
cl.insert_str("foobar");
assert_eq!(cl.as_str(), "foobar");pub fn add_virtio_mmio_device(
&mut self,
size: GuestUsize,
baseaddr: GuestAddress,
irq: u32,
id: Option<u32>
) -> Result<()>
pub fn add_virtio_mmio_device(
&mut self,
size: GuestUsize,
baseaddr: GuestAddress,
irq: u32,
id: Option<u32>
) -> Result<()>
Adds a virtio MMIO device to the kernel command line.
Multiple devices can be specified, with multiple virtio_mmio.device= options. This
function must be called once per device.
The function appends a string of the following format to the kernel command line:
<size>@<baseaddr>:<irq>[:<id>].
For more details see the documentation (section virtio_mmio.device=).
Arguments
size- size of the slot the device occupies on the MMIO bus.baseaddr- physical base address of the device.irq- interrupt number to be used by the device.id- optional platform device ID.
Examples
let mut cl = Cmdline::new(100);
cl.add_virtio_mmio_device(1 << 12, GuestAddress(0x1000), 5, Some(42)).unwrap();
let cl_cstring = CString::new(cl).unwrap();
assert_eq!(cl_cstring.to_str().unwrap(), "virtio_mmio.device=4K@0x1000:5:42");