Kvm notes sandbox: различия между версиями

Материал из Toshiba AC100 wiki
Перейти к навигации Перейти к поиску
м (add host patterns)
м (add spice and bios)
Строка 4: Строка 4:


==Host setup==
==Host setup==
Remember to enable virtualization inside bios: <br/>
for hp proliats it is: <br/>
<pre>
Advanced options -> Processor Options -> Intel(R) Virtualization Technology and No-Excecute Memory Protection
</pre>
Add to host cmdline: <br/>
Add to host cmdline: <br/>
<pre>
<pre>
Строка 13: Строка 19:
# zypper in -t pattern kvm_server
# zypper in -t pattern kvm_server
# zypper in -t pattern kvm_tools
# zypper in -t pattern kvm_tools
# zypper in spice-vdagent
</pre>
</pre>



Версия от 23:24, 31 марта 2017

Good links

openSUSE Guide
RHEL Guide

Host setup

Remember to enable virtualization inside bios:
for hp proliats it is:

Advanced options -> Processor Options -> Intel(R) Virtualization Technology and No-Excecute Memory Protection

Add to host cmdline:

intel_iommu=on console=ttyS0

Install kvm patterns:

# zypper in -t pattern kvm_server
# zypper in -t pattern kvm_tools
# zypper in spice-vdagent

Forward kvm host qemu vnc with ssh

$ ssh -L 5900:localhost:5900 <kvm-host-ip> -N

Create guest

virt-install \
 --virt-type kvm \
 --name basebox_opensuse42_2 \
 --description "My basebox openSUSE 42.2" \
 --os-type=Linux \
 --os-variant=opensuse42.2 \
 --ram=2048 --vcpus=2 \
 --disk path=/home/kvm/images/basebox_opensuse42_2.img,device=disk,bus=virtio,size=20,sparse=true,format=raw,cache=none \
 --disk path=/home/kvm/openSUSE-Leap-42.2-DVD-x86_64.iso,device=cdrom \
 --graphics spice,listen=172.16.1.78 \
 --network bridge:br0

Virsh


List all guests even not started

# virsh list --all

Guest migration

Dump config

# virsh dumpxml --migratable <guest-name> >guest-name.xml

Restore guest config on new host

# virsh define guest-name.xml

Edit guest with virsh

# virsh edit guest-name

Attach block device to guest

Create xml config for example vda.xml

<disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source dev='/dev/sda5'/>
      <target dev='vda' bus='virtio'/>
</disk>

Permanently attach block device to already existing domain

# virsh attach-disk <domain-name> vda.xml --persistent

Connect to console with virsh

Add serial console to guest, virsh edit guest

 <devices>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>

connect to guest console:

# virsh console guest-name

Clonning guest

It it possible to clone with virsh dumpxml, but dont forget to change uuid, mac and vm name.


KVM basebox notes

  1. Add console=ttyS0 into bootloader cmdline for virsh console to work. (require syslinux package)
  2. Install package rsyslog (this probably will remove systemd-logger package) and start rsyslog.service