qemu running prompts virtio-9p-pci is not a valid device model name and rootfs_debian_arm64.ext4 and probing gues

qemu running prompts ‘virtio-9p-pci’ is not a valid device model name and rootfs_debian_arm64.ext4′ and probing gues

  • 1 Commands executed by qemu and corresponding prompts
    • 1.1 qemu run command
    • 1.2 Errors prompted by qemu running
  • 2 ways to solve two problems
    • 2.1 Solve the problem of ‘virtio-9p-pci’ is not a valid device model name
      • 2.1.1 Download qemu source code and recompile qemu
        • 2.1.1.1 qemu download address
        • 2.1.1.2 qemu compilation and installation
        • 2.1.1.3 View the results after installation
      • 2.1.2 Compilation dependency issues during qemu compilation process
        • 2.1.2.1 How to solve AttributeError: Can’t get attribute ‘OctalInt’ on
        • 2.1.2.2 /home/xxx/sda2/software/tmp/meson-logs/meson-log.txt prompts that libcap-ng-dev libattr1-dev software is missing
        • 2.1.2.3 Cannot find Ninja
        • 2.1.2.3 glib-2.48 gthread-2.0 is required to compile QEMU
        • 2.1.2.4 ERROR: Dependency “pixman-1” not found, tried pkgconfig
      • 2.1.3 After successful installation of qemu, confirm whether the virtio-9p device is supported
    • 2.2 Solving rootfs_debian_arm64.ext4′ and probing guessed raw
      • 2.2.1 Error details
      • 2.2.2 Solutions

When using qemu debugging to start the kernel of runninglinuxkernel_5.0, executing the qemu startup command prompted the errors of 'virtio-9p-pci' is not a valid device model name and rootfs_debian_arm64.ext4′ and probing gues. When solving the problem, I referred to several articles previously summarized by other students.

1 Commands executed by qemu and corresponding prompts

1.1 qemu run command

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 Errors prompted by qemu running

Two errors were prompted, namely:

  • 'virtio-9p-pci' is not a valid device model name, indicating that the current qemu does not support the virtio-9p device
  • '/home/xxx/sda2/work/runninglinuxkernel_5.0/rootfs_debian_arm64.ext4' and probing guessed raw. prompts that the current file system is a raw file and you need to specify the raw attribute.
$ ./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 Methods to solve two problems

2.1 Solve the problem of ‘virtio-9p-pci’ is not a valid device model name

This solution refers to the article QEMU solves the operating problem virtio-9p-pci is not a valid device model name, but the summary of the article is not comprehensive enough, so I will add a little more.

2.1.1 Download qemu source code and recompile qemu

This section refers to the method of compiling and installing QEMU on ubuntu.

2.1.1.1 qemu download address

https://download.qemu.org/

What I downloaded locally is qemu-7.2.5.tar.xz

2.1.1.2 qemu compilation and installation

  • --enable-virtfs After configuring the option, QEMU will include code that supports virtfs

Place the downloaded qemu-7.2.5.tar.xz below into the directory you want to place it, and then perform the following steps.

tar xvJf qemu-7.2.5.tar.xz
mkdir build & amp; & amp; cd build
../qemu-7.2.5/configure --enable-virtfs (Dependent software will be checked here)
make -j8 (compiling here takes longer)
sudo make install (sudo is sometimes necessary when using it, otherwise it will prompt that you do not have root permission to execute)

2.1.1.3 View the results after installation

The executable program after installation is in the /usr/local/bin/ directory, just check its version number directly. As can be seen from the following prompts, our qemu is already the latest 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 Compilation dependency issues during qemu compilation

2.1.2.1 How to solve AttributeError: Can’t get attribute ‘OctalInt’ on

To solve this problem, please refer to the solution of Meson install error: Can’t get attribute OctalInt’ #8425. Just uninstall and reinstall meson.

The method of uninstalling and reinstalling meson is as follows:

If you want to remove Meson on Ubuntu system, you can use the following command:

sudo apt remove meson
This command will uninstall Meson and its related packages, but keep library files that may be relied upon by other software. If you wish to completely remove all files related to Meson, you can use the following command:

sudo apt purge meson
This command will remove Meson and its related packages, and delete configuration files and other related files.

Please note that before using the apt purge command, please carefully check the list of packages to be removed to ensure that other important packages are not deleted by mistake.

Once completed, you can run the following command to verify that Meson was successfully removed:

meson --version
If the command cannot find Meson and returns an error message, Meson has been correctly removed from the system.

Reinstall meson software:
sudo pip install meson

Check the meson version number to confirm whether meson is installed successfully.
meson --version

2.1.2.2 /home/xxx/sda2/software/tmp/meson-logs/meson-log.txt prompts that libcap-ng-dev libattr1-dev software is missing

Execute the installation commands of the two software libcap-ng-dev libattr1-dev

Update software
sudo apt-get update

Install libcap-ng-dev libattr1-dev
sudo apt-get install libcap-ng-dev libattr1-dev

2.1.2.3 Cannot find Ninja

When the system prompts that Ninja cannot be found, execute the following command to install it.

sudo apt-get install ninja-build

Check the installed Ninja version number:

rlk@rlk:build$ ninja --version
1.10.0

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

Just execute the following command

 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

Execute the following command:

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

2.1.3 After successful installation of qemu, confirm whether the virtio-9p device is supported

$ 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 Solving rootfs_debian_arm64.ext4’ and probing guessed raw

2.2.1 Error details

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 Solution

Change -drive if=none,file=/home/lixiang/sda2/work/runninglinuxkernel_5.0/rootfs_debian_arm64.ext4,id=hd0 to -drive if=none,file=/ home/lixiang/sda2/work/runninglinuxkernel_5.0/rootfs_debian_arm64.ext4,format=raw,id=hd0, add format=raw for rootfs_debian_arm64.ext4 properties.

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