pub fn load_cmdline(
    guest_mem: &GuestMemory,
    guest_addr: GuestAddress,
    cmdline: &CStr,
) -> Result<()> {
    let len = cmdline.to_bytes().len();
    if len == 0 {
        return Ok(());
    }

    let end = guest_addr
        .checked_add(len + 1)
        .ok_or(Error::CommandLineOverflow)?; // Extra for null termination.
    if end > guest_mem.end_addr() {
        return Err(Error::CommandLineOverflow)?;
    }

    guest_mem
        .write_slice_at_addr(cmdline.to_bytes_with_nul(), guest_addr)
        .map_err(|_| Error::CommandLineCopy)?;

    Ok(())
}
/// Writes the command line string to the given memory slice.
///
/// # Arguments
///
/// * `guest_mem` - A u8 slice that will be partially overwritten by the command line.
/// * `guest_addr` - The address in `guest_mem` at which to load the command line.
/// * `cmdline` - The kernel command line.
Writes the command line string to the given memory slice.
Writes the command line string to the given memory slice .
pub fn load_cmdline(
    guest_mem: &GuestMemory,
    guest_addr: GuestAddress,
    cmdline: &CStr,
) -> Result<()> {
    let len = cmdline.to_bytes().len();
    if len == 0 {
        return Ok(());
    }
    let end = guest_addr
        .checked_add(len + 1)
        .ok_or(Error::CommandLineOverflow)?; // Extra for null termination.
    if end > guest_mem.end_addr() {
        return Err(Error::CommandLineOverflow)?;
    }
    guest_mem
        .write_slice_at_addr(cmdline.to_bytes_with_nul(), guest_addr)
        .map_err(|_| Error::CommandLineCopy)?;
    Ok(())
}
pub fn load_cmdline ( guest_mem : & GuestMemory , guest_addr : GuestAddress , cmdline : & CStr , ) -> Result < ( ) > { let len = cmdline . to_bytes ( ) . len ( ) ; if len == 0 { return Ok ( ( ) ) ; } let end = guest_addr . checked_add ( len + 1 ) . ok_or ( Error :: CommandLineOverflow ) ? ; // Extra for null termination. if end > guest_mem . end_addr ( ) { return Err ( Error :: CommandLineOverflow ) ? ; } guest_mem . write_slice_at_addr ( cmdline . to_bytes_with_nul ( ) , guest_addr ) . map_err ( | _ | Error :: CommandLineCopy ) ? ; Ok ( ( ) ) }
Writes the command line string to the given memory slice.
Writes the command line string to the given memory slice .
guest_mem
&GuestMemory
guest_addr
GuestAddress
cmdline
&CStr
guest_mem
&GuestMemory
guest_addr
GuestAddress
cmdline
&CStr