+ All Categories
Home > Science > Qemu structure

Qemu structure

Date post: 15-Aug-2015
Category:
Upload: howard-chang
View: 142 times
Download: 11 times
Share this document with a friend
Popular Tags:
14
QEMU structure and scheduling 1 reference: http://blog.vmsplice.net/
Transcript
Page 1: Qemu structure

QEMU structure and scheduling

1

reference: http://blog.vmsplice.net/

Page 2: Qemu structure

Outline• QEMU

• Parallel vs Event-driven

• main_loop_wait

• Workers

• Running guest code

• iothread vs non-iothread

• Processes scheduling

• What’s being scheduled?

2

Page 3: Qemu structure

QEMU

• 3 guests on a host

• 3 QEMU processes

• $ qemu guest.imgLinux host kernel

QEMU QEMUQEMU Firebox

3

Page 4: Qemu structure

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

Page 5: Qemu structure

Parallel vs Event-driven

• QEMU use a :

• hybrid architecture:

• combination of event-driven and threaded architecture

5

Page 6: Qemu structure

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

Page 7: Qemu structure

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

Page 8: Qemu structure

Running guest code

• TCG (emulator)

• KVM (simulator)

Page 9: Qemu structure

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

Page 10: Qemu structure

iothread vs non-iothread• non-iothread

• used in default :

• ./configure && make.

• !CONFIG_IOTHREAD

• iothread

• ./configure --enable-io-thread

• CONFIG_IOTHREAD

10

Page 11: Qemu structure

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

Page 12: Qemu structure

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)

Page 13: Qemu structure

Processes scheduling

• QEMU don’t know how to / how it will be scheduled

• Only the host OS scheduler would know

Page 14: Qemu structure

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)


Recommended