-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqemu.py
90 lines (78 loc) · 1.96 KB
/
qemu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import subprocess
from . import config, cargo
mem_size = "1G"
core_num = "1"
# Run qemu command.
def run():
qemu_args = []
bus = "device"
if config.arch == "riscv64":
qemu_args += [
"qemu-system-riscv64",
"-kernel",
cargo.kernel_bin,
"-machine",
"virt",
]
elif config.arch == "x86_64":
qemu_args += [
"qemu-system-x86_64",
"-machine",
"q35",
"-kernel",
cargo.kernel_elf,
"-cpu",
"IvyBridge-v2",
]
bus = "pci"
elif config.arch == "aarch64":
qemu_args += [
"qemu-system-aarch64",
"-cpu",
"cortex-a72",
"-machine",
"virt",
"-kernel",
cargo.kernel_bin,
]
elif config.arch == "loongarch64":
qemu_args += ["qemu-system-loongarch64", "-kernel", cargo.kernel_elf]
qemu_args += [
"-m",
mem_size,
"-smp",
core_num,
"-D",
"qemu.log",
"-d",
"in_asm,int,pcall,cpu_reset,guest_errors",
]
qemu_args += [
"-device",
"sdhci-pci",
"-drive",
"id=mydrive,if=none,format=raw,file=mount.img",
"-device",
"sd-card,drive=mydrive",
]
# Enable E1000 Device.
qemu_args += ["-netdev", "user,id=net0", "-device", "e1000,netdev=net0"]
if not config.graphic or config.arch != "x86_64":
qemu_args += ["-nographic"]
# qemu_args += [
# "-drive",
# "file={},if=none,format=raw,id=x0".format("mount.img"),
# "-device",
# "virtio-blk-{},drive=x0".format(bus),
# ]
if config.gdb:
qemu_args += ["-s", "-S"]
print(
[
"qemu-system-{}".format(config.arch),
"-kernel",
cargo.kernel_bin,
]
+ qemu_args
)
subprocess.run(qemu_args).check_returncode()