Merge pull request #5254 from openanolis/chao/update_linux_loader

Dragonball: update linux_loader to 0.6.0
This commit is contained in:
Zhongtao Hu
2022-09-28 15:04:09 +08:00
committed by GitHub
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,