Chapter 8. Virtual Machines Concepts and Management

A virtual machine is a set of virtual hardware whose characteristics are determined by a set of encapsulated files; it is this virtual hardware that a guest operating system is installed on. A virtual machine runs an operating system and a set of applications in a similar fashion to a physical server. Essentially, a virtual machine is comprised of configuration files and its physical resources are provided by an ESXi host.

Virtual machines are created within a virtualization layer, and this virtualization layer manages requests from the virtual machine for resources such as CPU or memory. It is this virtualization layer that is responsible for translating these requests to the underlying physical hardware.

Each virtual machine is granted a portion of the physical hardware. All VMs have their own virtual hardware (there are important ones to note, called the core 4: CPU, memory, disk, and network). Each VM is isolated from the other and each interacts with the underlying hardware through a thin software layer known as the hypervisor. This is different from a physical architecture in which the installed operating system interacts with the installed hardware directly.

With virtualization, there are many benefits in relation to portability, security, and manageability that aren't available in an environment that uses a traditional physical infrastructure. However, once provisioned, virtual machines use many of the same principles that are applied to physical servers.

In this chapter, we will learn:

  • The components of a virtual machine
  • New vSphere 6 virtual machine features
  • How to create a virtual machine
  • Virtual machine settings
  • vSphere Fault Tolerance

Virtual machine components

A virtual machine needs four core resources: CPU, memory, network, and storage (disk). These resources are granted to the virtual machine through the configuration of the virtual hardware.

Virtual hardware

When a virtual machine is created, a default set of virtual hardware is assigned to it. VMware provides devices and resources that can be added and configured to the virtual machine. Not all virtual hardware devices will be available to every single virtual machine; both the physical hardware of the ESXi host and the VM's guest OS must support these configurations. For example, a virtual machine will not be capable of being configured with more vCPUs than the ESXi host has CPU sockets.

The virtual hardware available includes:

  • BIOS: Phoenix Technologies 6.00 that functions like a physical server BIOS. Virtual machine administrators are able to enable/disable I/O devices, configure boot order, and so on.
  • DVD/CD-ROM: NEC VMware IDE CDR10 that is installed by default in new virtual machines created in vSphere. The DVD/CD-ROM can be configured to connect to the client workstation DVD/CD-ROM, an ESXi host DVD/CD-ROM, or even an .iso file located on a datastore. DVD/CD-ROM devices can be added to or removed from a virtual machine.
  • Floppy drive: They are installed by default with new virtual machines created in vSphere. The floppy drive can be configured to connect to the client device's floppy drive, a floppy device located on the ESXi host, or even a floppy image (.flp) located on a datastore. Floppy devices can be added to or removed from a virtual machine.
  • Hard disk: This stores the guest operating system, program files, and any other data associated with a virtual machine. The virtual disk is a large physical file, or potentially a set of files, that can be easily copied, moved, and backed up.
  • IDE controller: Intel 82371 AB/EB PCI Bus Master IDE Controller that presents two Integrated Drive Electronics (IDE) interfaces to the virtual machine by default. This IDE controller is a standard way for storage devices, such as floppy drives and CD-ROM drives, to connect to the virtual machine.
  • Keyboard: This mirrors the keyboard that is first connected to the virtual machine console upon initial console connection.
  • Memory: This is the virtual memory size configured for the virtual machine that determines the guest operating system's memory size. A maximum of 4 TB may be configured for a virtual machine.
  • Motherboard/Chipset: The motherboard uses VMware proprietary devices that are based on the following chips:
    • Intel 440BX AGPset 82443BX Host Bridge/Controller
    • Intel 82093 AA I/O Advanced Programmable Interrupt Controller
    • Intel 82371 AB (PIIX4) PCI ISA IDE Xcelerator
    • National Semiconductor PC87338 ACPI 1.0 and PC98/99 Compliant Super I/O
  • Network adapter: ESXi networking features provide communication between virtual machines residing on the same ESXi host, between VMs residing on different ESXi hosts, and between VMs and physical machines. When configuring a VM, network adapters (NICs) can be added and the adapter type can be speci

