Difference between revisions of "QEMU"

From ReactOS Wiki
Jump to: navigation, search
m (Serial port connection using com0com)
(Adding a warning on using LiveCD on Qemu)
 
(50 intermediate revisions by 18 users not shown)
Line 1: Line 1:
Qemu is a free x86 Emulator/Virtual Machine for Linux and Windows.
+
[http://www.qemu.org/ QEMU] is a free x86 emulator for Linux and Windows.
  
If you are looking for something faster, you can try the [http://bellard.org/qemu/kqemu-doc.html Qemu Accelerator Module] or [[VMware]].
+
'''Note''': First of all, make sure you have read '''[[Installing ReactOS]]''' article.
  
== ReactOS preloaded with QEMU ==
+
== Installing ReactOS on QEMU ==
 +
 
 +
* Create a drive image, on which ReactOS will be installed, by typing:
 +
 
 +
qemu-img create -f qcow2 ReactOS.qcow2 1200M
 +
 
 +
<code>1200M</code> stands for 1200 megabytes - that shall be enough. It shall be greater, if you plan to install some application to try under ReactOS.
 +
 
 +
* In *nix only, type:
 +
 
 +
sudo umount /dev/shm
 +
sudo mount -t tmpfs -o size=144m none /dev/shm
 +
 
 +
* Type:
 +
 
 +
qemu-system-i386 -m 1G -drive if=ide,index=0,media=disk,file=ReactOS.qcow2 -drive if=ide,index=2,media=cdrom,file=ReactOS.iso -boot order=d -localtime -serial file:ReactOS.log
 +
 
 +
* <code>-m 1G</code> stand for 1&nbsp;GB RAM
 +
* <code>-boot order=d</code> instructs QEMU to boot from the CD-ROM. Without <code>-boot order=d</code> it will boot from the hard drive image.
 +
* <code>ReactOS.iso</code> is the image of the '''installation''' CD, which can be downloaded from https://reactos.org/download/
 +
 
 +
'''Important''': Currently only 0.4.14-RC or higher builds support QEMU 4.2.0 and above, you can download them [https://reactos.org/getbuilds/ from here]. If you are using an older version of QEMU, you can grab the image from the above link.
 +
 
 +
When reinstalling ReactOS, perform steps 2 (if necessary) and 3 only.
 +
 
 +
If you want to copy some files to ReactOS, you could create an CD-ROM image and mount it on QEMU.
 +
You can run QEMU this way:
 +
 
 +
qemu-system-i386 -m 1G -drive if=ide,index=0,media=disk,file=ReactOS.qcow2 -drive if=ide,index=2,media=cdrom,file=Applications.iso -localtime -serial file:ReactOS.log
 +
 
 +
=== Setting up Sound ===
 +
 
 +
==== Using AC97 emulation (QEMU 0.10.1 or later) ====
 +
 
 +
* Set emulation to AC97: <code>-device ac97</code>
 +
* On 0.4.15-dev builds that's it - it should just work, when using older versions of ReactOS install the drivers using Downloader (You need to reboot twice!)
 +
 
 +
===== Known Issues =====
 +
 
 +
* Audio sounds glitch when changing the audio stream with a high sample rate to a stream with low sample rate
 +
 
 +
==== Using ES1370MP emulation ====
  
A preloaded QEMU image of ReactOS can be found [http://www.reactos.org/en/download.html here].
+
* Set emulation to ES1370: <code>-device es1370</code>
<!-- file not found, url updated, previous url: http://www.reactos.org/xhtml/en/download.html -->
+
* Install drivers from here <s>[http://rapidshare.com/files/236843299/windows2.zip.html]</s> (if have this file please upload it somewhere else and edit this link, Rapidshare closed in 2015)
 +
* Create a file named import.reg with the following contents
  
== Installing ReactOS on QEMU ==
+
<syntaxhighlight lang="reg">
1. Create a drive image, on which ReactOS will be installed, by typing:
+
REGEDIT4
 +
 
 +
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96C-E325-11CE-BFC1-08002BE10318}\0000\Settings]
 +
"WaveVol_Left"=dword:00040000
 +
"WaveVol_Right"=dword:00040000
 +
"WaveLineSM"=dword:00000000
 +
"WaveWaveInSM_Left"=dword:01010101
 +
"WaveWaveInSM_Right"=dword:00000000
 +
"CDVol_Left"=dword:fffffff6
 +
"CDVol_Right"=dword:fffffff6
 +
"CDLineSM"=dword:00000000
 +
"CDWaveInSM_Left"=dword:00000000
 +
"CDWaveInSM_Right"=dword:00000000
 +
"LineInVol_Left"=dword:fffffff6
 +
"LineInVol_Right"=dword:fffffff6
 +
"LineLineSM"=dword:01000001
 +
"LineWaveInSM_Left"=dword:00000000
 +
"LineWaveInSM_Right"=dword:00000000
 +
"MicBoost"=dword:00000001
 +
"MicVol"=dword:fffffff6
 +
"MicLineMute"=dword:00000001
 +
"MicWaveInSM_Left"=dword:00000000
 +
"MicWaveInSM_Right"=dword:00000000
 +
"AuxVol_Left"=dword:fffffff6
 +
"AuxVol_Right"=dword:fffffff6
 +
"AuxLineSM"=dword:00000000
 +
"AuxWaveInSM_Left"=dword:00000000
 +
"AuxWaveInSM_Right"=dword:00000000
 +
"PhoneVol"=dword:fffffff6
 +
"PhoneMute"=dword:00000000
 +
"PhoneWaveInSM_Left"=dword:00000000
 +
"PhoneWaveInSM_Right"=dword:00000000
 +
"LineOutVol_Left"=dword:fff9f203
 +
"LineOutVol_Right"=dword:fff9f203
 +
"LineOutMute"=dword:00000000
 +
</syntaxhighlight>
  
<pre>qemu-img create ReactOS.img 100M</pre>
+
* Import those settings by starting cmd.exe and regedit import.reg
 +
* Reboot
  
''100M'' stands for 100 megabytes- that shall be enough.
+
If you don't hear any sound in '''QEMU 0.10.x''', you'll have to set QEMU_AUDIO_DRV=fmod (available: dsound; fmod; sdl; none ; wav (dump to file) – see QEMU documentation for information.
It shall be greater, if you plan to install some application to try under ReactOS.
 
  
2. In *nix only, type:
+
===== Known Issues =====
  
<pre>sudo umount /dev/shm
+
After starting first audio stream, you need to leave QEMU and re-enter (seems to be a QEMU bug)
sudo mount -t tmpfs -o size=144m none /dev/shm</pre>
 
  
3. Type:
+
=== Setting up network ===
 +
Networking should work by itself using both the <code>-net nic,model=e1000</code> and <code>-net user</code> switches with QEMU.
  
<pre>qemu -L . -m 256 -cdrom ReactOS.iso -hda ReactOS.img -boot d -localtime -serial file:ReactOS.log</pre>
+
Network card models that should work out-of-box as of 0.4.15-dev builds are:
''-m 256'' stand for 256MB RAM
+
* <code>e1000</code> - '''Intel 82540EM''' (PCI, e1000.sys driver)
''-boot d'' instructs qemu to boot from the cdrom. Without ''-boot d'' it will boot from the HDD (Reactos.img).
+
* <code>e1000-82545em</code> - '''Intel 82545EM''' (PCI, e1000.sys driver)
 +
* <code>e1000-82544gc</code> - '''Intel 82544GC''' (PCI, e1000.sys driver)
 +
* <code>ne2k_pci</code> - '''Realtek RTL8029''' (PCI, ne2000.sys driver)
 +
* <code>pcnet</code> - '''AMD PCnet Am79C970''' (PCI, pcnet.sys driver)
 +
* <code>rtl8139</code> - '''Realtek RTL8139''' (PCI, rtl8139.sys driver)
 +
* <code>tulip</code> - '''Intel 21143''' (PCI, dc21x4.sys driver)
 +
* <code>virtio-net</code> - '''Red Hat VirtIO''' (PCI, netkvm.sys driver)
  
''ReactOS.iso'' is the image of the '''installation''' cd, which can be downloaded from http://www.reactos.org/en/download.html
+
== Using ReactOS [[LiveCD]] on QEMU ==
  
 +
Note: Keep in mind that the LiveCD's default RAMDisk driver is Read-only, so programs that depend on being able to write (like RAPPS, wont work)
  
When reinstalling ReactOS, perform steps 2 (if necessary) and 3 only.
+
# Move to the previously created directory with the <code>cd</code> command.
 +
# There, type in the following command:
  
If you want to copy some files to ReactOS, you could create an CD-ROM image and mount it on qemu.
+
qemu-system-i386 -m 64M -drive if=ide,index=2,media=cdrom,file=<filename>.iso
You can run qemu this way:
 
<pre>qemu -L . -m 256 -cdrom Applications.iso -hda ReactOS.img -localtime -serial file:ReactOS.log</pre>
 
  
 
== Grabbing debug messages ==
 
== Grabbing debug messages ==
  
By default, ReactOS debug messages are sent to the serial port (COM1).
+
By default, ReactOS debug messages are sent to the serial port (COM1) of the guest machine.
For grabbing that output, you need Qemu version 0.6.1 or later, in which you can specify the -serial option.
+
For grabbing that output, you need QEMU version 0.6.1 or later, in which you can specify the <code>-serial</code> option.
  
Valid arguments to -serial include filenames, pipes, COM Ports and [http://bellard.org/qemu/qemu-doc.html#SEC10 more].
+
Valid arguments to -serial include file names, pipes, COM Ports and [http://www.qemu.org/qemu-doc.html#SEC10 more].
 
Those arguments could be:
 
Those arguments could be:
<pre>
+
 
-serial file:"C:\roslog.txt"
+
-serial file:"C:\roslog.txt"
-serial pipe:"\\pipe1\"
+
-serial pipe:"\\pipe1\"
-serial COM4
+
-serial COM4
</pre>
+
-serial tcp:127.0.0.1:1234,server,nowait
  
 
=== Redirect to a file ===
 
=== Redirect to a file ===
 +
 
If you're using the QEMU virtual machine and want to redirect the serial output to a file, add the following to your QEMU command line:
 
If you're using the QEMU virtual machine and want to redirect the serial output to a file, add the following to your QEMU command line:
 
  -serial file:''FILENAME''
 
  -serial file:''FILENAME''
Line 56: Line 140:
  
 
=== Redirect to the console ===
 
=== Redirect to the console ===
The method above redirects the output to a file.
+
 
If you want to redirect it to the console, there are two different methods. They depend on the operating system you run QEMU under.
+
The method above redirects the output to a file. If you want to redirect it to the console, there are two different methods. They depend on the operating system you run QEMU under.
 +
 
 
* Under Windows, add the following to your QEMU command line: <pre>-serial file:CON</pre>
 
* Under Windows, add the following to your QEMU command line: <pre>-serial file:CON</pre>
 
* Under a Unix-based operating system, add the following to your QEMU command line: <pre>-serial stdio</pre>
 
* Under a Unix-based operating system, add the following to your QEMU command line: <pre>-serial stdio</pre>
Line 63: Line 148:
 
=== Serial port connection using com0com ===
 
=== Serial port connection using com0com ===
  
Setup the com0com driver like explained in this [[com0com|com0com guide]].
+
Setup the com0com driver like explained in this [[com0com]] guide.
  
 
Add the following option to your QEMU command line
 
Add the following option to your QEMU command line
  
<pre>-serial COM4</pre>
+
-serial COM4
  
 
Write "COM4" with capital letters otherwise QEMU won't use the serial port at all!
 
Write "COM4" with capital letters otherwise QEMU won't use the serial port at all!
  
Open your terminal program and start a new connection on port COM5. If COM5 is not listed, try COM4.
+
Open your terminal program and start a new connection to your second virtual port. If that port is not listed, try COM4.
  
 
Another option is to use the [http://svn.reactos.org/downloads/RosTE-0.1.exe ReactOS Test Environment] instead of setting this up manually.
 
Another option is to use the [http://svn.reactos.org/downloads/RosTE-0.1.exe ReactOS Test Environment] instead of setting this up manually.
 +
 +
=== Serial port connection over network ===
 +
 +
With recent versions of QEMU you can map serial port to a listening TCP socket:
 +
-serial tcp:127.0.0.1:1234,server,nowait
 +
 +
Use <code>0.0.0.0</code> as listening address to allow debugging from a remote machine.
 +
 +
* If you are using GCC build with [[Kdbg]], you can connect to it using PuTTY or plain Telnet. See also [[ReactOS Remote Debugger]].
 +
* If you are using MSVC build, [[WinDBG]] can be connected to it like this:
 +
windbg.exe -k com:ipport=1234,port=127.0.0.1
 +
 +
Note that this method is different to [[Debugging#Network|KDNET]], as it utilizes standard COM port over TCP/IP.
 +
 +
== KQEMU ==
 +
 +
If you feel that QEMU is too slow for you, consider using the KQEMU module.
 +
 +
Please bear in mind that it just works with QEMU up to 0.11 and isn't maintained anymore.
 +
 +
[https://reactos.org/forum/viewtopic.php?f=22&t=1065 Tutorial] by mikedep333
 +
 +
On modern Linux systems you can use [[libvirt]] with KVM acceleration.
  
 
== See also ==
 
== See also ==
* [[HOWTO/setup_a_network_connection|Setup a network connection]]
+
* [[Transfer files from the host OS to the virtual drive]]
* [[HOWTO/setup_win32_QEMU_with_the_KQEMU_accelerator_module|Setup Windows/ReactOS QEMU with the kqemu accelerator module]]
 
* [[Xen]]
 
 
 
== External sites ==
 
  
* [http://bellard.org/qemu/ QEMU homepage]
+
{{Navigation Virtualization Software}}
  
[[Category:Virtualization software]]
+
[[Category: Tutorial]]
[[Category:Free software]]
 

Latest revision as of 23:52, 5 March 2024

QEMU is a free x86 emulator for Linux and Windows.

Note: First of all, make sure you have read Installing ReactOS article.

Installing ReactOS on QEMU

  • Create a drive image, on which ReactOS will be installed, by typing:
qemu-img create -f qcow2 ReactOS.qcow2 1200M

1200M stands for 1200 megabytes - that shall be enough. It shall be greater, if you plan to install some application to try under ReactOS.

  • In *nix only, type:
sudo umount /dev/shm
sudo mount -t tmpfs -o size=144m none /dev/shm
  • Type:
qemu-system-i386 -m 1G -drive if=ide,index=0,media=disk,file=ReactOS.qcow2 -drive if=ide,index=2,media=cdrom,file=ReactOS.iso -boot order=d -localtime -serial file:ReactOS.log
  • -m 1G stand for 1 GB RAM
  • -boot order=d instructs QEMU to boot from the CD-ROM. Without -boot order=d it will boot from the hard drive image.
  • ReactOS.iso is the image of the installation CD, which can be downloaded from https://reactos.org/download/

Important: Currently only 0.4.14-RC or higher builds support QEMU 4.2.0 and above, you can download them from here. If you are using an older version of QEMU, you can grab the image from the above link.

When reinstalling ReactOS, perform steps 2 (if necessary) and 3 only.

If you want to copy some files to ReactOS, you could create an CD-ROM image and mount it on QEMU. You can run QEMU this way:

qemu-system-i386 -m 1G -drive if=ide,index=0,media=disk,file=ReactOS.qcow2 -drive if=ide,index=2,media=cdrom,file=Applications.iso -localtime -serial file:ReactOS.log

Setting up Sound

Using AC97 emulation (QEMU 0.10.1 or later)

  • Set emulation to AC97: -device ac97
  • On 0.4.15-dev builds that's it - it should just work, when using older versions of ReactOS install the drivers using Downloader (You need to reboot twice!)
Known Issues
  • Audio sounds glitch when changing the audio stream with a high sample rate to a stream with low sample rate

Using ES1370MP emulation

  • Set emulation to ES1370: -device es1370
  • Install drivers from here [1] (if have this file please upload it somewhere else and edit this link, Rapidshare closed in 2015)
  • Create a file named import.reg with the following contents
REGEDIT4

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96C-E325-11CE-BFC1-08002BE10318}\0000\Settings]
"WaveVol_Left"=dword:00040000
"WaveVol_Right"=dword:00040000
"WaveLineSM"=dword:00000000
"WaveWaveInSM_Left"=dword:01010101
"WaveWaveInSM_Right"=dword:00000000
"CDVol_Left"=dword:fffffff6
"CDVol_Right"=dword:fffffff6
"CDLineSM"=dword:00000000
"CDWaveInSM_Left"=dword:00000000
"CDWaveInSM_Right"=dword:00000000
"LineInVol_Left"=dword:fffffff6
"LineInVol_Right"=dword:fffffff6
"LineLineSM"=dword:01000001
"LineWaveInSM_Left"=dword:00000000
"LineWaveInSM_Right"=dword:00000000
"MicBoost"=dword:00000001
"MicVol"=dword:fffffff6
"MicLineMute"=dword:00000001
"MicWaveInSM_Left"=dword:00000000
"MicWaveInSM_Right"=dword:00000000
"AuxVol_Left"=dword:fffffff6
"AuxVol_Right"=dword:fffffff6
"AuxLineSM"=dword:00000000
"AuxWaveInSM_Left"=dword:00000000
"AuxWaveInSM_Right"=dword:00000000
"PhoneVol"=dword:fffffff6
"PhoneMute"=dword:00000000
"PhoneWaveInSM_Left"=dword:00000000
"PhoneWaveInSM_Right"=dword:00000000
"LineOutVol_Left"=dword:fff9f203
"LineOutVol_Right"=dword:fff9f203
"LineOutMute"=dword:00000000
  • Import those settings by starting cmd.exe and regedit import.reg
  • Reboot

If you don't hear any sound in QEMU 0.10.x, you'll have to set QEMU_AUDIO_DRV=fmod (available: dsound; fmod; sdl; none ; wav (dump to file) – see QEMU documentation for information.

Known Issues

After starting first audio stream, you need to leave QEMU and re-enter (seems to be a QEMU bug)

Setting up network

Networking should work by itself using both the -net nic,model=e1000 and -net user switches with QEMU.

Network card models that should work out-of-box as of 0.4.15-dev builds are:

  • e1000 - Intel 82540EM (PCI, e1000.sys driver)
  • e1000-82545em - Intel 82545EM (PCI, e1000.sys driver)
  • e1000-82544gc - Intel 82544GC (PCI, e1000.sys driver)
  • ne2k_pci - Realtek RTL8029 (PCI, ne2000.sys driver)
  • pcnet - AMD PCnet Am79C970 (PCI, pcnet.sys driver)
  • rtl8139 - Realtek RTL8139 (PCI, rtl8139.sys driver)
  • tulip - Intel 21143 (PCI, dc21x4.sys driver)
  • virtio-net - Red Hat VirtIO (PCI, netkvm.sys driver)

Using ReactOS LiveCD on QEMU

Note: Keep in mind that the LiveCD's default RAMDisk driver is Read-only, so programs that depend on being able to write (like RAPPS, wont work)

  1. Move to the previously created directory with the cd command.
  2. There, type in the following command:
qemu-system-i386 -m 64M -drive if=ide,index=2,media=cdrom,file=<filename>.iso

Grabbing debug messages

By default, ReactOS debug messages are sent to the serial port (COM1) of the guest machine. For grabbing that output, you need QEMU version 0.6.1 or later, in which you can specify the -serial option.

Valid arguments to -serial include file names, pipes, COM Ports and more. Those arguments could be:

-serial file:"C:\roslog.txt"
-serial pipe:"\\pipe1\"
-serial COM4
-serial tcp:127.0.0.1:1234,server,nowait

Redirect to a file

If you're using the QEMU virtual machine and want to redirect the serial output to a file, add the following to your QEMU command line:

-serial file:FILENAME

Replace FILENAME with the name of a file, into which the debug output shall be written.

Redirect to the console

The method above redirects the output to a file. If you want to redirect it to the console, there are two different methods. They depend on the operating system you run QEMU under.

  • Under Windows, add the following to your QEMU command line:
    -serial file:CON
  • Under a Unix-based operating system, add the following to your QEMU command line:
    -serial stdio

Serial port connection using com0com

Setup the com0com driver like explained in this com0com guide.

Add the following option to your QEMU command line

-serial COM4

Write "COM4" with capital letters otherwise QEMU won't use the serial port at all!

Open your terminal program and start a new connection to your second virtual port. If that port is not listed, try COM4.

Another option is to use the ReactOS Test Environment instead of setting this up manually.

Serial port connection over network

With recent versions of QEMU you can map serial port to a listening TCP socket:

-serial tcp:127.0.0.1:1234,server,nowait

Use 0.0.0.0 as listening address to allow debugging from a remote machine.

  • If you are using GCC build with Kdbg, you can connect to it using PuTTY or plain Telnet. See also ReactOS Remote Debugger.
  • If you are using MSVC build, WinDBG can be connected to it like this:
windbg.exe -k com:ipport=1234,port=127.0.0.1

Note that this method is different to KDNET, as it utilizes standard COM port over TCP/IP.

KQEMU

If you feel that QEMU is too slow for you, consider using the KQEMU module.

Please bear in mind that it just works with QEMU up to 0.11 and isn't maintained anymore.

Tutorial by mikedep333

On modern Linux systems you can use libvirt with KVM acceleration.

See also

Virtualization software‎ to run ReactOS on
Windows Bochs | Hyper-V | PCem | QEMU | Virtual PC | VirtualBox | VMware
ReactOS Bochs | PCem | QEMU | Virtual PC
Linux Bochs | Libvirt | PCem | QEMU | VirtualBox