View previous topic :: View next topic |
Author |
Message |
piwacet Guru
Joined: 30 Dec 2004 Posts: 486
|
Posted: Mon Nov 14, 2005 5:17 am Post subject: How-To: Run WinXP in qemu virtual computer on AMD64 |
|
|
Hi. Recently got this working so I thought I 'd go over what I did. Goal was to install windows xp (the regular, 32-bit version) in a qemu virtual computer (native OS is Gentoo, 64-bit) with kqemu accelerator on my AMD64. It's working fine. Note the kqemu accelerator module is free but proprietary. Also note that qemu was recently upgraded from 0.7 to 0.8 with a few changes. I've updated this, but let me know if something's not working.
First, unmask relevant packages:
Code: | Nautilus magenta # cat /etc/portage/package.keywords
app-emulation/qemu ~amd64
app-emulation/qemu-softmmu ~amd64
app-emulation/qemu-user ~amd64 |
Next, add kqemu to your use flags. I did this in /etc/make.conf as I can't imagine what other programs this would affect, but if you want to be purist:
Code: | Nautilus profile # cat /etc/portage/package.use
app-emulation/qemu kqemu
app-emulation/qemu-softmmu kqemu
app-emulation/qemu-user kqemu
|
I don't think all these apps need the use flag, but it won't hurt.
Next,
Now, we'll use qemu to install XP. Note you can do this as a regular user with a few steps as root. First, we will make a file which will serve as a virtual hard drive for the qemu program. I made a directory for this file in my user's home directory, /home/magenta/qemu_windows, but you can do as you wish.
Code: | qemu-img create /path_to_virtual_hard_disk/winxp.img 5G
|
For instance, on my computer:
Code: | qemu-img create /home/magenta/qemu_windows/winxp.img 5G
|
You can change the size to what you think is suitable. The file winxp.img will be the virtual hard disk. (Duh).
The windows XP install takes a while, so before that, let's get kqemu running, to try to speed the process up as much as we can. As root:
Code: | modprobe kqemu major=0 |
The major=0 is necessary or it won't work. This will create a device /dev/kqemu. I believe the device is owned by root and in the group 'qemu', so you should make sure the user which will use qemu is in the group 'qemu'. (See Gentoo documentation on adding users to groups if you don't know how.) As root:
Code: | gpasswd -a [your_user] qemu
|
And, before proceeding, as root, check to see kqemu is working:
Code: | Nautilus magenta # lsmod | grep kqemu
kqemu 43656 0 |
Now, we'll install XP. Take your windows XP install disk and put it in your cdrom. In order to use qemu on an AMD64 running 64 bit, with kqemu enabled, you must use the program qemu_system-x86_64.
Code: | qemu-system-x86_64 -localtime -hda /path_to_virtual_hard_disk/winxp.img -cdrom /dev/hdc -m 450 -boot d
|
This tells qemu that your virtual computer's cdrom is your actual hdc (usually /dev/hdc, also /dev/cdrom or something like that under udev, you may need to adjust this for your system); '-boot d' tells your virtual computer to boot from the cdrom; '-localtime' sets the virtual computer's clock to your system's clock; '-m 450' allocates 450 MB of memory to the virtual computer (you'll need to adjust this to your system). '-hda' tells qemu the path to the virtual hard disk.
At this point a window should open and you should see the windows xp installation program start. As this will take a long time, I recommend confirming that kqemu is working before continuing. To do this, hit 'alt+cntrl+2' This will get you a console in qemu. Type 'info kqemu' in the console, and it should say 'kqemu is enabled.' At this point, type 'quit' to exit qemu, and then re-issue:
Code: | qemu-system-x86_64 -localtime -hda /path_to_virtual_hard_disk/winxp.img -cdrom /dev/hdc -m 450 -boot d
|
to re-start the windows xp install process. If kqemu is not enabled, it should still work, but will take longer.
Follow the windows install process as you normally would. Your virtual computer should re-boot a few times. If you ever reach a point where you would like to tell the virtual computer to boot from the virtual hard drive, just change '-boot d' to '-boot c' in the above command.
Helpful to know during this process:
1.) clicking you mouse over the virtual computer screen will bind your mouse and keyboard to the virtual computer;
2.) 'alt+cntrl' will unbind the mouse and keyboard
O.K. That should get windows xp installed on your virtual hard-drive. To actually use it, do the following:
1.) If kqemu module is not started, you must issue, as root:
Code: | modprobe kqemu major=0 |
2.) start the program (as user in the qemu group):
Code: | qemu-system-x86_64 -localtime -hda /path_to_virtual_hard_disk/winxp.img -m 450 -boot c
|
Again, '-localtime' sets the virtual computer's clock to your system's clock; '-hda' is the path to the virtual hard-drive; specifiying no network option causes qemu to set up a default network (which should work right out of the box); '-m 450' allots memory to your virtual computer (adjust as appropriate); '-boot c' tells the virtual computer to boot from the virtual hard drive. If you have a cdrom in the cdrom drive which you want to use, you can also add '-cdrom /dev/hdc'.
Helpful to know:
1.) clicking you mouse over the virtual computer screen will bind your mouse and keyboard to the virtual computer;
2.) 'alt+cntrl' will unbind the mouse and keyboard
3.) in a reqular linux console, just typing 'qemu' will get you very usefull and succinct help summary.
The proper way to shut down the virutal computer is to shut down windows xp as you would normally, wait until the virutal computer screen says 'it is safe to shut off your computer now,' then get a qemu console by typing 'alt+cntrl+2', then typing 'quit.'
As root,
will remove the kqemu module.
I have a script which automates all of this.
Good luck.
Last edited by piwacet on Sun Jan 29, 2006 10:02 pm; edited 4 times in total |
|
Back to top |
|
|
adrianeczek n00b
Joined: 31 Mar 2004 Posts: 5
|
Posted: Fri Nov 18, 2005 8:00 pm Post subject: |
|
|
thanks, it works... so... why kqemu use flag is masked? |
|
Back to top |
|
|
z0mb13 n00b
Joined: 03 May 2005 Posts: 10 Location: Cape Town, South Africa
|
Posted: Sat Nov 19, 2005 11:45 am Post subject: kqemu disabled - SOLVED |
|
|
Thanks piwacet for your howto!
PROBLEM:
"info kqemu" reported disbaled even with module loaded and /dev/kqemu in place (running as normal user).
SOLUTION:
As root, edit /etc/udev/rules.d/48-qemu.rules and change the MODE 0660 to 0666 as follows...
Code: |
KERNEL="kqemu*", NAME="%k", GROUP="qemu", MODE="0660"
|
to
Code: |
KERNEL="kqemu*", NAME="%k", GROUP="qemu", MODE="0666"
|
Even though I'm using 2.6 kernel I had to issue this command as root to get it working...
Code: |
# echo 1024 > /proc/sys/dev/rtc/max-user-freq
|
Now you should be working a little faster
NOTE:
I have not rebooted yet so I don't know if these udev changes will persist.
I have not thought about any security implications. |
|
Back to top |
|
|
piwacet Guru
Joined: 30 Dec 2004 Posts: 486
|
Posted: Sat Nov 19, 2005 9:15 pm Post subject: |
|
|
So I'm not a linux guru, if other people have thoughts, please chime in.
As to needing to unmask the kqemu USE flag, I'm not sure why, but it may have something to do with the fact that the only program which could use this USE flag is still masked.
About the kqemu being disabled, thanks z0mb13 for the suggestion. I haven't tried it myself as kqemu is working on my computer. I can tell you two instances where I did have difficulty getting kqemu working: first, if I issue the command "modprobe kqemu" without the 'major=0', and realized my mistake, and re-issued 'modprobe kqemu major=0.' This would not work as the kqemu module was already loaded without 'major=0'. So I would need to first remove the kqemu module and then issue 'modprobe kqemu major=0.' The second instance where kqemu sometimes would not work is when I use a script which loads the kqemu module and then runs qemu:
Code: | sudo /sbin/modprobe kqemu major=0
qemu-system-x86_64 -localtime -user-net -hda /home/magenta/qemu_windows/winxp.img -m 450 -boot c
|
I've tested this extensively and it seemed random when it would enable kqemu and when it would appear as disabled despite lsmod showing it was loaded. I don't know why this happens, and if I issue these commands manually it always runs successfully with kqemu enabled. One hypothesis I had was that it just takes a short amount of time to load the kqemu module and set up the /dev/kqemu, and perhaps the script was executing too fast, and qemu-system-x86_64 was loaded and running before kqemu had properly set up. Anyway, I modified my script with redundant modprobes, figuring it would not hurt, and may ensure that kqemu was set up properly before qemu ran:
Code: | sudo /sbin/modprobe kqemu major=0
sudo /sbin/modprobe kqemu major=0
sudo /sbin/modprobe kqemu major=0
qemu-system-x86_64 -localtime -user-net -hda /home/magenta/qemu_windows/winxp.img -m 450 -boot c
|
Using this script qemu always runs with kqemu enabled.
As to the max-user-frequency, I haven't tried that, and I'm not sure what it's significance would be as I don't know what it does. What's your experience with it?
Thanks! |
|
Back to top |
|
|
adrianeczek n00b
Joined: 31 Mar 2004 Posts: 5
|
Posted: Sun Nov 20, 2005 6:29 pm Post subject: |
|
|
I'm now sure what to do with this frequency thing and why we have this problem using kernel 2.6. Guest clock is going faster than host clock and maybe that's the reason.
z0mb13, are your clocks synchronized after several hours of running qemu? |
|
Back to top |
|
|
z0mb13 n00b
Joined: 03 May 2005 Posts: 10 Location: Cape Town, South Africa
|
Posted: Sun Nov 20, 2005 9:24 pm Post subject: |
|
|
I have just rebooted and kqemu is woking fine now with max-user-freq at it's default of 64.
The reason I used the max-user-freq thing at all is that qemu would initially not start when kqemu was enabled and part of the error message was to try that command "or use a 2.6 kernel".
Even though I'm on a 2.6 kernel I tried it and it worked. So unless you get an error message telling you to try max-user-freq=1024 - don't use it.
I have not run qemu long enough to see any noticeable difference in clocks. |
|
Back to top |
|
|
adrianeczek n00b
Joined: 31 Mar 2004 Posts: 5
|
Posted: Sun Nov 20, 2005 9:36 pm Post subject: |
|
|
This message is a warning (at least on my system) so qemu works. |
|
Back to top |
|
|
piwacet Guru
Joined: 30 Dec 2004 Posts: 486
|
Posted: Sun Nov 20, 2005 10:40 pm Post subject: |
|
|
This is the warning message I get with my max-user-freqency at default (64):
Code: | Could not configure '/dev/rtc' to have a 1024 Hz timer. This is not a fatal
error, but for better emulation accuracy either use a 2.6 host Linux kernel or
type 'echo 1024 > /proc/sys/dev/rtc/max-user-freq' as root.
|
Since I already use a 2.6 kernel, I assumed this message was not important, I didn't make any changes to the max-user-freqency, and qemu is working fine. Although I have not watched for clock drift on the virtual machine, so I'll keep an eye out for that.
z0mb13, does qemu work now without editing the udev rules, or do you still nee that modification? On my computer:
Code: | Nautilus rules.d # cat 48-qemu.rules
KERNEL="kqemu*", NAME="%k", GROUP="qemu", MODE="0660" |
And it works fine. Changing the MODE value, as you have done, would change the permisions for the module. Just a thought, is your user in the qemu group? If not, that may be why you needed to change the device permission. |
|
Back to top |
|
|
Sheepdogj15 Guru
Joined: 07 Jan 2005 Posts: 430 Location: Backyard
|
Posted: Mon Nov 21, 2005 4:43 am Post subject: |
|
|
hmm...
how is the performance? i presume you need a good amount of RAM (say a half gig or more)?
right now i use Remote Desktop, which works fine enough, but has enough inconveniences that i'm still interested in the emulation route. _________________ Sheepdog
Why Risk It? | Samba Howto |
|
Back to top |
|
|
z0mb13 n00b
Joined: 03 May 2005 Posts: 10 Location: Cape Town, South Africa
|
Posted: Tue Nov 22, 2005 6:50 am Post subject: |
|
|
piwacet wrote: |
z0mb13, does qemu work now without editing the udev rules, or do you still nee that modification? On my computer:
Code: | Nautilus rules.d # cat 48-qemu.rules
KERNEL="kqemu*", NAME="%k", GROUP="qemu", MODE="0660" |
And it works fine. Changing the MODE value, as you have done, would change the permisions for the module. Just a thought, is your user in the qemu group? If not, that may be why you needed to change the device permission. |
Yes, my user is in the qemu group. I changed back to 0660 mode and it still works. So it seems that was only needed before I did a reboot.
Must have been a permissions error on my part I added the user to qemu group but it seems I did not relogin to console for the change to take effect.
Sorry for for any confusion created. |
|
Back to top |
|
|
blackwhite Apprentice
Joined: 24 Jun 2004 Posts: 250
|
Posted: Fri Nov 25, 2005 4:54 pm Post subject: |
|
|
Quote: | Nautilus profile # cat /etc/portage/package.use
app-emulation/qemu kqemu
app-emulation/qemu-softmmu kqemu
app-emulation/qemu-user kqemu |
In my gentoo box , app-emulation/qemu-softmmu has kqemu use flag, others does not have kqemu use flag
About this problem:
Quote: | Could not configure '/dev/rtc' to have a 1024 Hz timer. This is not a fatal
error, but for better emulation accuracy either use a 2.6 host Linux kernel or
type 'echo 1024 > /proc/sys/dev/rtc/max-user-freq' as root. |
In the kernel, using the following choice for Timer frequency, this will fix this problem.
Quote: | │ CONFIG_HZ_1000: │
│ │
│ 1000 HZ is the preferred choice for desktop systems and other │
│ systems requiring fast interactive responses to events. │
│ │
│ Symbol: HZ_1000 [=y] │
│ Prompt: 1000 HZ │
│ Defined at kernel/Kconfig.hz:33 │
│ Depends on: <choice> │
│ Location: │
│ -> Processor type and features │
│ -> Timer frequency (<choice> [=y]) │
|
|
|
Back to top |
|
|
shirozaru n00b
Joined: 29 Nov 2005 Posts: 9
|
Posted: Tue Nov 29, 2005 8:05 pm Post subject: |
|
|
has anyone tried to use the x86_64 windows version in this scenario? i am curious to know how it might work. i will look in to it and report back. |
|
Back to top |
|
|
jamiethehutt n00b
Joined: 04 Oct 2004 Posts: 66 Location: Scotland!
|
Posted: Tue Nov 29, 2005 9:48 pm Post subject: Re: kqemu disabled - SOLVED |
|
|
z0mb13 wrote: | Thanks piwacet for your howto!
PROBLEM:
"info kqemu" reported disbaled even with module loaded and /dev/kqemu in place (running as normal user).
SOLUTION:
As root, edit /etc/udev/rules.d/48-qemu.rules and change the MODE 0660 to 0666 as follows...
Code: |
KERNEL="kqemu*", NAME="%k", GROUP="qemu", MODE="0660"
|
to
Code: |
KERNEL="kqemu*", NAME="%k", GROUP="qemu", MODE="0666"
|
Even though I'm using 2.6 kernel I had to issue this command as root to get it working...
Code: |
# echo 1024 > /proc/sys/dev/rtc/max-user-freq
|
Now you should be working a little faster
NOTE:
I have not rebooted yet so I don't know if these udev changes will persist.
I have not thought about any security implications. |
"gpasswd -a <your user> qemu" would also do the trick. _________________ "Someday, he thought, it'll be mandatory that we all sell the McDonald's hamburger as well as buy it; we'll sell it back and forth to each other forever from our living rooms. That way we won't even have to go outside." - A Scanner Darkly By PK Dick |
|
Back to top |
|
|
rickvernam Guru
Joined: 09 Jul 2004 Posts: 313
|
Posted: Fri Dec 16, 2005 8:49 pm Post subject: |
|
|
When I run as user who is part of qemu group, I keep getting: Code: | qemu: could not open hard disk image '/dev/cdrom' |
I don't understand why b/c /dev/cdrom has Code: | rick@ricklap ~/qemu $ stat /dev/cdrom
File: `/dev/cdrom' -> `hdc'
Size: 3 Blocks: 0 IO Block: 4096 symbolic link
Device: eh/14d Inode: 2708 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2005-12-16 14:46:33.000000000 -0600
Modify: 2005-12-16 14:12:45.496656000 -0600
Change: 2005-12-16 14:12:45.496656000 -0600 |
and I tried setting /dev/cdrom to group qemu, too...but that didn't help at all.
No problems at all when run as root.
whats the deal here?
Thanks... |
|
Back to top |
|
|
rickvernam Guru
Joined: 09 Jul 2004 Posts: 313
|
Posted: Fri Dec 16, 2005 8:54 pm Post subject: |
|
|
rickvernam wrote: | When I run as user who is part of qemu group, I keep getting: Code: | qemu: could not open hard disk image '/dev/cdrom' |
I don't understand why b/c /dev/cdrom has Code: | rick@ricklap ~/qemu $ stat /dev/cdrom
File: `/dev/cdrom' -> `hdc'
Size: 3 Blocks: 0 IO Block: 4096 symbolic link
Device: eh/14d Inode: 2708 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2005-12-16 14:46:33.000000000 -0600
Modify: 2005-12-16 14:12:45.496656000 -0600
Change: 2005-12-16 14:12:45.496656000 -0600 |
and I tried setting /dev/cdrom to group qemu, too...but that didn't help at all.
No problems at all when run as root.
whats the deal here?
Thanks... |
okay, figured it out
/dev/cdrom is link to /dev/hdc. /dev/hdc is Code: | Access: (0660/brw-rw----) Uid: ( 0/ root) Gid: ( 19/ cdrom) |
So, i just added my user to the cdrom group...
Haven't tested yet..but there is no reason why this solution should not work... |
|
Back to top |
|
|
Pizentios n00b
Joined: 28 Feb 2005 Posts: 26 Location: Brandon, Manitoba, Canada
|
Posted: Wed Dec 21, 2005 7:33 pm Post subject: |
|
|
great guide, worked right off the hop for me _________________ -Pizentios |
|
Back to top |
|
|
kinkozmasta n00b
Joined: 18 Jul 2005 Posts: 38
|
Posted: Fri Dec 23, 2005 7:31 pm Post subject: |
|
|
I've tried with WinXP x86_64 but it complains that the operating system I am trying to install does not have APIC enabled and to check the system's firmware...
Anybody know anything about this? |
|
Back to top |
|
|
boldaire n00b
Joined: 28 Dec 2005 Posts: 3 Location: France
|
Posted: Wed Dec 28, 2005 8:04 am Post subject: |
|
|
Hello,
Thanks for this very nice howto; I used it on a (32-bit) Dell Latitude x1 and it works quite well
I have some questions about the kqemu module:
1/ isn't there a way to lauch it at boot?
2/
Quote: | The proper way to shut down the virutal computer is to shut down windows xp as you would normally, wait until the virutal computer screen says 'it is safe to shut off your computer now,' then get a qemu console by typing 'alt+cntrl+2', then typing 'quit.'
As root,
Code:
modprobe -r kqemu
will remove the kqemu module. |
Any special reason for removing kqemu?
cheers, _________________ jean |
|
Back to top |
|
|
piwacet Guru
Joined: 30 Dec 2004 Posts: 486
|
Posted: Wed Dec 28, 2005 7:41 pm Post subject: |
|
|
I do not see the harm of having kqemu loaded all the time, so if you do not want to remove it after you shut off qemu, I don't see a problem with this.
Simillarly, I don't see the harm of loading kqemu at boot.
I guess to load kqemu at boot you would (I have not tested this):
edit /etc/modules.autoload.d/kernel-2.6 and add a line
to it. Then run
(both must be done as root.) Then it should automatically load at boot. Again, I have not tested this.
Good luck. |
|
Back to top |
|
|
slycordinator Advocate
Joined: 31 Jan 2004 Posts: 3065 Location: Korea
|
Posted: Thu Dec 29, 2005 1:23 am Post subject: Re: How-To: Run WinXP in qemu virtual computer on AMD64 |
|
|
piwacet wrote: | so you should make sure the user which will use qemu is in the group 'qemu'. (See Gentoo documentation on adding users to groups if you don't know how.) As root:
Code: | usermod -G qemu,[plus all the other groups your user should be a member of] [your_user]
|
|
A much simpler way (as it doesn't require you memorizing every group you already are a member of) is to do:
Code: | gpasswd -a [your_user] qemu |
edit:
Fixed my code |
|
Back to top |
|
|
piwacet Guru
Joined: 30 Dec 2004 Posts: 486
|
Posted: Thu Dec 29, 2005 6:30 am Post subject: |
|
|
Thanks, slycordinator, I changed the how-to with your suggestion. |
|
Back to top |
|
|
Sheepdogj15 Guru
Joined: 07 Jan 2005 Posts: 430 Location: Backyard
|
Posted: Mon Jan 02, 2006 7:20 am Post subject: |
|
|
kinkozmasta wrote: | I've tried with WinXP x86_64 but it complains that the operating system I am trying to install does not have APIC enabled and to check the system's firmware...
Anybody know anything about this? |
oh i had this problem when i tried to install 64bit XP a long time back. i don't remember the cause, but i had to change a BIOS setting. i doubt that would work here, except perhaps as a setting in qemu _________________ Sheepdog
Why Risk It? | Samba Howto |
|
Back to top |
|
|
Sheepdogj15 Guru
Joined: 07 Jan 2005 Posts: 430 Location: Backyard
|
Posted: Mon Jan 02, 2006 8:10 am Post subject: |
|
|
also i recommend unmasking packages by version number. that way if e.g. 0.8.1 comes out masked as ~amd64 and it's buggy, it won't be installed when you update world.
Code: | ~app-emulation/qemu-0.8.0 ~amd64
~app-emulation/qemu-softmmu-0.8.0 ~amd64
~app-emulation/qemu-user-0.8.0 ~amd64 |
qemu-softmmu is actually marked as stable, be we can keep it in there just in case (there are rare cases where a package gets remasked as testing or unstable). _________________ Sheepdog
Why Risk It? | Samba Howto |
|
Back to top |
|
|
Sheepdogj15 Guru
Joined: 07 Jan 2005 Posts: 430 Location: Backyard
|
Posted: Mon Jan 02, 2006 10:31 am Post subject: |
|
|
a couple of other points, since i'm up late monkeying with qemu. i'm feeling generous
piwacet wrote: | I guess to load kqemu at boot you would (I have not tested this):
edit /etc/modules.autoload.d/kernel-2.6 and add a line
to it. Then run
|
i thought the "major=0" was required. i don't know if you can put that option in kernel-2.6. but alternatively you can put the command into /etc/conf.d/local.start:
Code: | modprobe kqemu major=0 |
this will cause the command to be run towards the end of boot time.
and i don't think it's necessary, but the command to remove the module can be put in local.stop.
also, the "sdl" USE flag is required for qemu... otherwise you never get a window. i found out the hard way. i think "sdl" is in the default USE flags, so most people probably have it already. "emerge --info" will say what flags you have.
someone mentioned a problem with XP 64bit and APIC. i'm actually thinking using that edition of XP myself... i happened to find this page through googling: http://www.h7.dion.ne.jp/~qemu-win/
scroll down and there is a hack or something that should fix the problem. i haven't tried it out yet and to be honest i'm not sure how to use it. if i do play with it i'll report back here later. _________________ Sheepdog
Why Risk It? | Samba Howto |
|
Back to top |
|
|
rickvernam Guru
Joined: 09 Jul 2004 Posts: 313
|
Posted: Mon Jan 02, 2006 5:14 pm Post subject: |
|
|
Sheepdogj15 wrote: |
i thought the "major=0" was required. i don't know if you can put that option in kernel-2.6. but alternatively you can put the command into /etc/conf.d/local.start:
Code: | modprobe kqemu major=0 |
this will cause the command to be run towards the end of boot time.
|
You can have 'kqemu major=0' in kernel-2.6...it works fine. using it in my setup right now. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|