In the previous article http://blog.csdn.net/dobell/article/details/9003421, given the way Xen console connects Hvm, under KVM, how to use the Libvirt library Virsh Console connection HVM. It's also very simple.
In fact, it is not difficult to achieve. First, we need to insert the following tags in the Virsh-initiated virtual machine XML file kvm201.xml
<span style= "FONT-SIZE:14PX;" ><devices>
<serial type= ' pty ' tty= '/DEV/PTS/4 ' >
<target port= ' 0 '/>
</ serial>
<console type= ' pty ' >
<target type= ' serial ' port= ' 0 '/>
</console>
</devices></span>
Note that the serial and console tags must be added to the devcies tag, otherwise the Libvirt library does not recognize the console device to add .
Then we start the virtual machine, Virsh create Kvm201.xml, add the console to the /boot/grub/grub.cfg file of the virtual machine kvm201, as shown in the following figure
If it is a GRUB2 system, please modify the/etc/default/grub file,
grub_cmdline_linux= "Console=tty0 console=ttys0", then Update-grub
If you want to see and control grub when you enter the serial port, add the following paragraph
Grub_terminal=serial
grub_serial_command= "SERIAL--unit=0--speed=115200--word=8--parity=no--stop=1"
This paragraph indicates that grub itself supports serial output
Just so you can not log in with the console, only see the boot information, so we also add ttyS0 ssh boot. Add the following information to the/etc/init/ttys0.conf in the virtual machine
Then restart the virtual machine, Reboot,virsh console kmv201, found that you can connect the
* Starting ACPI daemon [OK]
* Starting regular background program processing daemon [OK]
* Starting deferred execution scheduler [OK]
* Starting CPU interrupts balancing daemon [OK]
* Starting crash report submission daemon [OK]
Apache2:could not reliably determine the server ' s fully qualified domain name, using 192.168.188.201 for ServerName
[OK]
* Starting Tomcat servlet engine TOMCAT7 [OK]
* Checking Battery State ... [OK]
Ubuntu 12.04.1 LTS kvm201 ttyS0
kvm201 Login:root