qemu 安装及具体配置使用

qemu 安装及具体配置使用

1 下载解压包
wget https://download.qemu.org/qemu-5.0.0.tar.xz
tar xvJf qemu-5.0.0.tar.xz
2 编译
cd qemu-5.0.0
./configure --target-list=riscv64-softmmu,riscv64-linux-user --prefix=~/riscv64-qemu
make -j $(nproc)
make install
export PATH="$PATH:~/riscv64-qemu/bin"
3 查看配置
root@3632224b9764:/home# qemu-system-riscv64 -machine help
Supported machines are:
microchip-icicle-kit Microchip PolarFire SoC Icicle Kit
none                 empty machine
shakti_c             RISC-V Board compatible with Shakti SDK
sifive_e             RISC-V Board compatible with SiFive E SDK
sifive_u             RISC-V Board compatible with SiFive U SDK
spike                RISC-V Spike board (default)
virt                 RISC-V VirtIO board
4参数配置项
4.1 内存大小(-m)
root@3632224b9764:/home# qemu-system-riscv64 -m help
qemu-system-riscv64: -m help: Parameter 'size' expects a non-negative number below 2^64
Optional suffix k, M, G, T, P or E means kilo-, mega-, giga-, tera-, peta-
and exabytes, respectively.
4.2 核心数(-smp)
root@3632224b9764:/home# qemu-system-riscv64 -smp help
smp-opts options:
  cores=<num>
  cpus=<num>
  dies=<num>
  maxcpus=<num>
  sockets=<num>
  threads=<num>
4.3驱动器映像文件(-drive)
-drive if=none,format=raw,file=./usb.img,id=usb0
-drive if=pflash,bus=0,unit=0,format=raw,file=$SHELL_FOLDER/output/fw/fw.bin,id=mtd0 \
-drive if=mtd,format=raw,file=$SHELL_FOLDER/output/fw/norflash.img,id=mtd1 \
-drive if=none,format=raw,file=$SHELL_FOLDER/output/fw/usb.img,id=usb0 \
-drive if=sd,format=raw,file=$SHELL_FOLDER/output/fw/sd.img,id=sd0 \
-drive if=none,format=raw,file=$SHELL_FOLDER/output/rootfs/rootfs.img,id=disk0 \

4.4 网络设备(-netdev)
-netdev user,net=192.168.31.0/24,host=192.168.31.2,hostname=qemu,dns=192.168.31.56,tftp=$SHELL_FOLDER/output,bootfile=/linux_kernel/Image,dhcpstart=192.168.31.100,hostfwd=tcp::3522-:22,hostfwd=tcp::3580-:80,id=net0
net=192.168.31.0/24 :配置网关地址/子网掩码
host=192.168.31.2 :配置主机地址
hostname=qemu :配置主机名称
dns=192.168.31.56 :创建一个dns服务器
tftp=$SHELL_FOLDER/output,bootfile=/linux_kernel/Image:创建一个tftp服务器
dhcpstart=192.168.31.100:dhcp地址分配起始地址
hostfwd=tcp::3522-:22:端口转发将客户机的22端口转发到宿主机的3522端口
4.5 字符设备(-chardev)
-chardev socket,telnet=on,host=127.0.0.1,port=3450,server=on,wait=off,id=usb1
-device usb-serial,always-plugged=true,chardev=usb1 \
root@3632224b9764:/home# qemu-system-riscv64 -chardev help
Available chardev backend types:
  ringbuf
  mux
  pipe
  qemu-vdagent
  null
  msmouse
  socket
  vc
  parallel
  memory
  udp
  file
  serial
  pty
  wctablet
  stdio
  testdev
4.6 文件系统设备(-fsdev)
-fsdev local,security_model=mapped-xattr,path=$SHELL_FOLDER,id=fsdev0
-device virtio-9p-device,fsdev=fsdev0,mount_tag=hostshare,id=fs0
4.7 音频设备(-audiodev)
--audio-drv-list=pa,alsa,sdl,oss
4.8全局参数(-global)
-global virtio-mmio.force-legacy=false
-global quard-star-syscon.boot-cfg="$DBOOTCFG"
4.9 设备(-device)
-device常用于指定guest上总线挂载的外部设备,例如virtio-mmio、usb、pci等总线,示例如下:
 -device virtio-blk-device,drive=disk0,id=hd0 \
-device virtio-gpu-device,xres=$WIDTH,yres=$HEIGHT,id=video0 \
-device virtio-mouse-device,id=input0 \
-device virtio-keyboard-device,id=input1 \
-device virtio-9p-device,fsdev=fsdev0,mount_tag=hostshare,id=fs0 \
-device virtio-net-device,netdev=net0 \
-device usb-storage,drive=usb0 \
-device usb-serial,always-plugged=true,chardev=usb1 \
-device wm8750,audiodev=audio0 \

4.10 -display 显示选项
-display sdl[,alt_grab=on|off][,ctrl_grab=on|off]
            [,window_close=on|off][,gl=on|core|es|off]
-display gtk[,grab_on_hover=on|off][,gl=on|off]|
-display vnc=<display>[,<optargs>]
-display curses[,charset=<encoding>]
-display egl-headless[,rendernode=<file>]
-display none
                select display backend type
                The default display is equivalent to
                "-display gtk"
-nographic      disable graphical output and redirect serial I/Os to console  //不用图形配置
--display gtk,zoom-to-fit=false
4.11 –serial --parallel --monitor 终端
--serial stdio
--serial vc:1280x720
--serial telnet:127.0.0.1:3441,server,nowait

参考

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值