I have a computer (let's call it as DevPC) that sometimes run Linux in native environment and that sometimes run Linux on Xen. I connect this computer to another computer (let's call it as MonitorPC) via serial console so that when the DevPC crashes, I know the error message.
The situation is as follows:
When the DevPC runs Linux in native environment, the serial console /dev/ttyS4 will use the configuration
exec /sbin/getty -8 -L ttyS4 115200 vt102 in /etc/init/ttyS0.conf;
When the DevPC runs Linux in Xen environment, the serial console /dev/ttyS4 will use the configuration
exec /sbin/getty -8 -L hvc0 115200 vt102 in /etc/init/ttyS0.conf
If the DevPC runs Linux in Xen environment, but uses the configuration
exec /sbin/getty -8 -L ttyS4 115200 vt102, I will see that the getty will fails to spawn. The error message is as follows:
[ 3807.606153] init: ttyS0 main process (7171) terminated with status 1
[ 3807.606197] init: ttyS0 main process ended, respawning
I can fix this manually by changing the /etc/init/ttyS0.conf when it happens. However, this is quite annoying and is a kind of labor work.
My question is:
Is there a way that I can configure the ttyS0.conf so that the getty can use different configurations in different environments?
I know how to detect if the machine is running in Xen environment by checking the output of the command
xl list. However, I'm not sure how to encode this information into the getty's spawning scripts or into the ttyS0.conf
Thank you very much for your help and time! I really appreciate for any advice or suggestion.