QEMU/KVM Virtual machine Management: Difference between revisions
m Стадий: 4 [Фаза:Авторизиране, Статус:Разработен]; Категория:Virtual Machines |
m Стадий: 5 [Фаза:Утвърждаване, Статус:Авторизиран]; Категория:Virtual Machines |
||
Line 89: | Line 89: | ||
{{devStage | {{devStage | ||
| Прндл = Virtual Machines | | Прндл = Virtual Machines | ||
| Стадий = | | Стадий = 5 | ||
| Фаза = | | Фаза = Утвърждаване | ||
| Статус = | | Статус = Авторизиран | ||
| ИдтПт = Spas | | ИдтПт = Spas | ||
| РзбПт = Spas | | РзбПт = Spas | ||
| АвтПт = {{REVISIONUSER}} | | АвтПт = Spas | ||
| УтвПт = {{REVISIONUSER}} | |||
| ИдтДт = 2.09.2022 | | ИдтДт = 2.09.2022 | ||
| РзбДт = 2.09.2022 | | РзбДт = 2.09.2022 | ||
| АвтДт = {{Today}} | | АвтДт = 2.09.2022 | ||
| УтвДт = {{Today}} | |||
| ИдтРв = [[Special:Permalink/31026|31026]] | | ИдтРв = [[Special:Permalink/31026|31026]] | ||
| РзбРв = [[Special:Permalink/31032|31032]] | | РзбРв = [[Special:Permalink/31032|31032]] | ||
| АвтРв = {{REVISIONID}} | | АвтРв = [[Special:Permalink/31033|31033]] | ||
| УтвРв = {{REVISIONID}} | |||
}} | }} | ||
</div> | </div> | ||
</noinclude> | </noinclude> |
Revision as of 15:06, 2 September 2022
Virsh: Command-line Management User Interface
The virsh program is the main interface for managing virsh guest domains. The program can be used to create, pause, and shutdown domains… Libvirt (which provides virsh program) is a C toolkit to interact with the virtualization capabilities of recent versions of Linux (and other OSes)… It currently supports Xen, QEMU, KVM, LXC, OpenVZ, VirtualBox and VMware ESX.
Basic operations
View the list of all available virtual machines:
virsh list --all
Start, reboot, suspend, rename, shutdown a VM:
virsh (start|reboot|suspend|rename|shutdown) {vm-name|vm-Id}
Dump a VM XML configuration file:
virsh dumpxml {vm-name} > {vm-name}.xml
Creating or defining a VM based on XML dump configuration file. Before this step modifi {vm-name}.xml and update the values of <name>, <uuid>, <title>, <description>:
virsh create {vm-name}.xml
virsh define {vm-name}.xml
virsh start {vm-name}
Completely remove a VM:
sudo virsh undefine {vm-name|vm-Id}
sudo virsh destroy {vm-name|vm-Id}
View the list of the associated virtual networks:
virsh net-list --all
Disable an network and disable autostart:
virsh net-destroy {net-name}
virsh net-autostart --network {net-name} --disable
Enable an network and disable autostart:
virsh net-start {net-name}
virsh net-autostart --network {net-name} --enable
Configuring Virtual machine automatic start
1. First get info about the target instance.
virsh list --all # list all available Virtual Machines
virsh dominfo {vm.name.org} # check whether given virtual machine is configured to autostart
ls /etc/libvirt/qemu/autostart/ # list all virtual machines already configured to autostart
2. Enable Virtual Machine automatic start.
virsh autostart {vm.name.org}
- If
virsh
command is not available/installed, to configure austostart simply create a new symbolic link within/etc/libvirt/qemu/autostart/
directory usingln
command. - Reload hyper-visor if necessary:
systemctl reload libvirtd
3. Disable Virtual Machine autostart.
virsh autostart --disable {vm.name.org}
- Or simply use
unlink
command to remove virtual machine’s symbolic link from/etc/libvirt/qemu/autostart/
directory:unlink /etc/libvirt/qemu/autostart/{vm.name.org}.xml
References
- Ubuntu Manuals:
virsh
– management user interface - OpenStack: Disable libvirt networking
- Fedora Documentation: Creating a virtual machine XML dump (configuration file)
- LinuxConfig.org: Configuring Virtual machine automatic start on Redhat Linux host
Virt-manager: GUI Management (local and via ssh)
For remote GUI management you can use the tool virt-manager
on the remote machine. If there is a set SSH connection (via ~/.ssh/config
) you can use this option where you won't have to worry about extra open ports in your firewall. If you are a Windows' user and WSL2 is enabled, you can use virt-manager
at least three ways:
- Setup xRDP in WSL2, watch WSL2 Ubuntu GUI by David Bombal for more details.
- Use GWSL available in Microsoft Store – this is really convenient way.
- Use WSLg, that will be available in Windows 11.