hypervisors and java virtual machine - operating-system

The questions I would like to ask are:
1) What exactly does hypervisor do? Why is it needed?
2) What is the difference between hypervisor and Java Virtual mMchine?
3) Does JVM use a hypervisor?
4) When a host operating system like linux can handle multiple guest operating system,why use hypervisor?
Would be great help if someone shed light on this

A Hypervisor also known as hardware virtualization are a virtualization layer that allows running one or more native operating system on top of it, as if they run on a physical machine. It is similar to emulation but only runs operating systems that would be able to run without the Hyperviser, which are much faster.
Both are virtualization layers. However Java are optimized for performance and portability. While Java are technicaly an emulator, it are much faster than an hyperviser. This can be achieved because the emulated platform are designed for fast emulation. Java do not run x86 or x86_64/amd64 code, it runs something called Bytecode. The technical term for Bytecode are Intermediate Language (IL). It are compiled to code that are native to your processor when you run it, by the Just In Time compiler (JIT). As the JIT do a compilation process it can make sure that the program follows Java:s security constraints, by simply not generating code that violates such constraints. The Hyperviser enforce security constraints by intercepting so called privileged instructions and by emulating devices such as disk drives. This are done because native x86 or x86_64/amd64 code are very hard for a program to understand, and changing it so that it self-enforce security constraints are next to impossible. Java on the other hand runs Bytecode which are easy for a program to understand and chance so that it self-enforce security rules.
The short answer: An hyperviser are slower than Java but allows you to run a multitude of complete operating systems, and all the software available for them. This while Java are faster, but you can only run Java software on it. If you want to run Windows and Office in your virtual machine, you can't do that in Java.
I think I answered this above but no, it use code inspection and modifies the program so that it self-enforce security rules. This can be done because runnable Java application are in a intermediate state called Bytecode, which are easy for Java to understand, inspect, find code that may violate the rules and modify it in order to obey them. This are a rather complex process that have several advantage over hypervisor. The first advantage are "compile once run everywhere", as Java are compiled and distributed as bytecode. The second advantage are speed, JIT:ed code have the same speed as non-virtualized code even when strict security are enforced. The disadvantage are that only Bytecode programs can run, so you for example cannot run Windows or Linux inside the virtual machine.
If you are running another operating system like Windows or another Linux distribution - you are running an Hyperviser. KVM, Xen and VirtualBox are examples of Hypervisors. You can also run multiple instances of Linux with one shared kernel, known as OS-based virtualization or "Container". But a Container share the kernel and therefor you can only virtual machines with the OS you are running. The advantage with Containers it are more lightweight as you do not need to run multiple kernels on top of each other...

Hypervisor or virtual machine manager, is a program that allows multiple operating systems to share a single hardware host.
JVM or Java Virtual Machine interprets bytecode for a computers processor so that it can perform Java program instructions.
No JVM does not use hypervisor as it is not an virtual machine that runs an OS rather it is just a interpreter.
A host operating system manages different VMs using Hypervisor or virtual machine manager

Before answering your questions, I would recommend you search related entries in wikipedia. A hypervisor is used to run multiple guest OSes while JVM is used to interpret java byte code. JVM runs on top of OS and it doesn't care whether the OS runs on top of bare metal or on a hypervisor. Actually, linux can handle multiple guest operating systems with KVM which is part of the linux kernel. So the description of the last question is totally wrong.

Related

What is meant by a "lightweight vm" as discussed in the technology stack for WSL2?

