Answers: What Is a Virtual Machine, and What Runs It?¶
1. What does the VM have that the browser doesn't?¶
Its own operating system, kernel included, running on virtual hardware.
The browser is an ordinary process. It runs on your laptop's one kernel, and asks that kernel for CPU time, memory, files and the network.
The VM is a whole computer: virtual hardware, a guest operating system with its own kernel, and its own programs, which ask the VM's own kernel.
Yes, on a KVM host the VM shows up as one process. One of CloudStack's own scripts finds VMs exactly that way (see the Evidence below).
But that one process holds a computer. One process on the outside, a whole computer on the inside: that's why a VM isn't just a process.
A container sits in between. Like a VM, it keeps its application apart from the others; like the browser, it shares the machine's one kernel.
2. What does a hypervisor do, and where does it run?¶
It does two jobs. It shares out a computer's real CPU, memory and devices among the VMs, and it keeps the VMs apart.
It runs on the computer whose hardware it shares out. A hypervisor can't share out hardware it doesn't run on, so every host has its own.
On a KVM host, the hypervisor's core is part of the host's own Linux kernel, as loadable modules: kvm, plus kvm_intel or kvm_amd for the processor. That's why lsmod | grep kvm finds it. CloudStack's own KVM code names the same modules when a machine can't run VMs (see the Evidence below).
3. "A cloud of ten hosts runs one hypervisor": true or false?¶
False. A hypervisor shares out the hardware of the machine it runs on, so every host needs its own. CloudStack's docs say "Each host has hypervisor software installed on it", and CloudStack records each host's own hypervisor, and its version, in that host's record.
The correct sentence: a cloud of ten hosts runs ten hypervisors, one on each host.
They don't even have to be of the same kind. In the docs' words, "A single cloud can contain multiple hypervisor implementations" (Concepts and Terminology).
This is the same mistake as the sentence "a group of hosts runs one hypervisor". Whatever the group, each host in it runs its own.
4. Why does the picture say virtual brand?¶
A virtual brand looks like a restaurant of its own: it has a name, a menu and recipes. But it has no kitchen of its own. Its meals are cooked at a station in a shared kitchen, next to other brands, each kept apart from the others.
A VM is the same. It looks like a computer of its own, but it runs on a share of a real host's hardware.
NIST's glossary has a second definition of a VM that says exactly this: "A virtual data processing system that appears to be at the disposal of a particular user but whose functions are accomplished by sharing the resources of a real data processing system" (NIST).
In both, "virtual" means: it behaves like something of your own, but it's made by sharing something real.
Evidence¶
The post states these facts in plain words. Here are the lines of CloudStack's code that back them, at the commit the post is written against.
Every VM has its own operating system, and runs on one host at a time¶
CloudStack's record of a VM must name the VM's guest operating system: the column can't be empty (nullable = false). The same record has a single host_id column, which is empty when the VM isn't on any host (VMInstanceVO.java, lines 104–108):
// cloudstack: engine/schema/src/main/java/com/cloud/vm/VMInstanceVO.java, lines 104–108
@Column(name = "guest_os_id", nullable = false, length = 17)
protected long guestOSId;
@Column(name = "host_id", updatable = true, nullable = true)
protected Long hostId;
Every VM in the code also answers one question, "which host are you on?", with a single host ID (RunningOn.java, lines 22–26):
// cloudstack: api/src/main/java/com/cloud/vm/RunningOn.java, lines 22–26
public interface RunningOn {
Long getHostId();
}
On KVM, a running VM is one process on its host¶
CloudStack's KVM heartbeat script has a function whose comment says "delete VMs". It looks for them in the host's process list, with ps aux, picking out the qemu processes (kvmheartbeat.sh, lines 75–78). QEMU is one of the programs that work with KVM on a CloudStack host; How Does a Hypervisor Work? explains its job.
# cloudstack: scripts/vm/hypervisor/kvm/kvmheartbeat.sh, lines 75–78
#delete VMs on this mountpoint
deleteVMs() {
local mountPoint=$1
vmPids=$(ps aux | grep qemu | grep "$mountPoint" | awk '{print $2}' 2> /dev/null)
Each VM has network cards of its own¶
In CloudStack's code, a network card record "represents one nic on the VM" (Nic.java, lines 33–35):
// cloudstack: api/src/main/java/com/cloud/vm/Nic.java, lines 33–35
* Nic represents one nic on the VM.
*/
public interface Nic extends Identity, InternalIdentity {
Each one has its own hardware (MAC) address, and belongs to one VM (Nic.java, lines 123–133):
// cloudstack: api/src/main/java/com/cloud/vm/Nic.java, lines 123–133
String getMacAddress();
/**
* @return network profile id that this
*/
long getNetworkId();
/**
* @return the vm instance id that this nic belongs to.
*/
long getInstanceId();
The web interface's VM list is titled "Instances"; the code still says virtual machine¶
The interface's Compute section lists VMs under the label label.instances, which the English labels turn into "Instances". The command it calls still uses the old words, listVirtualMachinesMetrics (compute.js, lines 40–45):
// cloudstack: ui/src/config/section/compute.js, lines 40–45
{
name: 'vm',
title: 'label.instances',
icon: 'cloud-server-outlined',
docHelp: 'adminguide/virtual_machines.html',
permission: ['listVirtualMachinesMetrics'],
The English labels turn the label's name, on the left, into the word you see, on the right (en.json, line 1391):
# cloudstack: ui/public/locales/en.json, line 1391
"label.instances": "Instances",
In the code, a VM is a VirtualMachine (VirtualMachine.java, lines 37–41):
// cloudstack: api/src/main/java/com/cloud/vm/VirtualMachine.java, lines 37–41
/**
* VirtualMachine describes the properties held by a virtual machine
*
*/
public interface VirtualMachine extends RunningOn, ControlledEntity, Partition, Displayable, StateObject<VirtualMachine.State> {
CloudStack records each host's own hypervisor¶
When a host connects, CloudStack fills in that host's record from that host's start-up report: its CPUs, memory, the kind of hypervisor it runs and that hypervisor's version (ResourceManagerImpl.java, lines 3808–3814):
// cloudstack: server/src/main/java/com/cloud/resource/ResourceManagerImpl.java, lines 3808–3814
host.setCpuSockets(ssCmd.getCpuSockets());
host.setCpus(ssCmd.getCpus());
host.setArch(hostCpuArch);
host.setTotalMemory(ssCmd.getMemory());
host.setSpeed(ssCmd.getSpeed());
host.setHypervisorType(hyType);
host.setHypervisorVersion(ssCmd.getHypervisorVersion());
Every host's record has a field for the kind of hypervisor that host runs, and it can't be empty (HostVO.java, lines 131–133):
// cloudstack: engine/schema/src/main/java/com/cloud/host/HostVO.java, lines 131–133
@Column(name = "hypervisor_type", updatable = true, nullable = false)
@Convert(converter = HypervisorTypeConverter.class)
private HypervisorType hypervisorType;
CloudStack's KVM code names the kernel modules that make up KVM¶
CloudStack's own program on a KVM host checks at start-up that libvirt can run full VMs, and if it can't, stops with a message that names the kernel modules that make up KVM's core (LibvirtComputingResource.java, lines 1419–1425):
// cloudstack: plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java, lines 1419–1425
if (HypervisorType.KVM == hypervisorType) {
/* Does node support HVM guest? If not, exit */
if (!IsHVMEnabled(conn)) {
throw new ConfigurationException("NO HVM support on this machine, please make sure: " + "1. VT/SVM is supported by your CPU, or is enabled in BIOS. "
+ "2. kvm modules are loaded (kvm, kvm_amd|kvm_intel)");
}
}
The message says "this machine": the check runs on each host, for that host.