Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

qemu redirecting guest output in terminal

550 views
Skip to first unread message

john doe

unread,
Oct 25, 2018, 11:30:06 AM10/25/18
to
Hi,

I'm trying to install Debian, it works if I do use the below command:

qemu -hda debian.img -cdrom debian-9.5.0-amd64-netinst.iso -boot d -m 1024

I'd like to redirect the output of the guest (Debian) to the terminal so
I have added '-nographic':

qemu -hda debian.img -cdrom debian-9.5.0-amd64-netinst.iso -boot d -m
1024 -nographic

The guest is running but I don't see any Debian output in the terminal.

What argument(s) should I use to redirect the output of the guest in the
terminal?

I appriciate any input.

--
John Doe

Reco

unread,
Oct 25, 2018, 3:00:04 PM10/25/18
to
Hi.
That's tricky one.
-nographic means you discard VGA/keyboard/mouse emulation and the only
means of user interaction is RS232 emulation.

And that means that now you have three problems:

1) All x86 bootloaders in Debian are configured for VGA/keyboard
input/output.
That includes GRUB2 in a conventional install, and syslinux that's used
in installer.

2) Linux kernel built for x86 use VGA for output by default.
RS232 means appending something like 'console=ttyS0,115200n8' to
kernel's commandline.

3) Systemd respects console= from kernel's commandline, but I cannot say
the same for other init systems.


But, you're using QEMU and that means you're in luck.
Unpack netinst image, extract vmlinux and initrd.gz from it. You won't
need anything else from it anyway.

Run QEMU this way:

qemu -hda debian.img -m 1024 -nographic \
-kernel vmlinux -append 'console=ttyS0,115200n8' \
-initrd initrd.gz

Replace -kernel, -initrd and -append with '-boot c' after the
installation.
Also consider using '-M q35' instead of old '-M pc' you're using now.

Reco

john doe

unread,
Oct 26, 2018, 3:20:04 AM10/26/18
to
Thanks to the help of "Dejan Jocic <jod...@gmail.com>" and to this
answer I manage to get the output of the guest redirected in the
terminal by using the following command:

PS C:\qemu> clear; & 'C:\Program Files\qemu\qemu-system-x86_64.exe' -hda
debian.img -cdrom debian-9.5.0-amd64-netinst.iso -boot d -m 1024
-nographic -kernel vmlinuz -append 'console=ttyS0,115200n8
DEBIAN_FRONTEND=text priority=low' -initrd initrd.gz

As you can see it is done on Windows and when attempting to install
Debian the output is a bit mest up:

Choose the next step in the install process:
1: Choose language [*],
2: Access software for a blind person using a braille display,
3: Configure the keyboard,
4: Detect and mount CD-ROM,
5: Load installer components from CD,
6: Change debconf priority,
7: Check the CD-ROM(s) integrity,
8: Save debug logs,
9: Execute a shell,
10: Abort the installation,
Prompt: '?' for help, default=1> 1

Select a language
-----------------

Choose the language to be used for the installation process. The selected
language will also be the default language for the installed system.
Language:
←[22A←[M←[22BPrompt: '?' for help, default=2> ←

Looks like it is character encoding related.

I understand that it is Windows/powershell but if anyone has a hint,
that would be awesome! :)

Note that this e-mail is folded by my mailer.

--
John Doe

john doe

unread,
Oct 26, 2018, 9:40:03 AM10/26/18
to
Using Cygwin the output is not mest up but during the installation I'm
stuck at:

"No disk drive was detected. If you know the name of the driver needed
by your
disk drive, you can select it from the list.
Driver needed for your disk drive:
1: continue with no disk drive [*], 46: loop,"

Should I select the default option (1) or what should I do?

Thanks for any help.

--
John Doe

Reco

unread,
Oct 26, 2018, 10:50:05 AM10/26/18
to
Hi.
Nah, we don't do Windows here. Way too many quirks for my personal
taste.
What you can try is to replace stdio with telnet:

qemu -hda debian.img -m 1024 \
-chardev socket,id=tty0,port=5555,server,telnet \
-serial chardev:tty0 -nographic \
-kernel vmlinux -append 'console=ttyS0,115200n8' \
-initrd initrd.gz

Port 5555 is just an example, obviously.
And you'll need telnet, but since you're using Cygwin you should got it
covered.

> > Note that this e-mail is folded by my mailer.

Meaning that I use 'format=flowed'? It's recommended to wrap lines at 72
characters here anyway.


> Using Cygwin the output is not mest up but during the installation I'm
> stuck at:
>
> "No disk drive was detected. If you know the name of the driver needed
> by your
> disk drive, you can select it from the list.
> Driver needed for your disk drive:
> 1: continue with no disk drive [*], 46: loop,"
>
> Should I select the default option (1) or what should I do?

No, that means that whatever you did with Cygwin denied QEMU read-write
access to a file that represents a disk drive. An installation is
impossible.

Reco

john doe

unread,
Oct 28, 2018, 1:00:04 PM10/28/18
to
I used Cygwin simply to test qemu with the output redirected in the
terminal but the reason why I'm looking at virtualisation/qemu is to go
away from Cygwin and to have Debian for linux related stuff!
While trying the above command, I get an error probably because I didn't
install the telnet package on Cygwin.
Qemu supports using COM port and I have install com0com (1) but when
using '-serial COM25' I get the following error:

$ qemu-system-x86_64.exe -drive file=debian.img,format=raw -boot c -m
8192 -nographic -accel hax -machine q35 -serial COM25
HAX is working and emulator runs in fast virt mode.
QEMU 3.0.0 monitor - type 'help' for more information
(qemu) C:\Program Files\qemu\qemu-system-x86_64.exe: -serial COM25:
Failed CreateFile (2)
C:\Program Files\qemu\qemu-system-x86_64.exe: -serial COM25: could not
connect serial device to character backend 'COM25'

I guess I'm missing something in the above command?
As far as I can tell, both ports are working (COM25 and COM26).

>>> Note that this e-mail is folded by my mailer.
>
> Meaning that I use 'format=flowed'? It's recommended to wrap lines at 72
> characters here anyway.
>

:)

>
>> Using Cygwin the output is not mest up but during the installation I'm
>> stuck at:
>>
>> "No disk drive was detected. If you know the name of the driver needed
>> by your
>> disk drive, you can select it from the list.
>> Driver needed for your disk drive:
>> 1: continue with no disk drive [*], 46: loop,"
>>
>> Should I select the default option (1) or what should I do?
>
> No, that means that whatever you did with Cygwin denied QEMU read-write
> access to a file that represents a disk drive. An installation is
> impossible.
>

Yep, removing 'debian.img' an recreating it by doing the below command
did it:

$ qemu-img create debian.img 25G


See (2) and (3) for the 'accel hax' option.

1) https://sourceforge.net/projects/com0com/
2) https://www.qemu.org/2017/11/22/haxm-usage-windows/
3) https://qemu.weilnetz.de/doc/qemu-doc.html