My understanding is that Docker on Windows currently uses a "regular VM" under the hood. WSL2 (and Docker) will switch to using a lightweight VM. But what does this actually mean; is it just using a smaller initial memory foot print with some memory passthrough technnique, or is there more to it?
TL;DR
The big change is in the move from a virtualized Linux system call interpreter for the Windows kernel in WSL to a full-on Linux kernel provided in WSL2. This move dramatically cuts down on virtualization overhead.
Juicy Details
Directly from the DevBlogs Post on the announcement of WSL2:
Microsoft will be shipping a Linux kernel with Windows ... This kernel has been specially tuned for WSL 2. It has been optimized for size and performance to give an amazing Linux experience on Windows.
This is a departure from the ways of the current (as of writing) WSL which doesn't make use of a proper Linux kernel, demonstrated in the original WSL overview from 2016.
WSL executes unmodified Linux ELF64 binaries by virtualizing a Linux kernel interface on top of the Windows NT kernel.
The WSL LXCore service runs an interpreter of sorts for native Linux system calls as well as running its own VolFs and DriveFs operations to provide file access between WSL and Windows 10, which essentially performs the role of a traditional VM's translation layer the likes of VirtualBox.
Citation: MSDN Blog
Little is known as of yet about the exact system employed for WSL2, what we do know is from the Build2019 WSL2 talk. To help answer the question regarding file system changes and the light VM:
Here, we see that the Linux kernel runs alongside the NT Kernel instead of as a virtualized environment on top of it. (as a Windows service). The lightweight VM likely comes into play for facilitating the necessary interactions between the two kernels.
This gives a peek into the inner workings of that interoperability layer. Discussed verbally in the Build2019 talk, the two kernels serve each other files via natively hosted file servers (inaccessible to the Windows userspace via means other than WSL2).
Again, much is still up in the air from our perspective as users due to the limited details currently available to us at the time of writing.

Why Xen requires an OS though it is a Type I Hypervisor?

Xen is a Type I hypervisor that means it can run directly on hardware so why do we need to install Ubuntu or CentOS or any OS to run Xen? It should run directly on the hardware as it's a Type I hypervisor.
The reason that an OS is needed is because Xen itself does not directly provide any mechanism for creating/managing virtual machines. Because these tasks require things like creating disk images, editing configuration files, setting up networking etc. It would be wasteful for the Xen project to reimplement all of this functionality when it is already included in widely-used OSes like Linux.
The only way to interact with Xen is by making hypercalls, some of which can only be made from the dom0 (Domain 0) VM. As noted in the Xen wiki this means that the hypervisor can be left to just the tasks which only it can perform - checking page tables, allocating resources for new domains, and scheduling domains.
I'm not aware of any type 1 hypervisor which does not need an OS in one way or another - many of them use Xen under the hood, with a custom OS. Things like VMWare ESXi (which does not use Xen) bundle their own OS as part of the distribution so still have an OS running on top of the hypervisor to provide needed functionality.

Are emulation and hardware-assisted virtualization synonyms?

What is the distinction between emulation and Full Virtualization, also called Hardware-assisted virtualizion (HVM)?
From this source, it is not clear what the relationship is.
Full Virtualization or Hardware-assisted virtualizion (HVM) uses
virtualization extensions from the host CPU to virtualize guests. HVM
requires Intel VT or AMD-V hardware extensions. The Xen Project
software uses Qemu to emulate PC hardware, including BIOS, IDE disk
controller, VGA graphic adapter, USB controller, network adapter etc.
Virtualization hardware extensions are used to boost performance of
the emulation. Fully virtualized guests do not require any kernel
support. This means that Windows operating systems can be used as a
Xen Project HVM guest. Fully virtualized guests are usually slower
than paravirtualized guests, because of the required emulation.
Source: Xen Project Wiki
In the following book these terms are considered synonymous.
At one extreme you have full virtualization, or emulation, in which
the virtual machine is a software simulation of hardware, real or
fictional — as long as there’s a driver, it doesn’t matter much.
Products in this category include VMware and QEMU.
Source: The book of Xen
Following are the excerpts from an article describing the actual difference between emulation and HWM. However, the only distinction I can see is, that virtualization enables to create more than one computing environment.
If emulation takes such a toll, why bother? Because we might want to
do one of the following:
Run an OS on a hardware platform for which it was not designed.
Run an application on a device other than the one it was developed for (e.g., run a Windows program on a Mac).
Read data that was written onto storage media by a device we no longer have or that no longer works.
Source: Russell Kay
Virtual machines offer the following advantages:
They're compatible with all Intel x86 computers.
They're isolated from one another, just as if they were physically separate.
Each is a complete, encapsulated computing environment.
They're essentially independent of the underlying hardware.
They're created using existing hardware.
Source: Russell Kay
There is another article, which only supports my hypothesis.
Emulation, in short, involves making one system imitate another. For
example, if a piece of software runs on system A and not on system B,
we make system B “emulate” the working of system A. The software then
runs on an emulation of system A.
In this same example, virtualization would involve taking system A and
splitting it into two servers, B and C.
So lets consider B=C and we have emulation, dont we?
Please note that virtualization is achieved by emulating the hardware components network adapters, USB, hard disk, CD drives etc in software. Thus emulation actually helps achieving virtualization.
Full virtualization is the technique of virtualization in which the guest OS runs unmodified, that is, the guest is not aware of whether it is running in a virtual machine environment or on a physical machine. Initially binary translation of the guest code was done in order to achieve full virtualization, but it wasn't good from performance perspective.
Para virtualization is a technique which requires modifications in the guest Operating System in order to gain better performance.
Hardware assisted virtualization is full virtualization technique as the guest Operating System runs unmodified. It is called hardware assisted because this type of virtualization utilizes virutalization specific extensions in host hardware like Intel-vtx, AMD-V etc. This technique not only offers full virtualization (guest OS does not require modification) but also has performance benefits and major vendors like Intel and AMD are providing extensions in hardware to support virtualization.

