I was reading some materials about qemu internals, and here it mentions that:
"Jumping into guest code takes away our control of execution and gives control to the guest. While a thread is running guest code it cannot simultaneously be in the event loop because the guest has (safe) control of the CPU. Typically the amount of time spent in guest code is limited because reads and writes to emulated device registers and other exceptions cause us to leave the guest and give control back to QEMU. In extreme cases a guest can spend an unbounded amount of time without giving up control and this would make QEMU unresponsive. In order to solve the problem of guest code hogging QEMU's thread of control signals are used to break out of the guest. A UNIX signal yanks control away from the current flow of execution and invokes a signal handler function. This allows QEMU to take steps to leave guest code and return to its main loop where the event loop can get a chance to process pending events."
So it's not clear to me what generates signals (qemu's IO thread or the kernel?) and how does it help to break out of the thread executing guest code? If the kernel sends such signal to the qemu process, then I would assume that qemu intentionally injects certain instructions (binary translation) in the guest code, which result in exceptions and then signals?