Prev Next

Tools / Virtualization Engineering questions

Last updated

1. What is virtualization? 2. What is a hypervisor? 3. What are the types of hypervisors? 4. What is a virtual machine? 5. What are the benefits of virtualization? 6. What are the types of virtualization? 7. What are guest OS and host OS in virtualization? 8. What is a vCPU? 9. What is a virtual disk? 10. What is a VM snapshot? 11. What is a virtual switch? 12. What is thin provisioning? 13. What is live migration of a VM? 14. What is VDI? 15. What is storage virtualization? 16. What is VM sprawl? 17. What is the difference between a VM and a container? 18. What is the difference between full virtualization and paravirtualization? 19. How does hardware-assisted virtualization work? 20. How does a hypervisor schedule vCPUs? 21. How does memory ballooning work? 22. What is the difference between KVM and ESXi? 23. What is the difference between a VM clone and a template? 24. What is the difference between a snapshot and a backup? 25. When should you choose a VM over a container? 26. What is NUMA and why does it matter for VMs? 27. What is the difference between a standard and a distributed virtual switch? 28. When is CPU overcommitment safe? 29. What happens when a hypervisor host runs out of physical memory? 30. What is the difference between SR-IOV and PCI passthrough? 31. How does VM high availability restart VMs after a host failure? 32. How does automated load balancing like DRS work? 33. Why do we use cloud-init with VM templates? 34. Why is virtio faster than emulated devices? 35. What is the difference between VMDK, VHDX, and QCOW2? 36. How does pre-copy live migration work? 37. How does Extended Page Tables (EPT) reduce memory virtualization overhead? 38. Explain the lifecycle of a VM in KVM and libvirt? 39. Explain the internal working of KVM and QEMU together? 40. How do you troubleshoot high CPU ready time? 41. How do you troubleshoot slow VM storage performance? 42. What happens when a VM exits to the hypervisor? 43. How can you optimize a VM for low-latency workloads? 44. How does nested virtualization work? 45. How do you mitigate VM escape and side-channel risks? 46. How do you design a virtualization cluster for N+1 capacity? 47. Why do long snapshot chains degrade performance? 48. When would you choose post-copy over pre-copy migration? 49. How do you plan a physical-to-virtual (P2V) migration? 50. Why is an IOMMU needed for device passthrough?

1. What is virtualization?

Virtualization is a technique that uses software to create virtual versions of physical resources such as servers, storage, networks, or desktops, so one physical machine can run several isolated environments at once.

A software layer, usually a hypervisor, sits between the hardware and the workloads. It slices up CPU, memory, disk, and network capacity and gives each slice to a separate virtual machine, which behaves as if it owned dedicated hardware.

The practical payoff is better utilization. Instead of ten servers idling at 10% load, you consolidate them onto one or two hosts and gain faster provisioning, isolation, and easier recovery.

Take quiz
What usually sits between the hardware and virtual machines to divide up resources?
A load balancer
A reverse proxy
A hypervisor
What is the main reason teams consolidate servers with virtualization?
Higher hardware utilization on fewer physical hosts
It removes the need for any operating system
It makes every application faster than on bare metal

2. What is a hypervisor?

A hypervisor, also called a virtual machine monitor (VMM), is the software, firmware, or hardware layer that creates and runs virtual machines. It owns the physical CPU, memory, and devices and decides how much of each a VM receives.

Its core jobs are:

  1. Allocate vCPUs and memory to each VM.
  2. Isolate VMs so one cannot read another's memory.
  3. Present virtual devices such as disks and network cards.
  4. Schedule VM work onto physical cores.

Common examples are VMware ESXi, KVM, Microsoft Hyper-V, and Xen.

Take quiz
Which of these is a hypervisor?
KVM
Nginx
Docker Compose
Which responsibility belongs to a hypervisor?
Compiling the applications running in guests
Isolating the memory of one VM from another
Resolving public DNS names for the internet

3. What are the types of hypervisors?

There are two types: Type 1 (bare-metal) and Type 2 (hosted). The difference is whether a general-purpose operating system sits underneath the hypervisor.

Type 1 (bare-metal) Type 2 (hosted)
Runs on Directly on server hardware As an application on a host OS
Examples ESXi, Xen, Hyper-V, KVM VirtualBox, VMware Workstation, Parallels
Overhead Lower, no host OS in between Higher, host OS adds a layer
Typical use Data centers and clouds Developer laptops, labs, testing

KVM is a nuance worth mentioning: it is a Linux kernel module, so the Linux kernel itself becomes the Type 1 hypervisor.

Take quiz
VirtualBox running on a Windows laptop is which type of hypervisor?
Type 1 (bare-metal)
Type 2 (hosted)
A container runtime
Why do data centers prefer Type 1 hypervisors?
They do not need CPU virtualization support
They can only run on desktop computers
No host OS in between, so lower overhead and a smaller attack surface

4. What is a virtual machine?

A virtual machine (VM) is a software-defined computer with its own virtual CPU, memory, disk, and network card, running its own guest operating system. The guest believes it is running on real hardware.

On the host, a VM is mostly just files: a configuration file (such as .vmx or libvirt XML) plus one or more virtual disk images (.vmdk, .qcow2). Because it is only files and a process, a VM can be copied, snapshotted, backed up, and moved between hosts.

  • Isolated from other VMs on the same host
  • Portable across compatible hosts
  • Independent OS, patch level, and software stack
Take quiz
How is a VM typically stored on the host?
As a physical partition with no files
As a firmware chip inside the CPU
As configuration plus virtual disk files
What does a guest OS inside a VM see?
Virtual hardware presented by the hypervisor
The host's kernel directly
The physical motherboard with no abstraction

5. What are the benefits of virtualization?

Virtualization improves how efficiently hardware is used and makes infrastructure far easier to manage.

  • Server consolidation: many workloads on fewer machines, lowering power, space, and hardware cost.
  • Isolation: a crash or compromise in one VM does not directly affect another.
  • Fast provisioning: clone a template instead of racking a server.
  • Snapshots and cloning: quick rollback and test environments.
  • Live migration and HA: maintenance without downtime and automatic restart after host failure.
  • Hardware independence: move workloads to new hardware without reinstalling.

The trade-offs are a small performance overhead, VM sprawl if unmanaged, and a shared failure domain: a host failure affects every VM on it.

Take quiz
Which capability lets you move a running workload off a host for maintenance?
Live migration
Thin provisioning
Template cloning
Which is a genuine drawback of virtualization?
VMs can never be backed up
A host failure can affect every VM running on it
Each VM needs its own physical CPU socket

6. What are the types of virtualization?

Virtualization is applied to several layers of the infrastructure stack:

  • Server virtualization: multiple VMs on one physical server.
  • Desktop virtualization (VDI): user desktops hosted as VMs in the data center.
  • Network virtualization: virtual switches, VLANs, overlays, and software-defined networking.
  • Storage virtualization: pooling physical disks or arrays into logical volumes.
  • Application virtualization: running apps in isolated bubbles without a full install.
  • OS-level virtualization: containers sharing one kernel.

In practice these layers combine: a private cloud usually pairs server virtualization with virtual networking and pooled storage, all managed together.

Take quiz
Which type of virtualization does VDI refer to?
Storage virtualization
Desktop virtualization
Network virtualization
Software-defined networking falls under which type?
Storage virtualization
Desktop virtualization
Network virtualization

7. What are guest OS and host OS in virtualization?

The host OS runs on the physical machine and, in a Type 2 setup, runs the hypervisor application. The guest OS is the operating system installed inside a virtual machine.

Host OS Guest OS
Runs on Physical hardware Virtual hardware
Count One per physical host One per VM
Example Windows 11 running VirtualBox Ubuntu installed inside that VirtualBox VM

With a Type 1 hypervisor like ESXi there is no conventional host OS, only the hypervisor and its guests.

Guest tools (VirtualBox Guest Additions, VMware Tools) are installed in the guest to improve drivers, clipboard sharing, and time synchronization.

Take quiz
On a laptop running Windows with VirtualBox hosting Ubuntu, Ubuntu is the:
Host OS
Hypervisor
Guest OS
In a Type 1 deployment, where does the guest OS run?
On virtual hardware presented directly by the hypervisor
Inside a host Windows desktop session
Inside a container runtime

8. What is a vCPU?

A vCPU is the virtual processor assigned to a VM. In KVM each vCPU is a thread of the QEMU process, and the hypervisor schedules it onto a physical core or hyperthread whenever it has work to do.

A VM with 4 vCPUs does not own 4 cores. It shares physical cores with other VMs through time slicing.

More vCPUs is not always faster. The scheduler may have to wait for several cores to be free at once, which raises CPU ready time. Right-size VMs to what the workload actually uses.

Take quiz
In KVM, each vCPU is implemented as:
A thread inside the QEMU process
A dedicated physical CPU socket
A separate host kernel
Why can adding more vCPUs slow a VM down?
vCPUs reduce available disk capacity
The scheduler may wait longer for free cores, raising CPU ready time
Extra vCPUs disable hardware virtualization

9. What is a virtual disk?

A virtual disk is a file or volume on the host that the guest OS sees as a normal block device. Common formats are VMDK (VMware), VHDX (Hyper-V), QCOW2 (KVM/QEMU), and raw images.

It can live on local disks, an NFS datastore, a SAN LUN, or distributed storage such as Ceph or vSAN. It can be provisioned thick or thin, and many formats support snapshots through delta files.

Resizing takes two steps: grow the virtual disk on the host, then extend the partition and filesystem inside the guest.

Take quiz
What does a VMDK file represent to a guest?
A virtual network card
A virtual hard disk
A CPU scheduling policy
Where can a virtual disk file be stored?
Only in the guest's RAM
Only on the guest's BIOS chip
On local disks, an NFS datastore, or a SAN-backed volume

10. What is a VM snapshot?

A snapshot captures the state of a VM at a point in time: its disk state, and optionally its memory and power state. It lets you roll back after a risky patch or configuration change.

Most platforms implement it with copy-on-write. The base disk is frozen and all new writes go to a delta (child) disk. Reverting discards the delta; deleting the snapshot merges it back.

Snapshots should be short-lived. Delta files keep growing and I/O slows as the chain gets longer.

Take quiz
After a snapshot is taken, where do new writes go?
To the original frozen base disk
To the hypervisor's BIOS
To a delta (child) disk
Why should snapshots be short-lived?
Delta disks grow and slow I/O as the chain lengthens
They automatically delete the VM after 24 hours
They stop the guest from using memory

11. What is a virtual switch?

A virtual switch is a software switch inside the hypervisor that connects VM virtual NICs to each other and to the physical network through uplinks (physical NICs). It forwards at Layer 2 and supports VLAN tagging, port groups, and traffic shaping.

Examples include the VMware vSwitch, Open vSwitch, the Linux bridge, and the Hyper-V Virtual Switch.

Traffic between two VMs on the same host and VLAN stays inside the switch and never touches the physical network.

Port groups label traffic by VLAN, so moving a VM to another network is a port group change rather than recabling.

Take quiz
Traffic between two VMs on the same host and VLAN usually:
Stays inside the virtual switch
Always goes out to the physical router
Must be encrypted by the CPU first
What is a vSwitch uplink?
A virtual disk controller
A physical NIC connecting the vSwitch to the external network
A type of snapshot chain

12. What is thin provisioning?

Thin provisioning allocates virtual disk space only as the guest actually writes data. A 100 GB thin disk holding 20 GB of data consumes roughly 20 GB on the datastore.

Thick provisioning reserves the full 100 GB immediately. Thin provisioning saves space and allows overcommitment, where the total promised capacity exceeds the physical capacity.

The risk is that an overcommitted datastore can fill up, causing VMs to pause or fail. Monitor free space and set alerts.

On KVM, qemu-img info reports virtual size versus actual disk size, which shows how thin a disk really is.

Take quiz
A 100 GB thin disk with 20 GB written consumes roughly:
100 GB on the datastore
20 GB on the datastore
0 GB until the next reboot
What is the main risk of thin provisioning?
The disk cannot be snapshotted
The guest OS cannot format the disk
An overcommitted datastore can run out of space and pause VMs

13. What is live migration of a VM?

Live migration moves a running VM from one host to another with little or no visible downtime. VMware calls it vMotion; KVM/libvirt and Hyper-V call it live migration.