What is the difference between Full, Para and Hardware assisted virtualization?

I am going through the topic of virtualization and i am totally sucked up understanding the basic concept, Wikipedia does provide some relevant information, but it is not good enough for me to understand the basic idea. The concept will be of 2 to 3 line, but neither I am able to find them on net, nor on the book.
I will be pleased if someone gives me a basic understanding of these three types. I am well aware of virtualization and understand it well, but these 3 types...
Paravirtualization is virtualization in which the guest operating system (the one being virtualized) is aware that it is a guest and accordingly has drivers that, instead of issuing hardware commands, simply issue commands directly to the host operating system. This also includes memory and thread management as well, which usually require unavailable privileged instructions in the processor.
Full Virtualization is virtualization in which the guest operating system is unaware that it is in a virtualized environment, and therefore hardware is virtualized by the host operating system so that the guest can issue commands to what it thinks is actual hardware, but really are just simulated hardware devices created by the host.
Hardware Assisted Virtualization is a type of Full Virtualization where the microprocessor architecture has special instructions to aid the virtualization of hardware. These instructions might allow a virtual context to be setup so that the guest can execute privileged instructions directly on the processor without affecting the host. Such a feature set is often called a Hypervisor. If said instructions do not exist, Full Virtualization is still possible, however it must be done via software techniques such as Dynamic Recompilation where the host recompiles on the fly privileged instructions in the guest to be able to run in a non-privileged way on the host.
There is also a combination of Para Virtualization and Full Virtualization called Hybrid Virtualization where parts of the guest operating system use paravirtualization for certain hardware drivers, and the host uses full virtualization for other features. This often produces superior performance on the guest without the need for the guest to be completely paravirtualized. An example of this: The guest uses full virtualization for privileged instructions in the kernel but paravirtualization for IO requests using a special driver in the guest. This way the guest operating system does not need to be fully paravirtualized, since this is sometimes not available, but can still enjoy some paravirtualized features by implementing special drivers for the guest.
In the case of hardware assisted virtualisation, the virtualisation is designed in. Instruction set provides instructions for partitioning the host. See VT-x technology of Intel as an example. So that the hypervisor works directly with hardware without using any operating system to acces it and provide full virtualisation

Newbie Hypervisor Questions

If I install a bare-metal hypervisor (say, ESXi), would it allow me to run Windows 7 concurrently with Linux?
Would it allow me to run multiple instances of Windows 7?
When I'm sitting at the PC that's running Win7 and Linux on a hypervisor, which OS do I see when I look at the screen? (I'm suspecting that the only way to access either OS is to do a remote login.)
Assuming the answer to #2 is yes, how do you manage multiple installs of Win7 on the same hard drive?
Thanks in advance!
If you simply want to run Linux and Windows in parallel you may of course do this on e.g. ESXi. Still, the OSes would run with virtualized (or emulated) hardware available to them, i.e. you would not be able to easily access all the hardware directly and the hypervisor itself not only introduces an overhead but this overhead is not deterministic.
If you want to run an RTOS (like Real-Time Linux) or any other RTOS, then you need a "real-time hypervisor".
You can google for such hypervisors - there are a few out there.
(I dont want to recommend one here as we are a vendor of such a solution our selves)
Regards
GFL