Kvm notes sandbox: различия между версиями
Перейти к навигации
Перейти к поиску
Zombah (обсуждение | вклад) м (fix indentation) |
Zombah (обсуждение | вклад) м (add virsh console) |
||
Строка 50: | Строка 50: | ||
<pre> | <pre> | ||
# virsh attach-disk <domain-name> vda.xml --persistent | # virsh attach-disk <domain-name> vda.xml --persistent | ||
</pre> | |||
===Connect to console with virsh=== | |||
Add serial console to guest, virsh edit guest | |||
<pre> | |||
<devices> | |||
<serial type='pty'> | |||
<target port='0'/> | |||
</serial> | |||
<console type='pty'> | |||
<target type='serial' port='0'/> | |||
</console> | |||
</pre> | |||
connect to guest console: <br/> | |||
<pre> | |||
# virsh console guest-name | |||
</pre> | </pre> |
Версия от 14:36, 27 марта 2017
Good links
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
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