While the VM keeps running, its memory is copied across the network. A very short pause at the end transfers the final state, and the VM resumes on the destination with the same network identity.

Typical requirements are compatible CPU features, a fast network between hosts, and shared storage (or a storage migration at the same time). Uses include host maintenance and load balancing.

Take quiz
Live migration is mostly used to:
Convert a VM into a container
Permanently enlarge a guest disk
Evacuate a host for maintenance without shutting VMs down
What is generally needed for live migration?
Compatible CPU features and a fast network between hosts
The VM must be powered off first
Identical MAC addresses on every host

14. What is VDI?

Virtual Desktop Infrastructure (VDI) hosts desktop operating systems as VMs in the data center. Users connect from a thin client or any device using a remote display protocol such as PCoIP, Blast, HDX, or RDP.

Desktops can be persistent (each user keeps their own VM) or non-persistent (a fresh clone from a golden image each login).

The benefits are central management and data that never leaves the data center. The challenges are GPU workloads, network latency, and boot storms, when many desktops start at once and hammer storage.

Take quiz
In VDI, where does the user's desktop OS run?
In a VM in the data center
On the thin client's local CPU
Only inside the user's web browser sandbox
What is a boot storm in VDI?
A hypervisor crash during patching
Many desktops starting at once and spiking storage and CPU load
A malware outbreak across VMs

15. What is storage virtualization?

Storage virtualization abstracts physical disks and arrays into pooled logical volumes. The VM sees a simple virtual disk while the layer underneath decides where the blocks actually live.

Examples include LVM, SAN virtualization appliances, VMware vSAN, and Ceph. Benefits include pooling capacity from many devices, migrating data between arrays without downtime, tiering hot and cold data, and thin provisioning.

Ceph is a good example: it spreads data across many servers with replication or erasure coding, so a disk or node failure does not lose data and VMs keep running.

Take quiz
Which technology pools local disks across hosts into a shared datastore?
A DHCP relay
A hyper-converged storage layer such as vSAN or Ceph
A VLAN trunk
What is a key benefit of storage virtualization?
It removes the need for any physical disks
It makes every disk the same speed
Data can move between arrays without changing what the VM sees

16. What is VM sprawl?

VM sprawl is the uncontrolled growth of virtual machines, many of them idle, forgotten, or unpatched. Because creating a VM takes minutes, they pile up faster than anyone retires them.

  • Wasted CPU, memory, storage, and license cost
  • Unpatched machines that become security risks
  • Harder backups, monitoring, and capacity planning

Controls that work: quotas per team, mandatory owner and expiry tags, chargeback or showback, lifecycle policies, and periodic audits of powered-off and idle VMs.

A quick win is to report VMs powered off for 30 days or showing near-zero CPU, network, and disk activity, then confirm with owners before deleting.

Take quiz
What mainly causes VM sprawl?
Hypervisors duplicating VMs automatically
Running too few VMs
Provisioning is so easy that unused VMs pile up
Which control best limits VM sprawl?
Owner and expiry tags, quotas, and periodic audits
Disabling all snapshots
Giving every team unlimited quota

17. What is the difference between a VM and a container?

A VM virtualizes hardware: each VM runs its own full guest OS and kernel on top of a hypervisor. A container virtualizes the operating system: containers share the host kernel and are isolated with namespaces and cgroups.

Virtual Machine Container
Isolation Strong, separate kernel per VM Process-level, shared kernel
Startup Tens of seconds to minutes Milliseconds to seconds
Size GBs (full OS) MBs (app plus libraries)
Overhead Higher Very low
OS variety Any guest OS Same kernel family as host

They are complementary: containers are often run inside VMs to combine density with a strong isolation boundary.

Startup time and density favor containers; kernel independence and hard isolation favor VMs.

Take quiz
What do containers on one host share?
The host kernel
A separate guest kernel each
A hypervisor-emulated BIOS
Which has stronger isolation by default?
Containers, because they share one kernel
VMs, because each has its own kernel behind the hypervisor
Both are identical

18. What is the difference between full virtualization and paravirtualization?

In full virtualization the guest OS runs unmodified and believes it is on real hardware; the hypervisor traps and emulates privileged operations, today mostly with CPU hardware assist.

In paravirtualization the guest kernel is aware it is virtual and calls the hypervisor directly through hypercalls instead of trapping, which reduces overhead. Early Xen PV worked this way.

Full Paravirtual
Guest changes None Modified kernel or drivers
Mechanism Trap and emulate / hardware assist Hypercalls
Example VMware, KVM with VT-x Xen PV, virtio drivers

Modern systems blend both: unmodified guests with hardware assist for CPU, plus paravirtual drivers for I/O.

In KVM, virtio is the paravirtual layer, so a Linux guest on VT-x hardware is fully virtualized for CPU yet paravirtualized for disk and network.

Take quiz
Which approach requires a virtualization-aware guest kernel or drivers?
Full virtualization with hardware assist
Paravirtualization
A bare-metal OS install
What does a hypercall do?
Reboots the physical NIC
Compresses a virtual disk
Lets a guest ask the hypervisor to perform a privileged operation directly

19. How does hardware-assisted virtualization work?

Intel VT-x and AMD AMD-V add new CPU modes: a privileged hypervisor mode (VMX root) and a guest mode (non-root). The guest runs natively on the CPU in guest mode, so ordinary instructions execute at full speed.

When the guest does something sensitive, such as touching an emulated device or executing certain instructions, the CPU triggers a VM exit, saves guest state into a control structure (VMCS on Intel, VMCB on AMD), and hands control to the hypervisor. After handling it, the hypervisor does a VM entry.

Before this, x86 had instructions that could not be trapped, which forced slow binary translation. You can check support on Linux:

grep -E 'vmx|svm' /proc/cpuinfo

Take quiz
Which /proc/cpuinfo flag indicates Intel VT-x support?
svm
avx2
vmx
What stores guest CPU state for entries and exits on Intel?
The VMCS
The page cache
The boot sector

20. How does a hypervisor schedule vCPUs?

Each vCPU is a runnable entity. The scheduler time-slices them across physical cores using shares or weights for priority under contention, reservations for guaranteed minimums, and limits for caps.

