User Tools

Site Tools


unix:kvm

Linux virtualization with kvm and libvirt

All the info below are somewhat Debian 6 centric (for both host and guest).

Guests

Enable serial console

To enable access to the guest via the serial emulation console:

For the getty console add in /etc/inittab:

T0:123:respawn:/sbin/getty -L ttyS0 9600 vt100

… and reload with telinit q

For the grub console append to /etc/default/grub:

### "Serial" console for libvirt
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1"
GRUB_TERMINAL="console serial"
GRUB_TIMEOUT=5
GRUB_CMDLINE_XEN="com1=9600,8n1 console=com1,vga"
GRUB_CMDLINE_LINUX="console=tty0 console=hvc0"

…and rebuild grub config with update-grub

Host

Assign a static IP to a guest

Leave the guest configured to use DHCP (for better portability) and map in libvirt DHCP the guest MAC address to a static ip adding some <host> entries in the dhcp configuration.

To change the configuration (we are editing the default network in the sample below):

  • Stop network: virsh net-destroy default
  • Edit the network: virsh net-edit default
<network>
  <name>default</name>
  <uuid>ffee01a4-7dc4-739a-fd10-f0ab726e9c41</uuid>
  <forward mode='nat'/>
  <bridge name='virbr0' stp='on' delay='0' />
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254' />
      <host mac='52:54:DE:AD:BE:EF' ip='192.168.122.101' />
      <host mac='52:54:CA:FE:BA:BE' ip='192.168.122.102' />
    </dhcp>
  </ip>
</network>
  • Restart the virtual network: virsh net-start default

Management

You can use the graphical Virtual Machine Manager at http://virt-manager.org/

unix/kvm.txt · Last modified: 2016/11/28 10:51 by ap

Informativa sui cookie