# Optimizing the kernel for VMware

## sinfidel

You can follow these configuration guidelines to optimize the kernel for vmware. Tested on both gentoo-sources and ck-sources. 

Don't forget to do this!

```
[*] 64-bit kernel (leave blank for x86)

General Setup --->

  [*] Optimize very unlikely/likely branches

Processor type and features --->

  Processor Family (usually Core2/Newer Xeon)

Bus Options --->

  < > PCCard (PCMCIA/Cardbus) support 

Networking support --->

  [ ] Amateur Radio support

  [ ] Wireless (only if you plan on using nat EXCLUSIVELY)

Device Drivers --->

  Generic Driver Options

    [*] Maintain a devtmpfs filesystem to mount at /dev

  Misc Devices --->

    [*] VMware Balloon Driver (manages memory between VM and host)

    [*] VMware VMCI Driver (Virtual Machine Communication Interface - low-latency access to host memory bus)

  SCSI device support --->

    [*] SCSI low-level drivers --->

      <*> VMware PVSCSI driver support (high throughput storage adapter)

  [*] Fusion MPT device support --->

    <*> Fusion MPT ScsiHost drivers for SPI

  [*] Network device support --->

    [*] Ethernet driver support --->

      (disable every driver but this)

      [*] AMD Devices 

        <*> AMD PCNet32 PCI support

    [ ] Wireless LAN (ONLY if you disabled Wireless networking support above)

    < > VMware VMXNET3 ethernet driver (PCNet32 is more than enough for most use cases - enable this only if you have spare cpu cycles to burn)

  Graphics support --->

    <*> Direct Rendering Manager 

    < > Intel 8xx/9xx/G3x/G4x/HD Graphics

    <*> DRM driver for VMware Virtual GPU

      [*] Enable framebuffer console support under vmwgfx by default

    <*> Support for frame buffer devices

    Console display driver support --->

      <*> Framebuffer Console support

  Sound card support ---> 

    <*> Advanced Linux Sound Architecture --->

      [*] PCI sound devices

        <*> (Creative) Ensoniq AudioPCI 1371/1373

        < > Intel HD Audio

  File systems --->

    (enable only those you anticipate using)

    <*> Second extended fs support

    <*> The Extended 4 (ext4) filesystem

    <*> XFS filesystem support

    <*> Btrfs filesystem Unstable disk format

    Pseudo filesystems --->

      [*] Tmpfs virtual memory file system support (former shm fs)

        [*] Tmpfs POSIX Access Control Lists
```

Last edited by sinfidel on Fri Jun 21, 2013 2:32 pm; edited 1 time in total

----------

## steveL

Nice post, sinfidel.

----------

## nendzd

Just curious at the

  [*] PCI sound devices 

        <*> (Creative) Ensoniq AudioPCI 1371/1373 

part.  Does VMWare emulate one of those or was that specific to your config?

----------

## sinfidel

VMware emulates AudioPCI 1371 by default. You can change this to realtek hd audio in the vmx file, but I'm not sure if there's any real benefit in doing so.

----------

## temporary_user

Is this useful only on guest machines, or on host too?

----------

## sinfidel

I forgot to mention that you'll need to edit your vmx to gain the full benefits of compiling your kernel with these drivers. 

To enable VMCI, append vmci0.present = "TRUE" to your vmx file.

temporary_user, here's some information from the VMware site

 *ʘ wrote:*   

> Without VMCI, virtual machines communicate with the host using the network layer. Using the network layer adds overhead to the communication. With VMCI communication overhead is minimal and different tasks that require that communication can be optimized.
> 
> 

 

 *Ϡ wrote:*   