Note

Keep in mind that snapshots are not supported with DirectPath I/O pass-through device configuration. For more information on virtual machine snapshots, see http://vmware.com/kb/1015180.

  • Pointing device: This mirrors the pointing device that is first connected to the virtual machine console upon initial console connection.
  • Processor: This specifies the number of sockets and core for the virtual processor. This will appear as AMD or Intel to the virtual machine guest operating system depending upon the physical hardware. A maximum of 128 vCPUs may be configured.
  • SATA controller: This provides access to DVD/CD-ROM devices and virtual disks. The SATA virtual controller will appear to the virtual machine as an AHCI SATA controller.
  • Serial port: This is an interface for connecting peripherals to the virtual machine. The virtual machine can be configured to connect to a physical serial port, a file on the host, or over the network. The serial port can also be used to establish a direct connection between two VMs. Virtual serial ports can be added to or removed from the virtual machine. A maximum of 32 serial ports may be configured.
  • SCSI controller: This provides access to virtual disks. The virtual SCSI controller may appear as one of several different types of controllers to a virtual machine, depending on the guest operating system of the VM. Editing the VM configuration can modify the SCSI controller type, a SCSI controller can be added, and a virtual controller can be configured to allocate bus sharing.
  • SCSI device: An SCSI device interface is available to the virtual machine by default. This interface is a typical way to connect storage devices (hard drives, floppy drives, CD-ROMs, and so on) to a VM. SCSI device is a device that can be added to or removed from a virtual machine.
  • SIO controller: The Super I/O controller provides serial and parallel ports, floppy devices, and performs system management activities. A single SIO controller is presented to the virtual machine. This cannot be configured or removed.
  • USB controller: This provides USB functionality to the USB ports managed. The virtual USB controller is the software virtualization of the USB host controller function in a VM.
  • USB device: Multiple USB devices may be added to a virtual machine. These can be mass storage devices or security dongles. The USB devices can be connected to a client workstation or to an ESXi host.
  • Video controller: This is a VMware Standard VGA II Graphics Adapter with 128 MB video memory.
  • VMCI: The Virtual Machine Communication Interface provides high-speed communication between the hypervisor and a virtual machine. VMCI can also be enabled for communication between VMs. VMCI devices cannot be added or removed.
  • Parallel port: This is an interface for connecting peripherals to the virtual machine. Virtual parallel ports can be added to or removed from the virtual machine.
  • PCI controller: This is a bus located on the virtual machine motherboard, communicating with components such as a hard disk. A single PCI controller is presented to the virtual machine. This cannot be configured or removed.
  • PCI device: DirectPath devices can be added to a virtual machine. The devices must be reserved for PCI pass-through on the ESXi host that the virtual machine runs on. You may add up to 16 CPI vSphere DirectPath devices to the virtual machine.

Core 4 resources

Virtualization decouples physical hardware from an operating system. Each virtual machine contains a set of its own virtual hardware and there are four primary resources that a virtual machine needs in order to correctly function. These are CPU, memory, network, and hard disk. These four resources look like physical hardware to the guest operating systems and applications. The virtual machine is granted access to a portion of the resources at creation and can be reconfigured at any time thereafter. If a virtual machine experiences constraint, one of the four core resources is where a bottleneck will generally occur.

CPU

The virtualization layer runs CPU instructions to make sure that the virtual machines run as though accessing the physical processor on the ESXi host. Performance is paramount for CPU virtualization, and therefore will use the ESXi host physical resources whenever possible.

