On Thu, Jan 07, 2021 at 11:23:42AM +0800, Liu Yinsi wrote:
before: support kvm for aarch64 after: support kvm for aarch64, x86_64, riscv64
[how] put public options like $kernel, $initrd, $smp together, list different options like $machine, $bios, $nic according to different qemu command, then merge all options.
Signed-off-by: Liu Yinsi liuyinsi@163.com
providers/qemu/kvm.sh | 106 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 93 insertions(+), 13 deletions(-)
diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index c926d3d..8749568 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -18,12 +18,6 @@ check_logfile() } }
-qemu_command() -{
- qemu=qemu-system-aarch64
- command -v $qemu >/dev/null || qemu=qemu-kvm
-}
write_logfile() { ipxe_script=ipxe_script @@ -72,6 +66,50 @@ get_initrd() cat $initrds > $initrd }
+get_bios() +{
bios=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd
[ -f "$bios" ] || bios=/usr/share/ovmf/OVMF.fd
+}
+get_helper() +{
helper=/usr/libexec/qemu-bridge-helper
[ -f "$helper" ] || helper=/usr/lib/qemu/qemu-bridge-helper
+}
+get_nic() +{
nic="tap,model=virtio-net-pci,helper=$helper,br=br0,mac=${mac}"
+}
+get_device() +{
- device="virtio-net-device,netdev=net0,mac=${mac}"
+}
+get_netdev() +{
- netdev="bridge,br=br0,id=net0,helper=${helper}"
+}
+get_qemu() +{
- qemu=(
qemu-system-aarch64
qemu-kvm
qemu-system-x86_64
- )
- for qemu in "${qemu[@]}"
- do
[ -n "$(command -v ${qemu})" ] && break
- done
- # debian has both qemu-system-x86_64 and qemu-system-riscv64 command
- [[ $kernel =~ 'riscv64' ]] && qemu=qemu-system-riscv64
+}
Above get_xxx can change to set_xxx.
Thanks, Xijian