QEMU
Iz Vikipedije, slobodne enciklopedije.
Sadržaj |
Pokretanje virtuelne mašine pod Ubuntuom 7.04
QEmu vam omogućava da pokrenete OS unutar drugog OS-a - na primer, Windows pod Linuxom. QEmu koristi kqemu, acceleration drajver iz Ubuntu 7.04 Feisty Fawn-a da bi pokrenuo Windows na pristojnoj brzini.
Ubuntu 7.04 Feisty Fawn takođe ima i novu verziju rdesktop-a koja može da se koristi za pokretanje individualnih aplikacija iz VM ali na vašem desktopu. Link: SeamlessVirtualization.
Napomena: Većina računara kupljenih 2006 i noviji imaju podršku za Intel-VT ili AMD Pacifica (AMD-V), tehnologije koje omogućavanju hardversku podršku virtuelizaciji. Da biste proverili da li vaš sistem ima ove tehnologije pokrenite sledeću naredbu u konzoli:
grep -E '^flags.*(vmx|svm)' /proc/cpuinfo
Ako dobijete neki rezultat preporučujemo vam korišćenje Kernel Virtuelizacije.
Napomena: Čak i ako ne dobijete rezultat ove komande vaš računar možda ima hardversku podršku virtuelizaciji. Neki računari se isporučuju sa isključenom opcijom hardverske virtuelizacije u BIOS-u dok druge mašine je koriste samo ako je BIOS ažuriran na najnoviju verziju.
Instalacija OS-a u QEmu sa Ubuntu Feisty 7.04
Iako ovaj vodič opisuje instalaciju Windows XP-a, bilo kog Linuxa ili BSD-a. Ranije verzije Windows-a rade fino, i možda su i preporučljivije s obzirom na brzinu kojom se izvršavaju.
1. Prvo treba da instalirate qemu kqemu-source, kqemu-common i module assistant iz Universe riznice.
sudo apt-get install qemu kqemu-source module-assistant kqemu-common
2. Sledi pravljenje kqemu modula
sudo module-assistant prepare sudo module-assistant auto-install kqemu
3. Zatim treba podesiti udev da pravi /dev/kqemu device node nakon učitavanja kqemu modula
- Napravite /etc/udev/rules.d/60-kqemu.rules
gksu gedit /etc/udev/rules.d/60-kqemu.rules
sa sledećim sadržajem: (redosled GROUP i MODE je izgleda bitan i obavezno napravite novi red na kraju fajla)
KERNEL=="kqemu", NAME="%k", GROUP="kqemu", MODE="0660"
4. Promenite sadržaj /etc/modprobe.d/kqemu u
options kqemu major=0
5. Napravite korisničku grupu "kqemu" i dodelite joj korisnike kojima će biti dozvoljeno korišćenje QEMU-a sa akceleratorom
sudo addgroup --system kqemu sudo adduser $USER kqemu
- Da bi vaš korisnički nalog bio deo grupe kqemu treba ažurirati okruženje, npr. odjavljivanje i ponovnim prijavljivanjem na sistem.
6. Učitaćemo kqemu modul
sudo modprobe kqemu
7. Proverite da li su dozvole kako treba
$ ls -l /dev/kqemu crw-rw---- 1 root kqemu 10, 62 2007-07-22 15:36 /dev/kqemu
- Ako ima problema sa dozvolama, najverovatnije udev nije pravilno učitan. Probajte da ga ponovo učitate kqemu modul
sudo modprobe -r kqemu sudo modprobe kqemu
Ako i dalje imate isti problem dodajte OWNER="vašekorisničkoime" na kraju udev rule-a i probajte ponovo
8. Ako vam je potrebno da kqemu bude učitan pri svakom podizanju sistema, dodajte novi red sa kqemu u /etc/modules datoteku
gksu gedit /etc/modules
9. Napravićemo virtuelni hard disk od 2 Gb za OS virtuelne mašine
qemu-img create -f qcow test.img 2G
- Ovako se pravi virtuelni disk od 2GB koji će biti smešten u datoteku ubuntu-server.img u folderu u kom ste izvršili naredbu. Virtuelni disk će u početku biti mala datoteka pa će polako narasti kako budete dodavali podatke. Za pravljenje instalaciju BSD sistema nemojte koristiti "-f qcow" jer ćete imati problema sa alociranjem diska. Za Windows XP SP2 stavite min 3-4GB
- Napomena: Ako koristite qcow format, takvu datoteku nećete moći da prikačite direktno na Ubuntu. S druge strane, ako izostavite "-f qcow" i napravite datoteku koja može da se zakači na Ubuntuov sistem datoteka tada će veličina virtuelnog diska biti velika (onoliko koliko ste odredili) i fiksna. Instrukcije za konverziju raw virtuelnog diska u qcow možete naći na dnu ovog teksta.
10. Instalirajte OS na virtuelnu mašinu. Stavite CD u uređaj i pokrenite:
qemu -localtime -cdrom /dev/cdrom -m 384 -boot d test.img
11. Ovako ćete pokrenuti QEmu sa časovnikom iz Ubuntu-a, test.img će predstavljati hard disk, /dev/cdrom predstavlja instalacioni CD, 384 MB sistemske memorije i podizanje sistema će biti sa CD-a.
12. Alternativno, možete koristiti .iso slike
qemu -localtime -cdrom InstalacioniCD.iso -m 384 -boot d test.img
13. If you're having trouble creating the Windows partition during Windows installation, check that you have read and write access to the disk image. Use this command to set the file permissions for the windows.img file so that all users in the kqemu group can access the virtual disk
chmod 660 test.img sudo chown $USER:kqemu test.img
- Napomena za 64 bitne korisnike: Koristite 'qemu-system-x86_64' umesto 'qemu'. Otherwise the "-kernel-kqemu" option will not work.
- Note for Windows 2000: Add the option '-win2k-hack'. Otherwise the install may fail with "Not enough disk space" even when that isn't the case.
14. QEmu will start, boot from the CD, and load the XP installer. The installer works like any other Windows install for the most part. However, on some systems the last part of the initial install, pictured, below, will stick around for a very long time. In this case, just reboot (restart QEmu), and the installer will proceed past this point.
15. After a few 'reboots' of QEmu you will be running Windows XP.
16. Clicking on the QEmu window will take control of the Windows cursor. To go back to Linux, press Ctrl + Alt and to toggle fullscreen press Ctrl + Alt + F
Mreža
QEmu provides two modes of networking. In both modes, a virtual network adapter is created inside Windows XP guest.
User mode mreža
In user mode networking, QEmu manages network interface internally in the user mode emulator application. QEmu provides DHCP host which assigns a dynamic IP for the guest OS. TCP and UDP ports can be redirected from the host OS to the guest OS using QEmu command line parameters.
QEMU VLAN <------> Firewall/DHCP server <-----> Host network
| (10.0.2.2)
|
----> DNS server (10.0.2.3)
|
----> SMB server (10.0.2.4)
Pros
- Easy to set up
Cons
- Only TCP and UDP connections are available by default. Ping command, for example, doesn't work inside the guest OS
- Incoming connections must be configured beforehand
TAP mreža
In TAP networking, QEmu connects the guest OS ethernet to the host OS using TAP network bridge. Linux creates a virtual network interface (tap0) which appears in ifconfig listing as other network interfaces. Further, it is possible to bridge network traffic to the guest OS using normal Linux network bridging functionalities.
For examples, see following pages
Pros
- Provides full emulated IP stack
Cons
- Difficult to set up. The set-up is especially cumbersome if you try to run QEmu without root priviledges
Dodatne opcije
Deljenje datoteka sa Windows XP-om
It's not much use having an XP installation if you can't transfer files between Ubuntu and XP. Fortunately, QEMU sets up a virtual LAN and DHCP server for you. You can transfer files to and from XP just as if it was on a real LAN. You can also browse the net and download files and do all the network stuff you would do on a real networked XP box.
Deljenje datoteka između Domaćina i VM-e
QEmu supports file sharing between the VM and host if you have [:SettingUpSamba:Samba configured on the host system]. The following assumes you have a share called 'qemu_share' in your home directory intended to transfer files between Ubuntu and Windows.
To set this up, start QEmu with the following command:
qemu -smb $HOME/qemu_share -m 384 -localtime windows.img
Inside Windows, you can access the shared drive with the following command from a DOS prompt. For example, to map Windows drive 'e' to the share
net use e: \\10.0.2.2\qemu_share
The IP address of Ubuntu will always be 10.0.2.2. If you have running servers on your Ubuntu box, they can also be accessed at this IP address (e.g. ftp:\\10.0.2.2)
Priključenje virtuelnog diska
You can also mount the QEmu virtual disk just like any other drive. QCOW images cannot be mounted. If the drive was created in qcow format you'll need to convert it first, see [#convertimg2raw below].
Make sure you are NOT running QEMU when you do this.
To mount the drive, create a directory '/media/qemu'. Then run
sudo mount -o loop,offset=32256 test.img /media/qemu
Snimanje i kasnije pozivanje stanja VM-e
You can quickly save and restore the state of your Windows System using QEmu's 'overlay images'. Once you have done your initial install, you can create an overlay image and run QEMU off this. The overlay image is very much smaller that the original image and will only contain changes made since the original install. If you trash your XP installation, you can simply delete the overlay image and create a new one from the original image.
To create an overlay image, use the qemu-image program. To create an image test.ovl from test.img, issue the following
qemu-img create -b test.img -f qcow test.ovl
To run Windows, you would now use
qemu test.ovl -enable-audio -user-net -localtime -smb qemu_share
If the test.ovl installation is ruined, you can delete it, and start QEmu using the test.img file. But you will lose changes made since the original install.
QEmu also accepts commands from the shell while it is running. To do this, though, you need to press CTRL+ALT+2 with the QEmu window active. This brings up the QEmu Monitor. From here, you can swap CDs, send keypresses to the emulator, suspend to disk and so on. See the official documentation for full details. To exit the QEmu monitor press CTRL+ALT+1
Converting a qcow image to a raw file
To convert a qcow image, 'test.img', to a raw 'test.raw' file , run
qemu-img convert test.img -O raw test.raw
Konverzija raw virtuelnog disk u qcow format
To convert a raw 'test.img' file to a qcow formatted 'test.qcow', run
qemu-img convert test.img -O qcow test.qcow
Problemi
If you experience problems with mouse pointer hanging in bottom right corner, try before you start up qemu
export SDL_VIDEO_X11_DGAMOUSE=0

