Virsh: Difference between revisions

From DWIKI
 
(8 intermediate revisions by the same user not shown)
Line 3: Line 3:
*http://virt-tools.org/learning/
*http://virt-tools.org/learning/
*[https://computingforgeeks.com/virsh-commands-cheatsheet/ virsh commands cheatsheet]
*[https://computingforgeeks.com/virsh-commands-cheatsheet/ virsh commands cheatsheet]
*[https://www.centos.org/docs/5/html/5.2/Virtualization/chap-Virtualization-Managing_guests_with_virsh.html Managing guests with virsh]


=FAQ=
==Find IP address of a guest==
https://rwmj.wordpress.com/2010/10/26/tip-find-the-ip-address-of-a-virtual-machine/




==Remove VM==
= HOWTO=
 
== Find IP address of a guest ==
 
[https://rwmj.wordpress.com/2010/10/26/tip-find-the-ip-address-of-a-virtual-machine/ https://rwmj.wordpress.com/2010/10/26/tip-find-the-ip-address-of-a-virtual-machine/]
 
 
 
== Communicate with guest agent ==
virsh qemu-agent-command
*[https://www.0xf8.org/2022/01/executing-arbitrary-commands-in-your-libvirt-qemu-virtual-machine-through-qemu-guest-agent/ Executing arbitrary commands in your libvirt/Qemu virtual machine through Qemu guest agent]
 
*[https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-using_the_qemu_guest_virtual_machine_agent_protocol_cli-libvirt_commands Using the QEMU Guest Agent with libvirt]
== Remove VM ==
 
  virsh list
  virsh list
  virsh destroy vmname
  virsh destroy vmname
Line 16: Line 26:
  virsh vol-delete /path/to/image
  virsh vol-delete /path/to/image


==Virsh console==
== Virsh console ==
     
=FAQ=
 
== error: Requested operation is not valid: cannot undefine domain with nvram ==
virsh undefine --nvram yourvm
 
=Cheatsheet=
==List virtual machines==
virsh list


===show resources===
==Start virtual machine==
virsh start <vmname>
 
==show resources==
  virsh dominfo <vmname>
  virsh dominfo <vmname>


==show volumes==
virsh vol-list default
==show disk sizes==
virsh pool-list --all --details


==enable virsh console==
systemctl enable serial-getty@ttyS0.service
systemctl start serial-getty@ttyS0.service


===Centos 6, 7===
===Centos 6, 7===

Latest revision as of 10:56, 7 March 2023

Docs


HOWTO

Find IP address of a guest

https://rwmj.wordpress.com/2010/10/26/tip-find-the-ip-address-of-a-virtual-machine/

 

Communicate with guest agent

virsh qemu-agent-command 

Remove VM

virsh list
virsh destroy vmname
virsh undefine vmname
virsh vol-delete /path/to/image

Virsh console

FAQ

error: Requested operation is not valid: cannot undefine domain with nvram

virsh undefine --nvram yourvm

Cheatsheet

List virtual machines

virsh list

Start virtual machine

virsh start <vmname>

show resources

virsh dominfo <vmname>

show volumes

virsh vol-list default

show disk sizes

virsh pool-list --all --details

enable virsh console

systemctl enable serial-getty@ttyS0.service
systemctl start serial-getty@ttyS0.service

Centos 6, 7

To get to see bootloader:

grubby --update-kernel=ALL --args="console=ttyS0"

ON Centos 6 you need to create /etc/init/ttyS0.conf:

stop on runlevel[S016]
start on stopped rc RUNLEVEL=[2345]
respawn
instance /dev/ttyS0
exec /sbin/mingetty /dev/ttyS0

Add "ttyS0" to /etc/securetty And then run:

initctl start ttyS0