5

I have two VMs which are running on different virtualization platforms (VMware and KVM). Now I want both the processes to run on a single host. Can I run both VMware and KVM in a single host?

6 Answers 6

7

in short - NO. Both platforms use their own kmod to manage the VT extensions, and the module requires exclusiveness.

7

As P Marecki said, YES, you can run them in parallel. Specifically VMware workstation can start VMs in parallel with KVM machines. However, this means that only KVM will be allowed hardware support (VT). In VMware you must explicitly disable this feature and enable "binary translation". An old, but still valid, article for how to do it can be found here. (Our colleagues should be more positive, investigating for their answers than just telling off others).

Furthermore, you can do the same with VBox, which can also co-exist with KVM, if you disable VT and enable binary translation. All these are penalising severely performance, though.

If you want KVM to work this way, well, you cannot. You have to use QEMU only (without the qemu-kvm), with several tricks to make it run without VT.

3

You can install as many hypervisors (VirtualBox, KVM, VMware Player/Workstation, ...) as you like on the same machine, however if they use hardware acceleration (known as VT-x on Intel chips) then you can only run VMs on one of them at a time. Otherwise, the kernel modules they install will interfere with each other as they try to respond to the same hardware virtualization VMEXIT events.

All the hypervisors listed do use VT-x, so you have to selectively disable the ones you're not using so they don't interfere with the one you're currently running VMs inside of. Here are the commands that you can use to disable/enable each of the popular Linux hypervisors' kernel modules (tested on Ubuntu 14.04):

VMware

# to disable
sudo /etc/init.d/vmware stop
# to enable
sudo /etc/init.d/vmware start

VirtualBox

# to disable
sudo /etc/init.d/virtualbox stop
# to enable
sudo /etc/init.d/virtualbox start

KVM

# to disable
sudo rmmod kvm_intel
sudo rmmod kvm
# to enable
sudo insmod /lib/modules/`uname -r`/kernel/arch/x86/kvm/kvm.ko
sudo insmod /lib/modules/`uname -r`/kernel/arch/x86/kvm/kvm-intel.ko
1

You can run VMware workstation VMs with KVM machines in parallel, and both them can use hardware acceleration.

To confirm that, here is the trace when VMware(vmx-vcpu-*-*) and KVM(qemu-system-x86-*) run in parallel.

# tracer: function
#
# entries-in-buffer/entries-written: 0/0   #P:20
#
#           TASK-PID     CPU#     TIMESTAMP  FUNCTION
#              | |         |         |         |
      vmx-vcpu-0-30068   [008]   5998.478565: Vmx86_RunVM <-LinuxDriver_Ioctl
      vmx-vcpu-0-30068   [008]   5998.479125: Vmx86_RunVM <-LinuxDriver_Ioctl
      vmx-vcpu-8-30076   [002]   5998.479163: Vmx86_RunVM <-LinuxDriver_Ioctl
      vmx-vcpu-9-30077   [010]   5998.479232: Vmx86_RunVM <-LinuxDriver_Ioctl
 qemu-system-x86-30689   [006]   5998.480042: kvm_arch_vcpu_ioctl_run <-kvm_vcpu_ioctl
 qemu-system-x86-30689   [006]   5998.480052: kvm_arch_vcpu_ioctl_run <-kvm_vcpu_ioctl
 qemu-system-x86-30689   [006]   5998.480054: kvm_arch_vcpu_ioctl_run <-kvm_vcpu_ioctl
 qemu-system-x86-30689   [006]   5998.480057: kvm_arch_vcpu_ioctl_run <-kvm_vcpu_ioctl
3
  • Could you provide the command for that output, and versions of kernel and software if possible? I would like to recreate. Also do you have any idea when/how did this get supported as older answers all state otherwise? To be clear, my intention is not to discredit you but the contrary.
    – cbugk
    Commented Sep 4, 2023 at 13:22
  • Just trace with "perf ftrace -T Vmx86_RunVM -T kvm_vcpu_ioctl". My setup is ubuntu 23.04 and VMware 17. Commented Sep 8, 2023 at 4:15
  • I reproduced that with Ubuntu 22.04, kernel 6.2.0, and VMWare Player17. But to be honest I could not get how this proves hardware acceleration. I will need to read on ftrace. As a bonus, I learned difference between paravirtualization and hardware-assisted virtualization. Thanks.
    – cbugk
    Commented Sep 12, 2023 at 14:19
0

This may be possible with nested virtualization:

  1. Install KVM on the pysical hypervisor and configure the host as follows:
  • Create /etc/modprobe.d/kvm.conf
# choose one:
options kvm_intel nested=1
#options kvm_amd nested=1
  • Then rmmod/re-modprobe your kvm_intel/kvm_amd driver (or reboot).
  1. Install the ESXi VM:
virt-install --virt-type=kvm --name=vmware-esxi7 \
--ram 4096 --vcpus=4 \
--virt-type=kvm --hvm \
--cdrom /home/pawel/ISO/VMware/VMware-VMvisor-Installer-7.0U3d-19482537.x86_64.iso \
--network network:default,model=vmxnet3 \
--graphics vnc --video qxl \
--disk pool=default,size=32,sparse=true,bus=sata,format=qcow2 \
--boot cdrom,hd --noautoconsole --force \
--cpu host-passthrough --os-variant linux2020

[ https://openterprise.it/2022/05/running-nested-vmware-esxi-7-0-host-under-kvm-hypervisor/ ]

  1. Use ESXi like normal

  2. Use the main Linux OS for KVM (or nest it, but performance is better if you do not).

-2

Your question lacks detail and thought. The amount of useful information you get out of a site like this will usually scale with the amount of work you put in to describing your problem.

To answer the question you have asked: no. Virtual Machine hosts are exclusive, like operating systems. You can, with some VM systems, run one inside another, but that way madness lies.

The sane approach is this: pick one VM system, run both VM guests inside it. There are tools to convert KVM disk images to VMware and vice versa.

2
  • 8
    Why write an answer if you do not want to help? Question was absolutely clear: OP wants run kvm and vmware(player) concurrently on single host. I have right now kvm running Fedora and vmware player v5 running windows 7, so the answer is - qualified - yes (virtualbox seems to conflict with kvm though). If I get a little more reputation here I will downvote this answer.
    – P Marecki
    Commented Jun 3, 2015 at 8:16
  • A good answer needs to address the question, but I think good advice need not. He addressed the important part the processes to run on a single host, and I agree on but that way madness lies. To not get down voted to hell, let me add running 2 type-1s is not common, generally they are two different OSes. But if type-1 hypervisor is a general purpose OS, then running non-nested type-2 is possible (virtualbox on linux, windows, etc.). Now the catch is could one run type-1s on same OS, with different implementations (e.g. Xen and KVM)? Yes (archive.virtualmin.com/node/24113). That's my critic
    – cbugk
    Commented Sep 11, 2023 at 14:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .