48

I want to run some programs on the High Performance Computer (With 8-core processor) in my department. Now I use that machine with ssh using terminal. The machine has Red Hat linux installed on it. But my programs need to run on Solaris. I use Nexenta Solaris for x86.

Can qemu be used to run Nexenta Solaris on that machine through terminal. I need to convince the administrator that it can, otherwise he won't install qemu on that machine and therefore allow me to use Solaris through a virtual machine. Also note that I don't use GUI with the Nexenta Solaris, just command line. In my machine, I use VMware to run it.

Snorik
  • 201
  • 3
  • 15
MetallicPriest
  • 29,191
  • 52
  • 200
  • 356

4 Answers4

71

You can compile qemu for youself and install it into your home directory. There will be no kernel-mode qemu accelerator, but the qemu will work and the speed will be rather high.

Qemu has two options for non-gui start: http://wiki.qemu.org/download/qemu-doc.html

2.3.4 Display options:

-nographic

  • Normally, QEMU uses SDL to display the VGA output. With this option, you can totally disable graphical output so that QEMU is a simple command line application. The emulated serial port is redirected on the console. Therefore, you can still use QEMU to debug a Linux kernel with a serial console.

-curses

  • Normally, QEMU uses SDL to display the VGA output. With this option, QEMU can display the VGA output when in text mode using a curses/ncurses interface. Nothing is displayed in graphical mode.

Also it can send graphic output to another machine via VNC protocol (-vnc option)

Nick is tired
  • 6,860
  • 20
  • 39
  • 51
osgx
  • 90,338
  • 53
  • 357
  • 513
  • 3
    Yes, `-curses` works over ssh whereas -nographic just hangs. – Sridhar Sarnobat Oct 24 '17 at 18:47
  • 1
    Original curses patch for qemu, 2005: https://lists.gnu.org/archive/html/qemu-devel/2005-12/msg00084.html "[Qemu-devel] qemu curses driver" From: andrzej zaborowski Date: Sat, 10 Dec 2005 "*When qemu is running with "-curses" it displays everything in the current terminal, be it native console, linux framebuffer, xterm, or running over ssh, leaving the task of rendering characters to the terminal... . This works as long as the virtual graphics adapter is in text-mode.* " – osgx Oct 24 '17 at 23:10
  • *the speed will be rather high* A bit late here, but in my experience using QEMU to compile some customer code for old CPUs, my off-the-cuff estimate is that the CPU and memory performance are reduced by about an order of magnitude, while IO performance won't be affected much. Compiles that take something like 10 minutes normally might take an hour or two. So your performance depends on your workload. But it does work and it works well. – Andrew Henle May 17 '20 at 16:29
25

Linux: -append 'console=ttyS0'

That option was also needed for Linux kernel be besides -nographic mentioned by osgx as in a comment:

qemu-system-x86_64 -append 'console=ttyS0' \
                   -initrd rootfs.cpio.gz \
                   -kernel bzImage \
                   -nographic \
                   -serial mon:stdio \
                   

Now you can do the following:

-append 'console=ttyS0' makes QEMU pass the console=ttyS0 kernel command line option to Linux, which tells the kernel to use a serial port instead of the display. The serial port sends characters between host and guest, instead of pixels on a display, and then QEMU can display those characters on the terminal.

-serial mon:stdio is optional in this minimal command, but it is generally a good idea to have around. E.g., it improves behaviour if you also want to add a handy -monitor telnet later on:

This can be easily tested with Buildroot qemu_x86_64_defconfig. I've created this is a highly self-contained and automated setup that allows you to try this out easily

Related but with less OS constraints:

Tested on Ubuntu 18.04, QEMU 2.11.1.

FreeBSD

Got it working there too: How to boot FreeBSD image under Qemu

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
  • 2
    What is `-kernel bzImage` ? – falsePockets Feb 11 '19 at 05:52
  • @falsePockets it is one of the many possible Linux kernel build outputs, see: https://unix.stackexchange.com/questions/5518/what-is-the-difference-between-the-following-kernel-makefile-terms-vmlinux-vml/482978#482978 Here is a [sample setup that just works as an example](https://github.com/cirosantilli/linux-kernel-module-cheat/tree/b13b140499b65a57ab67eff12fa7f38a07940bde#qemu-buildroot-setup). – Ciro Santilli OurBigBook.com Feb 11 '19 at 08:55
  • what about emulated dos? how can the output be redirected to cli ? – beppe9000 Sep 02 '20 at 16:23
  • @beppe9000 do you mean MS-DOS? It is extremely likely that it also supports serial since it is such an universal hardware, you just need to dig into their docs on how to tell it to use the desired serial. And if QEMU has an `-append` analogue for DOS. I'd just ask a separate specific question about it and link to it. – Ciro Santilli OurBigBook.com Sep 02 '20 at 16:29
6

I've struggled this for a while and finally figured out how to get it to work for me:

You need to have SGABIOS installed. Interestingly this BIOS is not included in the debian qemu package, so you need to install it (as the superuser):

apt install sgabios  

Then when you run qemu use the -device option to tell the virtural machine to use the sga output

qemu-system-i386 -nographic -device sga discimage.bin

Voila! works perfectly over ssh with both the monitor and text output sent through stdio. You can access the qemu monitor with C-a c.

cheers, ben

Ben White
  • 61
  • 1
  • 1
  • 1
    FYI: sgabios is no longer a separate package in recent debian. – hildred Mar 05 '21 at 18:25
  • no option because `apt install sgabios` removes `qemu-kvm qemu-system qemu-system-arm qemu-system-data qemu-system-mips qemu-system-misc qemu-system-ppc qemu-system-s390x qemu-system-sparc qemu-system-x86` – palik Feb 13 '22 at 21:43
-4

os terminal will not working qemu. So you should use putty on windows pc or you should use linux machine terminal.