Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Does anyone know of a way to limit the CPU speed in a virtual machine? Or if there is even a virtualization software that allows you to do this?

I am trying to find the minimum requirements for a system, given a specific OS image that I have. I see ways to limit RAM and hard disk size and number of cores, but I need to slow the CPU down to 800 MHz in order to really simulate the system configuration. Also, the computer running the virtual machine is a Windows 7 machine.

share|improve this question

migrated from stackoverflow.com Apr 1 '11 at 13:54

This question came from our site for professional and enthusiast programmers.

7 Answers 7

On VMWare ESX and ESXi you can create a Resource Pool and limit the CPU Resources for that pool. This would allow you limit the CPU speed of any systems created in that Resource Pool.

share|improve this answer
    
I read about the resource pool option, and thought it applied to player. Sadly, this is not the case. And ESX/ESxi are not free... But I might try the trial and if it actually works, look into it some more. –  RCC Apr 1 '11 at 14:56
5  
ESXi is free. (and a few more characters...) –  Tarnay Kálmán Apr 1 '11 at 16:04
    
Really? For some reason I did not think it was. But I stand corrected! Thanks very much for pointing that out. –  RCC Apr 1 '11 at 19:55

I have been tasked with the same problem and I installed Oracle VirtualBox on Windows 7 (as host) and Ubuntu (as guest). I used a standalone laptop, HP EliteBook 8540W with Intl Core i7 running at 1.87 GigHZ and 8Gig RAM.

Assuming your installation works properly, on your Guest machine (e.g. in my case, Ubuntu) select "Settings..." from "Machine" in the main menu; select "System" and click on "Processor" tab. You can adjust the clock speed (labeled, "Execution Cap") by sliding the indicator on the bar all the way down to 1 percent.

I assumed that the host OS (Windows 7 in my case) was not consuming any clock cycles (I confirmed this by checking the "Task Manager" and I found ZERO CPU utilization on the host machine .i.e. windows 7 in my case). Therefore, I asuumed 100% "execution cap" equals that of host machine (e.g. 1.87 GigHZ). I think by taking a percentage between your host machine clock speed and 800 MHZ, you are able to figure out the percentage value that corresponds to 800 MHZ.

I hope this helps.

Best of luck.

share|improve this answer

Compiled and used: cpulimit which worked like a charm to slow the VM down.

share|improve this answer

While I'm no expert on all the different virtualizations technologies, I think it's unlikely you'll find such a setting. However, you'll find settings (at least in MS hyper-V) that allow you to limit a virtual machine to a percent of the overall host machines actions. So if you have a 8 core host running at 2 GHz, you could try limiting the client virtual machine to one core, and no more than 45% of the core.

However, this would be very crude and not suitable if you're trying to test timing loops or something where the actual processor speed comes into play.

share|improve this answer
    
I saw a couple programs that do that - namely limit the percent of CPU usage per process - but had only seen Linux options. Granted, I have not looked much into them. If the solution I am trying as described in my response to MaxMackie does not work, I will look into these options further. –  RCC Apr 1 '11 at 14:54
    
Yeah, this could have a real bad effect on timing loops. It all depends on if it runs full speed up to 45% then cuts out, or if it tries to actually run at 45%. –  Zan Lynx Apr 1 '11 at 16:52

I can confirm that this is not supported in VirtualBox. However, the documentation seems to be iffy on whether or not VMware is able to do this.

EDIT: For VMware: "This is not possible with the Player and Server products, but I believe it is in the ESXi (the free "bare-metal hypervisor" product) and the paid-for products like VMWare Workstation."

share|improve this answer
    
I can confirm that as well - I set everything up on VirtualBox then discovered that. I am currently using VMware and have tried modifying the config.ini file to limit the host.cpukHz to 800000. This appears to spoof the virtual machine into thinking the CPU MHz is 800. I am not sure if this will actually do what I want it to, but that's what I'm hoping. Ideas? –  RCC Apr 1 '11 at 14:50
    
From what I've seen that should work. Just make sure you set host.noTSC = "TRUE" in that same config file. This regulates the CPU clock to make sure it doesn't slow down. Also, in the guest operating system, go to the Options tab and ensure that Time synchronization between the virtual machine and the host operating system is selected. –  MaxMackie Apr 1 '11 at 14:56
    
Yes, I have host.noTSc = "TRUE" as well. I have not been able to find where to enable time syncing between the vm and the host in vmware player though... –  RCC Apr 1 '11 at 15:02
    
I'm pretty sure you have to be running in the guest OS –  MaxMackie Apr 1 '11 at 15:39

You might be able to simulate this with CPU pinning. Then create some CPU bound processes pinned to the same CPU. Estimated CPU speed is (Real CPU speed / # of processes).

Some resource limiting software will allow you to limit resource percentages. This would make it easier to limit CPU speed. To do so you need to disable access to spare resources.

share|improve this answer

--cpuexecutioncap <1-100>: This setting controls how much cpu time a virtual CPU can use. A value of 50 implies a single virtual CPU can use up to 50% of a single host CPU.

share|improve this answer
    
More information would make this answer acceptable. –  Ramhound Oct 7 at 18:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.