rust-vmm / vhost-device

'vhost-user' device backends workspace
Apache License 2.0
67 stars 46 forks source link

Make error logs more descriptive #682

Open dorjoy03 opened 2 months ago

dorjoy03 commented 2 months ago

If I run vhost-device-vsock with a vring queue size smaller than 1024 with QEMU's vhost-user-vsock-device (i.e., the mmio version, not the pci one) an error is printed on the vhost-device-vsock terminal:

[2024-06-30T10:57:54Z ERROR vhost_device_vsock] Fatal error: failed to handle request: invalid parameters 

The commands to reproduce this are:

shell1: ./target/release/vhost-device-vsock --vm guest-cid=4,uds-path=/tmp/vm4.vsock,socket=/tmp/vhost4.socket

shell2: ./qemu-system-x86_64 -M microvm,memory-backend=mem0 -kernel ./bzImage -nographic -append "console=ttyS0 nokaslr" -initrd ./initramfs.cpio.gz -m 4G --enable-kvm -cpu host -object memory-backend-memfd,id=mem0,size=4G -chardev socket,id=char0,reconnect=0,path=/tmp/vhost4.socket -device vhost-user-vsock-device,chardev=char0

The error comes from set_vring_num when QEMU's device side tries to set the vring queue size to 1024 but vhost-device-vsock has a max queue size less than that.

The error log "invalid parameters" does not convey enough details why there was this error whereas the error log should contain more details that the error was due to trying to set vring queue size more than the max queue size currently allocated in vhost-device-vsock. Only saying "invalid parameters" makes it very hard to debug why there was an error.

This issue is about making the error logs (or other logs as well?) more descriptive so that it's easier to understand why there was an error.

See discussion around https://github.com/rust-vmm/vhost-device/pull/679#issuecomment-2214848659 for more context.