@@ -88,6 +88,7 @@ Usage: $SELF [-h|--help]
[<subtarget> [<extra-qemu-options>]]
[--kernel <kernel>]
[--rootfs <rootfs>]
+ [--mach <mach>]
<subtarget> will default to "generic" and must be specified if
<extra-qemu-options> are present
@@ -100,13 +101,14 @@ the actual <target> in use. They will default to files under bin/targets/
Examples
$SELF x86 64
- $SELF x86 64 -enable-kvm -device virtio-balloon-pci
+ $SELF x86 64 --mach q35,accel=kvm -device virtio-balloon-pci
$SELF x86 64 -incoming tcp:0:4444
$SELF x86 64-glibc
$SELF malta be -m 64
$SELF malta le64
$SELF malta be-glibc
$SELF armvirt 32 \\
+ --mach virt,highmem=off \\
--kernel bin/targets/armvirt/32/openwrt-armvirt-32-zImage \\
--rootfs bin/targets/armvirt/32/openwrt-armvirt-32-root.ext4
EOF
@@ -122,6 +124,7 @@ parse_args() {
case "$1" in
--kernel) o_kernel="$2"; shift 2 ;;
--rootfs) o_rootfs="$2"; shift 2 ;;
+ --mach) o_mach="$2"; shift 2 ;;
--help|-h)
usage
exit 0
@@ -152,6 +155,7 @@ parse_args() {
start_qemu_armvirt() {
local kernel="$o_kernel"
local rootfs="$o_rootfs"
+ local mach="${o_mach:-virt}"
local cpu
local qemu_exe
@@ -181,7 +185,7 @@ start_qemu_armvirt() {
)
}
- "$qemu_exe" -machine virt -cpu "$cpu" -nographic \
+ "$qemu_exe" -machine "$mach" -cpu "$cpu" -nographic \
-netdev bridge,id=lan,br="$BR_LAN,helper=$HELPER" -device virtio-net-pci,id=devlan,netdev=lan,mac="$MAC_LAN" \
-netdev bridge,id=wan,br="$BR_WAN,helper=$HELPER" -device virtio-net-pci,id=devwan,netdev=wan,mac="$MAC_WAN" \
-kernel "$kernel" \
@@ -193,6 +197,7 @@ start_qemu_malta() {
local isel
local qemu_exe
local kernel="$o_kernel"
+ local mach="${o_mach:-malta}"
# o_subtarget can be le, be, le64, be64, le-glibc, le64-glibc, etc..
is64="$(echo $o_subtarget | grep -o 64)"
@@ -204,7 +209,7 @@ start_qemu_malta() {
# NOTE: order of wan, lan -device arguments matters as it will affect which
# one will be actually used as the wan, lan network interface inside the
# guest machine
- "$qemu_exe" -machine malta -nographic \
+ "$qemu_exe" -machine "$mach" -nographic \
-netdev bridge,id=wan,br="$BR_WAN,helper=$HELPER" -device pcnet,netdev=wan,mac="$MAC_WAN" \
-netdev bridge,id=lan,br="$BR_LAN,helper=$HELPER" -device pcnet,netdev=lan,mac="$MAC_LAN" \
-kernel "$kernel" \
@@ -213,6 +218,7 @@ start_qemu_malta() {
start_qemu_x86() {
local rootfs="$o_rootfs"
+ local mach="${o_mach:-pc}"
local qemu_exe
[ -n "$rootfs" ] || {
@@ -227,7 +233,7 @@ start_qemu_x86() {
# 64: 64-bit, kvm guest, virtio
#
case "${o_subtarget%-*}" in
- legacy) qemu_exe="qemu-system-i386" ;;
+ legacy) qemu_exe="qemu-system-i386" ;;
generic|64) qemu_exe="qemu-system-x86_64" ;;
*)
__errmsg "target $o_target: unknown subtarget $o_subtarget"
@@ -247,7 +253,7 @@ start_qemu_x86() {
# -drive "file=$rootfs,format=raw,id=drv0,if=none" \
#
# [1] https://dev.openwrt.org/ticket/17947
- "$qemu_exe" -nographic \
+ "$qemu_exe" --machine "$mach" -nographic \
-netdev bridge,id=lan,br="$BR_LAN,helper=$HELPER" -device e1000,id=devlan,netdev=lan,mac="$MAC_LAN" \
-netdev bridge,id=wan,br="$BR_WAN,helper=$HELPER" -device e1000,id=devwan,netdev=wan,mac="$MAC_WAN" \
-device ide-drive,drive=drv0 \
@@ -255,7 +261,7 @@ start_qemu_x86() {
"${o_qemu_extra[@]}"
;;
generic|64)
- "$qemu_exe" -nographic \
+ "$qemu_exe" --machine "$mach" -nographic \
-netdev bridge,id=lan,br="$BR_LAN,helper=$HELPER" -device virtio-net-pci,id=devlan,netdev=lan,mac="$MAC_LAN" \
-netdev bridge,id=wan,br="$BR_WAN,helper=$HELPER" -device virtio-net-pci,id=devwan,netdev=wan,mac="$MAC_WAN" \
-drive "file=$rootfs,format=raw,if=virtio" \
Value of the new option will be passed to qemu --machine verbatim. This can be used to set machine options like highmem=off for running old armvirt/32 kernel lacking LPAE support on QEMU version 3.0 or later Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> --- scripts/qemustart | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)