0
I want to use the following feature of Linux (which one of my virtual machines):
If no console device is specified, the first device found capable of acting as a system console will be used. At this time, the system first looks for a VGA card and then for a serial port. https://github.com/torvalds/linux/blob/master/Documentation/serial-console.txt The reason for that is in production we use the video output to interact with the virtual machine (text only) but for testing I want to interact programmatically with the machine using a serial port provided by VirtualBox.
Disclaimers:
- I am aware of running virtual machines headless, but this is different from running them without a graphics card.
- I am aware of SSH but SSH is not permitted in the VM
- I am aware of RDP but using a RDP client during testing is not possible.
- I am aware of taking screenshots of the VM and OCR them (desperate, I know), but then I can't provide input.
- I am aware of the VirtualBox undocumented cli option:
VBoxManage modifyvm "$(VM_REL_NAME)" --graphicscontroller none
but that seems not to trigger the feature quoted above.
Not an answer, but instead of worrying about disabling the VGA card (since you are going to use that in production), why not configure the VM to have a serial port pointed to a named-pipe on the host machine (assuming you are using Windows as the host) and then configuring the serial port on Guest OS as a terminal connection. Then you could connect a host OS terminal app to the named pipe and ta-da, you have a terminal connection to the Guest OS. Understandably not helpful if you have to be GUI-less for the whole install. – David Rouse – 2016-01-13T18:58:33.630
@DavidRouse That would work if I would you the serial port as a console to e.g. login to it. But as I use it during boot up (the unit I want to interact with is a systemd unit) I can have that unit only output/input to one console. – Kreisquadratur – 2016-01-13T19:10:49.850
"I want to use the following feature of Linux" -- then do so. I currently see no question, except "seems not to trigger the feature quoted above" implies you're having difficulty using the feature. What is the difficulty? Why can't you use SSH? (That sounds like a networking issue that may be something that ought to be fixed, eventually, anyway.) The VM software I typically use has a way to send a keystroke to the local console (even if I cannot see it), which might work with screenshots. OS-specific details may help, so which Linux OS? – TOOGAM – 2016-01-13T19:11:04.217
@TOOGAM Regarding using the Linux feature, I can't find a way in Virtualbox to start the VM without a graphics card/VGA to be configured (which then should case the linux kernel to trigger the console switch feature); so my question is targeting VirtualBox as well as how and if that linux kernel feature should work. Regarding SSH: the VM image will be used by a customer that should not have access to SSH and I want to test the exact image the customer gets, so can't activate SSH during testing as this would alter the image (an OVA). Linux is CoreOS and I want to interact with a Systemd unit. – Kreisquadratur – 2016-01-13T19:15:20.530
@TOOGAM "The VM software I typically use has a way to send a keystroke" you mean programmatically or interactively? if programmatically, which VM software do you use? I don't see a simple way (besides using RPD or KVM) to send keystrokes to a VM using VirtualBox. If that would be possible, that would make the need for a serial port redundant. – Kreisquadratur – 2016-01-13T19:16:51.117
Again, not an answer, but maybe what you want to Google for is 'serial console redirection' -- it looks like you should be able to prefer the serial port during booting. It looks like folks with similar constraints as yours use this technique. If that doesn't help, I've no idea -- if it was a physical machine, I'd say LOM. – David Rouse – 2016-01-13T19:26:41.407
Qemu has a feature called the "Qemu monitor", which can be accessed via Telnet (which should be automatable, leading to at least one possible way to automate-- there may be others too). The Qemu monitor allows a person to interact with the machine, and to make some changes to a running machine, including simulating a keystroke. VirtualBox should allow you to send keystrokes to a console. (You know how to do that for a normal machine, with a graphics card, right?) Some information about using VirtualBox (and hyperlink in final post)
– TOOGAM – 2016-01-13T19:38:34.737You don't mention what flavor of Linux you're using, but here are some instructions on setitng up Ubuntu to boot using a serial console.
– heavyd – 2016-01-13T20:05:11.123@TOOGAM Thanks, yes, I finally found the "send keystroke" subcommand and will give that a try. Regarding Qemu: agree, it has the feature I want, but I was unable to configure it to the extend where it's not magnitudes slower than VirtualBox, so discarded the Qemu path. – Kreisquadratur – 2016-01-14T11:37:33.787
@heavyd Sorry, it's CoreOS 766.5.0. Again, the problem is not to set up serial console per se, it's to set up "both", a serial tty (for testing) and a virtual tty (for production) as consoles. So far I think I will try to redirect everything from /dev/tty0 to /dev/stty0 for outputs, and use VirtualBox's
sendkeyboardscancodes
for inputs. – Kreisquadratur – 2016-01-14T11:40:19.360Also, the problem is not that I can't have access to both, /dev/tty0 and /dev/ttyS0, but that the part I need to interact with for both is a Systemd unit during boot up, so simple using a login (which is restricted due to security guidelines anyway) is not possible / would be too late and allow to simulate a user in production. – Kreisquadratur – 2016-01-14T11:42:48.257