A virtual machine can be configured with up to 128 virtual CPUs (vCPUs) as of vSphere 6.0. The maximum vCPUs able to be allocated depends on the underlying logical cores that the physical hardware has. Another factor in the maximum vCPUs is the tier of vSphere licensing; only Enterprise Plus licensing allows for 128 vCPUs. The VMkernel includes a CPU scheduler that dynamically schedules vCPUs on the ESXi host's physical processors.

The VMkernel scheduler, when making scheduling decisions, considers socket-core-thread topology. A socket is a single, integrated circuit package that has one or more physical processor cores. Each core has one or more logical processors, also known as threads. If hyperthreading is enabled on the host, then ESXi is capable of executing two threads, or sets of instruction, simultaneously. Effectively, hyperthreading provides more logical CPUs to ESXi on which vCPUs can be scheduled, providing more scheduler throughput. However, keep in mind that hyperthreading does not double the core's power. During times of CPU contention, when VMs are competing for resources, the VMkernel time-slices the physical processor across all virtual machines to ensure that the VMs run as if having a specified number of vCPUs.

VMware Virtual Symmetric Multiprocessing (SMP) is what allows the virtual machines to be configured with up to 128 virtual CPUs, which allows a larger CPU workload to run on an ESXi host. Though most supported guest operating systems are multiprocessor aware, many guest OSs and applications do not need and are not enhanced by having multiple vCPUs. Check vendor documentation for operating system and application requirements before configuring SMP virtual machines.

Memory

In a physical architecture, an operating system assumes that it owns all physical memory in the server, which is a correct assumption. A guest operating system in a virtual architecture also makes this assumption but it does not, in fact, own all of the physical memory. A guest operating system in a virtual machine uses a contiguous virtual address space that is created by ESXi as its configured memory.

Virtual memory is a well-known technique that creates this contiguous virtual address space, allowing the hardware and operating system to handle the address translation between the physical and virtual address spaces. Since each virtual machine has its own contiguous virtual address space, this allows ESXi to run more than one virtual machine at the same time. The virtual machine's memory is protected against access from other virtual machines.

This effectively results in three layers of virtual memory in ESXi: physical memory, guest operating system physical memory, and guest operating system virtual memory. The VMkernel presents a portion of physical host memory to the virtual machine as its guest operating system physical memory. The guest operating system presents the virtual memory to the applications:

Memory

The virtual machine is configured with a set of memory; this is the sum that the guest OS is told it has available to it. A virtual machine will not necessarily use the entire memory size, it only uses what is needed at the time by the guest OS and applications. However, a VM cannot access more memory than the configured memory size. A default memory size is provided by vSphere when creating the virtual machine. It is important to know the memory needs of the application and guest operating system being virtualized so that the virtual machine's memory can be sized accordingly.

Network

There are two key components with virtual networking: the virtual switch and virtual Ethernet adapters. A virtual machine can be configured with up to 10 virtual Ethernet adapters called vNICs. A vNIC is the virtual machine's network adapter that connects it to the port group on a virtual switch, whereas a vmnic is the physical NIC acting as an uplink on an ESXi host.

Virtual network switching is software interfacing between virtual machines at the vSwitch level until the frames hit an uplink or a physical adapter, exiting the ESXi host and entering the physical network. Virtual networks exist for virtual devices; all communication between the virtual machines and the external world (physical network) goes through vSphere standard switches or vSphere distributed switches.

Virtual networks operate on layer 2, data link, of the OSI model. A virtual switch is similar to a physical Ethernet switch in many ways. For example, virtual switches support the standard VLAN (802.1Q) implementation and have a forwarding table, like a physical switch. An ESXi host may contain more than one virtual switch. Each virtual switch is capable of binding multiple vmnics together in a Network Interface Card (NIC) team, which offers greater availability to the virtual machines using the virtual switch.

