mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 11:22:26 +00:00
vmm: config: Make the cmdline config serializable
The linux_loader crate Cmdline struct is not serializable. Instead of forcing the upstream create to carry a serde dependency, we simply use a String for the passed command line and build the actual CmdLine when we need it (in vm::new()). Also, the cmdline offset is not a configuration knob, so we remove it. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
6a722e5c0b
commit
f2de4d0315
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
extern crate vm_virtio;
|
extern crate vm_virtio;
|
||||||
|
|
||||||
use linux_loader::cmdline::Cmdline;
|
|
||||||
use net_util::MacAddr;
|
use net_util::MacAddr;
|
||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
use std::net::AddrParseError;
|
use std::net::AddrParseError;
|
||||||
@ -180,16 +179,14 @@ pub struct KernelConfig {
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct CmdlineConfig {
|
pub struct CmdlineConfig {
|
||||||
pub args: Cmdline,
|
pub args: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CmdlineConfig {
|
impl CmdlineConfig {
|
||||||
pub fn parse(cmdline: Option<&str>) -> Result<Self> {
|
pub fn parse(cmdline: Option<&str>) -> Result<Self> {
|
||||||
let cmdline_str = cmdline
|
let args = cmdline
|
||||||
.map(std::string::ToString::to_string)
|
.map(std::string::ToString::to_string)
|
||||||
.unwrap_or_else(String::new);
|
.unwrap_or_else(String::new);
|
||||||
let mut args = Cmdline::new(arch::CMDLINE_MAX_SIZE);
|
|
||||||
args.insert_str(cmdline_str).unwrap();
|
|
||||||
|
|
||||||
Ok(CmdlineConfig { args })
|
Ok(CmdlineConfig { args })
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ use kvm_bindings::{
|
|||||||
};
|
};
|
||||||
use kvm_ioctls::*;
|
use kvm_ioctls::*;
|
||||||
use libc::{c_void, siginfo_t};
|
use libc::{c_void, siginfo_t};
|
||||||
|
use linux_loader::cmdline::Cmdline;
|
||||||
use linux_loader::loader::KernelLoader;
|
use linux_loader::loader::KernelLoader;
|
||||||
use signal_hook::{iterator::Signals, SIGWINCH};
|
use signal_hook::{iterator::Signals, SIGWINCH};
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
@ -677,7 +678,10 @@ impl Vm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn load_kernel(&mut self) -> Result<GuestAddress> {
|
fn load_kernel(&mut self) -> Result<GuestAddress> {
|
||||||
let mut cmdline = self.config.cmdline.args.clone();
|
let mut cmdline = Cmdline::new(arch::CMDLINE_MAX_SIZE);
|
||||||
|
cmdline
|
||||||
|
.insert_str(self.config.cmdline.args.clone())
|
||||||
|
.map_err(|_| Error::CmdLine)?;
|
||||||
for entry in self.devices.cmdline_additions() {
|
for entry in self.devices.cmdline_additions() {
|
||||||
cmdline.insert_str(entry).map_err(|_| Error::CmdLine)?;
|
cmdline.insert_str(entry).map_err(|_| Error::CmdLine)?;
|
||||||
}
|
}
|
||||||
@ -709,7 +713,6 @@ impl Vm {
|
|||||||
&cmdline_cstring,
|
&cmdline_cstring,
|
||||||
)
|
)
|
||||||
.map_err(|_| Error::CmdLine)?;
|
.map_err(|_| Error::CmdLine)?;
|
||||||
|
|
||||||
let vcpu_count = u8::from(&self.config.cpus);
|
let vcpu_count = u8::from(&self.config.cpus);
|
||||||
let end_of_range = GuestAddress((1 << get_host_cpu_phys_bits()) - 1);
|
let end_of_range = GuestAddress((1 << get_host_cpu_phys_bits()) - 1);
|
||||||
match entry_addr.setup_header {
|
match entry_addr.setup_header {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user