How works a virtual machine?

A virtual machine (VM) is an emulation of a computer system. Virtual machines are based on computer architectures and provide functionality of a physical computer. Software called a hypervisor separates the virtual machine from the hardware layer and manages resource allocation between virtual machines.

How works a virtual machine?

Understanding Virtual Machines

A virtual machine is created when the hypervisor allocates a certain amount of the host’s resources, such as RAM, CPU, storage, and network bandwidth, to the guest machine. The guest machine then utilizes these resources to run its own operating system and applications, just like a physical computer.

Some key traits of virtual machines include:

  • Encapsulated set of resources: VMs include virtualized components like virtual CPUs, RAM, storage, and network interfaces. The hypervisor allocates these resources from the host.
  • Isolated from host and other VMs: VMs run independently from each other and the host. If one VM fails, it does not directly affect others.
  • Behaves like an independent computer: Within the allocated resources, each VM can run its own apps and operating system as if it were a separate physical computer.

Benefits of Virtual Machines

Virtualization and VMs offer significant benefits for businesses:

  • Improved hardware utilization: Instead of having multiple underutilized servers, you can run multiple VMs efficiently sharing the resources of fewer powerful hosts.
  • Cost savings: Reducing physical servers saves on real estate, electricity, and maintenance costs.
  • Fast provisioning: New VMs can be spun up quickly from templates without having to configure physical hardware.
  • Increased uptime: VMs can be live migrated between hosts during maintenance. Critical VMs can also failover to alternate hosts.
  • Better test environments: Replicating production environments for testing is easier by spinning up complete VMs as needed.
  • Environment isolation: VMs operate independently from each other which improves security and isolates application issues.

How Does Virtualization Work?

Virtualization allows abstraction and sharing of physical resources through a layer called the hypervisor or virtual machine monitor (VMM). The hypervisor manages all the physical resources and distributes them to enable multiple VMs to share hardware safely and efficiently.

There are two main types of hypervisor architectures:

Type 1 Hypervisor

Runs directly on the system hardware rather than within an operating system. It has direct access to system resources. The Type 1 hypervisor effectively replaces the host operating system.

Examples: VMware vSphere Hypervisor, Microsoft Hyper-V, Citrix XenServer

Type 2 Hypervisor

Runs as software on an operating system, like other computer programs. It utilizes the underlying OS for device support and physical resource management.

Examples: Oracle VirtualBox, VMware Workstation, VMware Fusion

![Diagram showing Type 1 and Type 2 hypervisors]( Choices-Type1-Type2-Hypervisor-300×225.jpg)

Type 1 vs Type 2 Hypervisors (Image Source: VMBlog)

The hypervisor creates virtualized hardware platforms that include virtual devices like a CPU, motherboard, network card, storage, and memory. An individual VM consists of these virtual devices together with a guest operating system and applications running on top.

The guest OS is not aware that it is virtualized. It operates as if it is running on physical hardware but all the resources are actually virtual allocations from the hypervisor. The VM and applications continue running in an encapsulated environment until the VM is powered off or suspended.

Key Components of Virtual Infrastructure

The main components that enable virtualization include:

  • Hosts: The physical servers that provide CPU, memory, storage and networking resources to power the VMs.
  • Hypervisor: The virtualization layer that creates and runs VMs. It allows sharing of underlying host resources across VMs.
  • Virtual machines: Emulated computer systems running their own OS and apps as if on separate hardware.
  • Virtual networks: Enables networking capabilities for VMs through virtual network adapters and switches. Guest VMs connect to each other and physical networks.

Storage resources can be provided to VMs in two main ways:

  1. Virtual disks – Virtual hard disk files hosted on a storage system available on the network.
  2. Passthrough disks – Direct pass-through of a physical storage disk to a VM.

Network resources are provided to VMs through:

  1. Virtual Network Interface Cards (vNICs) – Emulated network interface assigned to each VM by the hypervisor.
  2. Virtual Switches – Software that enables network connectivity between VMs and links virtual networks to physical networks.

How is a Virtual Machine Created?

The process to create a new VM involves allocating resources through the hypervisor to assemble the virtual hardware platform and installing an OS on top.

  1. Resources allocation – The user specifies desired computing capacity like number of vCPUs, RAM, storage etc. The hypervisor allocates these from the host machine.
  2. Virtual hardware formation – Virtual components like motherboard, vNICs, virtual disks are automatically created by the hypervisor.
  3. OS installation – An OS installer disk image (.iso) is mounted to the VM. The OS goes through the installation process inside the VM.
  4. Software and data – Once the OS install finishes, additional software like applications, libraries, tools that are needed can be installed in the VM. Any data or files associated with the software environment can also be copied/mounted into the VM.

The new VM will now be ready to power on and start operating like a regular computer within the allocated resource limits. The lifecycle of this VM can be managed independently through controls like power on/off, suspend, reset, take snapshots etc.

How is a Virtual Machine Executed?

There are specialized CPU instructions that enable hypervisors to manage the sharing of host system resources efficiently across virtual machines:

  • Binary translation – Intercepts guest application instructions and converts them to instructions that are safe to execute on the host CPU.
  • Hardware assisted virtualization – Utilizes CPU extensions like Intel VT-x or AMD-V to run guest code natively while isolating and protecting host resources.