> The memory balloon driver (vmmemctl) collaborates with the server to reclaim pages that are considered least valuable by the guest operating system.
> 
> The driver uses a proprietary ballooning technique that provides predictable performance that closely matches the behavior of a native system under similar memory constraints. This technique increases or decreases memory pressure on the guest operating system, causing the guest to use its own native memory management algorithms. When memory is tight, the guest operating system determines which pages to reclaim and, if necessary, swaps them to its own virtual disk.

 

 *Ѫ wrote:*   

> PVSCSI adapters are high-performance storage adapters that can result in greater throughput and lower CPU utilization. PVSCSI adapters are best suited for environments, especially SAN environments, where hardware or applications drive a very high amount of I/O throughput. PVSCSI adapters are not suited for DAS environments. 
> 
> In other words, you don't need this if you're not using networked storage.
> 
> 

 

 *Ѯ wrote:*   

> To configure an existing boot disk to use a PVSCSI adapterCreate a new temporary 1GB disk(SCSI 1:0) and assign a new SCSI controller (default is LSI LOGIC SAS).
> 
> Change the new SCSI controller to PVSCSI for the new SCSI controller.
> 
> Click Change Type.
> ...

 

----------

## shi^Yo

Hi, thanks for the post, very helpful. 

I am looking for VMWARE_BALLOON on kernel 3.10.17 and I can't find it. Is it related to the fact that I have selected hardened server profile (profile 11)? 

```
# cat . config | grep VMWARE

CONFIG_VMWARE_VMCI=y

CONFIG_VMWARE_PVSCSI=y
```

EDIT: My bad, forgot to set CONFIG_HYPERVISOR_GUEST=y

----------

## chamawill

The original post seems more geared up for ESX or Workstation.

Here's some notes for Gentoo on VMWare Fusion 6 Pro for Mac OS X 10.9 working out some of the kinks:

(Note this is a kernel 3.12 from kernel.org extracted to /usr/src and then symlinked to /usr/src/linux)

KERNEL CONFIG

```
emerge -av bc

make menuconfig

Device Drivers ---> Generic Driver Options ---> [*] Maintain a devtmpfs filesystem to mount at /dev

Device Drivers --->  Fusion MPT device support ---> <*>   Fusion MPT ScsiHost drivers for SPI

Device Drivers --->  Graphics support ---> <*> DRM driver for VMware Virtual GPU

Device Drivers --->  Graphics support --->  [*]   Enable framebuffer console under vmwgfx by default

Device Drivers --->  Sound card support ---> Advanced Linux Sound Architecture ---> PCI sound devices ---> <*>   (Creative) Ensoniq AudioPCI 1371/1373

make && make modules_install && make headers_install
```

INSTALLING TOOLS

```
mkdir /etc/rc{0..6}.d
```

RUNSCRIPT

```
nano -w /etc/init.d/vmware

#!/sbin/runscript

depend() {

   after logger

}

start () {

   ebegin "Starting VMware tools (hack)"

   /etc/init.d/vmware-tools start

   echo

   eend $?

}

stop () {

   ebegin "Stopping VMware tools (hack)"

   /etc/init.d/vmware-tools stop

   echo

   eend $?

}

chmod +x /etc/init.d/vmware

rc-update add vmware default
```

FOR POWER ON FAILURE

```
nano -w /sbin/ifup

/sbin/ifconfig $1 up

chmod +x /sbin/ifup
```

----------

## noisebleed

Great post sinfidel. Very appreciated.

Just a little note, I'm creating a new Gentoo VM on ESXi 5.1.0 and the network adapter uses the E1000 driver. So for everyone that added the PCNet32 and/or VMXNET3 modules and are still missing network interface(s) please make sure to add support for E1000. 

```
[*] Network device support ---> 

    [*] Ethernet driver support ---> 

        [*]   Intel devices

            <M>     Intel(R) PRO/100+ support

            <M>     Intel(R) PRO/1000 Gigabit Ethernet support

            <M>     Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support
```

----------

## GenProm

Hello Guys and Girls  :Smile: 

Thanks for the tipps.

Important tho:

