DaemonForums  

Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 5th May 2008
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,052
Thanked 118 Times in 93 Posts
Default HOWTO: QEMU on FreeBSD

I wrote short qemu howto install/usage on FreeBSD as host os, and in this example with Win2000 as guest os.

changelog:
1. removed useless /etc/qemu-ifup script [it was used in older versions of qemu with tap/bridge interfaces]
2. added info about sound emumation inside qemu OS.
3. removed HACKS_CIRRUS from options [thx to scottro sugestion], reason here: http://forums.bsdnexus.com/viewtopic...d=14036#p14036
4. sometimes OS installation requires unload of kqemu. short: install without kqemu and the use with kqemu
Install qemu with options showed below:
Code:
# cd /usr/ports/emulators/qemu && make install clean
Code:
Options for qemu:
 [X] KQEMU          Build with (alpha!) accelerator module
 [ ] HACKS_CIRRUS   Large display speedup (buggy!)
 [ ] RTL8139_TIMER  allow use of re(4) nic with FreeBSD guests
 [ ] SAMBA          samba dependency (for -smb)
 [X] SDL            SDL/X dependency (graphical output)
 [X] CDROM_DMA      IDE CDROM DMA
install and configure sudo:
Code:
# cd /usr/ports/security/sudo && make install clean
sudo config:
Code:
# cat > /usr/local/etc/sudoers << EOF
root            ALL=(ALL) ALL
username        ALL=(ALL) NOPASSWD: ALL
EOF
username is YOU.

load needed modules:
Code:
# sudo kldload aio
# sudo kldload kqemu
create Windows2000 install CD image, use cat or dd:
Code:
% cat /dev/acd0 > ~/qemu/win2k.iso
% dd bs=2048 if=/dev/acd0 of=~/qemu/win2k.iso
create qemu image for new OS:
Code:
% qemu-img create -f qcow2 ~/qemu/win2000.img 4G
install new os, Windows2000 in our example:
Code:
% qemu -boot d -hda ~/qemu/win2000.img -m 128 -cdrom ~/qemu/win2k.iso -win2k-hack -localtime
if You have any problems while installing the OS then unload kqemu module and install again, then after install, load the kqemu module again:
Code:
% sudo kldunload kqemu
% qemu -boot d -hda ~/qemu/win2000.img -m 128 -cdrom ~/qemu/win2k.iso -win2k-hack -localtime
% sudo kldload kqemu
typical usage of OS under qemu:
Code:
% qemu -hda ~/qemu/win2000.img -m 256 -localtime
typical usage of OS under qemu in snapshot mode [to commit made changes hit left_CTRL+left_ALT+2 and type commit]:
Code:
% qemu -hda ~/qemu/win2000.img -m 256 -localtime -snapshot
1. to switch focus between qemu mouse focus and X11 mouse focus use: left_CTRL+left_ALT
2. to ensure that You use kqemu kernel module in user mode hit left_CTRL+left_ALT+2 and type info kqemu, if everything is ok You will see:
Code:
kqemu support: enabled for user code
if not You will see:
Code:
kqemu support: disabled
if disabled it will work, but terribly slow, You will be running at Pentium 75 speed at host with CPU AthlonXP 1.66GHz.
3. to switch between qemu console and qemu os emualtion use left_CTRL+left_ALT+2 to go to console and left_CTRL+left_ALT+1 to back to emulation.
4. enabling network on emulated os, use DHCP configuration inside emulated os to get automatic IP adress 10.x.x.x

after You quit You os inside emulated os, or by qemu console left_CTRL+left_ALT+2 and type quit use this command to launch again Your emulated OS:
Code:
% qemu -hda ~/qemu/win2000.img -m 256 -localtime

How to have sound in qemu OS, You just need to launch qemu the way I listed above, only with -soundhw sb16 or -soundhw es1370 to emulate Sound Blaster 16, or Sound Blaster 128. You can also enable standart annoying BEEP with -soundhw pcspk. You can also enable all three of them like that: -soundhw sb16,es1370,pcspk, or just BEEP + one of them: -soundhw es1370,pcspk, examples
Code:
% qemu -hda ~/qemu/win2000.img -m 256 -localtime -soundhw pcspk
Code:
% qemu -hda ~/qemu/win2000.img -m 256 -localtime -soundhw es1370,pcspk
Code:
% qemu -hda ~/qemu/win2000.img -m 256 -localtime -soundhw es1370,pcspk,sb16

