mirror of
https://github.com/philmmanjaro/alma.git
synced 2025-07-26 23:19:29 +02:00
Enable KVM only if available
This commit is contained in:
parent
4e12052f5a
commit
34020614e1
18
src/main.rs
18
src/main.rs
@ -421,12 +421,8 @@ fn chroot(command: ChrootCommand) -> Result<(), Error> {
|
|||||||
fn qemu(command: QemuCommand) -> Result<(), Error> {
|
fn qemu(command: QemuCommand) -> Result<(), Error> {
|
||||||
let qemu = Tool::find("qemu-system-x86_64")?;
|
let qemu = Tool::find("qemu-system-x86_64")?;
|
||||||
|
|
||||||
let err = qemu
|
let mut run = qemu.execute();
|
||||||
.execute()
|
run.args(&[
|
||||||
.args(&[
|
|
||||||
"-enable-kvm",
|
|
||||||
"-cpu",
|
|
||||||
"host",
|
|
||||||
"-m",
|
"-m",
|
||||||
"4G",
|
"4G",
|
||||||
"-netdev",
|
"-netdev",
|
||||||
@ -443,8 +439,14 @@ fn qemu(command: QemuCommand) -> Result<(), Error> {
|
|||||||
"file={},if=virtio,format=raw",
|
"file={},if=virtio,format=raw",
|
||||||
command.block_device.display()
|
command.block_device.display()
|
||||||
))
|
))
|
||||||
.args(command.args)
|
.args(command.args);
|
||||||
.exec();
|
|
||||||
|
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)?
|
Err(err).context(ErrorKind::Qemu)?
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user