15.1 Virtual Machines
Specification
show understanding of the concept of a virtual machine
give examples of the role of virtual machines
show understanding of the benefits and limitations of virtual machines
NOTE: Java Virtual Machines are covered in 1.5.4 & 3.4.3 Translators
Exam Key Terms
Summary of Key Terms
To understand a Virtual Machine (VM) we need to look at the options around its use. We'll start with looking at the key differences between a VM, hypervisor and emulator. The specification does not mention emulation, but it is implicit in understanding and discussing VMs.
Virtual Machine (VM):
What it is: A VM is a software emulation of a complete computer system. It has its own virtual hardware (CPU, memory, storage, network) and runs a guest operating system (OS) independently from the host OS.
How it works: VMs run on top of a hypervisor, which manages the allocation of resources and communication between the VM and the underlying hardware.
Benefits:
Isolation: VMs provide strong isolation, preventing guest OS crashes or security issues from affecting the host OS or other VMs.
Flexibility: You can run different operating systems (Windows, Linux, macOS, etc.) on the same physical hardware.
Portability: VMs can be easily migrated between physical machines.
Use cases:
Testing and development: VMs provide safe environments for testing software, new OS versions, or configurations.
Server consolidation: Multiple VMs can run on a single server, maximizing resource utilization.
Legacy software support: VMs can run older applications or operating systems that are incompatible with newer hardware.
Hypervisor:
What it is: A hypervisor (or Virtual Machine Monitor, VMM) is a thin software layer that enables virtualization. It sits directly on top of the physical hardware and creates and manages VMs.
Types:
Type 1 (bare-metal): Hypervisors run directly on the hardware without a host OS, providing better performance and efficiency. (e.g., VMware ESXi, Microsoft Hyper-V Server)
Type 2 (hosted): Hypervisors run on top of a host OS (e.g., VMware Workstation, VirtualBox).
Role:
Resource management: Allocates CPU, memory, storage, and networking resources to VMs.
Isolation: Ensures that each VM runs independently and securely.
Hardware access: Controls VM access to physical devices, like network interfaces or GPUs.
Emulator:
What it is: An emulator is a software or hardware system that allows one computer system (the host) to behave like another computer system (the guest). It focuses on replicating the behaviour of a specific hardware environment, including the CPU, peripherals, and even firmware.
How it works: Emulators translate guest system instructions into instructions the host system can understand. This translation process can be slower than running code natively on the hardware.
Use cases:
Gaming: Emulators allow you to play games designed for older consoles (e.g., NES, SNES) or different platforms (e.g., Android games on PC) on your modern hardware.
Software development: Emulators help developers test software on different target platforms without needing physical devices.
Legacy system preservation: Emulators can help preserve software and hardware systems that are no longer manufactured.
Key Differences Summary:
To jump into more detail for VMs:
Examples of a VMs role:
Server consolidation: A single powerful server can host multiple VMs, each running different operating systems or applications. This optimizes resource utilization and reduces hardware costs.
Testing and development: VMs offer isolated sandboxes for testing software, new OS versions, or configurations without risking the stability of the host system.
Cloud computing: Cloud providers leverage VMs to deliver scalable and flexible computing resources to their customers. Users can easily provision VMs with specific configurations to meet their needs.
Legacy software support: VMs enable running older applications or operating systems that may not be compatible with modern hardware.
Training and education: VMs provide a safe and controlled environment for students to learn and experiment with different operating systems and software configurations.
Benefits and limitations of VMs
Benefits:
Cost savings: Reduced hardware costs due to server consolidation and efficient resource utilization.
Flexibility: Ability to run multiple operating systems and applications on the same hardware.
Scalability: Easy to scale resources up or down based on demand.
Isolation: Protects the host system and other VMs from potential crashes or security issues in one VM.
Portability: VMs can be easily migrated between different hosts.
Limitations:
Performance overhead: VMs may not be as performant as running directly on the hardware due to the virtualization layer.
Resource contention: If multiple VMs on a host demand excessive resources simultaneously, it can lead to performance degradation.
Complexity: Managing multiple VMs can be more complex than managing physical machines.
Security risks: VMs are not immune to security threats and require proper configuration and management.
Licensing costs: Some virtualization software may require licenses for each VM, adding to the overall cost.
Background Reading (detail)
This section was re-written on the 17 March 2019.
While the textbooks provide little content, there is a confusing array of information on the Internet. You will the terms emulator and virtual machine used interchangeably. This is NOT the case. The key differences are:
The purpose of a virtual machine is to create an isolated environment.
The purpose of an emulator is to accurately reproduce the behaviour of some hardware.
Both aim for some level of independence from the hardware of the host machine, but a virtual machine tends to simulate just enough hardware to make the guest work, and do so with an emphasis on efficiency of the emulation/virtualization. Ultimately the virtual machine may not act like any hardware that really exists, and may need VM-specific drivers.
An emulator on the other hand tries to exactly reproduce all the behaviour, including quirks and bugs, of some real hardware being simulated. Required guest drivers will exactly match the environment being simulated. Emulators are used to allow gamers to play console games on vastly different hardware.
What is Virtual Machine(VM)?
Computers vary in the hardware they use, and run different programs and operating systems. Sometimes we might want to have the functionality and capability of another computer system running on our own computer. It may be that the hardware for the other system no longer exists or is unavailable, or we may wish to have several versions of a computer running simultaneously on one hardware system.
We can use software to emulate the other computer system so that our computer can behave like that system. This emulation is known as a virtual machine.
The process of creating and running a virtual machine is known as virtualisation. The computer that runs the virtual machine is known as the host. The virtualised system is known as a guest. Virtualisation software, known as an emulator, creates a virtual implementation of the guest system on the host computer, providing the host with the functions and programs of the guest. The emulator translates the instructions of the guest computer so that the host computer can understand them. Most modern CPUs allow instructions to bypass the host OS and run directly, allowing the VM software to directly access hardware without having to translate instructions for the host OS to run. This can give big speed improvments.
The emulator also provides a bridge that allows the virtual machine to use the user interface, via the host operating system (I/O – input/output), allowing the user to interact with the software running on the virtual machine.
Tasks of Virtual Machine Software
Virtual machine software undertakes many tasks, including:
Create the virtual machine
Delete the virtual machine
Existing hardware made available to guest OS
Hardware emulation
making the guest OS believe certain hardware is there, or, provide translation from that hardware to the actual physical hardware. This is especially important if emulating a totally different device, such as an old computer (e.g. Atari, Amiga) or, games console.
Ensure each virtual machine is protected from the actions of another virtual machine (machine independence). This is why you can run malware infested programs safely within a VM.
Types of Virtual Machine
There are two main types you should know about:
System VMs: provides a complete system platform which supports the execution of a complete operating system (OS),E.g. VirtualBox or VMWare are two examples.
Process VMs (aka application VM): runs as a normal application inside a host OS and supports a single process. It is created when that process is started and destroyed when it exits.
System virtual machines
System virtual machines emulate the software of another computer system completely. They allow the host computer to have all the software functionality of the guest system.
System virtual machines run the operating system of the guest system within the operating system of the host, allowing programs supported by the guest operating system to be run on the host computer. As a result, system virtual machines are often used to allow the host computer to run an operating system written for another hardware platform.
Users running Apple operating systems often use a Microsoft Windows virtual machine to run the Windows operating system on Apple computers. Similarly, users of Apple- or Windows-based computers often run Linux as a virtual machine. The system virtual machine allows full use of the guest computer operating system and the programs that run on it.
Another use of system virtual machines is to provide access to programs that current operating systems no longer support. Many old DOS and Windows 3.1, 95 and 98 programs are not supported in Windows 8 and 10. Through using a system virtual machine for these old operating systems, such programs can still be run.
System virtual machines often require substantial processing power and memory. This is inevitable, as many modern operating systems require fast processors and plenty of memory. When emulating these operating systems, the more capable a host computer is, the faster and more capable the guest operating system will be. A host computer with limited resources may still be able to run a system virtual machine but it may have degraded performance.
Process virtual machines
Sometimes called an application virtual machine, runs as a normal application inside a host OS and supports a single process. Its purpose is to provide a platform-independent programming environment that abstracts away details of the underlying hardware or operating system, and allows a program to execute in the same way on any platform. For example Wine software in Linux helps to run Windows application. Therefore, they do not provide a platform on which an entire operating system could run, just a single program.
They are often used to support a programming language, allowing programs created in that language to run on a variety of systems. They are frequently used to emulate old video game systems and arcade games.
Running virtual machines simultaneously
If a host system is powerful enough, several virtual machines can be run side-by-side on one computer. A good example of this is the increasing use of virtual machines to run several virtual servers, such as a domain name server, web server and print server, on one physical server. The host server maintains the virtual machines and allows them to act as though they are all separate computers.
Use of VMs
The desire to run multiple operating systems was the initial motive for virtual machines, so as to allow time-sharing among several single-tasking operating systems. The use of virtual machines to support separate guest operating systems is popular in regard to embedded systems. A typical use would be to run a real-time operating system simultaneously with a preferred complex operating system, such as Linux or Windows. Another use would be for novel and unproven software still in the developmental stage, so it runs inside a sandbox. Virtual machines have other advantages for operating system development, and may include improved debugging access. They can also be used to run older software that may be incompatible with newer OS variants. For example, many old MS-DOS games do not run under Windows 7, 8 or 10. A DOS emulator provides a virtual machine in which the game can communicate as programmed and the VM is able to communicate with the host hardware as necessary.
The role of the VM is to provide a virtual environment, separate from the host OS (on which the VM is running). In addition, VMs will also allow you to run software on hardware they were not designed for. For example, running Apple's OS X within Windows 10. The more recent the operating system, the more sophisticated the VM typically needs to be, as recent OS will expect hardware features which need to be interpreted by the VM. Performance can be a significant issue with VMs.
Virtual machines have a number of popular uses:
To summarise the paragraphs above, uses include:
Test new versions of operating systems: You can run the development version of Windows 8 in a virtual machine on your Windows 7 computer. This allows you to experiment with Windows 8 without installing an unstable version of Windows on your computer.
Experiment with other operating systems: You can install various distributions of Linux and other more obscure operating systems in a virtual machine to experiment with them and learn how they work. If you’re interested in Ubuntu, you can install it in a virtual machine and play with it at your own pace — in a window on your normal desktop.
Use software requiring an outdated operating system: If you’ve got an important application that only runs on Windows XP, you can install XP in a virtual machine and run the application in the virtual machine. The virtual machine is actually running Windows XP, so compatibility shouldn’t be a problem. This allows you to use an application that only works with Windows XP without actually installing Windows XP on your computer.
Run software designed for another operating systems: Mac and Linux users can run Windows in a virtual machine to run Windows software on their computers without the compatibility headaches of Wine and Crossover. Unfortunately, games can be a problem - due to the graphical hardware requirements.
Test software on multiple platforms: If you need to test whether an application works on multiple operating systems – or just different versions of Windows – you can install each in a virtual machine instead of keeping separate computers around for each.
Consolidate servers: For businesses running multiple servers, existing servers can be placed into virtual machines and run on a single computer. Each virtual machine is an isolated container, so this doesn’t introduce the security headaches involved with running different servers on the same operating system. The virtual machines can also be moved between physical servers.
Testing software for malware: if you want to run and test an unknown program, you can set up a VM and test the software there. Any malware would be restricted and limited to the virtual machine, so could cause no harm to the host OS.
Benefits and Limitations
The main advantages of virtual machines:
Multiple OS environments can exist simultaneously on the same machine, isolated from each other;
Virtual machine can offer an instruction set architecture that differs from real computer's;
Easy maintenance, application provisioning, availability and convenient recovery.
The main disadvantages:
When multiple virtual machines are simultaneously running on a host computer, each virtual machine may introduce an unstable performance, which depends on the workload on the system by other running virtual machines;
Virtual machine is not that efficient as a real one when accessing the hardware;
They emulate in software, not hardware. Users trying to get the full functionality from software for another platform may find that they still cannot use the software correctly.
Emulation requires processing power and memory. Running a virtual machine may take a substantial amount of these resources, resulting in reduced performance from the host computer
If the host system lacks sufficient resources, the virtual machine will also suffer from poor performance and be difficult to use.
Links
Videos
DOS box and discussion of emulation