|
|
| (13 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| {{stub}}
| | [[Computing]]: [[Linux]]: [[Qemu]]: [[Qemu on Linux|on Linux]]{{seed}} |
| [[Techniques]]: [[Qemu on Linux]] | | This article is about setting up and running the [[Qemu]] emulator on [[Linux]]. |
| This article is about setting up and running the [[Qemu]] emulator on | | ==Reference== |
| [[Linux]]. | | * [[Qemu manpage]] |
| ==Notes== | | ==Notes== |
| When [[Bochs]] mysteriously stopped being able to run [[Windows | | When [[Bochs]] mysteriously stopped being able to run [[Windows 98|Win98]], I found that Qemu was able to use the exact same .img file Bochs had been using, and it did manage to load Win98 quite easily. It would appear, then, that the setup for Qemu on Linux is probably quite similar to that of [[Bochs on Linux|Bochs]]. |
| 98|Win98]], I found that Qemu was able to use the exact same .img file | | ===Current issues=== |
| Bochs had been using, and it did manage to load Win98 quite easily. It | | * 2005-12-29 Current repository version of Qemu no longer says "warning: could not open /dev/net/tun: no virtual network emulation", but still can't see anyone on network except the local (virtual) machine. DHCP is not fetching an IP address. |
| would appear, then, that the setup for Qemu on Linux is probably quite | | * Need to figure out how to [[mount]] an .img file -- although it's probably not safe to write to an .img while it's in use by the emulator, so this actually wouldn't be all that useful; you'd have to shut down before writing files to the image. Networking is greatly preferable. |
| similar to that of [[Bochs on Linux|Bochs]]. | | * Is there any way to tell Qemu to show a different window title (other than just "Qemu")? When running multiple sessions, it would be nice to be able to tell them apart at a glance. |
| Current issue: "warning: could not open /dev/net/tun: no virtual | | |
| network emulation" | | ===Problems/Solutions=== |
| ==Manpage Documentation==
| | * '''Problem''': "warning: could not open /dev/net/tun: no virtual network emulation"; '''Solution''': |
| ===NAME===
| | ** as root, run "[[modprobe]] [[tun]]"; if no error, then the [[tun]] [[module (Linux)|module]] has been installed successfully |
| [[qemu]] - QEMU System Emulator ===SYNOPSIS===
| | ** "[[ls]] /dev/net/tun" to make sure the device has been created |
| usage: [[qemu]] [options] [disk_image] ===DESCRIPTION===
| | ** Try qemu again. If the console asks for a password for "/etc/qemu-ifup", on [[Ubuntu]] the password it wants is your user password (not sure if this must be the user who installed qemu or the user who is running qemu; perhaps they have to be the same?); this may be different for other distros |
| The QEMU System emulator simulates a complete PC. In order to meet
| | ** However, the network card may still not work at this point; see Current Issues above. |
| specific user needs, two versions of QEMU are available:
| | ===The disk image=== |
| #"[[qemu-fast]]" uses the host Memory Management Unit (MMU) to simulate
| | * '''To create the image''': |
| the x86 MMU. It is fast but has limitations because the whole 4 GB
| | [[qemu-img]] create <u>win98hd.img</u> 2G |
| address space cannot be used and some memory mapped peripherials cannot | | [[qemu]] -hda <u>win98hd.img</u> -cdrom <u>win98.iso</u> -boot d |
| be emulated accurately yet. Therefore, a specific guest Linux kernel
| | ...where <u>win98hd.img</u> is the name of your disk-image file (it can be anything) and <u>win98.iso</u> is the name of a CD ISO image (useful for installing an operating system from CD). |
| can be used.
| | * '''To access the image''', i.e. to read and write files to it by [[mount]]ing it as a folder, see [[accessing a disk image in Linux]] |
| #:Moreover there is no separation between the host and target address
| | ===Accelerator=== |
| spaces, so it offers no security (the target OS can modify the
| | For [[linux]] host systems, there is a loadable kernel module (called [[kqemu]]) that will allow qemu to run at near native speeds. At the time of this writing, there aren't distributed packages available with the module built, so you'll need to download the source from the website and compile it locally. |
| "qemu-fast" code by writing at the right addresses). #"[[qemu]]" uses a
| | |
| software MMU. It is about two times slower but gives a more accurate
| | I've been told that [[kqemu]] (or is that [[qemu-fast]], or are they the same thing?) and Win98 don't get along, which seems borne out by my failed attempts so far to boot Win98 using either one of them – but that could be due to some configuration problem, as I haven't tried booting anything else with either of them either. --[[User:Woozle|Woozle]] 12:10, 18 February 2006 (EST) |
| emulation and a complete separation between the host and target address
| | ===Other stuff=== |
| spaces. QEMU emulates the following PC peripherials: *i440FX host PCI
| | The sample <u>/etc/qemu-ifup</u> file which comes with linux-test-*.tar.gz: |
| bridge and PIIX3 PCI to ISA bridge *Cirrus CLGD 5446 PCI VGA card or
| | #!/bin/sh |
| dummy VGA card with Bochs VESA extensions (hardware level, including
| | [[sudo]] /sbin/[[ifconfig]] $1 172.20.0.1 |
| all non-standard modes). *PS/2 mouse and keyboard *2 PCI IDE interfaces
| |
| with hard disk and CD-ROM support *Floppy disk *NE2000 PCI network
| |
| adapters *Serial ports *Soundblaster 16 card QEMU uses the PC BIOS from
| |
| the [[Bochs]] project and the Plex86/Bochs LGPL VGA BIOS. ===OPTIONS===
| |
| *''disk_image'' is a raw hard disk image for IDE hard disk 0.
| |
| ====General options==== | |
| *'''-fda''' ''file'' | |
| *'''-fdb''' ''file''
| |
| :Use file as floppy disk 0/1 image You can use the host floppy by using | |
| /dev/fd0 as filename. *'''-hda''' ''file'' | |
| *'''-hdb''' ''file'' | |
| *'''-hdc''' ''file'' | |
| *'''-hdd''' ''file''
| |
| :Use file as hard disk 0, 1, 2 or 3 image *'''-cdrom''' ''file''
| |
| :Use file as CD-ROM image (you cannot use -hdc and and -cdrom at the
| |
| same time). You can use the host CD-ROM by using /dev/cdrom as
| |
| filename. *'''-boot''' ['''a'''|'''c'''|'''d''']
| |
| :Boot on floppy (a), hard disk (c) or CD-ROM (d). Hard disk boot is the
| |
| default. *'''-snapshot'''
| |
| :Write to temporary files instead of disk image files. In this case,
| |
| the raw disk image you use is not written back. You can however force | |
| the write back by pressing C-a s *'''-m''' ''megs''
| |
| :Set virtual RAM size to ''megs'' megabytes. Default is 128 MB.
| |
| *'''-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. *'''-enable-audio'''
| |
| :The SB16 emulation is disabled by default as it may give problems with
| |
| Windows. You can enable it manually with this option. *'''-localtime'''
| |
| :Set the real time clock to local time (the default is to UTC time).
| |
| This option is needed to have correct date in MS-DOS or Windows.
| |
| *'''-full-screen'''
| |
| :Start in full screen. ====Network options====
| |
| *'''-n''' ''script'' | |
| :Set TUN/TAP network init script [default=/etc/qemu-ifup]. This script
| |
| is launched to configure the host network interface (usually tun0)
| |
| corresponding to the virtual NE2000 card. *'''-macaddr''' ''addr''
| |
| :Set the mac address of the first interface (the format is
| |
| aa:bb:cc:dd:ee:ff in hexa). The mac address is incremented for each new
| |
| network interface. *'''-tun-fd''' ''fd''
| |
| :Assumes ''fd'' talks to a tap/tun host network interface and use it.
| |
| Read <http://bellard.org/qemu/tetrinet.html> to have an example
| |
| of its
| |
| use. *'''-user-net'''
| |
| :Use the user mode network stack. This is the default if no tun/tap
| |
| network init script is found. *'''-tftp''' ''prefix''
| |
| :When using the user mode network stack, activate a built-in TFTP
| |
| server. All filenames beginning with ''prefix'' can be downloaded from
| |
| the host to the guest using a TFTP client. The TFTP client on the guest
| |
| must be configured in binary mode (use the command "bin" of the Unix
| |
| TFTP client). The host IP address on the guest is as usual 10.0.2.2.
| |
| *'''-smb''' ''dir''
| |
| :When using the user mode network stack, activate a built-in SMB server
| |
| so that Windows OSes can access to the host files in ''dir''
| |
| transparently. :In the guest Windows OS, the line: 10.0.2.4 smbserver
| |
| :must be added in the file C:\WINDOWS\LMHOSTS (for windows 9x/Me) or
| |
| C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS (Windows NT/2000). Then dir can
| |
| be accessed in \\smbserver\qemu. :Note that a SAMBA server must be
| |
| installed on the host OS in /usr/sbin/smbd. QEMU was tested succesfully
| |
| with smbd version 2.2.7a from the Red Hat 9. *'''-redir'''
| |
| ['''tcp'''|'''udp''']''':'''''host-port''''':'''[''guest-host'']''':'''''guest-port''
| |
| :When using the user mode network stack, redirect incoming TCP or UDP
| |
| connections to the host port host-port to the guest guest-host on guest
| |
| port guest-port. If guest-host is not specified, its value is 10.0.2.15
| |
| (default address given by the built-in DHCP server). :For example, to
| |
| redirect host X11 connection from screen 1 to guest screen 0, use the
| |
| following: # on the host [[qemu]] -redir tcp:6001::6000 [...] # this
| |
| host xterm should open in the guest X11 server [[xterm]] -display :1
| |
| :To redirect telnet connections from host port 5555 to telnet port on
| |
| the guest, use the following: # on the host [[qemu]] -redir
| |
| tcp:5555::23 [...] [[telnet]] localhost 5555
| |
| :Then when you use on the host "telnet localhost 5555", you connect to
| |
| the guest telnet server. *'''-dummy-net''' | |
| :Use the dummy network stack: no packet will be received by the network
| |
| cards. ====Linux boot specific====
| |
| When using these options, you can use a given Linux kernel without
| |
| installing it in the disk image. It can be useful for easier testing of
| |
| various kernels. *'''-kernel''' ''bzImage''
| |
| :Use ''bzImage'' as kernel image. *'''-append''' ''cmdline''
| |
| :Use cmdline as kernel command line *'''-initrd''' ''file''
| |
| :Use ''file'' as initial ram disk. ====Debug/Expert options====
| |
| *'''-serial''' ''dev''
| |
| :Redirect the virtual serial port to host device ''dev''. Available
| |
| devices are: **"vc"
| |
| **:Virtual console **"pty"
| |
| **:[Linux only] Pseudo TTY (a new PTY is automatically allocated)
| |
| **"null"
| |
| **:void device **"stdio"
| |
| **:[Unix only] standard input/output :The default device is "vc" in
| |
| graphical mode and "stdio" in non graphical mode. :This option can be
| |
| used several times to simulate up to 4 serials ports. *'''-monitor'''
| |
| ''dev''
| |
| :Redirect the monitor to host device ''dev'' (same devices as the
| |
| serial port). The default device is "vc" in graphical mode and "stdio"
| |
| in non graphical mode. *'''-s'''
| |
| :Wait gdb connection to port 1234 *'''-p''' ''port''
| |
| :Change gdb connection port. *'''-S'''
| |
| :Do not start CPU at startup (you must type 'c' in the monitor).
| |
| *'''-d'''
| |
| :Output log in /tmp/qemu.log *'''-isa'''
| |
| :Simulate an ISA-only system (default is PCI system). *'''-std-vga''' | |
| :Simulate a standard VGA card with Bochs VBE extensions (default is | |
| Cirrus Logic GD5446 PCI VGA) *'''-loadvm''' ''file''
| |
| :Start right away with a saved state ("loadvm" in monitor) ====PowerPC
| |
| Options====
| |
| The following options are specific to the PowerPC emulation: | |
| *'''-prep'''
| |
| :Simulate a PREP system (default is PowerMAC) *'''-g'''
| |
| ''W'''''x'''''H''['''x'''''DEPTH'']
| |
| :Set the initial VGA graphic mode. The default is 800x600x15.
| |
| ===Keys===
| |
| During the graphical emulation, you can use the following keys:
| |
| *'''Ctrl-Alt-f'''
| |
| *:Toggle full screen *'''Ctrl-Alt-'''''n''
| |
| *:Switch to virtual console 'n'. Standard console mappings are:
| |
| **'''1''' : Target system display **'''2''' : Monitor **'''3''' :Serial
| |
| port *'''Ctrl-Alt'''
| |
| *:Toggle mouse and keyboard grab. *In the virtual consoles, you can
| |
| use '''Ctrl-Up''', '''Ctrl-Down''', '''Ctrl-PageUp''' and
| |
| '''Ctrl-PageDown''' to move in the back log. *During emulation, if you
| |
| are using the -nographic option, use '''Ctrl-a h''' to get terminal
| |
| commands: **'''Ctrl-a h'''
| |
| **:Print this help **'''Ctrl-a x'''
| |
| **:Exit emulatior **'''Ctrl-a s'''
| |
| **:Save disk data back to file (if -snapshot) **'''Ctrl-a b'''
| |
| **:Send break (magic sysrq in Linux) **'''Ctrl-a c'''
| |
| **:Switch between console and monitor **'''Ctrl-a Ctrl-a'''
| |
| **:Send Ctrl-a ===SEE ALSO===
| |
| The HTML documentation of QEMU for more precise information and Linux
| |
| user mode emulator invocation. ===AUTHOR===
| |
| Fabrice Bellard
| |
| ==Edit Log==
| |
| *'''2005-06-25''': Added contents of manpage
| |
Computing: Linux: Qemu: on Linux<hide>
page status::seed
</hide>
This article is about setting up and running the Qemu emulator on Linux.
Reference
Notes
When Bochs mysteriously stopped being able to run Win98, I found that Qemu was able to use the exact same .img file Bochs had been using, and it did manage to load Win98 quite easily. It would appear, then, that the setup for Qemu on Linux is probably quite similar to that of Bochs.
Current issues
- 2005-12-29 Current repository version of Qemu no longer says "warning: could not open /dev/net/tun: no virtual network emulation", but still can't see anyone on network except the local (virtual) machine. DHCP is not fetching an IP address.
- Need to figure out how to mount an .img file -- although it's probably not safe to write to an .img while it's in use by the emulator, so this actually wouldn't be all that useful; you'd have to shut down before writing files to the image. Networking is greatly preferable.
- Is there any way to tell Qemu to show a different window title (other than just "Qemu")? When running multiple sessions, it would be nice to be able to tell them apart at a glance.
Problems/Solutions
- Problem: "warning: could not open /dev/net/tun: no virtual network emulation"; Solution:
- as root, run "modprobe tun"; if no error, then the tun module has been installed successfully
- "ls /dev/net/tun" to make sure the device has been created
- Try qemu again. If the console asks for a password for "/etc/qemu-ifup", on Ubuntu the password it wants is your user password (not sure if this must be the user who installed qemu or the user who is running qemu; perhaps they have to be the same?); this may be different for other distros
- However, the network card may still not work at this point; see Current Issues above.
The disk image
qemu-img create win98hd.img 2G
qemu -hda win98hd.img -cdrom win98.iso -boot d
...where win98hd.img is the name of your disk-image file (it can be anything) and win98.iso is the name of a CD ISO image (useful for installing an operating system from CD).
Accelerator
For linux host systems, there is a loadable kernel module (called kqemu) that will allow qemu to run at near native speeds. At the time of this writing, there aren't distributed packages available with the module built, so you'll need to download the source from the website and compile it locally.
I've been told that kqemu (or is that qemu-fast, or are they the same thing?) and Win98 don't get along, which seems borne out by my failed attempts so far to boot Win98 using either one of them – but that could be due to some configuration problem, as I haven't tried booting anything else with either of them either. --Woozle 12:10, 18 February 2006 (EST)
Other stuff
The sample /etc/qemu-ifup file which comes with linux-test-*.tar.gz:
#!/bin/sh
sudo /sbin/ifconfig $1 172.20.0.1