Transcript
Outline• QEMU
• Parallel vs Event-driven
• main_loop_wait
• Workers
• Running guest code
• iothread vs non-iothread
• Processes scheduling
• What’s being scheduled?
2
QEMU
• 3 guests on a host
• 3 QEMU processes
• $ qemu guest.imgLinux host kernel
QEMU QEMUQEMU Firebox
3
Parallel vs Event-driven• Parallel architecture ( threaded architecture ) :
• splits work into processes or threads
• do works simultaneously.
• Event-driven:
• events determine the flow of program.
• loop and dispatch events to handlers
4
Parallel vs Event-driven
• QEMU use a :
• hybrid architecture:
• combination of event-driven and threaded architecture
5
main_loop_wait()• it waits for
• file descriptor (io ,files, sockets and other resources)
• timers to expired
• then invokes callback()
• callbacks could be expensive sometime
• workers are here to help
6
Workers• dedicated thread on a job
• parallel parts of core QEMU
• How do they work
• QEMU issues an asynchronous request
• request are pushed to queue
• worker dequeues and execute
• worker emits an event / signal
7
Running guest code
• TCG (emulator)
• KVM (simulator)
Running guest code• while running guest code:
• guest OS has the control of execution
• until…
• exception
• UNIX signal
• control of execution is then back to QEMU
iothread vs non-iothread• non-iothread
• used in default :
• ./configure && make.
• !CONFIG_IOTHREAD
• iothread
• ./configure --enable-io-thread
• CONFIG_IOTHREAD
10
non-iothread model• QEMU thread:
• run guest code
• exception / signal
• check event loop
• back to guest code
Linux host kernel
QEMU QEMUQEMU
QEMU
Worker(s)
11
iothread model• 1 QEMU thread per vCPU
• execute guest code
• 1 iothread
• check event loop
• many workers
Linux host kernel
QEMU
12
vCPU 0
iothread
vCPU 1
Worker(s)
vCPU 0
iothread
vCPU 1
Worker(s)
Processes scheduling
• QEMU don’t know how to / how it will be scheduled
• Only the host OS scheduler would know
What’s being scheduled?• QEMU( 1 thread/VM in non-iothread model )
• vCPUs ( 1 thread/vCPU in iothread, -smp )
• workers ( 0 to many when handling special jobs )
• iothread (1 thread/VM in iothread model)
• other processes on host ( firefox, spotify)
top related