mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +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:
@@ -277,6 +277,9 @@ pub struct DeviceManager {
|
|||||||
|
|
||||||
// mmap()ed region to unmap on drop
|
// mmap()ed region to unmap on drop
|
||||||
mmap_regions: Vec<(*mut libc::c_void, usize)>,
|
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 {
|
impl DeviceManager {
|
||||||
@@ -392,6 +395,8 @@ impl DeviceManager {
|
|||||||
&mut mmap_regions,
|
&mut mmap_regions,
|
||||||
)?);
|
)?);
|
||||||
|
|
||||||
|
let mut cmdline_additions = Vec::new();
|
||||||
|
|
||||||
let pci_root = PciRoot::new(None);
|
let pci_root = PciRoot::new(None);
|
||||||
let mut pci = PciConfigIo::new(pci_root);
|
let mut pci = PciConfigIo::new(pci_root);
|
||||||
|
|
||||||
@@ -421,6 +426,7 @@ impl DeviceManager {
|
|||||||
ioapic,
|
ioapic,
|
||||||
pci,
|
pci,
|
||||||
mmap_regions,
|
mmap_regions,
|
||||||
|
cmdline_additions,
|
||||||
};
|
};
|
||||||
|
|
||||||
dm.register_devices()?;
|
dm.register_devices()?;
|
||||||
@@ -963,6 +969,10 @@ impl DeviceManager {
|
|||||||
pub fn console(&self) -> &Arc<Console> {
|
pub fn console(&self) -> &Arc<Console> {
|
||||||
&self.console
|
&self.console
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn cmdline_additions(&self) -> &[String] {
|
||||||
|
self.cmdline_additions.as_slice()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for DeviceManager {
|
impl Drop for DeviceManager {
|
||||||
|
|||||||
+6
-2
@@ -752,8 +752,12 @@ impl<'a> Vm<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_kernel(&mut self) -> Result<GuestAddress> {
|
pub fn load_kernel(&mut self) -> Result<GuestAddress> {
|
||||||
let cmdline_cstring =
|
let mut cmdline = self.config.cmdline.args.clone();
|
||||||
CString::new(self.config.cmdline.args.clone()).map_err(|_| Error::CmdLine)?;
|
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 mem = self.memory.read().unwrap();
|
||||||
let entry_addr = match linux_loader::loader::Elf::load(
|
let entry_addr = match linux_loader::loader::Elf::load(
|
||||||
mem.deref(),
|
mem.deref(),
|
||||||
|
|||||||
Reference in New Issue
Block a user