There are two connection types available on a virtual switch: a port group and a VMkernel port. Virtual machines are connected to port groups on a virtual switch, allowing access to network resources. VMkernel ports provide a network service to the ESXi host to include IP storage, management, vMotion, and so on. Each VMkernel port must be configured with its own IP address and network mask. The port groups and VMkernel ports reside on a virtual switch and connect to the physical network through the physical Ethernet adapters known as vmnics. If uplinks (vmnics) are associated with a virtual switch, then the virtual machines connected to a port group on this virtual switch will be able to access the physical network.

Disk

In a non-virtualized environment, physical servers connect directly to storage, either to an external storage array or to their internal hard disk arrays to the server chassis. The issue with this configuration is that a single server expects total ownership of the physical device, tying an entire disk drive to one server. Sharing storage resources in non-virtualized environments can require complex filesystems and migration to file-based Network Attached Storage (NAS) or Storage Area Networks (SAN), or with vSphere 6.0, Virtual SAN (VSAN) or Virtual Volumes (VVOLs).

Shared storage is a foundational technology that allows many things to happen in a virtual environment (High Availability, Distributed Resource Scheduler, and so on). Virtual machines are encapsulated in a set of discrete files stored on a datastore. This encapsulation makes the VMs portable and easy to be cloned or backed up. For each virtual machine, there is a directory on the datastore that contains all of the VM's files. A datastore is a generic term for a container that holds files as well as .iso images and floppy images. It can be formatted with VMware's Virtual Machine File System (VMFS) or can use NFS. Both datastore types can be accessed across multiple ESXi hosts.

VMFS is a high-performance, clustered filesystem devised for virtual machines, which allows a virtualization-based architecture of multiple physical servers to read and write to the same storage simultaneously. VMFS is designed, constructed, and optimized for virtualization. The newest version, VMFS-5, exclusively uses 1 MB block size, which is good for large files, while also having an 8 KB subblock allocation for writing small files such as logs. VMFS-5 can have datastores as large as 64 TB. The ESXi hosts use a locking mechanism to prevent the other ESXi hosts accessing the same storage from writing to the VMs' files. This helps prevent corruption.

Several storage protocols can be used to access and interface with VMFS datastores. These include Fibre Channel, Fibre Channel over Ethernet, iSCSI, and direct attached storage. The NFS protocol can also be used to create an NFS datastore. The VMFS datastore can be dynamically expanded, allowing the growth of the shared storage pool with no downtime.

vSphere significantly simplifies accessing storage from the guest OS of the VM. The virtual hardware presented to the guest operating system includes a set of familiar SCSI and IDE controllers; this way the guest OS sees a simple physical disk attached via a common controller. Presenting a virtualized storage view to the virtual machine's guest OS has advantages such as expanded support and access, improved efficiency, and easier storage management.

Virtual machine files

vSphere administrators should know the components of virtual machines. There are multiple VMware file types that are associated with and make up a virtual machine. These files are located in the VM's directory on a datastore. The following table will summarize and provide a quick reference and short description of all the files that make up a virtual machine:

Virtual machine files

Depending on the state and configuration of the virtual machine, not all files will be present in the virtual machine directory.

Let's explore these virtual machine files in more detail.

Configuration files

The .vmx file describes the current configuration information and hardware settings for the VM. This can contain a large variety of information regarding the virtual machine, to include its specific virtual hardware configuration (amount of RAM, NIC settings, CD-ROM information, parallel/serial port information, and so on), as well as its advanced resource and power settings, VMware tools options, and so forth. It is possible to make changes and directly edit this file; however, you should only do this at your own risk.

Note

Generally, it is recommended to have a backup of this file first and to not edit until recommended by VMware support.

The .vmx file is a plain-text file that functions as the structural definition of the VM. The .vmx file can be copied from the datastore and opened using a program that supports the creation and saving of files using UTF-8 encoding, such as WordPad. The following excerpt shows an example of a .vmx file for a virtual machine named ExampleVM:

