# kvm without module?

## siaton

I tried to use kvm/qemu but qemu complains about missing kvm support. In fact there is no /dev/kvm although my processor supports hw virtualisation:

 *Quote:*   

> Architecture:          x86_64
> 
> CPU op-mode(s):        32-bit, 64-bit
> 
> Byte Order:            Little Endian
> ...

 

I have disabled module loading in my hardened 3.10 kernel but activated KVM support:

 *Quote:*   

> CONFIG_KVM_GUEST=y
> 
> CONFIG_HAVE_KVM=y

 

Just wondering if KVM is only available through loading the appropriate kernel module - in my case probably kvm_amd.

----------

## NeddySeagoon

siaton,

You need to get KVM support on the host (bare hardware) before you can start a Virtual Machine.

```
/usr/src/linux $ grep KVM .config

CONFIG_KVM_APIC_ARCHITECTURE=y

CONFIG_KVM_MMIO=y

CONFIG_KVM_ASYNC_PF=y

CONFIG_KVM=y

CONFIG_KVM_AMD=y

CONFIG_KVM_DEVICE_ASSIGNMENT=y
```

To get the best out of KVM, you need the VIRTIO drivers.  This avoids the use of emulated hardware.

```
usr/src/linux $ grep VIRT .config

CONFIG_VIRT_CPU_ACCOUNTING=y

CONFIG_VIRT_CPU_ACCOUNTING_GEN=y

CONFIG_VIRT_TO_BUS=y

CONFIG_VIRTIO_BLK=m

# CONFIG_VIRTIO_NET is not set

# CONFIG_VIRTIO_CONSOLE is not set

# CONFIG_HW_RANDOM_VIRTIO is not set

# CONFIG_FB_VIRTUAL is not set

# CONFIG_SND_VIRTUOSO is not set

CONFIG_VIRT_DRIVERS=y

CONFIG_VIRTIO=m

CONFIG_VIRTIO_PCI=m

CONFIG_VIRTIO_BALLOON=m

CONFIG_VIRTIO_MMIO=m

# CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES is not set

# CONFIG_DEBUG_VIRTUAL is not set

CONFIG_VIRTUALIZATION=y
```

I have  4 or 5 kvms running an a HP Microserver.  I can post the .config files for the bare hardware and a KVM if you like.

Its all gentoo-hardened

----------

## siaton

Please let me know your host/guest config files. 

I didn't saw the KVM options you mentioned in my kernel config (3.10). I guess something went wrong when I used "make oldconfig".

Thanks for the hint.

----------

## NeddySeagoon

siaton,

This is the bare metal config.  

I seem to be having VM problems. They all work but none of them want to run wgetpaste

----------

## guoyingshou

I'm using gentoo-sources-3.10.25, my CHOST is CHOST="x86_64-pc-linux-gnu".

After make menuconfig, under [*] Virtualization  --->  , there is only one item configurable: <M>   Host kernel accelerator for virtio net.

In the document http://wiki.gentoo.org/wiki/QEMU, there seems to have more configurable items: 

<*>     KVM for Intel processors support

<*>     KVM for AMD processors support

...

However, my menuconfig misses the said items.

Can anyone help me figure out what's wrong with my kernel?

----------

## NeddySeagoon

guoyingshou,

I'm all AMD and I have

```
  │ ┌────────────────────────────────────────────────────────────────────────┐ │  

  │ │    --- Virtualization                                                  │ │  

  │ │    <*>   Kernel-based Virtual Machine (KVM) support                    │ │  

  │ │    <*>     KVM for AMD processors support                              │ │  

  │ │    [*]     KVM legacy PCI device assignment support                    │ │  

  │ │    <M>   Host kernel accelerator for virtio net 
```

The help says

```
  ┌────────────────────── KVM for AMD processors support ──────────────────────┐

  │ CONFIG_KVM_AMD:                                                            │  

  │                                                                            │  

  │ Provides support for KVM on AMD processors equipped with the AMD-V         │  

  │ (SVM) extensions.                                                          │  

  │                                                                            │  

  │ To compile this as a module, choose M here: the module                     │  

  │ will be called kvm-amd.                                                    │  

  │                                                                            │  

  │ Symbol: KVM_AMD [=y]                                                       │  

  │ Type  : tristate                                                           │  

  │ Prompt: KVM for AMD processors support                                     │  

  │   Location:                                                                │  

  │     -> Virtualization (VIRTUALIZATION [=y])                                │  

  │       -> Kernel-based Virtual Machine (KVM) support (KVM [=y])             │  

  │   Defined at arch/x86/kvm/Kconfig:67                                       │  

  │   Depends on: VIRTUALIZATION [=y] && KVM [=y] 
```

Unless the  Depends on: evaluates to true, tho option will be hidden.

If I cheat a little and use maxe xconfig, so I can see hidden options, I can get  

```
KVM for Intel processors support (KVM_INTEL)

CONFIG_KVM_INTEL:

Provides support for KVM on Intel processors equipped with the VT

extensions.

To compile this as a module, choose M here: the module

will be called kvm-intel.

Symbol: KVM_INTEL [=n]

Type : tristate

Prompt: KVM for Intel processors support

Location:

-> Virtualization (VIRTUALIZATION [=y])

-> Kernel-based Virtual Machine (KVM) support (KVM [=y])

Defined at arch/x86/kvm/Kconfig:55

Depends on: VIRTUALIZATION [=y] && KVM [=y] && CPU_SUP_INTEL [=n]
```

Notice that CPU_SUP_INTEL [=n], so the KVM for Intel processors support menu item does not appear for me.

It looks as if you have KVM off.  Its help says 

```
Kernel-based Virtual Machine (KVM) support (KVM)

CONFIG_KVM:

Support hosting fully virtualized guest machines using hardware

virtualization extensions. You will need a fairly recent

processor equipped with virtualization extensions. You will also

need to select one or more of the processor modules below.

This module provides access to the hardware capabilities through

a character device node named /dev/kvm.

To compile this as a module, choose M here: the module

will be called kvm.

If unsure, say N.

Symbol: KVM [=y]

Type : tristate

Prompt: Kernel-based Virtual Machine (KVM) support

Location:

-> Virtualization (VIRTUALIZATION [=y])

Defined at arch/x86/kvm/Kconfig:20

Depends on: VIRTUALIZATION [=y] && HAVE_KVM [=y] && HIGH_RES_TIMERS [=y] && NET [=y]

Selects: PREEMPT_NOTIFIERS [=y] && MMU_NOTIFIER [=y] && ANON_INODES [=y] && HAVE_KVM_IRQCHIP [=y] && HAVE_KVM_IRQ_ROUTING [=y] && HAVE_KVM_EVENTFD [=y] && KVM_APIC_ARCHITECTURE [=y] && KVM_ASYNC_PF [=y] && USER_RETURN_NOTIFIER [=y] && KVM_MMIO [=y] && TASKSTATS [=y] && TASK_DELAY_ACCT [=y] && PERF_EVENTS [=y] && HAVE_KVM_MSI [=y] && HAVE_KVM_CPU_RELAX_INTERCEPT [=y]

```

Likewise, if its depens on is false, it will be hidden,  so check Depends on: VIRTUALIZATION [=y] && HAVE_KVM [=y] && HIGH_RES_TIMERS [=y] && NET [=y].  My guess is that you are missing HIGH_RES_TIMERS.

----------

## guoyingshou

NeddySeagoon,

Thanks for your help. My case is exactly as you point out that I missed HIGH_RES_TIMERS. As soon as I enabled it, the missing kvm_intel appears.

Best,

guoyingshou

----------

