What Is A Virtual Machine ?

happypeter
3 min readDec 30, 2018

--

Virtual machines (VMs) came into existence in the 1960s. Here in this blog, we will answer the following questions: What is a VM? Why people need VMs? What role are VMs playing in blockchain projects?

For a Chinese version of this blog: https://zhuanlan.zhihu.com/p/53692225 .

What Is A VM?

So, what on earth is a VM? When first showed up in the computer world, VM is originally defined as an duplicate of a real computer machine.

But VM actually has different kinds. The first is called System VMs(also full virtualization VMs), it provide a substitute for a real machine. We can run full unmodified guest OS, like Linux or Windows, on top of it. Real world examples are VirtualBox and VMware server, to name two most popular ones among developers. The second kind is called Process VMs, which are designed to execute computer programs in a platform-independent environment. The well-known JVM is of this kind, on top of which we can run programs written in Java.

The concept of host comes hand in hand with VM. Remember VM is still software, we need to run it on top of a real computer. The physical, “real-world” hardware running the VM is generally referred to as the ‘host’.

To conclude, A VM is an OS(in case of System VM) or application(in case of Process VM) environment that runs on a host.

Why People Need VMs ?

Now we know what a VM is, let’s talk about why people need it.

The first use case. When my hardware CPU has a A architecture, while I need to run a program only works on a CPU of B architecture, VM will come in handy.

The second use case. When I can only afford one host, but need to run several OS at the same time. Say I have Linux install on my hardware machine, now I want to run a Linux server to host my web app, and a Windows Desktop to test my web app. Then I can pick a VM software, say Virtual Box, have it installed on my Linux platform, then fire two VM instance to run the other two OS I need.

The third case. I want to write my program once and have it run on all kinds of platforms. To avoid writing and compiling my program for different platform OS, I need a layer on top of each OS to eliminate the differences. Then VM is a great tool for the job. Say people only write their Java program once, and then they can have faith to run the program on any platform with JVM installed.

VMs are widely used in real work, and we have not all the use case listed yet.

Blockchain VMs

VMs are also used in blockchains.

If you are in the blockchain filed, there is a good chance you’ve already heard of Ethereum VM (EVM). It is the runtime environment for running programs, namely smart contracts, in Ethereum blockchain. People can run their program, written in a language called Solidity, on EVM. This reminds us of JVM just mentioned, both JVM and EVM are Process VMs.

And the Nervos CKB blockchain also has its own VM, named CKB-VM. CKB-VM takes a really different approach to run smart contracts. Instead of providing support only for program written in particular high-level language, CKB-VM is a System-VM imitating a RISC-V CPU hardware. In case you don’t know about RISC-V , it is a open source CPU architecture showing a lot of potential recent years. Now we can do our smart contracts in any high-level programming language we want, then have it compiled to binary for RISC-V CPU and run the program. Isn’t this cool?

Now I hope I made how VMs works on blockchains a bit more clearer for you.

Conclusion

That is all I have to say about VM. To recap, there are two kinds of VMs, one is System VM, the other Process VM. EVM is mostly a Process VM, while CKB-VM a System VM.

Ref:

--

--