fluxbox add-on:
in ~/.fluxbox/apps:
Code:
# qemu
[app] (class=SDL_App)
  [Workspace]  {2}
  [Deco]       {BORDER}
[end]
resources:

man qemu-img
man qemu
man aio
man dd
man cat
http://kidsquid.com/cgi-bin/moin.cgi/QuickStartGuide
http://qemu-forum.ipi.fi/qemu-snapshots/
http://qemu-forum.ipi.fi/
http://qemu.org/user-doc.html
http://en.wikipedia.org/wiki/QEMU


The same schema works for Solaris 10 and WindowsXP, You only do not use -win2k-hack.

feel free to point errors, typo and Your hints/suggestions here.
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd

Last edited by Carpetsmoker; 7th May 2008 at 06:43 AM. Reason: Fix title
Reply With Quote
  #2   (View Single Post)  
Old 18th January 2009
Bitweiler Bitweiler is offline
Real Name: Patrick
New User
 
Join Date: Jun 2008
Location: St. Louis, MO
Posts: 7
Thanked 0 Times in 0 Posts
Default

Hey can I setup qemu up on NetBSD this way as well? I never emulation software before so I'm green ;-)
Reply With Quote
  #3   (View Single Post)  
Old 18th January 2009
Oko's Avatar
Oko Oko is offline
Fsck Surgeon
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 768
Thanked 36 Times in 32 Posts
Default

Quote:
Originally Posted by Bitweiler View Post
Hey can I setup qemu up on NetBSD this way as well? I never emulation software before so I'm green ;-)
Of course. The real qestion is why would you want to use Qemu on NetBSD when you have Xen? NetBSD has by a mile best support as a host OS for virtualization of any BSD.
Reply With Quote
  #4   (View Single Post)  
Old 18th January 2009
Bitweiler Bitweiler is offline
Real Name: Patrick
New User
 
Join Date: Jun 2008
Location: St. Louis, MO
Posts: 7
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Oko View Post
Of course. The real qestion is why would you want to use Qemu on NetBSD when you have Xen? NetBSD has by a mile best support as a host OS for virtualization of any BSD.
Because I don't know or understand the hardware requirements to run Xen.
Are their any memory requirements? I have only 256MB on my machine so would
Xen run on my machine?
Reply With Quote
  #5   (View Single Post)  
Old 18th January 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

If you only have 256MB for both NetBSD/X, adding QEMU is probably not a great idea.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #6   (View Single Post)  
Old 18th January 2009
Bitweiler Bitweiler is offline
Real Name: Patrick
New User
 
Join Date: Jun 2008
Location: St. Louis, MO
Posts: 7
Thanked 0 Times in 0 Posts
Default

what about xen then
Reply With Quote
  #7   (View Single Post)  
Old 19th January 2009
Bitweiler Bitweiler is offline
Real Name: Patrick
New User
 
Join Date: Jun 2008
Location: St. Louis, MO
Posts: 7
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by TerryP View Post
If you only have 256MB for both NetBSD/X, adding QEMU is probably not a great idea.
Why is that? I use a very light window manager known as stumpwm
Reply With Quote
  #8   (View Single Post)  
Old 19th January 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

Ok, here is an example:

Windows XP requires a minimal of 64MB of RAM; 128MB is recommended (although how anyone could live with that on XP, is beyond me). So let us say, QEMU will be allowed 96MB of memory for running an Windows XP image. Let us further postulate, that between stumpwm and QEMU itself, a further 4MB of memory is consumed (fair enough? This will probably be a bit worse, depending on the size of the disk image used with QEMU).

This leaves 156MB of memory free, not deducting memory space used by the Kernel, hardware resources, or incurred by file system related operations (a background fsck perhaps?).


You will have to be running the X Windows System. A standard X.Org installation I believe, maps part or all of the gfx cards memory into it's own address space where possible; so memory usage on X.Org should be less then most things could ever report; I'm not familiar with NetBSDs X setup, but assume it would be similiar to normal X.Org/Xenocara. So, let us say at least 20MB of system memory for X. If your graphics card uses shared memory, like several (cheaper) ATI Xpress and Intel GMA cards do; that will increase the drain on system memory. X also should be caching image data used by programs, so that out to keep its memory usage lower....