--
John Doe

Reco

unread,
Oct 28, 2018, 1:40:04 PM10/28/18
to
Hi.


On Sun, Oct 28, 2018 at 05:51:13PM +0100, john doe wrote:
> On 10/26/2018 4:44 PM, Reco wrote:
> > Nah, we don't do Windows here. Way too many quirks for my personal
> > taste.
> > What you can try is to replace stdio with telnet:
> >
> > qemu -hda debian.img -m 1024 \
> > -chardev socket,id=tty0,port=5555,server,telnet \
> > -serial chardev:tty0 -nographic \
> > -kernel vmlinux -append 'console=ttyS0,115200n8' \
> > -initrd initrd.gz
> >
> > Port 5555 is just an example, obviously.
> > And you'll need telnet, but since you're using Cygwin you should got it
> > covered.
> >
>
> While trying the above command, I get an error probably because I didn't
> install the telnet package on Cygwin.

No, it was because I left out one argument that did not have a default
value. This should work (works for me at least):

qemu -hda debian.img -m 1024 \
-chardev socket,id=tty0,host=127.0.0.1,port=5555,server,telnet \
-serial chardev:tty0 -nographic \
-kernel vmlinux -append 'console=ttyS0,115200n8' \
-initrd initrd.gz

If you're seeing something like:

QEMU waiting for connection on: disconnected:telnet:127.0.0.1:5555,server

that means it works, connect with telnet, or netcat, or whatever.


> Qemu supports using COM port and I have install com0com (1) but when
> using '-serial COM25' I get the following error:
>
> $ qemu-system-x86_64.exe -drive file=debian.img,format=raw -boot c -m
> 8192 -nographic -accel hax -machine q35 -serial COM25
> HAX is working and emulator runs in fast virt mode.
> QEMU 3.0.0 monitor - type 'help' for more information
> (qemu) C:\Program Files\qemu\qemu-system-x86_64.exe: -serial COM25:
> Failed CreateFile (2)
> C:\Program Files\qemu\qemu-system-x86_64.exe: -serial COM25: could not
> connect serial device to character backend 'COM25'
>
> I guess I'm missing something in the above command?

-serial [dev] means:

Redirect the virtual serial port to host character device dev.

As I wrote earlier, we don't do Windows here, so I cannot produce a
Windows equivalent of /dev/com25.


> >
> >> Using Cygwin the output is not mest up but during the installation I'm
> >> stuck at:
> >>
> >> "No disk drive was detected. If you know the name of the driver needed
> >> by your
> >> disk drive, you can select it from the list.
> >> Driver needed for your disk drive:
> >> 1: continue with no disk drive [*], 46: loop,"
> >>
> >> Should I select the default option (1) or what should I do?
> >
> > No, that means that whatever you did with Cygwin denied QEMU read-write
> > access to a file that represents a disk drive. An installation is
> > impossible.
> >
>
> Yep, removing 'debian.img' an recreating it by doing the below command
> did it:
>
> $ qemu-img create debian.img 25G

Reco

john doe

unread,
Oct 28, 2018, 3:20:03 PM10/28/18
to
Hi,
It is indeed, in Cygwin and in cmd.exe but not in powershell.

>> Qemu supports using COM port and I have install com0com (1) but when
>> using '-serial COM25' I get the following error:
>>
>> $ qemu-system-x86_64.exe -drive file=debian.img,format=raw -boot c -m
>> 8192 -nographic -accel hax -machine q35 -serial COM25
>> HAX is working and emulator runs in fast virt mode.
>> QEMU 3.0.0 monitor - type 'help' for more information
>> (qemu) C:\Program Files\qemu\qemu-system-x86_64.exe: -serial COM25:
>> Failed CreateFile (2)
>> C:\Program Files\qemu\qemu-system-x86_64.exe: -serial COM25: could not
>> connect serial device to character backend 'COM25'
>>
>> I guess I'm missing something in the above command?
>
> -serial [dev] means:
>
> Redirect the virtual serial port to host character device dev.
>
> As I wrote earlier, we don't do Windows here, so I cannot produce a
> Windows equivalent of /dev/com25.
>

Nevermind, I can install/run the guest using telnet if using 'cmd.exe'.

I'm a happy camper!

Thanks for your help.

--
John Doe
0 new messages