在 x86 Linux 主机上的 Qemu 中模拟 armv8 AArch64

在 x86 Linux 主机上的 Qemu 中模拟 armv8 AArch64

我正在尝试在 QEMU 模拟器中模拟 Ubuntu/arm64。因此我关注了 Ubuntu wiki (https://wiki.ubuntu.com/ARM64/QEMU),但我无法运行它。首先我安装了 qemu:

$ sudo apt-get install qemu-system-arm qemu-efi

然后我为 UEFI 创建了两个 pflash 卷:

 $ dd if=/dev/zero of=flash0.img bs=1M count=64
 $ dd if=/usr/share/qemu-efi/QEMU_EFI.fd of=flash0.img conv=notrunc
 $ dd if=/dev/zero of=flash1.img bs=1M count=64

最后:

  $ sudo qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt -nographic -pflash flash0.img -pflash flash1.img -drive if=none,file=xenial-server-cloudimg-arm64-uefi1.img,id=hd0 -device virtio-blk-device,drive=hd0 -netdev type=tap,id=net0 -device virtio-net-device,netdev=net0,mac=$randmac

运行此命令时出现了两个警告:

WARNING: Image format was not specified for 'flash0.img' and probing guessed raw.
     Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
     Specify the 'raw' format explicitly to remove the restrictions.

WARNING: Image format was not specified for 'flash1.img' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.

因此,为了克服警告,我将磁盘格式指定为 format=raw:

sudo qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt -nographic -drive file=flash0.img,format=raw,if=pflash -drive file=flash1.img,format=raw,if=pflash -drive if=none,file=xenial-server-cloudimg-arm64-uefi1.img,id=hd0 -device virtio-blk-device,drive=hd0 -device virtio-net-device,netdev=net0,mac=$randmac -netdev type=tap,id=net0

但我得到:

W: /etc/qemu-ifup: no bridge for guest interface found
qemu-system-aarch64: -device virtio-net-device,netdev=net0,mac=: Property 'virtio-net-device.mac' doesn't take value ''

我应该怎么办 ?

注意:我不一定需要启动 Ubuntu/arm64,任何其他 Linux 发行版(例如 Debian)都可以。

有人能帮帮我吗?谢谢。

答案1

您使用了无效的参数:

... virtio-net-device,netdev=net0,mac=$randmac ....

需要将一个有效的 mac 地址放入 randmac 中,在命令前,你可以输入类似以下内容:

# Set mac address
randmac='00:de:ad:de:ad:00'
# Start VM
sudo qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt -nographic \
       -drive file=flash0.img,format=raw,if=pflash \
       -drive file=flash1.img,format=raw,if=pflash \
       -drive if=none,file=xenial-server-cloudimg-arm64-uefi1.img,id=hd0 \
       -device virtio-blk-device,drive=hd0 \
       -device virtio-net-device,netdev=net0,mac=$randmac \
       -netdev type=tap,id=net0

randmac 的值仅作为示例,需要选择一个唯一的值。

干杯

相关内容