The implementation differs by platform: KVM uses the host Linux scheduler and cgroups, VMware ESXi uses a relaxed co-scheduling algorithm for multi-vCPU VMs, and Xen offers schedulers such as Credit2.

Time a vCPU spends waiting for a core is CPU ready. CPU pinning and NUMA affinity can override default placement for latency-sensitive guests.

Wide VMs are harder to schedule because the hypervisor must keep sibling vCPUs from drifting too far apart (co-stop), so a 2-vCPU VM often beats the same load on 8 vCPUs when the host is busy.

Take quiz
Who schedules KVM vCPUs onto physical cores?
The host Linux scheduler
The guest's scheduler alone
A separate scheduler chip on the NIC
What do CPU shares or weights control?
The maximum disk size
Relative priority when CPUs are contended
The guest boot order

21. How does memory ballooning work?

Ballooning lets the hypervisor reclaim memory from a guest cooperatively. A balloon driver inside the guest (vmmemctl in VMware Tools, virtio-balloon in KVM) is the mechanism.

  1. The hypervisor is short of memory and asks the driver to inflate.
  2. The driver allocates pages inside the guest, so the guest OS sees less free memory.
  3. Under pressure, the guest OS decides what to evict or swap, picking its own coldest pages.
  4. The hypervisor reclaims the physical pages behind the balloon and gives them to other VMs.
  5. Deflating releases the pages back to the guest.

It beats host-level swapping because the guest knows which pages are least useful. It requires the driver to be installed and running.

Take quiz
What does inflating the balloon do?
Increases the VM's vCPU count
Makes the guest allocate pages so the host can reclaim them
Creates a new snapshot
Why is ballooning preferred over hypervisor swapping?
It needs no driver at all
It writes directly into host swap
The guest OS chooses which pages to give up, so cold pages go first

22. What is the difference between KVM and ESXi?

Both are Type 1 style hypervisors, but they differ in origin, licensing, and ecosystem.

KVM VMware ESXi
Origin Kernel module in mainline Linux Proprietary VMware vmkernel
License Open source (GPL) Commercial
Device emulation QEMU in userspace, virtio VMware virtual hardware, VMware Tools
Management libvirt, virsh, Proxmox, oVirt, OpenStack vCenter, ESXi host client
Strength Flexibility, Linux ecosystem, cloud stacks Mature enterprise features and tooling

Feature packaging differs in practice: ESXi bundles DRS, vMotion, and vSAN into one licensed suite, while KVM platforms assemble equivalents (live migration, Ceph, Pacemaker or Proxmox HA) from separate open source parts. Skills and support contracts often decide the choice more than raw performance.

Take quiz
KVM is part of which software?
Windows Server only
VMware vCenter
The Linux kernel
Which statement is accurate?
ESXi is VMware's proprietary hypervisor; KVM is open source inside Linux
KVM is proprietary and ESXi is open source
Both are only hosted Type 2 tools for Windows

23. What is the difference between a VM clone and a template?

A clone is a copy of an existing VM. A template is a protected master image used to stamp out many new VMs.

Clone Template
Purpose Duplicate one VM Golden image for repeated deployment
Can be powered on Yes No, convert back first
Customization Often manual Applied at deploy (sysprep, cloud-init)
Variants Full or linked Usually full

A linked clone shares the parent's base disk and stores only its own changes, saving space but depending on the parent.

Keep templates patched: convert one back to a VM monthly, apply updates, run cleanup, and convert it back so new deployments start current.

Take quiz
A template differs from a clone mainly because it:
Is a non-running golden image meant for repeated deployments
Can only be deployed once
Always uses more RAM
How does a linked clone save space?
It compresses guest RAM
It shares the parent's base disk and stores only its changes
It deletes the parent disk

24. What is the difference between a snapshot and a backup?

A snapshot is a point-in-time marker that depends on the original disk and lives on the same storage as the VM. A backup is an independent copy stored elsewhere with retention rules.

Snapshot Backup
Location Same datastore Separate storage or media
Survives datastore loss No Yes
Retention Hours or days Weeks to years
Speed to create Seconds Minutes to hours

They work together: backup tools usually take a short snapshot to read a consistent image while the VM keeps running, then remove it.

A snapshot also gives no protection against ransomware or accidental deletion of the whole VM, because deleting the VM usually deletes its snapshots too.

Take quiz
If the datastore is lost, which survives?
The snapshot on the same datastore
A backup stored on separate storage
The delta disk
Why do backup tools take a snapshot first?
To shrink the VM's vCPU count
To encrypt the guest's network
To read a consistent point-in-time image while the VM keeps running

25. When should you choose a VM over a container?

Choose a VM when you need a stronger boundary or a different OS than the host kernel can offer.

  • Running Windows workloads next to Linux on the same host
  • Multi-tenant or untrusted code that needs kernel-level isolation
  • Legacy applications that expect a full OS
  • Workloads needing custom kernel modules or kernel versions
  • Compliance rules that demand hardware-level separation

Containers fit stateless microservices that must start in seconds and pack densely. Many teams run containers inside VMs to get both.

Licensing can tip the decision as well: software licensed per host or per core is easier to account for behind a VM boundary.

Take quiz
Which is the best case for choosing a VM?
A stateless microservice needing sub-second startup
Sharing one kernel to save RAM
Running a Windows workload alongside Linux workloads on one host
Why run containers inside VMs?
It adds an extra isolation boundary and simplifies host-level management
Containers cannot run on any platform without a VM
It removes the need for networking

26. What is NUMA and why does it matter for VMs?

NUMA (Non-Uniform Memory Access) describes multi-socket servers where each CPU socket has its own local memory. A core reads local memory quickly but needs extra hops to read memory attached to another socket.

It matters because a VM whose vCPUs or memory span sockets pays this remote-access penalty on every miss. Hypervisors expose vNUMA to large VMs so the guest OS can place threads and memory sensibly.

The rule of thumb: keep a VM's vCPUs and memory within one NUMA node when possible, and align the virtual topology with the physical one when the VM is bigger. Inspect the host with:

numactl --hardware
virsh numatune <domain>

Take quiz
Why does NUMA matter for VM sizing?
Memory attached to another socket is slower to access
Remote sockets have no memory
It controls datastore IOPS limits
What is the best sizing practice for a latency-sensitive VM?
Always assign every vCPU the host has
Fit its vCPUs and memory inside a single NUMA node if possible
Spread it evenly over all sockets regardless of size

