vhost-user-gpu: fd handler registered for descriptor -1; with the io_uring fd monitor the main loop spins forever ("failed to read msg header: 0")
Environment: as in #4846 (QEMU 11.0.3, pve-qemu-kvm 11.0.3-3; unchanged in master as of 2026-09-10, including util/fdmon-io_uring.c).
Setup: as in #4846.
Steps: start the VM while a Display1 client is already attached, so it connects before the guest driver sets DRIVER_OK. Keeping a client attached across a device stop (VM pause, guest reset) leads to the same state.
Result: from the first acknowledged GL update on, QEMU logs
kvm: failed to read msg header: 0, 95about 1,250 times a second, with no end: 75,000 lines a minute for 2.5 hours, until the VM was stopped. The main loop never sleeps (QEMU at 438% CPU), the guest barely boots and never starts its GPU. The same VM started without an attached client works.
Analysis:
- Every Display1 UpdateDMABUF completion (a reply, a timeout, or a client that went away) unblocks the console: qemu_console_hw_gl_block(con, false) → virtio_gpu_gl_block() → vhost_user_gpu_gl_flushed() → vhost_user_gpu_update_blocked(g, false) → qemu_set_fd_handler(g->vhost_gpu_fd, vhost_user_gpu_chr_read, ...). vhost_gpu_fd is -1 from realize until the first DRIVER_OK and again after every stop, and nothing checks it.
- aio_context_setup() uses fdmon-io_uring whenever io_uring is available. IORING_OP_POLL_ADD on -1 completes at once with -EBADF, and process_cqe_aio_handler() hands cqe->res to pfd_events_from_poll(), which turns -9 into G_IO_IN, G_IO_OUT and G_IO_HUP. The handler runs, qemu_chr_fe_read_all() on a frontend without a chardev returns 0, and the poll is re-armed.
- The node for fd -1 is never removed, so the loop continues after the real GPU socket exists. With fdmon-poll or fdmon-epoll the same registration is harmless.
Expected: no fd handler while there is no GPU socket; a negative POLL_ADD result treated as an error rather than readiness (or aio_set_fd_handler() refusing fd < 0). Any other caller that registers -1 would spin the same way under fdmon-io_uring.
Signed-off-by: Dmitry R rdmitry0911@gmail.com