Diary and notebook of whatever tech problems are irritating me at the moment.

20080920

Improving Windows XP guest in VMware Player

I use XP in VMware Player to run some CAD applications on my Ubuntu system. I don't actually have to use XP for them as they function under Wine but I've been too busy to reinstall them and recreate their configurations. This setup works more or less but there are a few bugs and performance problems I've had to find workarounds for.

The first thing you need is RAM obviously. XP will function with 256MB of memory allocated to the VM but you'll need more for any app larger than Notepad. The host desktop (Gnome in my case) also needs a lot, how much depends on what native apps you have running. Open up Firefox with a bunch of tabs with Flash, Java, and Acrobat plug-ins active and you can easily use up 1GB total. For the VM you want to allocate enough for your guest applications but not exceeding what the host can provide else what the guest thinks is RAM will be paged out to disk by the host and it gets incredibly slow. If your host is a bit short on RAM then try switching to a lighter desktop like XFCE (Xubuntu), LXDE (Ubuntu Lite), Openbox, or even just xterm. If you're building a new system and plan to use VMs a lot then I recommend getting at least 2GB of RAM.

If you have a lot of memory available then you can improve speed in a XP guest by disabling the paging file. You'll find a lot of web sites warning against this but it's no more risky then running out of both RAM and disk space with the paging file active. If your guest apps use more than whats available then you will get an out of memory error either way, except with a paging file active you will often trash the registry in the process as it can't be written to. To turn it off go to Start > Control Panel > System (or press the logo key + Pause), Advanced > Settings (Performance) > Advanced > Change (Virtual Memory). In the Virtual Memory window select "No paging file", Set, Ok, then apply the setting (in Windows terms "apply" means reboot). Afterwards you may notice that the Windows Task Manager (Ctrl-Alt-Delete or logo key + R and then run taskmgr) will still show PF Usage >0 in the performance tab. Ignore it. I'm not sure if it's including some other non-memory related temporary file usage or is just an estimate but the important thing is that the hidden pagefile.sys in the root of the drive is gone and the setting can be confirmed in the registry.

Because I do a lot of file management from both Nautilus and the VMware guest I set up a shared folder and redirected the Windows special folder "My Documents" to the share. To set up a shared folder in VMware Player you need to manually edit the guest's vmx file. Here is a sample of the entries:

sharedFolder.option = “alwaysEnabled”
sharedFolder0.present = "TRUE"
sharedFolder0.enabled = "TRUE"
sharedFolder0.readAccess = "TRUE"
sharedFolder0.writeAccess = "TRUE"
sharedFolder0.hostPath = "/home/user/vmware/shared"
sharedFolder0.guestName = "shared"
sharedFolder0.expiration = "never"
sharedFolder.maxNum = "1"

You may have to enable it from the Player controls bar under Player > Shared Folders. The shared folders show up as a network location "\\.host\Shared Folders\shared". To set My Documents to this location right-click My Documents > Properties > Target then enter the path in the Target box and move your existing files there if desired. All of your applications should now be able to access the files the same as from the original location. I emphasize "should" as special folder usage in Windows is a Microsoft "suggested" practice that is not enforced by file system permissions. Some apps access the My Documents folder directly by an absolute path like "C:\Documents and Settings\User\My Documents" and they will ignore the target change. It also doesn't affect apps written in the "traditional" DOS programming style with behavior like writing user files to the same directory as the application executable.

This method eliminates having to synchronize files between the guest and host. You could also set up a Samba share on the host or another system and redirect My Documents to that instead but you will need centralized logins between your Linux and Windows systems to prevent permissions problems. One behavior you need to be aware of when using using shared folders is that VMware will often lock the files while the guest is running.

One problem I discovered with shared folders is that there is a long delay in accessing them. I found out the delay is caused by Windows trying to find a system named ".host" on the network and the solution is to define it as local host. Browse to the directory "C:\WINDOWS\system32\drivers\etc". If there is no "lmhosts" file present then copy lmhosts.sam to lmhosts. Edit it with Notepad and add the line "127.0.0.1 .host". Apply it (reboot again) and the delay should be gone.

I'm using a multi-head (non-Xinerama) monitor setup where I can run a VMware guest full screen on one monitor and have the Gnome desktop (or another VMware guest) on the other. One problem that I've encountered is that the Ctrl, Alt, and Shift keys would occasionally stop responding and eventually any Linux app I tried to type into would crash. This is a known bug in VMware and the solution is to run "setxkbmap". Since even a terminal window can crash when the problem is occurring I found it easiest to create a custom application launcher on the Gnome panel so I can just click it with the mouse. The fix is instantaneous and doesn't require VMware to be shut down.

Another oddity with Player on my multi-head system is that if it's running on the secondary monitor and I switch to a VT (Ctrl-Alt-F1, etc.) the vmplayer process disconnects from vmware-vmx process and the guest window is gone when I switch back. It doesn't happen on my primary monitor. If I run Player again it will reconnect to the running VM if I tell it to run the same one again so it's not fatal, just annoying.