27. What is the difference between a standard and a distributed virtual switch?

A standard switch is configured separately on every host. A distributed switch (VMware vDS) is defined once in vCenter and spans all member hosts, so the policy is identical everywhere.

Standard vSwitch Distributed vSwitch
Configured Per host Centrally in vCenter
Consistency Manual, drift-prone Automatic across hosts
Advanced features Basic NetFlow, port mirroring, LACP, Network I/O Control
Port state on vMotion Rebuilt on the new host Moves with the VM

In large clusters the distributed switch saves effort and prevents the mismatched port groups that cause failed migrations.

Mind the vCenter dependency: running VMs keep their networking if vCenter goes down, because hosts keep a local copy, but you cannot change the switch until it returns.

Take quiz
Where is a distributed switch's configuration managed?
Separately on every host
Centrally in vCenter
Inside the guest OS
What is the main advantage of a distributed switch?
It removes the need for physical NICs
It disables VLANs
Consistent network policy across all hosts in the cluster

28. When is CPU overcommitment safe?

CPU overcommitment means assigning more vCPUs in total than the host has physical cores. It is safe when VMs are mostly idle and their peaks do not line up.

  • General-purpose or test servers: ratios of 3:1 to 5:1 are often fine.
  • Latency-critical databases and real-time workloads: stay near 1:1 or 2:1.
  • VDI desktops: higher ratios work because users are idle most of the time.

The ratio alone is not the verdict. Watch CPU ready time and co-stop. If ready time stays above roughly 5% per vCPU, the host is contended and the ratio is too high for that workload mix.

Take quiz
Which workload tolerates a higher CPU overcommit ratio?
Real-time trading engines
Latency-critical databases at peak load
Mostly idle general-purpose servers
Which metric best reveals CPU contention?
CPU ready time
Datastore free space
Guest uptime

29. What happens when a hypervisor host runs out of physical memory?

The hypervisor escalates through reclamation techniques, from cheap to expensive, as free memory drops.

flowchart TD
  A["Free memory falls"] --> B["Page sharing"]
  B --> C[Ballooning]
  C --> D["Memory compression"]
  D --> E["Hypervisor swapping to disk"]
  E --> F["VMs stall or host kills processes"]

Ballooning asks guests to give up cold pages. Compression keeps pages in RAM in compressed form. Hypervisor swapping is the last resort: pages are written to disk without the guest knowing, so hot pages can land on disk and performance falls sharply.

On a Linux KVM host, if reclaim fails the kernel OOM killer may terminate a QEMU process, which means that VM dies instantly.

Take quiz
Which technique is the last resort for reclaiming memory?
Hypervisor swapping to disk
Memory ballooning
Memory compression
Why does hypervisor swapping hurt performance so much?
It deletes guest files
Pages are paged out without guest knowledge, so hot pages may hit disk
It disables VT-x

30. What is the difference between SR-IOV and PCI passthrough?

Both give a VM near-native access to a physical device, bypassing most of the virtual device stack. The difference is sharing.

PCI passthrough SR-IOV
Assignment Whole device to one VM Virtual Functions (VFs) to many VMs
Device sharing No Yes, one card exposes many VFs
Hardware support IOMMU IOMMU plus SR-IOV capable device
Typical use GPU, single dedicated NIC High-speed NICs, NVMe, NFV

An SR-IOV card exposes one Physical Function (PF) controlled by the host and many lightweight Virtual Functions handed to VMs. The shared drawback is that the VM is tied to specific hardware, which complicates live migration.

Check IOMMU groups first, since devices that share a group must be assigned together.

Take quiz
What does SR-IOV let one physical NIC do?
Act as a hypervisor
Present multiple virtual functions to different VMs
Replace the virtual switch's CPU entirely
What is a common drawback of passthrough and SR-IOV?
Guests cannot use the device at all
They only work with emulated drivers
Live migration is harder because the VM is tied to physical hardware

31. How does VM high availability restart VMs after a host failure?

In an HA cluster, hosts exchange heartbeats over the management network and shared datastores. When a host stops responding and the isolation checks confirm it is down, the cluster restarts its VMs on surviving hosts.

flowchart LR
  A["Host heartbeat lost"] --> B["Check datastore heartbeat"]
  B --> C{Host really failed?}
  C -- Yes --> D["Restart VMs by priority on other hosts"]
  C -- No --> E["Treat as network isolation"]

HA means a short outage, since the VM boots again. That differs from live migration, which moves a healthy running VM with no downtime. Admission control reserves spare capacity so the failed host's VMs actually fit elsewhere.

Take quiz
How does HA differ from live migration?
HA moves running VMs with zero downtime
They are the same feature under two names
HA restarts VMs after a failure with downtime; live migration moves running VMs without it
What does admission control do in an HA cluster?
Reserves spare capacity so failed VMs can restart
Blocks users from logging in
Encrypts VM memory

32. How does automated load balancing like DRS work?

VMware DRS watches CPU and memory demand on every host in a cluster, computes how unbalanced they are, and recommends or automatically performs live migrations to even out the load. It also chooses the best host for a VM at power-on.

  • Migration threshold sets how aggressive moves can be.
  • Affinity rules keep chosen VMs together.
  • Anti-affinity rules keep redundant VMs on separate hosts.
  • Host groups pin VMs to licensed or specific hardware.

Other platforms have equivalents, such as Hyper-V Dynamic Optimization and the oVirt scheduler.

Start in partially automated mode, review the recommendations for a week, and move to fully automated once the migration frequency looks sensible.

Take quiz
Which capability does DRS rely on to move running VMs?
Live migration
Cold cloning
Snapshot chains
What is an anti-affinity rule used for?
Pinning all VMs to one host
Keeping redundant VMs on different hosts
Disabling HA

33. Why do we use cloud-init with VM templates?

A golden template should be generic. cloud-init turns that one image into a customized instance at first boot by reading metadata and user-data: hostname, users, SSH keys, network settings, packages, and scripts.

Without it you either bake secrets and per-host settings into the image, which is unsafe, or log in manually after every deployment. A minimal example:

#cloud-config
hostname: web-01
users:
  - name: ops
    ssh_authorized_keys:
      - ssh-ed25519 AAAA... ops@example
