By virsh console to enter the virtual machine

1, virsh start a virtual machine.
Execute scripts test_qga.sh

2、virsh vncdisplay <vm_ID>

3, vnc log on to the inside vm, execute
#systemctl Start [email protected]
#systemctl enable [email protected]

4, the host returns, enter cd / etc / libvirt / qemu directory, the backup <vm_name> .xml is <vm_name> .xml.bak

5、
virsh destroy <vm_name>

6、
virsh undefine <vm_name>

7, enter cd / etc / libvirt / qemu catalog,
edit <vm_name> .xml.bak, between <devices> </ devices> Add

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

mv <vm_name>.xml.bak为<vm_name>.xml

8, in the / etc / libvirt / qemu catalog implementation
virsh define <vm_name> .xml

9、

virsh start <vm_name>

10、

virsh console <vm_name>

 

virsh create / close / stop virtual machines commonly used in a few instructions

Definitions: virsh definexxx.xml xxx is the path and file name of the xml file is located, is not written in the current directory path

Start: virsh start xyz xyz is the name of the virtual machine xml configuration file of the virtual machine <name> rhel6.2_2 </ name>

Stop: virsh shutdownxyz this method for a normal shutdown process takes a while to shut down

Under power: virsh destroy xyz this method for electricity under violence, immediately shut down the virtual machine

Delete: virsh undefinexxx shut down the virtual machine, but it is not running, you can (virsh list to view the list of virtual machines in the current system, see Section 2.4) from virsh list inside by virsh undefine xxx to remove it, undefine command It does not delete the image file and xml file. Virtual machine operating status can not be deleted.

Provisional starting a virtual machine: virsh create xxx.xml this method to facilitate the temporary needs of development and debugging, not persistent, virtual machine disappeared after authorities do not recommend the use of production systems.

View VNC port: virshvncdisplay xx View VNC port, where xx can be viewed by virsh list

Guess you like

Origin www.cnblogs.com/lizhewei/p/11887809.html