qemu运行提示‘virtio-9p-pci‘ is not a valid device model name以及rootfs_debian_arm64.ext4‘ and probing gues

在使用qemu调试启动runninglinuxkernel_5.0的内核时,执行qemu启动命令提示了'virtio-9p-pci' is not a valid device model name以及rootfs_debian_arm64.ext4’ and probing gues的错误,在解决的时候分别参考了几篇其他同学之前总结的文章。

1 qemu执行的命令以及对应的提示

1.1 qemu运行命令

qemu-system-aarch64 -m 1024 -cpu max,sve=on,sve256=on -M virt,gic-version=3,its=on,iommu=smmuv3 -nographic -smp 4 -kernel arch/arm64/boot/Image -append "noinitrd nokaslr loglevel=8 sched_debug root=/dev/vda rootfstype=ext4 rw crashkernel=256M vfio.dyndbg=+pflmt irq_gic_v3_its.dyndbg=+pflmt iommu.dyndbg=+pflmt irqdomain.dyndbg=+pflmt" -drive if=none,file=/home/lixiang/sda2/work/runninglinuxkernel_5.0/rootfs_debian_arm64.ext4,id=hd0 -device virtio-blk-device,drive=hd0 --fsdev local,id=kmod_dev,path=./kmodules,security_model=none -device virtio-9p-pci,fsdev=kmod_dev,mount_tag=kmod_mount

1.2 qemu运行提示的错误

提示了两个错误,分别为:

  • 'virtio-9p-pci' is not a valid device model name,表示当前的qemu不支持virtio-9p设备
  • '/home/xxx/sda2/work/runninglinuxkernel_5.0/rootfs_debian_arm64.ext4' and probing guessed raw.提示当前的文件系统是一个raw文件,需要指定一下raw属性。
$ ./run_debian_arm64.sh run
running:
qemu-system-aarch64 -m 1024 -cpu max,sve=on,sve256=on -M virt,gic-version=3,its=on,iommu=smmuv3 -nographic -smp 4 -kernel arch/arm64/boot/Image -append "noinitrd nokaslr loglevel=8 sched_debug root=/dev/vda rootfstype=ext4 rw crashkernel=256M vfio.dyndbg=+pflmt irq_gic_v3_its.dyndbg=+pflmt iommu.dyndbg=+pflmt irqdomain.dyndbg=+pflmt" -drive if=none,file=/home/lixiang/sda2/work/runninglinuxkernel_5.0/rootfs_debian_arm64.ext4,id=hd0 -device virtio-blk-device,drive=hd0 --fsdev local,id=kmod_dev,path=./kmodules,security_model=none -device virtio-9p-pci,fsdev=kmod_dev,mount_tag=kmod_mount
WARNING: Image format was not specified for '/home/xxx/sda2/work/runninglinuxkernel_5.0/rootfs_debian_arm64.ext4' 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.
qemu-system-aarch64: -device virtio-9p-pci,fsdev=kmod_dev,mount_tag=kmod_mount: 'virtio-9p-pci' is not a valid device model name
$

2 解决两个问题的方法

2.1 解决’virtio-9p-pci’ is not a valid device model name的问题

该解决方法参考了QEMU解决运行问题virtio-9p-pci is not a valid device model name文章,但是该文章的总结不够全面,所以再稍微补充一下。

2.1.1 下载qemu源码,重新编译qemu

该处参考了在ubuntu上执行QEMU的编译安装文章的方法。

2.1.1.1 qemu的下载地址

https://download.qemu.org/

我在我本地下载的是qemu-7.2.5.tar.xz

2.1.1.2 qemu编译安装

  • --enable-virtfs 配置选项后,QEMU 将包含支持 virtfs 的代码

将下面的下载的qemu-7.2.5.tar.xz放到自己想放置的目录中, 然后执行下面的步骤。

tar xvJf qemu-7.2.5.tar.xz
mkdir build && cd build
../qemu-7.2.5/configure	--enable-virtfs	(在该处会检查依赖软件)
make -j8	(在该处编译的时间比较长)
sudo make install	(sudo在使用的时候有的时候是必须的,否则会提示没有root权限去执行)

2.1.1.3 查看安装之后的结果

安装之后的可执行程序在/usr/local/bin/目录下,直接查看它的版本号即可。由下面的提示可以看出,我们的qemu已经是最新的7.2.5了。

$ qemu-system-aarch64 --version
QEMU emulator version 7.2.5
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
lixiang@whw:~/sda2/software/qemu-7.2.5$

2.1.2 qemu编译过程中的编译依赖问题

2.1.2.1 如何解决AttributeError: Can’t get attribute ‘OctalInt’ on <module ‘mesonbuild.coredata’ from ‘/usr/lib/python3/dist-packages/mesonbuild/coredata.py’>

该问题的解决参考了Meson install error: Can’t get attribute ‘OctalInt’ #8425的解决方法,卸载并重新安装meson即可
在这里插入图片描述
meson卸载和重新安装的方法如下所示:

如果你想在 Ubuntu 系统上移除 Meson,可以使用以下命令:

sudo apt remove meson
该命令会卸载 Meson 及其相关的包,但保留可能被其他软件依赖的库文件。如果你希望彻底移除与 Meson 相关的所有文件,可以使用以下命令:

sudo apt purge meson
此命令将移除 Meson 及其相关的包,并删除配置文件和其他相关文件。

请注意,在使用 apt purge 命令之前,请仔细检查所列出的要被移除的包列表,以确保不会误删其他重要的软件包。

完成后,可以运行以下命令来验证 Meson 是否已成功移除:

meson --version
如果该命令找不到 Meson 并返回错误消息,则说明 Meson 已被正确地从系统中移除。

重新安装meson软件:
sudo pip install meson

查看meson的版本号来确认meson是否安装成功
meson --version

2.1.2.2 /home/xxx/sda2/software/tmp/meson-logs/meson-log.txt提示libcap-ng-dev libattr1-dev软件缺失

执行libcap-ng-dev libattr1-dev两个软件的安装命令

更新软件
sudo apt-get update

安装libcap-ng-dev libattr1-dev
sudo apt-get install libcap-ng-dev libattr1-dev

2.1.2.3 Cannot find Ninja

当系统提示找不到Ninja时,执行下面的命令去安装即可。

sudo apt-get install ninja-build

查看安装的Ninja版本号:

rlk@rlk:build$ ninja --version
1.10.0

2.1.2.3 glib-2.48 gthread-2.0 is required to compile QEMU

执行下面的命令即可

 sudo apt-get install libglib2.0-dev

2.1.2.4 ERROR: Dependency “pixman-1” not found, tried pkgconfig

Run-time dependency pixman-1 found: NO (tried pkgconfig)

../qemu-7.0.0/meson.build:522:2: ERROR: Dependency "pixman-1" not found, tried pkgconfig

A full log can be found at /home/chehejia/work/qemu/build/meson-logs/meson-log.txt

ERROR: meson setup failed

执行下面的命令:

sudo apt-get install meson
sudo apt-get install libpixman-1-dev

2.1.3 qemu安装成功之后确认是否已经支持virtio-9p设备

$ qemu-system-aarch64 --version
QEMU emulator version 7.2.5
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
$

$ qemu-system-aarch64 -device help | grep virtio-9p-pci
name "virtio-9p-pci", bus PCI, alias "virtio-9p"
name "virtio-9p-pci-non-transitional", bus PCI
name "virtio-9p-pci-transitional", bus PCI
$

2.2 解决rootfs_debian_arm64.ext4’ and probing guessed raw

2.2.1 错误的详细信息

WARNING: Image format was not specified for '/home/xxx/sda2/work/runninglinuxkernel_5.0/rootfs_debian_arm64.ext4' 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.

2.2.2 解决方法

-drive if=none,file=/home/lixiang/sda2/work/runninglinuxkernel_5.0/rootfs_debian_arm64.ext4,id=hd0 修改为-drive if=none,file=/home/lixiang/sda2/work/runninglinuxkernel_5.0/rootfs_debian_arm64.ext4,format=raw,id=hd0 ,为rootfs_debian_arm64.ext4添加format=raw的属性。

qemu-system-aarch64 -m 1024 -cpu max,sve=on,sve256=on -M virt,gic-version=3,its=on,iommu=smmuv3 -nographic -smp 4 -kernel arch/arm64/boot/Image -append "noinitrd nokaslr loglevel=8 sched_debug root=/dev/vda rootfstype=ext4 rw crashkernel=256M vfio.dyndbg=+pflmt irq_gic_v3_its.dyndbg=+pflmt iommu.dyndbg=+pflmt irqdomain.dyndbg=+pflmt" -drive if=none,file=/home/lixiang/sda2/work/runninglinuxkernel_5.0/rootfs_debian_arm64.ext4,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 --fsdev local,id=kmod_dev,path=./kmodules,security_model=none -device virtio-9p-pci,fsdev=kmod_dev,mount_tag=kmod_mount

猜你喜欢

转载自blog.csdn.net/u014100559/article/details/132604327