Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.
Dom edited this page Aug 18, 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
2.Format partition
mkfs.ext4 /dev/nvme0n1p1

3.Mount partition
mount /dev/nvme0n1p1 nvme

SRIOV error:

./build/qemu-system-aarch64 -nographic -machine virt -cpu host -accel kvm -bios /home/dom/Qemu/bin/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=/home/dom/Qemu/bin/images/debian-12-generic-arm64-20230711-1438.qcow2,format=qcow2,id=hd1 -device virtio-blk-pci,drive=hd1,bootindex=0 -drive if=none,file=/home/dom/Qemu/bin/images/cloudinit,format=raw,id=hd10 -device virtio-blk-pci,drive=hd10,bootindex=10 -device nvme-subsys,id=subsys0 -device nvme,id=nvme0,bus=pcie.0,addr=4.0,serial=deadbead,subsys=subsys0,sriov_max_vfs=3,sriov_vq_flexible=6,sriov_vi_flexible=3

Error:slot 4 function 0 not available for nvme, in use by virtio-blk-pci,id=(null)

Solution

--device virtio-blk-pci
+-device virtio-blk-device

On VM Error:

echo 7 > /sys/bus/pci/devices/0000\:01\:00.0/sriov_numvfs
[  171.261175] pci 0000:01:00.0: no driver bound to device; cannot configure SR-IOV
bash: echo: write error: No such file or directory

Solution:

TBD

PCI Error:

/usr/bin/qemu-system-x86_64 -nographic -name avocado-vt-vm1 -machine pc,memory-backend=mem-machine_mem -m 2048 -object memory-backend-ram,size=2048M,id=mem-machine_mem -smp 2,maxcpus=2,cores=2,threads=
1,dies=1,sockets=1 -cpu Skylake-Client-noTSX-IBRS -blockdev node-name=file_image1,driver=file,aio=native,filename=/root/avocado/data/avocado-vt/images/jeos-27-x86_64_test.qcow2,cache.direct=on,cache.no-f
lush=off -blockdev node-name=drive_image1,driver=qcow2,cache.direct=on,cache.no-flush=off,file=file_image1 -device virtio-blk-pci,id=image1,drive=drive_image1,bootindex=1,write-cache=on,bus=pci.0,addr=0x
1 -blockdev node-name=file_unattended,driver=file,aio=native,filename=/root/avocado/data/avocado-vt/images/jeos-27-x86_64/ks.iso,cache.direct=on,cache.no-flush=off -blockdev node-name=drive_unattended,dr
iver=raw,read-only=on,cache.direct=on,cache.no-flush=off,file=file_unattended -device ide-cd,id=unattended,drive=drive_unattended,bootindex=3,write-cache=on,bus=ide.0,unit=0 -kernel /root/avocado/data/av
ocado-vt/images/jeos-27-x86_64/vmlinuz -append 'console=tty0 console=ttyS0 ks=cdrom nicdelay=60 inst.repo=https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/27/Server/x86_64/os' -initrd
 /root/avocado/data/avocado-vt/images/jeos-27-x86_64/initrd.img -rtc base=utc,clock=host -boot menu=off,order=cdn,once=c,strict=off -net nic -net user -enable-kvm

qemu-system-x86_64: -device virtio-blk-pci,id=image1,drive=drive_image1,bootindex=1,write-cache=on,bus=pci.0,addr=0x3: PCI: slot 3 function 0 not available for virtio-blk-pci, in use by e1000

Change addr=0x03 to addr = 0x01,the error still exists:

qemu-system-x86_64: -device virtio-blk-pci,id=image1,drive=drive_image1,bootindex=1,write-cache=on,bus=pci.0,addr=0x1: PCI: slot 1 function 0 not available for virtio-blk-pci, in use by PIIX3

Solution:

-device virtio-blk-pci,id=image1,drive=drive_image1,bootindex=1,write-cache=on,bus=pci.0,addr=0x4