Function linux_loader::loader::load_cmdline [−][src]
pub fn load_cmdline<M: GuestMemory>(
guest_mem: &M,
guest_addr: GuestAddress,
cmdline: &CStr
) -> Result<()>
Writes the command line string to the given guest memory slice.
Arguments
guest_mem
-GuestMemory
that will be partially overwritten by the command line.guest_addr
- The address inguest_mem
at which to load the command line.cmdline
- The kernel command line.
Examples
let mem_size: usize = 0x1000000; let gm = GuestMemoryMmap::from_ranges(&[(GuestAddress(0x0), mem_size)]).unwrap(); let cl = CStr::from_bytes_with_nul(b"foo=bar\0").unwrap(); let mut buf = vec![0u8;8]; let result = load_cmdline(&gm, GuestAddress(0x1000), &cl).unwrap(); gm.read_slice(buf.as_mut_slice(), GuestAddress(0x1000)).unwrap(); assert_eq!(buf.as_slice(), "foo=bar\0".as_bytes());