In hardware assisted virtualization, a VM is created with its own:

  • Guest physical address space – The VM’s view of memory is mapped to available host physical RAM through a shadow page table maintained by the hypervisor.
  • Guest virtual address space – The guest OS creates virtual memory mappings for applications inside the VM which are translated by the guest OS into guest physical addresses.
  • Hypervisor – Maps guest physical addresses to host physical addresses through techniques like shadow page tables. The hypervisor controls execution and ensures guest OS actions do not impact memory assigned to other VMs.

This allows the guest OS in a VM to operate without any modification while enabling other VMs to securely share the host resources through the hypervisor’s virtualization of the hardware.

Key Takeaways

  • Virtual machines are software emulations of physical computer systems with their own virtual CPUs, memory, storage, and network resources.
  • A hypervisor manages the host hardware resources and distributes them across VMs efficiently while keeping VMs isolated from each other.
  • VMs allow consolidation of workloads on powerful multi-core servers for better hardware utilization.
  • Virtualization enables fast provisioning of software environments for development, testing, and production workloads.


Virtual machine technology enables emulating the functionality of physical computers on a shared hardware infrastructure for significant efficiency and management benefits. The hypervisor plays a key role in hosting, executing, isolating and managing VMs efficiently across available resources like CPU, memory, storage and networking. Understanding how VMs are created, allocated resources and executed by the hypervisor helps gain insight into how they deliver computational capabilities similar to dedicated systems on shared infrastructure.

Frequently Asked Questions

  1. What is virtualization?
    Virtualization refers to technologies designed to provide virtual abstractions of computer resources rather than actual hardware. It creates virtual versions of computing resources like servers, network, storage etc.
  2. What is a virtual machine?
    A virtual machine (VM) is a software computer that like a physical computer runs an operating system and applications. The VM is composed of virtual components and behaves like a separate computer system.
  3. What is a hypervisor?
    A hypervisor, also called a virtual machine monitor, is a software layer that creates and runs virtual machines. It allows multiple VMs to share the underlying host resources safely and efficiently.
  4. What types of hypervisors are there?
    The two main types are Type 1 hypervisor that runs directly on host hardware and Type 2 hypervisor that runs as software on a host operating system. Examples: VMware ESXi, Citrix XenServer – Type 1; VMware Workstation, Oracle VirtualBox – Type 2.
  5. What are benefits of virtualization?
    Benefits include better hardware utilization through consolidation, faster provisioning of computational resources, improved availability and scalability, easier replication of environments for testing/development purposes.
  6. How are virtual machines created?
    VMs are created by allocating virtualized hardware resources like CPU, memory, storage and networking to form a virtual platform. An OS is installed on this and any other necessary software stacks and data are provisioned.
  7. What is hardware assisted virtualization?
    It utilizes CPU features like Intel VT-x to efficiently run virtual machine code directly on the hardware for performance while still allowing the hypervisor to retain isolation and control.
  8. How does a hypervisor manage OS execution?
    Through a process called binary translation, a hypervisor can intercept OS instructions and convert them to safe equivalents that won’t impact other virtual machines or the host itself. The hypervisor has complete control over scheduling instruction execution across VMs.
  9. What hardware resources are virtualized?
    Hypervisors can virtualize CPU, RAM, disk storage, CD/DVD drives, network interfaces, USB ports creating virtual hardware platforms for VMs with equivalent device functionality.
  10. What is a virtual network?
    A virtual network is a software emulation of a physical network (like a LAN) created to allow VMs to communicate with each other and connect to external networks. Traffic is routed virtually between VMs internal network interface cards.
  11. How is VM storage implemented?
    VM storage is provisioned by the hypervisor as virtual disks stored as files or LUNs on networked storage servers. The hypervisor maps these to VMs as if physical disks attached to a real motherboard allowing the guest OS to access storage capacity.
  12. What is live migration of virtual machines?
    Live migration refers to the ability to seamlessly move a running virtual machine from one host server to another without disruption for purposes like load balancing or host maintenance.
  13. What are some leading virtualization platforms?
    Popular virtualization platforms include VMware vSphere and ESXi, Microsoft Hyper-V, Citrix XenServer, Red Hat Virtualization (RHEV), Oracle VM and VirtualBox among others.
  14. Can you run a virtual machine inside another VM?
    Yes, this is called nested virtualization. Modern hypervisors allow configuring a VM as a hypervisor host itself that can run its own nested VMs. For example, VMware Workstation can run ESXi to host nested VMs.
  15. What are some uses of virtual machines?
    VMs have many production uses like server consolidation, running legacy apps, isolating services & apps, disaster recovery, as well as development & testing environments, operating system testing, running software demos without risk etc.
  16. How are virtual CPUs implemented?
    Virtual CPUs utilize techniques like binary translation and direct execution by hypervisor to schedule VM instruction execution across one or more physical CPU cores allocated to VMs as virtual processors.
  17. What is virtual memory in a VM?
    It is a memory management technique that uses software to allow VM memory address spaces that can exceed available physical RAM through techniques like paging and swapping some contents to storage.

Leave a Comment