Dragonball: update linux_loader to 0.6.0

Since linux-loader 0.4.0 and 0.5.0 is yanked due to null terminator bug,
we need to update linux-loader to 0.6.0.

And as_str() function should also be changed.

fixes: #5253

Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
This commit is contained in:
Chao Wu 2022-09-27 17:55:36 +08:00
parent 8a2df6b31c
commit 90ecc015e0
4 changed files with 19 additions and 3 deletions

View File

@ -26,7 +26,7 @@ kvm-bindings = "0.5.0"
kvm-ioctls = "0.11.0"
lazy_static = "1.2"
libc = "0.2.39"
linux-loader = "0.5.0"
linux-loader = "0.6.0"
log = "0.4.14"
nix = "0.24.2"
seccompiler = "0.2.0"

View File

@ -577,7 +577,13 @@ impl BlockDeviceMgr {
) -> std::result::Result<(), DeviceMgrError> {
// Respect user configuration if kernel_cmdline contains "root=",
// special attention for the case when kernel command line starting with "root=xxx"
let old_kernel_cmdline = format!(" {}", kernel_config.kernel_cmdline().as_str());
let old_kernel_cmdline = format!(
" {:?}",
kernel_config
.kernel_cmdline()
.as_cstring()
.map_err(DeviceMgrError::Cmdline)?
);
if !old_kernel_cmdline.contains(" root=") && self.has_root_block {
let cmdline = kernel_config.kernel_cmdline_mut();
if let Some(ref uuid) = self.part_uuid {

View File

@ -127,6 +127,10 @@ pub enum StartMicroVmError {
#[error("failure while configuring guest kernel commandline: {0}")]
LoadCommandline(#[source] linux_loader::loader::Error),
/// Cannot process command line string.
#[error("failure while processing guest kernel commandline: {0}.")]
ProcessCommandlne(#[source] linux_loader::cmdline::Error),
/// The device manager was not configured.
#[error("the device manager failed to manage devices: {0}")]
DeviceManager(#[source] device_manager::DeviceMgrError),

View File

@ -217,11 +217,17 @@ impl Vm {
linux_loader::loader::load_cmdline(vm_memory, cmdline_addr, cmdline)
.map_err(StartMicroVmError::LoadCommandline)?;
let cmdline_size = cmdline
.as_cstring()
.map_err(StartMicroVmError::ProcessCommandlne)?
.as_bytes_with_nul()
.len();
configure_system(
vm_memory,
self.address_space.address_space(),
cmdline_addr,
cmdline.as_str().len() + 1,
cmdline_size,
&initrd,
self.vm_config.vcpu_count,
self.vm_config.max_vcpu_count,