For Kernel 3.12.x and probably onwards it is important to NOT set:

```

  Misc Devices --->

    [ ] VMware Balloon Driver (manages memory between VM and host)

    [ ] VMware VMCI Driver (Virtual Machine Communication Interface - low-latency access to host memory bus) 
```

Otherwise the app-emulation/vmware-modules-279.2 will not compile with the kernel!

----------

## Massimo B.

Do virtualized kernels need to support things like CONFIG_CPU_FREQ or CONFIG_ACPI_PROCESSOR or even CONFIG_ACPI in general? I' ve taken a native kernel config and optimizing/minimizing for a VMware Workstation VM, so there may be lot of settings left which are not required on VMs.

----------

## WWWW

 *Massimo B. wrote:*   

> Do virtualized kernels need to support things like CONFIG_CPU_FREQ or CONFIG_ACPI_PROCESSOR or even CONFIG_ACPI in general? I' ve taken a native kernel config and optimizing/minimizing for a VMware Workstation VM, so there may be lot of settings left which are not required on VMs.

 

Good question. I would like to know this as well.

A while back I tried to build a VM machine with the absolute least bloat possible, but I can't recall now everything in detail.

I think ACPI manages power schemes for physical devices at least in qemu since many devices are managed by virtio drivers I am not sure how these interact.

Still is a tricky question, some VM machines use no physical devices, some do like VGA, Ethernet, usb passthrough etc.

These are all tied to ACPI for power management.

If anyone could elaborate more on this?

thanks.

----------

## zhak

Very useful tips. Thanks.

But I've got one more question on the subject:

I'm configuring kernel 4.0.1 for vmware workstation 11 (64-bit) and not sure about whether

Processor type and features  --->

[ ] Linux guest support  --->

    [ ] Enable paravirtualization code

features should be enabled or not.

Description for 'Linux guest support' feature itself says, that it should be enabled for basic hypervisor detection and platform setup. But enabling 'Enable paravirtualization code' feature opens additional options for Type-1 hypervisors. Specifically, Xen and KVM. Nothing about VMWare WS

Do I need to enable this or not? How could either choice affect the system?

Thanks in advance!

----------

## archenroot

Hi guys, just to follow this thread.

I am now on kernel 4.11.4 and pulled in workstation from vmware overlay (the standard vmware-modules from Gentoo tree didn't work) and here is my kernel config:

https://pastebin.com/sxiNJj2f

It is Dell XPS 15 9550 laptop compatible kernel started via UEFI, not grub or lilo needed. I am running without issues following apps from app-emulation:

```
*  app-emulation/vmware-modules

      Latest version available: 308.5.6

      Latest version installed: 308.5.6

      Size of files: 0 KiB

      Homepage:      http://www.vmware.com/

      Description:   VMware kernel modules

      License:       GPL-2

*  app-emulation/vmware-tools

      Latest version available: 9.9.4.3206955

      Latest version installed: 9.9.4.3206955

      Size of files: 0 KiB

      Homepage:      http://www.vmware.com/products/player/

      Description:   VMware Tools for guest operating systems

      License:       vmware

*  app-emulation/vmware-workstation

      Latest version available: 12.5.6.5528349

      Latest version installed: 12.5.6.5528349

      Size of files: 161,854 KiB

      Homepage:      http://www.vmware.com/products/workstation/

      Description:   Emulate a complete PC without the performance overhead of most emulators

      License:       vmware GPL-2 GPL-3
```

Entries in /etc/conf.d/modules:

```
# VirtualBox and VmWare

modules="vboxdrv vboxnetadp vboxnetflt vboxpci vmnet vmci vmmon"

```

----------

## Dominus_Gentoo

LTS Kernel 4.9+

Add:

http://cateee.net/lkddb/web-lkddb/VMWARE_VMCI_VSOCKETS.html

→ Networking support → Networking Options → Virtual Socket Protocol

----------

