mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-03 13:11:31 +00:00
cleanup elf loader and more work towards boot support
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
use std::alloc::Layout;
|
||||
use std::{env, process};
|
||||
use xencall::domctl::DomainControl;
|
||||
use xencall::sys::CreateDomain;
|
||||
use xencall::XenCall;
|
||||
@ -7,12 +8,27 @@ use xenclient::elfloader::ElfImageLoader;
|
||||
use xenclient::XenClientError;
|
||||
|
||||
fn main() -> Result<(), XenClientError> {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() != 2 {
|
||||
println!("usage: boot <kernel-image>");
|
||||
process::exit(1);
|
||||
}
|
||||
let kernel_image_path = args.get(1).expect("argument not specified");
|
||||
let call = XenCall::open()?;
|
||||
let domctl = DomainControl::new(&call);
|
||||
let _domain = domctl.create_domain(CreateDomain::default())?;
|
||||
let boot = ElfImageLoader::load_file_kernel("/boot/vmlinuz-6.1.0-17-amd64")?;
|
||||
let domid = domctl.create_domain(CreateDomain::default())?;
|
||||
let domain = domctl.get_domain_info(domid)?;
|
||||
println!("domain created: {:?}", domain);
|
||||
let boot = ElfImageLoader::load_file_kernel(kernel_image_path.as_str())?;
|
||||
let ptr = unsafe { std::alloc::alloc(Layout::from_size_align(128 * 1024 * 1024, 16).unwrap()) };
|
||||
let info = boot.load(ptr)?;
|
||||
println!("{:?}", info);
|
||||
println!("loaded kernel image into memory: {:?}", info);
|
||||
// The address calculations don't make sense here and I am certain something
|
||||
// is wrong up the stack.
|
||||
// if info.virt_hypercall != XEN_UNSET_ADDR {
|
||||
// domctl.hypercall_init(domid, info.virt_hypercall)?;
|
||||
// }
|
||||
domctl.destroy_domain(domid)?;
|
||||
println!("domain destroyed: {}", domid);
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user