So in reality, you've got closer to < 2/3 your memory to run other applications in. The exact memory used by programs is very hard to gauge, and the figures I've given are for the sake of *example* only. Needless to say, running things like OpenOffice, MS Office, Flash player, Mozilla, running a 3D game, encoding/decoding video, or building anything from ports or with GCC -- will further reduce your memory closer to swap space by a 'nice chunk'. In short: it helps drains system resources, which depending on your needs could someday become a problem sooner then later. FreeBSD is pretty efficient with it's usage of memory IMHO, but not always wise to push it to low memory situations. That is why I said, 'If you only have 256MB for both NetBSD/X, adding QEMU is probably not a great idea.' If one wants to run multiple OSes at once.... oy: much higher chance of getting into SWAP.


Running Windows in QEMU with 96MB of RAM available to it, plus MS Office and IE6; alone would probably push XP into using SWAP file on the disk image. Most Linux or BSD systems, you'd want at least 64MB for QEMU... but ya get my point.

You should really test it out before you commit to it, if you have a real need for using it in such a configuration; rather then a passing fancy.



--> That is my 2 cents.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #9   (View Single Post)  
Old 19th January 2009
phoenix's Avatar
phoenix phoenix is offline
Risen from the ashes
 
Join Date: May 2008
Posts: 699
Thanked 90 Times in 81 Posts
Default

Quote:
Originally Posted by Bitweiler View Post
Because I don't know or understand the hardware requirements to run Xen.
Are their any memory requirements? I have only 256MB on my machine so would
Xen run on my machine?
You need at least 128 M to run the Xen dom0 (the management domain). If you want to run Windows, you also need a CPU that supports hardware virtualisation (Intel VT or AMD SVM). Then you need however much RAM the virtual OS requires (256 MB at least for Windows XP).

You really should not run any kind of VM software on a system with less than 512 MB of RAM.

Personally, I recommend 1 GHz of CPU power and 1 GB of RAM per VM as a starting point.
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
Old 20th January 2009
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,052
Thanked 118 Times in 93 Posts
Default

Quote:
Originally Posted by phoenix View Post
You need at least 128 M to run the Xen dom0 (the management domain).
Official NetBSD Xen HOWTO states that 64MB for dom0 is ok:
http://www.netbsd.org/ports/xen/howto.html

Code:
(...)
# An entry for NetBSD/xen, using /netbsd as the domain0 kernel, and serial
# console. Domain0 will have 64MB RAM allocated.
# Assume NetBSD is installed in the first MBR partition.
title Xen 3.0 / NetBSD (hda0, serial)
  root(hd0,0)
  kernel (hd0,a)/xen.gz dom0_mem=65536 com1=115200,8n1
  module (hd0,a)/netbsd bootdev=wd0a ro console=ttyS0
(...)
... but IMHO 512-1024MB will be a good start point for virtualization.
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
Old 9th March 2009
Mr-Biscuit Mr-Biscuit is offline
Banned
 
Join Date: May 2008
Posts: 272
Thanked 0 Times in 0 Posts
Default

Add for x86_64/amd64 hosts.

# kldload kqemu aio if_tap if_bridge
# sysctl net.link.tap.user_open=1
# ifconfig tap0 create
# ifconfig bridge0 create

## example from my computer##
vi /etc/devfs.rules

#BiscuitBox Rules
#
[biscuitbox_rules=100]
add path 'acd*' mode 666
#add path 'cd*' mode 666
#own tap0 moleque:moleque <-- remove the # from this line to where it looks like this:
vi /etc/devfs.rules

#BiscuitBox Rules
#
[biscuitbox_rules=100]
add path 'acd*' mode 666
#add path 'cd*' mode 666
own tap0 moleque:moleque-->
Save changes and exit.

Jurgen suggested
" Or if you really want to run qemu as root use something like kdesu to
allow root to access your X display, or just do the following `hack':
ln -sf ~yourlogin/.Xauthority ~
(as root.)"

Use the qcow2 format for images.
Reply With Quote
Reply

Tags
qemu

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
FreeBSD GPT howto graudeejs Guides 10 21st December 2010 12:24 AM
HOWTO: FreeBSD CPU Scaling with cpufreq.ko vermaden Guides 10 27th October 2010 07:58 AM
HOWTO: Enemy Territory on FreeBSD tangram Guides 0 9th June 2009 03:31 PM
HOWTO: FreeBSD with CCACHE vermaden Guides 10 9th July 2008 06:14 PM
ssh to FreeBSD run in Qemu mfaridi FreeBSD Security 11 19th May 2008 01:00 PM


All times are GMT. The time now is 12:46 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick