Limiting CPU speed in a virtual machine?

29

8

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.

RCC

Posted 2011-04-01T13:51:15.760

Reputation: 291

Answers

21

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.

Seif

Posted 2011-04-01T13:51:15.760

Reputation: 211

9

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.

LeoB

Posted 2011-04-01T13:51:15.760

Reputation: 653

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 – 2011-04-01T14:56:49.350

6ESXi is free. (and a few more characters...) – Tarnay Kálmán – 2011-04-01T16:04:48.840

Really? For some reason I did not think it was. But I stand corrected! Thanks very much for pointing that out. – RCC – 2011-04-01T19:55:08.033

6

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

Nicolas Modrzyk

Posted 2011-04-01T13:51:15.760

Reputation: 391

2

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.

Knox

Posted 2011-04-01T13:51:15.760

Reputation: 1 168

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 – 2011-04-01T14:54:32.270

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 – 2011-04-01T16:52:07.130

2

--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.

Oh Nah

Posted 2011-04-01T13:51:15.760

Reputation: 21

1More information would make this answer acceptable. – Ramhound – 2014-10-07T18:42:15.447

1

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."

n0pe

Posted 2011-04-01T13:51:15.760

Reputation: 14 506

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 – 2011-04-01T14:50:57.653

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. – n0pe – 2011-04-01T14:56:08.933

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 – 2011-04-01T15:02:18.783

I'm pretty sure you have to be running in the guest OS – n0pe – 2011-04-01T15:39:51.457

1

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.

BillThor

Posted 2011-04-01T13:51:15.760

Reputation: 9 384

0

On VirtualBOX there is a slider where you can configure the % of host CPU that guest CPU can use. Such percent applies to each core.

On VirtualBOX there is no way to simulate a multi-core with diffrent speeds on each core, only one slider for all cores.

Setting the slider at 50% will make guest cores to run at 1/2 of host cores (a per core basics).

So if you have a deca core (10 cores) on host and a tri core on guest (three), and you want guest run at X MHz while host runs at Y MHz, just ignore the number of cores to calculate the percent.

The formula would be: Percent=100*X/Y

Hope this also helps other people comming here on the future.

Laura

Posted 2011-04-01T13:51:15.760

Reputation: 1