static void qemu_kvm_wait_io_event(CPUState *cpu) { while (cpu_thread_is_idle(cpu)) { /* HLT 退出情况下,cpu_thread_is_idle 成立 * vcpu 线程等在 halt_cond 信号上 */ qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex); } /* qemu_kvm_eat_signals 中会等一个 SIG_IPI 信号 */...
server发现断点会通过cpu_breakpoint_insert()将断点加入cpu的断点列表cpu->breakpoints,并执行breakpoint_invalidate() -> tb_flush(),将do_tb_flush放入cpu的工作队列(work item list),并用qemu_cond_broadcast()通知在qemu_wait_io_event()中等待的cpu有work item需要执行。之后恢复cpu的执行,即可以进入cpu_ex...
* qemu_tcg_wait_io_event. async_run_on_cpu, instead, * causes cpu_thread_is_idle to return false. This way, * handle_icount_deadline can run. * If we have no CPUs at all for some reason, we don't * need to do anything. */ async_run_on_cpu(first_cpu, do_nothing, RUN_ON...
}qemu_wait_io_event(cpu);}while(!cpu->unplug ||cpu_can_run(cpu)); kvm_destroy_vcpu(cpu); cpu_thread_signal_destroyed(cpu); qemu_mutex_unlock_iothread(); rcu_unregister_thread();returnNULL; } void*kvm_cpu_thread(void*data) {structkvm *kvm = (structkvm *)data;intret =0; kvm_r...
event_notifier_init:完成eventfd的创建工作,它实际上就是调用系统调用eventfd()的接口,得到对应的文件描述符; memory_region_add_eventfd:为内存区域添加eventfd,将eventfd和对应的内存区域关联起来; 看一下memory_region_add_eventfd的流程: 内存区域MemoryRegion中的ioeventfds成员按照地址从小到大排序,memory_region_ad...
Qemu中的main loop主要采用 了glib中的事件循环,关于此详细内容,准备后面专门写一小节,本节主要看主体IO框架。 该函数主要就分配了一个Garray结构存储全局的GpollFD,在main_loop中的main_loop_wait阶段有两个比较重要的函数:qemu_iohandler_fill,os_host_main_loop_wait和qemu_iohandler_poll,前者把用户添加的fd...
qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex); }qemu_kvm_eat_signals(cpu); qemu_wait_io_event_common(cpu); }static void *qemu_kvm_cpu_thread_fn(void *arg) { CPUState *cpu = arg; int r;qemu_mutex_lock(&qemu_global_mutex); qemu_thread_get_self(cpu->thread); ...
qemu_wait_io_event(cpu); } while (!cpu->unplug || cpu_can_run(cpu)); tcg_cpus_destroy(cpu); tcg_cpu_destroy(cpu); bql_unlock(); rcu_remove_force_rcu_notifier(&force_rcu.notifier); rcu_unregister_thread(); Expand Down 4 changes: 2 additions & 2 deletions 4 accel/tcg/tcg-acce...
event_notifier_init:完成eventfd的创建工作,它实际上就是调用系统调用eventfd()的接口,得到对应的文件描述符; memory_region_add_eventfd:为内存区域添加eventfd,将eventfd和对应的内存区域关联起来; 看一下memory_region_add_eventfd的流程: 内存区域MemoryRegion中的ioeventfds成员按照地址从小到大排序,memory_region_ad...
/usr/bin/qemu-system-aarch64 -id 112 -name 'vm112,debug-threads=on' -no-shutdown -chardev 'socket,id=qmp,path=/var/run/qemu-server/112.qmp,server=on,wait=off' -mon 'chardev=qmp,mode=control' -chardev 'socket,id=qmp-event,path=/var/run/qmeventd.sock,reconnect=5' -mon 'chardev...