mirror of
https://github.com/philmmanjaro/alma.git
synced 2025-07-25 22:49:28 +02:00
Enable KVM only if available
This commit is contained in:
parent
4e12052f5a
commit
34020614e1
50
src/main.rs
50
src/main.rs
@ -421,30 +421,32 @@ fn chroot(command: ChrootCommand) -> Result<(), Error> {
|
||||
fn qemu(command: QemuCommand) -> Result<(), Error> {
|
||||
let qemu = Tool::find("qemu-system-x86_64")?;
|
||||
|
||||
let err = qemu
|
||||
.execute()
|
||||
.args(&[
|
||||
"-enable-kvm",
|
||||
"-cpu",
|
||||
"host",
|
||||
"-m",
|
||||
"4G",
|
||||
"-netdev",
|
||||
"user,id=user.0",
|
||||
"-device",
|
||||
"virtio-net-pci,netdev=user.0",
|
||||
"-device",
|
||||
"qemu-xhci,id=xhci",
|
||||
"-device",
|
||||
"usb-tablet,bus=xhci.0",
|
||||
"-drive",
|
||||
])
|
||||
.arg(format!(
|
||||
"file={},if=virtio,format=raw",
|
||||
command.block_device.display()
|
||||
))
|
||||
.args(command.args)
|
||||
.exec();
|
||||
let mut run = qemu.execute();
|
||||
run.args(&[
|
||||
"-m",
|
||||
"4G",
|
||||
"-netdev",
|
||||
"user,id=user.0",
|
||||
"-device",
|
||||
"virtio-net-pci,netdev=user.0",
|
||||
"-device",
|
||||
"qemu-xhci,id=xhci",
|
||||
"-device",
|
||||
"usb-tablet,bus=xhci.0",
|
||||
"-drive",
|
||||
])
|
||||
.arg(format!(
|
||||
"file={},if=virtio,format=raw",
|
||||
command.block_device.display()
|
||||
))
|
||||
.args(command.args);
|
||||
|
||||
if PathBuf::from("/dev/kvm").exists() {
|
||||
debug!("KVM is enabled");
|
||||
run.args(&["-enable-kvm", "-cpu", "host"]);
|
||||
}
|
||||
|
||||
let err = run.exec();
|
||||
|
||||
Err(err).context(ErrorKind::Qemu)?
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user