mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 11:22:26 +00:00
vmm: Allow the DeviceManager to inject extra kernel commandline entries
This is useful for virtio-mmio to be able to provide the commandline entries for the devices. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
3df1680888
commit
6d27ac9dfc
@ -277,6 +277,9 @@ pub struct DeviceManager {
|
||||
|
||||
// mmap()ed region to unmap on drop
|
||||
mmap_regions: Vec<(*mut libc::c_void, usize)>,
|
||||
|
||||
// Things to be added to the commandline (i.e. for virtio-mmio)
|
||||
cmdline_additions: Vec<String>,
|
||||
}
|
||||
|
||||
impl DeviceManager {
|
||||
@ -392,6 +395,8 @@ impl DeviceManager {
|
||||
&mut mmap_regions,
|
||||
)?);
|
||||
|
||||
let mut cmdline_additions = Vec::new();
|
||||
|
||||
let pci_root = PciRoot::new(None);
|
||||
let mut pci = PciConfigIo::new(pci_root);
|
||||
|
||||
@ -421,6 +426,7 @@ impl DeviceManager {
|
||||
ioapic,
|
||||
pci,
|
||||
mmap_regions,
|
||||
cmdline_additions,
|
||||
};
|
||||
|
||||
dm.register_devices()?;
|
||||
@ -963,6 +969,10 @@ impl DeviceManager {
|
||||
pub fn console(&self) -> &Arc<Console> {
|
||||
&self.console
|
||||
}
|
||||
|
||||
pub fn cmdline_additions(&self) -> &[String] {
|
||||
self.cmdline_additions.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for DeviceManager {
|
||||
|
@ -752,8 +752,12 @@ impl<'a> Vm<'a> {
|
||||
}
|
||||
|
||||
pub fn load_kernel(&mut self) -> Result<GuestAddress> {
|
||||
let cmdline_cstring =
|
||||
CString::new(self.config.cmdline.args.clone()).map_err(|_| Error::CmdLine)?;
|
||||
let mut cmdline = self.config.cmdline.args.clone();
|
||||
for entry in self.devices.cmdline_additions() {
|
||||
cmdline.insert_str(entry).map_err(|_| Error::CmdLine)?;
|
||||
}
|
||||
|
||||
let cmdline_cstring = CString::new(cmdline).map_err(|_| Error::CmdLine)?;
|
||||
let mem = self.memory.read().unwrap();
|
||||
let entry_addr = match linux_loader::loader::Elf::load(
|
||||
mem.deref(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user