.encoding = "UTF-8" 
config.version = "8" 
virtualHW.version = "11" 
nvram = "ExampleVM.nvram" 
pciBridge0.present = "TRUE" 
svga.present = "TRUE" 
pciBridge4.present = "TRUE" 
pciBridge4.virtualDev = "pcieRootPort" 
pciBridge4.functions = "8" 
pciBridge5.present = "TRUE" 
pciBridge5.virtualDev = "pcieRootPort" 
pciBridge5.functions = "8" 
pciBridge6.present = "TRUE" 
pciBridge6.virtualDev = "pcieRootPort" 
pciBridge6.functions = "8" 
pciBridge7.present = "TRUE" 
pciBridge7.virtualDev = "pcieRootPort" 
pciBridge7.functions = "8" 
vmci0.present = "TRUE" 
hpet0.present = "TRUE" 
svga.vramSize = "8388608" 
memSize = "4096" 

sched.cpu.units = "mhz" 
sched.cpu.affinity = "all" 
sched.mem.affinity = "all" 
powerType.powerOff = "default" 
powerType.suspend = "default" 
powerType.reset = "default" 
scsi0.virtualDev = "lsisas1068" 
scsi0.present = "TRUE" 
sata0.present = "TRUE" 
scsi0:0.deviceType = "scsi-hardDisk" 
scsi0:0.fileName = "ExampleVM.vmdk" 
sched.scsi0:0.shares = "normal" 
sched.scsi0:0.throughputCap = "off" 
scsi0:0.present = "TRUE" 
ethernet0.virtualDev = "e1000e" 
ethernet0.networkName = "VM Network" 
ethernet0.addressType = "vpx" 
ethernet0.generatedAddress = "00:50:56:ac:e1:a8" 
ethernet0.present = "TRUE" 
sata0:0.startConnected = "FALSE" 
sata0:0.deviceType = "cdrom-raw" 
sata0:0.clientDevice = "TRUE" 
sata0:0.fileName = "emptyBackingString" 
sata0:0.present = "TRUE" 
floppy0.startConnected = "FALSE" 
floppy0.clientDevice = "TRUE" 
floppy0.fileName = "vmware-null-remote-floppy" 
displayName = "ExampleVM" 
guestOS = "windows8srv-64" 
disk.EnableUUID = "TRUE" 
toolScripts.afterPowerOn = "TRUE" 
toolScripts.afterResume = "TRUE" 
toolScripts.beforeSuspend = "TRUE" 
toolScripts.beforePowerOff = "TRUE" 
uuid.bios = "42 2c 9e f6 48 47 8f 8c-60 2f 5a 66 37 0a 6e 3c" 
vc.uuid = "50 2c 81 6b 04 4c 47 19-77 c9 16 97 d0 1b 33 43" 
sched.cpu.min = "0" 
sched.cpu.shares = "normal" 
sched.mem.min = "0" 
sched.mem.minSize = "0" 
sched.mem.shares = "normal" 

Reading through this file gives us important information regarding the configuration of the virtual machine. Here are a few examples:

  • The VM's configured guest operating system can be derived from the guestOS line
  • Based upon the memsize line, it is known that the VM was configured for 4 GB of memory
  • The virtual machine only has one network adapter configured for the VM Network port group based on the ethernet0 lines
  • The virtual machine's vNIC has a MAC address of 00:50:56:ac:e1:a8, specified by the ethernet0.generatedAddress line

A virtual machine's .vmx file is most commonly edited to modify the MAC address so that it matches the effective MAC address set within the guest operating system. However, this practice is becoming less and less common due to this configuration change being done more easily in the vSphere Web Client.

The .vmx file is extremely important to the virtual machine. However, keep in mind that it only structurally defines the VM's virtual hardware composition. It does not hold any actual data from the guest OS running within the VM. The virtual machine's data is stored in its virtual disk file. Here's an overview of the configuration and BIOS files:

  • .vmtx: When a virtual machine is converted to a template, the virtual machine configuration file (.vmx) is replaced by the template configuration file (.vmtx).
  • .nvram: This is generally a fairly small file which contains the BIOS settings that the VM uses upon boot. This is similar to how a physical server that has a BIOS chip allows hardware configuration options. The virtual BIOS settings, contained in the .nvram file, can be accessed by pressing F2 when the virtual machine is powered on.

