sifive / freedom-u-sdk

Freedom U Software Development Kit (FUSDK)
278 stars 125 forks source link

Failed to get "write" lock when trying to run qemu #152

Closed yslys closed 3 years ago

yslys commented 3 years ago

Hi, I successfully set up the environment several weeks ago, and it worked well until then.

Since I am using ssh to another remote machine, sometimes the connection might be closed due to some issues. This leads to the fact that I have not yet hit "Ctrl A + X" but lost the connection. Therefore, all I could do was to ssh again.

This error has never occurred before, but it happens today. After I execute the command: MACHINE=qemuriscv64 runqemu qemuparams="-m 2048" nographic slirp, error occurs:

runqemu - INFO - Running MACHINE=qemuriscv64 bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [/path_to_src/riscv-sifive/build/tmp-glibc/deploy/images/qemuriscv64/Image--5.10.25+git0+031f6c76e4_cf5b0320cf-r0-qemuriscv64-20210701160127.bin]
BIOS: [/path_to_src/riscv-sifive/build/tmp-glibc/deploy/images/qemuriscv64/fw_jump.elf]
MACHINE: [qemuriscv64]
FSTYPE: [ext4]
ROOTFS: [/path_to_src/riscv-sifive/build/tmp-glibc/deploy/images/qemuriscv64/demo-coreip-cli-qemuriscv64-20210701160127.rootfs.ext4]
CONFFILE: [/path_to_src/riscv-sifive/build/tmp-glibc/deploy/images/qemuriscv64/demo-coreip-cli-qemuriscv64-20210701160127.qemuboot.conf]

runqemu - INFO - Network configuration: ip=dhcp
runqemu - INFO - Acquiring lockfile /tmp/qemu-port-locks/2222.lock failed: [Errno 11] Resource temporarily unavailable
runqemu - INFO - Port forward changed: 2222 -> 2223
runqemu - INFO - Acquiring lockfile /tmp/qemu-port-locks/2323.lock failed: [Errno 11] Resource temporarily unavailable
runqemu - INFO - Port forward changed: 2323 -> 2324
runqemu - INFO - Port forward: hostfwd=tcp::2223-:22 hostfwd=tcp::2324-:23
runqemu - INFO - Running //path_to_src/riscv-sifive/build/tmp-glibc/work/x86_64-linux/qemu-helper-native/1.0-r1/recipe-sysroot-native/usr/bin/qemu-system-riscv64 -device virtio-net-device,netdev=net0,mac=52:54:00:12:35:04 -netdev user,id=net0,hostfwd=tcp::2223-:22,hostfwd=tcp::2324-:23,tftp=/path_to_src/riscv-sifive/build/tmp-glibc/deploy/images/qemuriscv64 -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 -drive id=disk0,file=/path_to_src/riscv-sifive/build/tmp-glibc/deploy/images/qemuriscv64/demo-coreip-cli-qemuriscv64-20210701160127.rootfs.ext4,if=none,format=raw -device virtio-blk-device,drive=disk0 -device virtio-mouse-pci -device virtio-keyboard-pci  -machine virt  -m 2048  -m 2048 -serial mon:stdio -serial null -nographic -device bochs-display -kernel /path_to_src/riscv-sifive/build/tmp-glibc/deploy/images/qemuriscv64/Image--5.10.25+git0+031f6c76e4_cf5b0320cf-r0-qemuriscv64-20210701160127.bin -append 'root=/dev/vda rw  mem=2048M ip=dhcp console=ttyS0 console=hvc0 earlycon=sbi ' -bios /path_to_src/riscv-sifive/build/tmp-glibc/deploy/images/qemuriscv64/fw_jump.elf

runqemu - ERROR - Failed to run qemu: qemu-system-riscv64: -device virtio-blk-device,drive=disk0: Failed to get "write" lock
Is another process using the image [/path_to_src/riscv-sifive/build/tmp-glibc/deploy/images/qemuriscv64/demo-coreip-cli-qemuriscv64-20210701160127.rootfs.ext4]?

runqemu - INFO - Cleaning up

May I know if this is because of I not hitting "Ctrl A + X" before losing the connection to the host machine? What could I do to check if another process is using such image? Will simply killing such process work?

Could anyone please tell me how to solve this issue? Thanks in advance.

yslys commented 3 years ago

By executing ps aux | grep user_name where user_name is current user, I noticed that there was a process currently running the qemu. By executing kill pid, the problem is solved.