A Virtual machine is an emulation of a real computer system. Virtual Machines or VMs run on top of a physical machine using a "Hypervisor".
The host machine using hypervisor, provides the VMs with resources that are required. Hypervisor distributes the resources between different VMs.
A virtual machine contains both the application and it's dependencies. It also contains an entire virtualized hardware stack of it's own, including network adapters, storage and CPU -- also it's own virtual operating system. From inside, the virtual machine behaves as an individual computer system with it's own dedicated resources. From outside, it is just a VM sharing resources of Host machine provided by hypervisor.
Two types of hypervisors :
- Hosted Machine Hypervisor
- 'Bare-Metal' Hypervisor
Hosted Machine Hypervisor :
It runs on the operating system of the host machine. For example : A computer system running Windows 8.1 can have a VMware or Virtualbox installed on top of that. Thus, in this case the Hypervisor doesn't have a direct access to hardware, instead it had to go through the host operating system (in this case Win8.1).
Advantages of Hosted Machine Hypervisor -
While using hosted machine hypervisor, underlying hardware is less important. Instead of hypervisor itself, the host's operating system takes care for the hardware drivers. This driver-less approach for hosted-machine hypervisor makes it more "hardware compatible".
Disadvantages of Hosted Machine Hypervisor - Having this additional layer of Host machine operating system between hardware and hypervisor creates more resource overhead, reducing the performance of Virtual Machine.
Bare-Metal Hypervisor :
A bare-metal hypervisor eliminates the performance issue by running directly on host machine's hardware. The first thing installed on a machine's hardware as operating system is hypervisor itself. Bare-Metal Hypervisor has its own set to device drivers and handles I/O, processing and OS-specific tasks itself.
This approach advances bare-metal hypervisor with better efficiency, performance and scalability. However, this limits the hardware compatibility.