I mentioned above about running two VMs at the same time. To save time you can use the same base VM and make duplicates of it for each with some minor modifications. You can also use them on different PCs. Regardless, there are some caveats to running multiple XP VMs simultaneously.

First is licensing. Make sure you have a valid license for each one. It's possible to change the product key after installation which will allow you to re-authenticate with Microsoft if necessary. This will save you from having to perform a reinstall of XP from scratch on each system. One thing to remember about VMware - it doesn't virtualize everything (the host's CPU for instance) and some parameters like the VM's MAC address are unique to each guest. These can be used by Windows Genuine Advantage to identify the system. Changing them can cause a revalidation prompt.

Second, some things must be different with each guest, the VM directory (obviously) and the aforementioned MAC address. The MAC address needs to be different in order for your DHCP server to assign a unique IP address to each one. By default Player uses an auto-generated MAC address which appears to be based on the VM UUID. Copying a VM will result in the same UUID and MAC address. To change it you need to change the UUID or set the MAC address manually in the vmx file, either of which can set off WGA revalidation. VMware also requires a different address range, 00:50:56:00:00:00 - 00:50:56:3F:FF:FF, for static values. Example:

ethernet0.addressType = "static"
ethernet0.Address = "00:50:56:3F:FF:FD"

Another parameter you may want to change is the displayed name of the VM which is shown in the "recently used" VM list in Player:

displayName = "Windows XP Professional - Testing"

On one of my systems Player would start misbehaving some time after installation. The guest VM would operate way too fast which would cause XP to freeze during boot probably due to timing problems with devices between the guest and host. This bug is caused by VMware misidentifying the host's maximum CPU speed due to power management or maybe ACPI problems. Minor timing problems often show up as creeping RTC (real time clock, aka "time of day") errors. The solution is to manually set the speed in "/etc/vmware/config". For a 2.53GHz CPU (cat /proc/cpuinfo):

host.cpukHz = 2530000
host.noTSC = TRUE
ptsc.noTSC = TRUE

There are many other parameters you can tweak in the vmx file. Some I've found usefull are ide1:0.fileName = "/dev/scd0" which had to be changed when IDE device names changed in recent kernels and the various "present" and "startConnected" parameters for specifying the default state of devices.

16 comments:

Blue Rain said...

Is it possible to install AutoCAD in Ubuntu using Wine? If so, which version works well? I've tried installing AutoCAD 2005 under Wine but somehow couldn't get it to work. I'd be grateful if you could help me out and maybe point me to some links which discuss installing AutoCAD under Wine in Linux/Ubuntu.

jhansonxi said...

The semi-official guide is the Wine AppDB. The AutoCad section seems to indicate that older versions are better. Some versions don't have recent reports so things may be better with the current version of Wine (1.1.5). I don't use AutoCad myself as my primary customer still uses AutoSketch for mechanical drawings. I'm primarily a PCB designer and the same customer uses Altium DXP. Generally there are two hurdles to overcome with Wine. The first is installation, the second is operation. Many Windows apps will install but not operate with Wine while others fail to install but will operate if the files are extracted or copied manually into the correct directories.

Unknown said...

Hello jhansonxi !

I "love" vmware - but recently I'm facing an annoying problem

I have a similar problem to the one you mention above, and I hope you might have seen something similar...
It's a new problem for me in the sense that on 4 PCs configured almost the same, only one PC has the problem.

THE problem: is that I can start my vmplayer windoze guest, runs normally and then , for unknown reasons , my input devices jams (keyboard + mouse) - mouse still moves, but I cant move any linux or PC windows. If I wait 15 min, then I can get the control back to unix, and if I move a window on top of my vmplayer, then the vmplayer takes like 5 minutes before re-drawing. In that state, if I click inside my vmplayer, I'll get back to the state where my keyboard and mouse have no effect !!
Quite anoying !

Note, I installed vmtools ...so I dont need to press CTRL-ALT to exit the vm, basically, all the hardware in my guest are vmware devices

so I suspect the problem could be related to this, I'm screwed because I dont know what to look for - and I dont feel like restoring a non-vmtool image !

All my PCs run SUSE linux 10.1, 10.3, 11.0, and the vm guest uses shared folders and vmtools


PC with the problem:

ASUS Quad Core, vmplayer 2.0.4 x86,

PCs that work fine:

Dell Laptop, Core Duo, vmplayer 2.0.4 x86, SUSE Linux 10.3

ASUS P4, vmplayer 2.0.4 32bit SUSE 10.1

DELL Dual P4, vmplayer 2.0.4 32bit SUSE 11.0



For sure I'm going to try your paging file trick and .host trick... cant wait

jhansonxi said...

That seems like a load problem. What is your hard drive doing when this occurs? A busy drive could be a symptom of the VM's "RAM" area being swapped out by the host. Like I mentioned above, don't allocate more memory to the VM than the host has available. The "Change Memory Allocation" window in Player tells you what it estimates to be the maximum available memory. If the PCs are identical and it's only occurring on one then it could be a hardware problem like bad RAM.

jhansonxi said...

Another thing to try is updating to the latest Player, 2.0.5 build-109488. If it's not available from Suse's repos then uninstall it and install the tar version manually.

Unknown said...

When this happens,

My system is idle, almost no disk activity, "top" shows all 4 CPU idling

Note:

My quad core has 2Gig of ram, 512M allocated to windoze vm

as for 2.0.5, my Quad was the only one with 2.0.5 and with the problem, so to remove one parameter to the equation, I reverted back to 2.0.4


Here is more on what I noticed,
vmplayer has somekind of control on the KDE interface, either KDE gets Keyboard+Mouse or VMplayer gets Keyboard+mouse it depends on where the mouse is on the screen
when my machine jams, I have the VM mouse pointer even when outside the VM window
So it's as if VMplayer does not give back the control to KDE

Also, when VM has the control of Mouse+Keyboard, nothing responds, the VM is extreamly slow - and even though I cant go back to unix I can see "top" still running and showing that VMPlayer uses no cpu time...

My next step is painful, but I'm going to restore an old image without VMtools
Thus I'll have to use CTRL+ALT to go back to KDE

I'll let you know what difference it makes - thanks for the answer

Unknown said...

self-Follow-up...

After some tests with vmtools, I found 2 things
1- I installed vmtools a long time ago and just brought my vm from PC to PC and now, if I reinstall the vmtools, I get a warning 25012.setup...detected previous hardware and will not install vlance VMNet
...interesting

2- If I do a

ifdown vmnet1

Before starting my halting vm, then the image is ok
So it seems the problem is related to the network

in my Quad Core PC, I have a wireless DLink and an intel PRO 100
My vm uses no particular hardware emulation - I saw somewhere that I can force a network card emulation

crap... as I writing this, I see that my vm just halted
so it's not network after all
dam-it !

jhansonxi said...

Maybe it's a Suse kernel bug/incompatibility with VMware. I'm using a Phenom 9550 with Ubuntu 8.04 (Hardy Heron) x64 with the x64 version of VMware. It's works fine. I do have an occasional lockup that freezes the entire system but I suspect it's a hardware problem as the original build of this system was very unstable and I ended up sending the MB+CPU+RAM back for replacements.

Unknown said...

Thanks for posting this. I'm going to try your tips on balancing memory between host and guest, disableing paging, and sharing folders. Makes perfect sense to a non tech person, like me.

Unknown said...

It's been a while...

re-follow-up :

I went back to an older image without the shared directories
and it works fine

In my case, I'm pretty sure the root of the problem is my vm image itself, not my version of os, not my version of vmplayer...
probably the shared folders caused a problem in my vm image

I now activate shared folder only when required, I'll do the rest via a samba share

For sure the above tips on removing swap space and adding memory improves performances

enjoy

Unknown said...

Hi Mike,

I have almost exactly the same problem as you on a DELL Optiplex 960 quad core Workstation, running Ubuntu 9.10 and the latest VMware Player, running Windows XP SP3 as the guest VM.

I can actually be doing something outside the VM and suddenly the VM grabs the screen back and the keyboard and mouse stop working. About 5 mins later it gives control back. At the time, the VM should be doing nothing!

I'm considering porting my image to VirtualBox.

Did you ever get to the bottom of this?

jhansonxi said...

I've never encountered that one myself. Maybe it is being triggered by power management in the guest.

Unknown said...

Hello James,

are you using shared folders ?

I started to get this while activating
-shared folders and
-vmtools (which is essential !! )

and unfortunately, I'm not sure how I fixed it, but if I remember correctly, I wend back to a previous vmdk (before installing all this)

and re-installed vmtools only
-> problem solved
then after a few months, I activated shared folders, and it was still ok !!

I think the problem is with the little network trick that vmware uses to share forders tied with a bad installation sequence
because mine works A1 right now

try restarting vmnetworks :
shutdown your vm
# cd /etc/init.d
# ./vmware restart

Also, if ever your control keys becomes unusable in your main system do:
# setxkbmap
(I was so happy when I found this one !! )

Charukant said...

Hi,

I am running Windows XP as VM on VMware player. I have increased memory allocation to my VM from 3GB to 6 GB, but the guest Windows XP is not picking the change. It still shows 3GB in My System properties and task manager.

Can you please help me in rectifing this problem.

Thanks

jhansonxi said...

@K
Check "memsize" in the vmx file. It should be 6144 (6*1024) for 6GB. Make sure VMware actually has that much memory available. You need to use a 64-bit OS with that much RAM (probably XP x64 also).

Elliott Hayes said...

Very useful. Thanks a lot.

About Me

Omnifarious Implementer = I do just about everything. With my usual occupations this means anything an electrical engineer does not feel like doing including PCB design, electronic troubleshooting and repair, part sourcing, inventory control, enclosure machining, label design, PC support, network administration, plant maintenance, janitorial, etc. Non-occupational includes residential plumbing, heating, electrical, farming, automotive and small engine repair. There is plenty more but you get the idea.