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

Материал из Toshiba AC100 wiki
Перейти к навигации Перейти к поиску
м (add edit with virsh)
м (rearrange)
Строка 8: Строка 8:
</pre>
</pre>


==Create guest==
<pre>
# virt-install --name <name> --connect qemu:///system --virt-type kvm --memory 30720 --vcpus 8 --nodisks \
--os-variant opensuse42 --network bridge=br0 --boot=hd --pxe --vnc --vnclisten=localhost --vncport=5900
</pre>
==Virsh==
---
==List all guests even not started==
==List all guests even not started==
<pre>
<pre>
Строка 13: Строка 21:
</pre>
</pre>


==Guest migration==
===Guest migration===
Dump config
Dump config
<pre>
<pre>
Строка 24: Строка 32:
</pre>
</pre>


==Create guest==
===Edit guest with virsh===
<pre>
# virt-install --name <name> --connect qemu:///system --virt-type kvm --memory 30720 --vcpus 8 --nodisks \
--os-variant opensuse42 --network bridge=br0 --boot=hd --pxe --vnc --vnclisten=localhost --vncport=5900
</pre>
 
==Edit guest with virsh==
<pre>
<pre>
# virsh edit guest-name
# virsh edit guest-name
</pre>
</pre>


==Attach block device to guest==
===Attach block device to guest===
Create xml config for example vda.xml
Create xml config for example vda.xml
<pre>
<pre>

Версия от 15:11, 26 марта 2017

Good links

openSUSE Guide
RHEL Guide

Forward kvm host qemu vnc with ssh

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

Create guest

# virt-install --name <name> --connect qemu:///system --virt-type kvm --memory 30720 --vcpus 8 --nodisks \
--os-variant opensuse42 --network bridge=br0 --boot=hd --pxe --vnc --vnclisten=localhost --vncport=5900

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