mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-03 13:11:31 +00:00
map initrd and multiple other fixes, it's so very close
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
use std::fs::read;
|
||||
use std::{env, process};
|
||||
use xencall::domctl::DomainControl;
|
||||
use xencall::memory::MemoryControl;
|
||||
@ -11,16 +12,26 @@ fn main() -> Result<(), XenClientError> {
|
||||
env_logger::init();
|
||||
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() != 2 {
|
||||
println!("usage: boot <kernel-image>");
|
||||
if args.len() != 3 {
|
||||
println!("usage: boot <kernel-image> <initrd>");
|
||||
process::exit(1);
|
||||
}
|
||||
let kernel_image_path = args.get(1).expect("argument not specified");
|
||||
let initrd_path = args.get(2).expect("argument not specified");
|
||||
let call = XenCall::open()?;
|
||||
let domctl = DomainControl::new(&call);
|
||||
let domain = CreateDomain { max_vcpus: 2, ..Default::default() };
|
||||
let domain = CreateDomain {
|
||||
max_vcpus: 1,
|
||||
..Default::default()
|
||||
};
|
||||
let domid = domctl.create_domain(domain)?;
|
||||
let result = boot(domid, kernel_image_path.as_str(), &call, &domctl);
|
||||
let result = boot(
|
||||
domid,
|
||||
kernel_image_path.as_str(),
|
||||
initrd_path.as_str(),
|
||||
&call,
|
||||
&domctl,
|
||||
);
|
||||
domctl.destroy_domain(domid)?;
|
||||
result?;
|
||||
println!("domain destroyed: {}", domid);
|
||||
@ -30,6 +41,7 @@ fn main() -> Result<(), XenClientError> {
|
||||
fn boot(
|
||||
domid: u32,
|
||||
kernel_image_path: &str,
|
||||
initrd_path: &str,
|
||||
call: &XenCall,
|
||||
domctl: &DomainControl,
|
||||
) -> Result<(), XenClientError> {
|
||||
@ -37,7 +49,8 @@ fn boot(
|
||||
let image_loader = ElfImageLoader::load_file_kernel(kernel_image_path)?;
|
||||
let memctl = MemoryControl::new(call);
|
||||
let mut boot = BootSetup::new(call, domctl, &memctl, domid);
|
||||
let mut state = boot.initialize(&image_loader, 512)?;
|
||||
let initrd = read(initrd_path)?;
|
||||
let mut state = boot.initialize(&image_loader, initrd.as_slice(), 512)?;
|
||||
boot.boot(&mut state, "debug")?;
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user