如何将 qemu 映像 (2 pflash + ide) 转换为 virtualbox vdi?

How to convert a qemu image (2 pflash + ide) to virtualbox vdi?

我以这种方式启动带有 QEMU 的虚拟机:

qemu-system-x86_64 \
    -m 512M \
    -drive file=ovmf.qcow2,if=pflash,format=qcow2,unit=0,readonly=on \
    -drive file=ovmf.vars.qcow2,if=pflash,format=qcow2,unit=1 \
    -nographic \
    -drive file=file.uefiimg,if=ide,format=raw

fdisk -l file.uefiimg 输出:

Disk file.uefiimg: 2 GiB, 2147483648 bytes, 4194304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: DC9B048E-91D0-4DD0-BD7A-4D6130AA726F

Device          Start     End Sectors  Size Type
file.uefiimg1   16384   49151   32768   16M EFI System
file.uefiimg2   49152 1589247 1540096  752M Linux filesystem
file.uefiimg3 1589248 3129343 1540096  752M Linux filesystem
file.uefiimg4 3129344 4177919 1048576  512M Linux filesystem

现在棘手的部分是我想在 Virtualbox 上启动它。如果不可能,vmware 也是一种选择。我尝试使用 VBoxManage 将 uefiimg 转换为原始图像,然后再转换为 vdi,但没有成功。我认为主要问题是我需要包含 qcow2 文件。我读到了这 2 个文件,作为 pflash 插入,但我不明白如何将它们加载到 VirtualBox 中(或者如果可能的话)

我用

将图像转换为 vdi

VBoxManage convertfromraw file.uefiimg --format vdi file.vdi

然后,加载此 vdi,它完美运行。