packages:
  - nginx

Network settings can be supplied the same way, so a static IP and DNS are set without touching the console. Run cloud-init clean before turning the image into a template so first-boot logic runs again on each clone.

Take quiz
When does cloud-init run its customization?
Only when the VM is deleted
At first boot, using metadata and user-data
Before the hypervisor starts
What is the main benefit of cloud-init with templates?
It removes the need for a virtual disk
It prevents live migration
One generic image can become many differently configured VMs

34. Why is virtio faster than emulated devices?

An emulated device such as an e1000 NIC or IDE disk makes the hypervisor imitate real hardware. Every register access by the guest driver causes a VM exit, and one packet or disk request can need dozens of them.

virtio is a paravirtual standard. The guest driver knows it is virtual and exchanges requests with the host through shared-memory rings called virtqueues, batching work and notifying the host only when needed. That cuts exits sharply.

vhost-net goes further by moving the network backend into the host kernel, skipping a trip through QEMU userspace.

On Windows guests, install the virtio driver ISO before switching the disk or NIC model, or the VM will not find its boot disk.

Take quiz
Why is virtio faster than emulated hardware?
It uses real physical devices
It skips the guest kernel entirely
The guest cooperates through shared rings, reducing VM exits
What is a virtqueue?
A shared-memory ring for passing I/O requests between guest and host
A type of snapshot chain
A CPU cache level

35. What is the difference between VMDK, VHDX, and QCOW2?

All three are virtual disk formats, tied to different hypervisor families.

VMDK VHDX QCOW2
Platform VMware Hyper-V KVM / QEMU
Max size 62 TB 64 TB Very large (practically exabytes)
Notable features Thin/thick, snapshots, delta Resilient to power loss, 4K aware Copy-on-write, backing files, compression, encryption

Conversion is straightforward with qemu-img:

qemu-img convert -f vmdk -O qcow2 disk.vmdk disk.qcow2

Choose by where the VM will run and which features you need: QCOW2 for snapshots and backing files on KVM, VMDK for ESXi, VHDX for Hyper-V. Converting is safe offline, but keep the original until the new VM boots and its drivers load correctly.

Take quiz
Which format is native to KVM/QEMU and supports backing files?
QCOW2
VHDX
VMDK
Which tool converts between virtual disk formats?
iptables
qemu-img
ip link

36. How does pre-copy live migration work?

Pre-copy migrates memory while the VM keeps running on the source, then switches over once little is left to move.

  1. The destination prepares an empty VM with matching configuration.
  2. All memory pages are copied to the destination while the guest runs.
  3. The hypervisor tracks dirty pages (changed since the copy) and resends them in repeated rounds.
  4. When the dirty set is small enough, the VM is paused briefly and the last pages, CPU state, and device state are sent.
  5. The VM resumes on the destination and network switches are notified of its new location.
  6. The source copy is cleaned up.
flowchart LR
  A["Copy all pages"] --> B["Resend dirty pages"]
  B --> C{Small enough?}
  C -- No --> B
  C -- Yes --> D["Pause and send final state"]
  D --> E["Resume on destination"]

If the guest dirties memory faster than the network can send it, the loop never converges. Auto-converge (throttling the guest), compression, or post-copy are the usual answers.

Take quiz
What is re-copied in the later rounds of pre-copy?
Only disk blocks
Pages modified since the previous round
Only CPU registers
Why might a pre-copy migration fail to converge?
The destination has too much free disk
The source has too few snapshots
The guest dirties memory faster than the network can transfer it

37. How does Extended Page Tables (EPT) reduce memory virtualization overhead?

A guest OS maps guest virtual addresses to what it thinks is physical memory (guest physical). The hypervisor must then map that to real host physical memory. Before hardware help, hypervisors kept shadow page tables combining both, and every guest page-table update caused a costly VM exit.

EPT (Intel) and NPT/RVI (AMD) make the CPU do two-level translation in hardware: guest page tables handle GVA to GPA, and the EPT handles GPA to HPA. The TLB caches the combined result, so the hypervisor stays out of the path.

The trade-off is a longer two-dimensional page walk on a TLB miss, up to 24 memory references with 4-level tables. Huge pages (2 MB or 1 GB) reduce misses and recover most of that cost.

Take quiz
What does EPT translate?
Host virtual addresses to guest virtual addresses
Disk blocks to filenames
Guest physical addresses to host physical addresses
Why do huge pages help when EPT is in use?
They reduce TLB misses and shorten the two-dimensional page walk
They add extra vCPUs
They compress guest RAM

38. Explain the lifecycle of a VM in KVM and libvirt?

In libvirt a VM is a domain. It moves between a few states, driven by virsh commands.

flowchart LR
  A[Undefined] -->|define| B["Defined, shut off"]
  B -->|start| C[Running]
  C -->|suspend| D[Paused]
  D -->|resume| C
  C -->|shutdown| B
  C -->|destroy| B
  B -->|undefine| A
virsh define vm.xml
virsh start vm1
virsh suspend vm1
virsh resume vm1
virsh shutdown vm1   # graceful via ACPI
virsh destroy vm1    # hard power off
virsh undefine vm1

Note that destroy only stops the domain, like pulling the plug. The definition and disks remain until undefine.

Managed save is a useful variation: virsh managedsave vm1 writes memory to disk and stops the domain, and the next start resumes exactly where it left off. Use it for host reboots.

Take quiz
What does virsh destroy do to a running domain?
Forcibly powers it off while keeping its definition
Deletes its definition and disks
Performs a graceful ACPI shutdown
Which command pauses a running domain in memory?
virsh define
virsh suspend
virsh undefine

39. Explain the internal working of KVM and QEMU together?

KVM and QEMU split the work between kernel and userspace.

  • KVM (kvm.ko plus kvm-intel or kvm-amd) turns Linux into a hypervisor and exposes /dev/kvm. It manages VMX/SVM mode, EPT, and vCPU state.
  • QEMU runs as one userspace process per VM. It allocates guest memory, emulates devices, and talks to KVM through ioctl calls.
flowchart LR
  G["Guest code"] -->|VM exit| K["KVM in kernel"]
  K -->|simple exit| G
  K -->|I/O exit| Q["QEMU userspace"]
  Q -->|device emulated| K

