France-Grilles | Université Toulouse 3
This is an [Advanced Topic] intended to people with a good understanding about VMs.
In the following, we'll show you how to gain access to a running VM through its tty line (i.e serial link —COM1). This is especially usefull in the hunt for bogus network setup which prevent you from accessing your VM through a SSH or telnet session.
[for those that can't wait] –> VM serial console access
First of all, one point to note is that all VM images provided by the oneadmin group come with serial link support enabled.
This means that we added the kernel parameter console=ttyS0
during VM install and it is now inherited.
Next and most important point for end-users is the resources declaration file (i.e ONE template file).
In the template file below, we have added a RAW XML section defining the serial port resource:
NAME = SL65 CPU="1" MEMORY="2048" VCPU="1" DISK=[ BUS="virtio", DRIVER="qcow2", IMAGE="SL65", IMAGE_UNAME = "admin" ] NIC=[ MODEL="virtio", NETWORK="production", NETWORK_UNAME="admin" ] OS=[ ARCH="x86_64", BOOT="hd", MACHINE="rhel6.5.0" ] # Contextualization CONTEXT=[ SSH_PUBLIC_KEY="$USER[SSH_PUBLIC_KEY]" ] # Console (don't forget to pass the option 'console=ttyS0' to the kernel args) RAW = [ type = "kvm", data = "<devices> <serial type='pty'> <source path='/dev/pts/1'/> <target port='0'/> <alias name='serial0'/> </serial> <console type='pty' tty='/dev/pts/1'> <source path='/dev/pts/1'/> <target type='serial' port='0'/> <alias name='serial0'/> </console> </devices>" ]
The XML declared RAW section is added as-is to the generated XML file sent to qemu on the various nodes intended to host a VM.
Without this serial port definition, it won't be possible to access a VM without a NIC.
Becarful: OpenNebula / Sunstone bogus cloning function strips off the serial console definition within the XML RAW section. This means that when you clone a template, it will skip the serial port definition!
Now that you've just launched a new VM, you'd like now to see its kernel booting sequence.
This action involves the following steps:
virsh
command.
Considering the following use case:
<user>@cloudmip[~] onevm list francois@cloudmip[~] onevm list ID USER GROUP NAME STAT UCPU UMEM HOST TIME 104 francois users SL65-104 runn 99 2G wn1 0d 00h00
Thus, we'll connect to the node named wn1
and ask for the virsh
list of deployed VMs:
francois@cloudmip[~] ssh wn1 Warning: Permanently added 'wn1,172.28.112.1' (RSA) to the list of known hosts. Last login: Tue May 6 23:39:48 2014 from frontal.cloudmip.univ-tlse3.fr
francois@wn1[~] virsh list Id Name State ---------------------------------------------------- 28 one-104 running
We now have identified the VMID = 28
as our VM, and we'll ask for console to virsh:
francois@wn1[~] virsh console 28 Connected to domain one-104 Escape character is ^] Scientific Linux release 6.5 (Carbon) Kernel 2.6.32-431.11.2.el6.x86_64 on an x86_64 vm-112-105.cloudmip.univ-tlse3.fr login:
You're then pretty much like the same as being in front of the console of a real node.
[Note]: to espace from the virsh
console, press the sequence CTRL + AltGr + ]