Cpu Virtualization
Summary
CPU Virtualization
Hypervisor has to give illusion of ownership of cpu for each VM
- This includes the “ready queue”
The hypervisor schedules execution of VMs, just like guest schedules execution of its processes
- proportional share or fair share
Delivering Events to Parent Guest OS
Interrupts from currently executing process (owned by guest OS) need to get back to that guest
Program discontinuities (PD) need to be passed up from hypervisor to guest OS in full and para virtualization:
- Syscalls
- Page faults
- Throw exception
- External Interrupt
Some PDs needs elevated privileges, but guest OS has normal user-level privileges (especially in fully virtualized)
- Sends a trap back to hypervisor
Device Virtualization
- Full virtualization
- “trap and emulate”
- Para virtualization
- more opportunity for innovation
- guest OS can see devices directly
- Shared buffers can optimize communication
Control Transfer
- Full virtualization
- implicit (traps) guest -> hypervisor
- software interrupts (events) hypervisor -> guest
- Para virtualization
- explicit (hypercalls) guest -> hypervisor
- software interrupts (events) hypervisor -> guest
- guest has control via hypercalls on when event notifications need to be delivered
Data Transfer
- Full
- implicit
- Para
- explicit
- opportunity to innovate
- explicit
Xen provides async IO rings
- Shared between guest and Xen for communication
- Ring buffer
Control and Data Transfer in Action
Network virtualization
2 IO Rings
- One for transmit
- One for receive
If you want to transmit data, you place file descriptors on transmit IO ring
- via hypercalls
Data pointed to by file descriptors are NOT copied into Xen, instead they’re guest OS buffers
- No copying
- page pinned
Receiving data works the same way
- Before receiving packet, Xen allocates guest OS buffer and puts data directly there
Disk IO Virtualization
No copying into Xen
Requests from competing domains may be reordered
Reorder barrier
supported by Xen for guest OS semantics- useful for things like Write-Ahead Logging
Xen and Guests
Different between full vs para is a focus on protection
and flexibility