Each vCPU is a QEMU thread running a loop around KVM_RUN. Simple exits are handled inside the kernel; I/O and MMIO exits return to QEMU. libvirt sits above, managing the QEMU processes.

This split explains why a QEMU crash kills only its own VM, while a bug in the KVM kernel module can affect the whole host.

Take quiz
How does QEMU communicate with KVM?
Through SSH
Through ioctl calls on /dev/kvm
Through a REST API on port 443
Which component emulates virtual devices when vhost is not used?
The guest BIOS
The physical switch
QEMU in userspace

40. How do you troubleshoot high CPU ready time?

CPU ready is time a vCPU was runnable but had no physical core. A VM can show low CPU inside the guest while the application crawls. As a rough guide, over 5% per vCPU deserves attention and over 10% is a problem.

  1. Confirm it at the hypervisor: %RDY and %CSTP in esxtop, or steal time and run-queue delay on KVM.
  2. Check host CPU utilization and the vCPU to core ratio.
  3. Find oversized VMs and reduce their vCPU count, since wide VMs wait longer for cores.
  4. Review limits and shares on resource pools that throttle VMs.
  5. Rebalance with DRS or migrate noisy VMs away.
  6. Add hosts if demand has genuinely outgrown capacity.

Raising a VM's CPU shares or reservation does not cure real contention; it only moves the waiting onto other VMs.

Take quiz
A guest shows low CPU but the app is slow and the host is busy. What is likely?
A full guest swap partition only
An expired guest OS license
High CPU ready time
What is the first fix for oversized VMs with high ready time?
Reduce the vCPU count to what the workload really uses
Add more vCPUs
Disable the balloon driver

41. How do you troubleshoot slow VM storage performance?

Measure latency at each layer before changing anything, so you know whether the problem is in the guest, the hypervisor, or the array.

Metric (esxtop) Meaning High value points to
DAVG Latency at the device/array Array, SAN fabric, or backend disks
KAVG Time in the hypervisor storage stack Queue depth exhausted, too much outstanding I/O
GAVG DAVG plus KAVG as seen by the guest Overall guest-visible latency

  1. Check the guest with iostat -x.
  2. Look for long snapshot chains and stale snapshots.
  3. Check IOPS limits and noisy neighbors on the same datastore.
  4. Use paravirtual controllers (pvscsi, virtio-scsi) rather than emulated ones.
  5. Review multipathing and, for iSCSI or NFS, the network path.

Change one thing at a time and re-measure, since fixing the controller type and removing a snapshot together hides which one actually helped.

Take quiz
What does a high KAVG value suggest?
Commands are queuing inside the hypervisor storage stack
Only a failed array disk
The guest has too little swap
What does DAVG measure?
Time waiting for a vCPU
Latency at the storage device or array
Memory ballooning delay

42. What happens when a VM exits to the hypervisor?

A VM exit happens when the guest does something the CPU cannot complete in guest mode: touching an emulated device register, port I/O, MMIO, CPUID, HLT, an EPT violation, or an external interrupt.

The CPU saves guest state into the VMCS, switches to hypervisor mode, and runs the exit handler. The hypervisor emulates the operation or fulfils the request, then resumes the guest with a VM entry. Each exit costs on the order of microseconds, which adds up at high I/O rates.

  • Use virtio drivers to batch I/O.
  • Enable posted interrupts and APIC virtualization.
  • Use huge pages and vhost backends.
  • Avoid chatty emulated devices.

On a KVM host, perf kvm stat live shows exit counts by reason, so you can see whether I/O, interrupts, or EPT faults dominate.

Take quiz
Which action causes a VM exit?
The guest executing an ordinary ADD instruction
The guest touching an emulated device register
The guest reading its own stack
What helps reduce the number of VM exits?
Using more emulated IDE disks
Raising the vCPU count
Paravirtual virtio drivers that batch requests

43. How can you optimize a VM for low-latency workloads?

Low latency means removing anything that makes the VM wait or jitter: contention, remapping, and reclaim.

  • Pin vCPUs to dedicated, isolated host cores (isolcpus, CPU pinning).
  • Keep the VM inside a single NUMA node.
  • Use 1 GB huge pages and reserve all memory to disable ballooning and swapping.
  • Use SR-IOV or DPDK instead of a software switch path for networking.
  • Disable deep C-states and frequency scaling on the host.
  • Avoid snapshots and keep the host kernel tickless or real-time.
  • Set VMware latency sensitivity to High where applicable.

Validate with a tool like cyclictest inside the guest, which reports worst-case wake-up latency. Averages hide spikes, and it is the maximum that breaks trading, telecom, and audio workloads. Record it before and after each tuning change.

Take quiz
Which combination helps low-latency VMs most?
CPU overcommit at 8:1
Aggressive memory ballooning
Dedicated pinned cores with memory fully reserved
Why avoid overcommit for these VMs?
Contention and reclaim add scheduling and memory delays
It voids the guest license
It shrinks the virtual disk

44. How does nested virtualization work?

Nested virtualization runs a hypervisor inside a VM. The layers are named L0 (physical host hypervisor), L1 (the guest running a hypervisor), and L2 (VMs inside L1).

The CPU only supports one level natively, so L0 emulates VT-x for L1. L1's control structure is shadowed and merged by L0 into the one the hardware actually uses. Exits from L2 reach L0 first and are forwarded to L1 only when L1 must handle them, which multiplies the cost.

Enable it on KVM and verify:

echo &#x27;options kvm_intel nested=1&#x27; | sudo tee /etc/modprobe.d/kvm.conf
cat /sys/module/kvm_intel/parameters/nested

Typical uses are labs, hypervisor CI, and testing cloud images.

Public clouds expose it only on some instance types, and bare-metal instances exist precisely so you can avoid the nested overhead.

Take quiz
In nested virtualization, what is L2?
A guest running inside a guest hypervisor
The physical hardware
The host hypervisor
Why is nested virtualization slower?
L2 cannot use the CPU
Exits from L2 pass through L0 and often L1, multiplying overhead
EPT is forbidden in every nested setup

45. How do you mitigate VM escape and side-channel risks?