Swap files

The .vswp file is created when the virtual machine is powered on. The size of the .vswp file is equal to that of a configured memory, unless there is a reservation. When a memory reservation is configured for a VM, then the .vswp file size would equal the configured memory size minus the memory reservation. This file is used as a last resort when the hypervisor is reclaiming physical memory from its virtual machines due to contention.

Looking at the previous table, you may have noticed the vmx-<vmname>.vswp file. This file is for the overhead memory created for a VM, a new feature in vSphere 5.x. Historically, this memory overhead was not swappable. Though there was a memory reservation to back this, the entire address space did not actually have to reside in memory. This file helps to reduce the reservation requirements for virtual machines.

Virtual disks

The following are some of the virtual disk files:

  • .vmdk: This is the Virtual disk descriptor, which holds information such as the size and disk geometry of the virtual disk, information that makes the VM believe it has a real hard disk and not files on a datastore. Such information includes the virtual disk's adapter type, drive sectors, heads, and cylinders. This descriptor file also contains a pointer to the larger data file for the virtual disk or the -flat.vmdk file.
  • -flat.vmdk: This file actually contains the virtual disk's data. This is created by default when a virtual hard drive is added to a virtual machine that is not using the Raw Device Mapping (RDM) option. When created as a thick provisioned disk, it will be sized approximately to what was specified in the creation wizard.
  • -rdm.vmdk: This is the mapping file for the RDM option, managing the RDM device's mapping data. The virtual machine isn't aware of this since the mapping file is presented to the ESXi host as a traditional disk file and is available for normal filesystem operations. The storage virtualization layer presents the mapped device as a virtual SCSI device to the VM. An -rdm.vmdk file exists for each RDM configured for the virtual machine.

Snapshot files

The following are the snapshot files:

  • -delta.vmdk: These files are only used when creating snapshots. When a snapshot is created, the original -flat.vmdk file is no being longer written to; it becomes read only. All changes that are written to the virtual disk are now being written to the -delta.vmdk files instead. The -delta.vmdk file cannot exceed the size of the original -flat.vmdk file due to the fact that these -delta.vmdk files are bitmaps of changes made to a virtual disk. A -delta.vmdk file is created for each snapshot taken. These -delta.vmdk files are updated in 16 MB increments as changes are written to the virtual disk.
  • .vmsd: This file is a snapshot descriptor that contains information regarding which files are used by each snapshot, description, display name, and any associated UIDs. There is only one .vmsd file per virtual machine, regardless of how many snapshots the virtual machine has. This file is updated each time a new snapshot is created or a snapshot is deleted.
  • .vmsn: This file stores the virtual machine's state at the time the snapshot was taken. The size of this file varies depending on whether the option to include the VM's memory state was selected during snapshot creation. A separate .vmsn file will be created for each snapshot and will automatically be removed when the snapshot is deleted.

Other files

Let's take a look at some other files:

  • .vmss: This file is used when a virtual machine is suspended so as to preserve the VM's memory contents; it is only present when the VM is suspended. When the virtual machine is resumed from the suspended state, it can start again right from where it left off. The contents of this file are written back to the ESXi host's physical memory when the virtual machine is brought out of a suspended state; however, the file will not be automatically deleted until the VM is powered off. This file will be approximately the same size as the configured memory for the virtual machine, unless memory contention is present.
  • .log: Log files are created in order to log information regarding the virtual machine, typically used during troubleshooting efforts. The current log file is always named vmware.log, and by default up to six older log files will be retained. These older log files will have a number appended at the end of their names, which will be updated with each file (vmware-2.log).
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.137.240