2008/05/10

The Labs.Com OS Lab Qemu
Last update 2008/04/13
The Labs - Design & Functionality For The Net

A Fast CPU Emulator

I'm quite a fan of virtualization, and VMware was the only commercial product I bought the last years, and it was worth it; but needless to say I was eager to see an open-source replacement or implementation for emulating an entire PC hardware ... and Qemu seems to be it! Not just i386, but also PowerPC (ppc), and other CPUs are under way.
  1. First Steps
  2. Remote Virtual Machines
  3. Webmin Module
  4. Netinstall
  5. Links
Qemu
1. First Steps
  1. FreeBSD: install /usr/ports/emulators/qemu/ port, for other UNIXs check Qemu Homepage
  2. Get CDROM ISO: Best search for netinstall ISO images of your favourite OS, e.g. google for "Debian Netinstall". Under FreeBSD use "bootonly" ISO image, aprx. 20MB.
  3. Create an empty filesystem: dd if=/dev/zero of=scratch.img bs=1024 count=1000000, creates 1GB file, to be used as virtual harddisk
  4. Start Qemu: qemu -cdrom Debian-3.0-netinstall.iso -hda scratch.img -boot d

Qemu
2. Remote Virtual Machines

Currently I develop a webmin module for Qemu for handling virtual machines remotely. For now here a few hints.

Requirements: VNC (see RealVNC.com), its vncviewer actually

Prior qemu-0.8.0 there wasn't a VNC built-in support, now it has it:

On the server:

 dd if=/dev/zero of=empty.img bs=1024 count=1500000 
 qemu -cdrom FreeBSD-5.3-bootonly.iso -hda empty.img -boot d -vnc :1 

and on another machine:

 vncviewer server:1.0 

Attention: Up to version 0.7.2 there are problems with keyboard input (keyscan code translation), check with google for "qemu keyboard problems" for a path, you essentially need to enable SDL keycode translation:

In sdl.c of qemu source code, insert this line at top of file (before the first #include's)

 #define CONFIG_SDL_GENERIC_KBD=1 

and recompile qemu.

Qemu
3. Webmin Module

History:

  • 2008/03/31: 0.020: fix for process table on solaris, support for linux
  • 2008/03/13: 0.019: supporting solaris as host, thanks to S. Meyer for the patch incl. optional args for qemu
  • 2007/05/12: 0.018: qemu 0.9.0 has -vnc switch now, supporting it
  • 2005/04/02: 0.017: enforcing vncpasswd used to define default passwd for vncserver, first public release
  • 2005/01/03: 0.016: disk image checking if referenced or not (+/- write permission set)
  • 2004/12/30: 0.015: uptime for each vm, more links in the 'connect' page
  • 2004/12/29: 0.014: os image creation (empty), upload not yet working
  • 2004/12/27: 0.013: multiple selection start/halt/etc works now, fixed
  • 2004/12/21: 0.012: qemu.sh and qemutab (auto installs) for autostart (FreeBSD only for now)
  • 2004/12/15: 0.011: multiline comments support
  • 2004/12/08: 0.010: more infos, bug fixes
  • 2004/11/24: 0.009: custom images removed, beautifying code, cleaning up disk format conversion/creation
  • 2004/11/23: 0.008: vmdk, cloop, qcow, cow support, os-images improved, more general os image selection functionality
  • 2004/11/23: 0.007: more detailed infos on viewing/editing vm
  • 2004/11/23: 0.006: vga, port-redirection, as well 'nice' implemented
  • 2004/11/22: 0.005: reboot only restarts qemu, but not Xvnc
  • 2004/11/21: 0.004: code beautifying, cleaner stop/start/reboot, and cpu%/mem% correct (calling fork/exec)
  • 2004/11/21: 0.003: misc bug fixes, iso/img selector fixed, verbose switch added, better preview
  • 2004/11/11: 0.002: file chooser added, for fd[ab], h[abcd], and cdrom
  • 2004/11/11: 0.001: qemu & Xvnc start & stop work, we use root window.
  • 2004/11/05: 0.000: started to code it
  • Based on the few hints of remote virtual machine I wrote a webmin module called "virtualpc", it gives a web-interface to Qemu. It's early BETA software! I release it for your enjoyment.

    Download
     
    virtualpc-0.020.wbm
    The Virtual PC Webmin Module (frontend for Qemu)
    Requirements: WebMin, qemu, VNC, and xsetroot, xset (part of X11 distribution), License: GPL
    fbsd_theme-0.006.wbt
    FreeBSD Web Console Theme
    Requirements: WebMin
    License: GPL
    Installation: "Webmin" -> "Webmin Configuration" -> "Webmin Theme" and paste URL there.

    Installation
     Install it via Webmin itself, go to "Webmin" -> "Webmin Configuration" -> "Webmin Modules", and then paste the URL above to "From ftp or http URL", and select that method. The module will be listed under "Network" section.

    I additionally recommend my "FreeBSD Web Console Theme", which is one of the better designed theme for Webmin I think (based on Linux Management Console by D.V. Dhulla), with nice KDE Crystal icons.

    More installation notes you find in the running module under "About" then.

    Screenshots
     

    Overview of all VMs

    Detailed View of VM

    Connected to VM Console via VNC

    As you see, I run a FreeBSD-5.3 host multiple Linux distributions, NetBSD, yet PPC and SPARC emulation seems broken in the FreeBSD version of Qemu (compiled via FreeBSD ports).

    FreeBSD-5.3: I noticed also with multiple qemu-sessions running I quickly (within 10 days) run out of kernel memory, I assume this is a FreeBSD-5.x specific problem.

    Qemu
    4. Netinstall

    Here are few links to fetch small netinstall .ISO and boot-floppies:
    FreeBSD ISOs
    choose bootonly or netinstall
    NetBSD Floppy FS
    choose installation/floppy
    Debian Netinstall ISO
    Very well prepared
    SuSE i386
    choose boot.iso
    Fedora Core
    look for Downloads -> OS -> Images
    Most OS do netinstall just fine, as Qemu has DHCP Server build-in and network should be up just fine.

    Boot via -cdrom iso-file, or when you used a floppy-image via -fda boot-floppy.

    A few hints on netinstall procedures:

    FreeBSD
     FreeBSD-4.10/i386 and FreeBSD-5.3/i386 as guest works.
    Status: OK

    NetBSD
     NetBSD-1.6.2/i386: Just select fda -> NetBSD-boot.fs, and boot fda (for the first boot), and start it with an empty disk at hda; I had problems formating and writing MBR, I continuously run (2-3 times) over it, and finally it worked, make sure you have 700MB+ empty diskimage. When doing ftp install, it failed to lookup ftp.netbsd.org, and I used its direct IP (204.152.190.13), then it worked. Install worked, but system didn't boot properly: system not useable - unfortunately.
    Status: FAILED

    NetBSD-2.0/i386: I installed it via full ISO, and after a few hick ups (e.g. I had to define the mount points by hand from /mnt to / and /mnt/usr to /usr), it worked, and booted successfully.
    Status: OK

    Debian
     Debian-3.0/i386 works fine
    Status: OK

    Fedora Core 3
     i386: Once you booted the small netinstall .iso (which just boots), choose "HTTP" Install Method, select DHCP whenever you are asked, and later enter (there are no intelligent defaults):

     Web Site: download.fedora.redhat.com 
     Path: pub/fedora/linux/core/3/i386/os/ 

    and the rest goes as usual. Fedora Core 3 worked with Qemu-0.6.0 just fine.
    Status: OK

    SuSE 9.1
     i386: Set memory to 256MB, otherwise it won't succeed (forget to install SuSE on low memory PCs!) - once you booted it will complain about missing CD1 of SuSE, since I describe here the Netinstall approach it was to be expected, as next "Kernel Modules" -> "Load Network Module Driver" -> "NE-2K PCI", then go back to Network Installation -> FTP, select DHCP Network Setup, once you are asked about IP, then use those (you might lookup ftp.suse.com if the IP below doesn't work):

     IP: 195.135.221.132 
     Path: pub/suse/i386/9.1 

    as next it will load the ramdisk (quite slowly), after that the GUI installer stops when selecting the language - mouse neither keyboard do respond, so one has to use TAB & RETURN to walk and select GUI options. After installation machine boots and appears useable.
    Status: OK

    Qemu
    5. Links

    QEMU CPU Emulator
    Homepage, with lots of useful links
    Qemu Launcher
    GTK2/Perl based GUI for Qemu
    KQEMU
    KDE GUI for Qemu
    Qemudo
    Webinterface (without Webmin)

                                                                                                                                       

    InterOS OS LabVMware

    Last update 2008/04/13

    All Rights Reserved - (C) 1997 - 2008 by The Labs.Com

    Top of Page

    The Labs.Com