VM escape is when code in a guest breaks out into the host, usually through a bug in the hypervisor or an emulated device (the 2015 VENOM floppy controller flaw is a classic case). Side channels such as Spectre, Meltdown, and L1TF leak data through shared CPU resources.

  1. Patch hypervisor, firmware, and CPU microcode promptly.
  2. Remove unused emulated devices to shrink the attack surface.
  3. Confine QEMU with SELinux (sVirt) or AppArmor and seccomp, and never run it as root.
  4. For high-risk tenants, disable SMT or use core scheduling so untrusted VMs do not share a core.
  5. Consider confidential computing such as AMD SEV or Intel TDX to encrypt guest memory.
  6. Isolate the management network and enforce RBAC with MFA.

Test patches in staging first, because some side-channel mitigations cost measurable CPU performance.

Take quiz
Which step reduces the QEMU attack surface?
Adding more virtual USB controllers
Removing unused emulated devices and confining QEMU with SELinux and seccomp
Running QEMU as root
What are Spectre-class issues?
Disk corruption bugs
DNS spoofing flaws
Side channels that exploit speculative execution

46. How do you design a virtualization cluster for N+1 capacity?

N+1 means the cluster can lose any one host and still run every protected VM. The check is simple: total capacity minus the largest host must still cover demand, for both CPU and memory.

Example: 5 hosts with 512 GB each give 2,560 GB total. For N+1, only 4 hosts' worth, 2,048 GB, counts as usable. Memory is usually the limiting factor, not CPU.

  • Set HA admission control to match, for example 20% reserved for 5 hosts.
  • Spread hosts across racks or chassis so one failure domain cannot take down more than one host.
  • Use redundant storage paths and dual NICs on separate switches.
  • Plan N+2 if hosts are patched one at a time during failures-prone windows.

Re-run the calculation whenever a large host or a very large VM is added, since the largest host defines the reserve.

Take quiz
What does N+1 mean in cluster design?
One extra VM per host
Two vCPUs per physical core
The cluster can lose one host and still run all protected VMs
With 5 hosts of 512 GB each, how much memory is usable under N+1?
2,048 GB
2,560 GB
1,024 GB

47. Why do long snapshot chains degrade performance?

Each snapshot adds another delta disk. A read may have to look through several deltas to find the newest copy of a block, and every extra layer adds metadata lookups.

Writes land in the top delta, which grows on demand. Growing means allocating and zeroing space and updating metadata, which adds latency, and big deltas can fill the datastore.

Deleting or consolidating the chain merges deltas back into the base disk. With big deltas this takes a long time and can briefly stun the VM at the end.

  • Keep chains to a few snapshots and only for days, not weeks.
  • Never use snapshots as long-term backups.
  • Monitor for orphaned deltas after failed backups and consolidate them.

Backup software that crashes mid-run is the usual source of forgotten snapshots, so alert on any snapshot older than a set age.

Take quiz
Why are reads slower with deep snapshot chains?
The hypervisor may traverse several delta files to find a block's newest version
The guest compresses every read
Snapshots lock the CPU frequency
What does snapshot consolidation do?
Moves the VM to another host
Merges delta disks back into the base disk
Deletes the base disk

48. When would you choose post-copy over pre-copy migration?

Pre-copy keeps the VM running on the source until nearly everything is copied. Post-copy switches execution to the destination almost immediately and pulls remaining pages on demand through page faults (userfaultfd on Linux), with a background push.

Pre-copy Post-copy
Failure during migration VM stays safe on source VM can be lost, memory is split
Write-heavy guests May never converge Completes in bounded time
Total migration time Can be long Predictable
Early performance Good Page-fault stalls at first

Choose post-copy for huge, write-intensive VMs on a reliable fast network. A hybrid approach runs a few pre-copy rounds first, then switches to post-copy, and is often the safest balance.

QEMU supports post-copy through the postcopy-ram capability, enabled before migration starts and triggered after the first pre-copy rounds.

Take quiz
What is the main risk of post-copy migration?
It copies the whole disk twice
A network or destination failure mid-migration can lose the VM because memory is split
It needs identical host hardware serial numbers
Which fits a write-heavy VM that never converges?
Pre-copy with no auto-converge
Doing nothing and waiting
Post-copy or a hybrid approach

49. How do you plan a physical-to-virtual (P2V) migration?

P2V converts a physical server into a VM. Careful planning prevents surprises on cutover day.

  1. Inventory CPU, memory, disks, NICs, dependencies, and hardware-bound licenses or USB dongles.
  2. Baseline performance over a representative period, including peaks, to right-size the VM.
  3. Pick a tool such as VMware Converter, virt-p2v, Disk2vhd, or a backup product.
  4. Prepare the source: clean up disks and plan paravirtual drivers (virtio, pvscsi).
  5. Convert hot or cold, then test on an isolated network.
  6. Cut over with a rollback plan, keeping the physical server powered off but intact.
  7. Afterwards remove old hardware agents, install guest tools, and right-size.

Plan downtime for the final delta sync, and schedule database servers for a quiet window so the last incremental copy captures committed data.

Take quiz
Why take a performance baseline before P2V?
To avoid installing guest tools
To preserve the old BIOS
To right-size vCPU and memory from real usage
What is the safest rollback strategy?
Keep the original physical server intact but powered off until validation
Wipe the physical server immediately
Run two conversions of the same server at once

50. Why is an IOMMU needed for device passthrough?

Devices use DMA to read and write memory without involving the CPU, and a plain device can address any physical memory. If you hand a device to a VM, a buggy or malicious guest driver could make it overwrite the host or other VMs.

An IOMMU (Intel VT-d, AMD-Vi) translates device addresses through per-device page tables, confining each device to its VM's memory. It also remaps interrupts.

On Linux, VFIO relies on IOMMU groups, the smallest set of devices that can be isolated. Enable and verify:

# kernel params: intel_iommu=on iommu=pt
dmesg | grep -e DMAR -e IOMMU

In cloud and nested setups passthrough may be unavailable entirely, because the outer hypervisor has to expose a virtual IOMMU to the guest first.

Take quiz
Without an IOMMU, what could a passed-through device do?
DMA into memory belonging to the host or other VMs
Change only the VM's MAC address
Nothing, DMA is always virtualized by the CPU
What is Intel's IOMMU technology called?
VT-x
VT-d
EPT
«
»

Comments & Discussions