Aug 29 2011

Assigning more than 4 VCPUs to a Hyper-V virtual machine

Category: IT&CRpx @ 18:26

Users of Microsoft’s Hyper-V virtualization system have been forever plagued by one tiny yet incredibly annoying issue. You cannot assign more than 4 logical processors to a single virtual machine. This is supposed to go away with the next version of Hyper-V which will be available with the server version of Windows 8, but what to do until then?

Well, the obvious thing to do is try to hack that value somehow and guess what… you can actually do it.

Hyper-V keeps the virtual machine settings in XML files and those files can be manually modified to change that value. However, there’s a catch or two…

  • The virtual machine for which you want to change the CPU allocation must be stopped when modifying this value;
  • The Hyper-V Virtual Machine Management Service (vmms) must be stopped when modifying this value;

For convenience, here’s a PowerShell script I’ve written to do this. Note that if the virtual machine is running when executing it, the change will obviously be effective only after the machine has been restarted.

In order to change the allocation for a certain VM, let’s say “foo” to 8 logical processors, follow these steps:

  • Open the script with a text editor;
  • Change the $VMname variable to “foo”  and $VCPUs to 8;
  • Start a PowerShell console as the Administrator (running it as a normal user will not work);
  • Execute the script.

It should give this kind of output:

PS C:\Windows\system32> S:\Scripts\Hyper-V-change-vcpus-2.ps1
Current CPU Count:  4
New CPU Count:  8
Please wait… Do not stop execution and ignore possible warnings about VMMS stopping; they are intended.
WARNING: Waiting for service ‘Hyper-V Virtual Machine Management (vmms)’ to finish stopping…
WARNING: Waiting for service ‘Hyper-V Virtual Machine Management (vmms)’ to finish stopping…
WARNING: Waiting for service ‘Hyper-V Virtual Machine Management (vmms)’ to finish stopping…
Done!

NB: Stopping the VMMS service will not disrupt the virtual machines (suspend or stop them). It will only temporarily stop the management service which is used to access the GUI of Hyper-V.

Tags: , ,

Leave a Reply