Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.
Dom edited this page Aug 10, 2023 · 20 revisions
./qemu-system-aarch64 -nographic -machine virt -cpu host -accel kvm -bios QEMU_EFI.fd -net user,hostfwd=tcp::2222-:22 -net nic -smp cpus=8 -m 4G -net nic -net user,hostfwd=tcp::10021-:22 -drive if=none,file=/root/avocado/data/avocado-vt/images/debian-9.4.0-aarch64_test.qcow2,format=qcow2,id=hd1 -device virtio-blk-pci,drive=hd1,bootindex=0 -drive if=none,file=cloudinit,format=raw,id=hd10 -device virtio-blk-pci,drive=hd10,bootindex=10

ssh debian@127.0.0.1 -p 10021

VM stucks.

AmpereOne

07.24

git clone https://gitlab.com/qemu-project/qemu.git code
pushd code
./configure --target-list=aarch64-softmmu --enable-trace-backends=log --enable-debug --enable-debug-info --enable-vnc --disable-lzo --disable-snappy --disable-docs --disable-werror
make -j100
popd

mkdir bin
cd bin
cp ../code/aarch64-softmmu/qemu-system-aarch64 .

Copy some files for qemu from other server.

./qemu-system-aarch64 -nographic -machine virt -cpu host -bios QEMU_EFI.fd -smp cpus=8 -m 4G -net nic -net user,hostfwd=tcp::2222-:22 -enable-kvm -drive if=none,file=debian-12-nocloud-arm64-20230711-1438.qcow2,format=qcow2,id=hd1 -device virtio-blk-pci,drive=hd1,bootindex=0 -drive if=none,file=cloudinit,format=raw,id=hd10 -device virtio-blk-pci,drive=hd10,bootindex=10
qemu-system-aarch64: PMU: KVM_SET_DEVICE_ATTR: Invalid argument
qemu-system-aarch64: failed to set irq for PMU
./run.sh: line 22: 18000 Aborted

Solution:

qemu-system-aarch64 -nographic -machine virt,gic-version=max -drive file=test/flash0.img,format=raw,if=pflash -drive file=test/flash1.img,format=raw,if=pflash -cpu max -smp cpus=2 -m 1G -drive if=none,file=debian-12-nocloud-arm64-20230711-1438.qcow2,format=qcow2,id=hd1 -device virtio-blk-pci,drive=hd1,bootindex=0

VM gets stuck when kvm is enabled.

QMP usage

echo -e '{ "execute": "qmp_capabilities" }\n { "execute": "query-commands", "id": "RAND91" }\n { "execute": "quit" }' | qemu-system-x86_64 -qmp stdio -vnc none -S

HMP usage

Output help message on aarch64 platform

echo -e 'help\nquit' | /home/dom/Qemu/code/qemu_6.2/build/qemu-system-x86_64 -monitor stdio -vnc none -S

Output error on aarch64 platform:

echo -e 'help\nquit' | /home/dom/Qemu/code/qemu_6.2/build/qemu-system-aarch64 -monitor stdio -vnc none -S

return:
qemu-system-aarch64: No machine specified, and there is no default
Use -machine help to list supported machines

Solution:

echo -e 'help\nquit' | /home/dom/Qemu/code/qemu_6.2/build/qemu-system-aarch64 -machine none -monitor stdio -vnc none -S

The command with pipe is same as:
/home/dom/Qemu/code/qemu_6.2/build/qemu-system-aarch64 -machine none -monitor stdio -vnc none -S
(qemu) help
(qemu) quit

BTW,the parameter "-e" must exist in shell,but not in python.

Shell error in python

virttest/qemu_devices/qcontainer.py
            _ = process.run("echo -e 'help\nquit' | %s -monitor "
                            "stdio -vnc none -S" % qemu_binary,
                            timeout=10, ignore_status=True,
                            shell=True, verbose=False).stdout_text

It returns:

QEMU 8.0.3 monitor - type 'help' for more information^M (qemu) -^[[K^[[D-e^[[K^[[D^[[D-e ^[[K^[[D^[[D^[[D-e h^[[K^[[D^[[D^[[D^[[D-e he^[[K^[[D^[[D^[[D^[[D^[[D-e hel^[[K^[[D^[[D^[[D^[[D^[[D^[[D-e help^[[K^M unknown command: '-e'^M (qemu) q^[[K^[[Dqu^[[K^[[D^[[Dqui^[[K^[[D^[[D^[[Dquit^[[K^M

Solution:

            _ = process.run("echo 'help\nquit' | %s -monitor "
                            "stdio -vnc none -S" % qemu_binary,
                            timeout=10, ignore_status=True,
                            shell=True, verbose=False).stdout_text
It returns:
QEMU 8.0.3 monitor - type 'help' for more information^M
(qemu) h^[[K^[[Dhe^[[K^[[D^[[Dhel^[[K^[[D^[[D^[[Dhelp^[[K^M
announce_self [interfaces] [id] -- Trigger GARP/RARP announcements^M
balloon target -- request VM to change its memory allocation (in MB)^M
block_job_cancel [-f] device -- stop an active background block operation (use -f^M
             if you want to abort the operation immediately^M
             instead of keep running until data is in sync)^M
...
xp /fmt addr -- physical memory dump starting at 'addr'^M
(qemu) q^[[K^[[Dqu^[[K^[[D^[[Dqui^[[K^[[D^[[D^[[Dquit^[[K^M

nvme Command:

qemu-img create -f raw nvm.img 10G
qemu-system-aarch64 -nographic -machine virt -cpu host -accel kvm -bios images/QEMU_EFI.fd -net user,hostfwd=tcp::2222-:22 -net nic -smp cpus=8 -m 4G -net nic -net user,hostfwd=tcp::10021-:22 -drive if=none,file=images/debian-12-generic-arm64-20230711-1438.qcow2,format=qcow2,id=hd1 -device virtio-blk-pci,drive=hd1,bootindex=0 -drive if=none,file=images/cloudinit,format=raw,id=hd10 -device virtio-blk-pci,drive=hd10,bootindex=10 -drive file=images/nvm.img,format=raw,if=none,id=nvm -device nvme,serial=foo,drive=nvm

On VM:
lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
vda     254:0    0    2G  0 disk
├─vda1  254:1    0  1.9G  0 part /
└─vda15 254:15   0  127M  0 part /boot/efi
vdb     254:16   0    8M  0 disk
nvme0n1 259:0    0   10G  0 disk

mkdir nvme
mount /dev/nvme0n1 nvme
wrong fs type, bad option, bad superblock on /dev/nvme0n1, missing codepage or helper program, or other error.

Solution:

1.Create partition.
fdisk /dev/nvme0n1
n     
p
w

mkfs.ext4 /dev/nvme0n1p1

mount /dev/nvme0n1p1 nvme
Clone this wiki locally