Welcome to MSDN Blogs Sign in | Join | Help

Processor topology inside of Hyper-V virtual machines

A number of people have noticed that they can create a virtual machine with four virtual processors, and then successfully run Windows XP on it and have it utilize all four virtual processors.  This strikes them as odd, because Windows XP supposedly only supports the use of one or two processors in a computer.

To understand what is happening we need to talk about processor topology.

A long time ago, the universe used to be quite simple.  When you talked about a processor you meant a physical chip that you put inside a computer that was capable of handling one stream of execution.  Then along came concepts such as hyper-threading and multi-core processors.  These technologies allow a single physical processor to handle multiple streams of execution, and effectively appear like multiple physical processors.

In this new world, in order to differentiate between the physical chip that you put in a computer and a single stream of execution on the chip, we use the terms "package", "socket" or "physical processor" to refer to the actual physical chip that you put inside the computer,  and the term "logical processor" to refer to a single stream of execution on the chip.

"Processor topology" is simply the ratio, and nature, of logical processors to physical processors in a computer.

This all gets interesting when it comes to the question of how virtual processors are represented inside of a virtual machine.

When hyper-threading and multi-core processors first came onto the scene, Microsoft made the decision to license all of its software based on the number of physical processors [and not logical processors] in a system.  This means that when you try to create a "four processor" virtual machine the way in which we represent those four processors can affect how the software that runs inside the virtual machine will need to be licensed.

Obviously, as Microsoft, we do not want you to be able to run software that utilizes more processing power than you are correctly licensed to use.  On the flip side, we understand that you do not want to have to pay more for your software than you actually need to. 

To this end, Hyper-V examines the processor topology of your physical computer and exposes that into the virtual machine.

Thus, a virtual machine with four virtual processors that is running on a physical computer with a single quad-core physical processor will appear to only have a single physical processor with four logical processors.  The same virtual machine running on a system using two dual-core physical processors would appear to have two physical processors with four logical processors [two logical processors per physical processor].

And this is what allows Windows XP to run on your "four virtual processor" virtual machine and utilize all of the virtual processors, because it is still within its licensing right of one or two physical processors, if you are running on a hyper-threaded or multi-core system.

Cheers,
Ben

UPDATE: To help visualize this, below is a table that shows you the processor topology that will be reported inside the virtual machine, given the processor topology of the physical computer and the number of virtual processors configured for the virtual machine.

# Virtual Processors / Physical Processor Topology 1 Virtual Processor 2 Virtual Processors 4 Virtual Processors
4 single-core processors 1 single-core processor 2 single-core processors 4 single-core processors
2 dual-core processors 1 single-core processor 1 dual-core processor 2 dual-core processors
1 quad-core processor 1 single-core processor 1 dual-core processor 1 quad-core processor

Hyper-V Clustering without shared storage

Jose has a great post over on his blog that talks about how to setup a Hyper-V cluster using a file share instead of traditional shared storage:

http://blogs.technet.com/josebda/archive/2008/07/16/failover-clustering-for-hyper-v-with-file-server-storage.aspx

This is especially handy for anyone who wants to try their hand at clustering without investing in the hardware - as you can do this with three standard physical computers.

Cheers,
Ben

Posted by Virtual PC Guy | 1 Comments
Filed under:

Confusion over Multi-Processor Guest OS Support with Hyper-V

After posting a link to our supported guest operating system list (http://support.microsoft.com/kb/954958/en-us) I have received a number of queries about the issue of multi-processor support.  You see, while we state that we only support Windows Server 2003 with up to virtual processors, and Windows Vista / XP with a single virtual processor - multiple people have let me know that they are running these operating systems with greater numbers of virtual processors, and are seeing no problems.

This is not surprising.

We have no idea what operating system you are going to run inside a virtual machine, and allow you to configure up to 4 virtual processors for any operating system you want.

The point of the support statement above is that these are the configurations that we have specifically tested, and will officially support.

Case in point - if you configure a Windows Server 2003 virtual machine with 4 virtual processors it will appear to correctly identify and utilize all 4 virtual processors.  However, as we have not formally tested this configuration and do not support it, if you encountered an issue while running in the configuration and needed to contact Microsoft product support - you would be asked to reproduce the problem with only 2 virtual processors first.

To summarize:

  • If you are running production / critical workloads - please stick to the supported list of operating systems / number of virtual processors.
  • If you are just playing around - feel free to try running greater than the officially supported number of virtual processors, but don't get mad at me if things blow up / fail in mysterious ways.

Cheers,
Ben

Posted by Virtual PC Guy | 4 Comments
Filed under:

PowerShell Management Library for Hyper-V

James O'Neill posts here: http://hypervoria.com/hyper-v/hyper-v-powershell-library-now-on-codeplex.aspx to let us know that he has provided a PowerShell Management Library for Hyper-V available here: http://www.codeplex.com/PSHyperv

Cheers,
Ben

Hyper-V RTM now on Windows Update!

So now updating to the final release is easier than ever. Hurray!

Cheers,
Ben

Posted by Virtual PC Guy | 2 Comments
Filed under:

Hyper-V: Supported Guest Operating Systems

In case you missed this one, with the RTM of Hyper-V we expanded the list of supported guest operating systems.  You can see the full official list here:

http://support.microsoft.com/kb/954958/en-us

Cheers,
Ben

Posted by Virtual PC Guy | 3 Comments
Filed under:

Ronald Beekelaar on Hyper-V

There is a great post today on the team blog where Ronald Beekelaar, Microsoft Virtualization MVP, talks about Hyper-V.  Read more here: http://blogs.technet.com/virtualization/archive/2008/07/01/Top-5-things-to-know-about-Hyper_2D00_V.aspx

Cheers,
Ben

Posted by Virtual PC Guy | 0 Comments
Filed under:

Hyper-V RTM!

Okay - this is going to be a short post as I am off to party for the rest of the day.

Hyper-V has RTM'd!

Press release here: http://www.microsoft.com/presspass/features/2008/jun08/06-26hyperv.mspx

John Howard has install directions here: http://blogs.technet.com/jhoward/archive/2008/06/26/hyper-v-rtm-announcement-available-today-from-the-microsoft-download-centre.aspx

And my favorite - QLogic reports getting up to 180,000 IOPs at 88 - 97% native performance on Hyper-V RTM:

http://ir.qlogic.com/phoenix.zhtml?c=85695&p=irol-newsArticle&ID=1169854&highlight=

Cheers,
Ben

Posted by Virtual PC Guy | 5 Comments
Filed under:

Whitepaper: Hyper-V and BitLocker

There is a new whitepaper on how to use BitLocker with Hyper-V for securing Hyper-V server installations.  This is great for branch office / other situations where there is a potential physical security issue.  Read more here:

http://www.microsoft.com/downloads/details.aspx?FamilyID=2c3c0615-baf4-4a9c-b613-3fda14e84545&DisplayLang=en

Cheers,
Ben

Posted by Virtual PC Guy | 2 Comments
Filed under:

Hyper-V: Storing VHDs on network shares

Jose has done a great post on how to store VHDs on network shares when using Hyper-V.  Go check it out here: http://blogs.technet.com/josebda/archive/2008/06/24/storing-windows-server-2008-hyper-v-files-on-an-cifs-smb-file-share.aspx

Cheers,
Ben

Posted by Virtual PC Guy | 2 Comments
Filed under:

Hyper-V Sidebar Gadget

Tore Lervik has made a great little Hyper-V Sidebar Gadget available on his website: http://mindre.net/post/Hyper-V-Monitor-Gadget-for-Windows-Sidebar.aspx

This gadget allows you to see the status of virtual machines on multiple servers "at a glance" and to quickly connect to them with the Virtual Machine Connection program.

I have this installed on my computer now - and find it very useful.  So go check it out!

Cheers,
Ben

Posted by Virtual PC Guy | 1 Comments
Filed under:

Updated VHDs Available

There are a couple of interesting VHD updates that have recently come out:

Cheers,
Ben

Hyper-V Script: Compact VHD

Continuing on with my walk through the storage WMI API - here are some scripts for compacting VHDs with Hyper-V.  Note that Hyper-V allows you to compact both differencing and dynamically expanding virtual hard disks.

PowerShell:

# Prompt for the Hyper-V Server to use
$HyperVServer = Read-Host "Specify the Hyper-V Server to use (enter '.' for the local computer)"
 
# Get name for VHD
$VHDName = Read-Host "Specify the name of the virtual had disk to compact"
 
# Get the Msvm_ImageManagementService object
$ImageManagementService = gwmi Msvm_ImageManagementService -namespace "root\virtualization" -computername $HyperVServer
 
# Compact the VHD
$result = $ImageManagementService.CompactVirtualHardDisk($VHDName)
 
#Return success if the return value is "0"
if ($Result.ReturnValue -eq 0)
   {write-host "The virtual hard disk has been compacted."} 
 
#If the return value is not "0" or "4096" then the operation failed
ElseIf ($Result.ReturnValue -ne 4096)
   {write-host "The virtual hard disk has not been compacted.  Error value:" $Result.ReturnValue}
 
  Else
   {#Get the job object
    $job=[WMI]$Result.job
 
    #Provide updates if the jobstate is "3" (starting) or "4" (running)
    while ($job.JobState -eq 3 -or $job.JobState -eq 4)
      {write-host "Compacting. "$job.PercentComplete "% complete"
       start-sleep 1
 
       #Refresh the job object
       $job=[WMI]$Result.job}
 
     #A jobstate of "7" means success
    if ($job.JobState -eq 7)
       {write-host "The virtual hard disk has been compacted."}
      Else
       {write-host "The virtual hard disk has not been compacted."
        write-host "ErrorCode:" $job.ErrorCode
        write-host "ErrorDescription" $job.ErrorDescription}
   }

VBScript:

Option Explicit
 
Dim HyperVServer
Dim VHDName
Dim WMIService
Dim Msvm_ImageManagementService
Dim Result
Dim Job
Dim InParam
Dim OutParam
 
'Prompt for the Hyper-V Server to use
HyperVServer = InputBox("Specify the Hyper-V Server to create the virtual machine on:")
 
'Get name for VHD
VHDName = InputBox("Specify the name of the virtual had disk to compact:")
 
'Get an instance of the WMI Service in the virtualization namespace.
Set WMIService = GetObject("winmgmts:\\" & HyperVServer & "\root\virtualization")
 
'Get the Msvm_ImageManagementService object
Set Msvm_ImageManagementService = WMIService.ExecQuery("SELECT * FROM Msvm_ImageManagementService").ItemIndex(0)
 
'Setup the input parameter list
Set InParam = Msvm_ImageManagementService.Methods_("CompactVirtualHardDisk").InParameters.SpawnInstance_()
InParam.Path = VHDName 
 
'Execute the method and store the results in OutParam
Set OutParam = Msvm_ImageManagementService.ExecMethod_("CompactVirtualHardDisk", InParam) 
 
'Check to see if the job completed synchronously
if (OutParam.ReturnValue = 0) then
   Wscript.Echo "The virtual hard disk has been compacted."
elseif (OutParam.ReturnValue <> 4096) then
   Wscript.Echo "The virtual hard disk has not been compacted."
else   
 
   'Get the job object
   set Job = WMIService.Get(OutParam.Job)
 
    'Wait for the job to complete (3 == starting, 4 == running)
   while (Job.JobState = 3) or (Job.JobState = 4)
      Wscript.Echo "Compacting. " & Job.PercentComplete & "% complete"
      WScript.Sleep(1000)
 
      'Refresh the job object
      set Job = WMIService.Get(OutParam.Job)
   Wend
 
   'Provide details if the job fails (7 == complete)
   if (Job.JobState <> 7) then
      Wscript.Echo "The virtual hard disk has not been compacted."
      Wscript.Echo "ErrorCode:" & Job.ErrorCode
      Wscript.Echo "ErrorDescription:" & Job.ErrorDescription
   else
      Wscript.Echo "The virtual hard disk has been compacted."
   end If
end if
Cheers,
Ben

SCVMM 2008 Beta Update for Hyper-V RC1

An update for the System Center Virtual Machine Manager 2008 beta, which adds support for managing Hyper-V RC1, is now available.  You can grab it now from http://connect.microsoft.com (if you are not already signed up for the SCVMM 2008 beta - you will need to do so).

Cheers,
Ben

Posted by Virtual PC Guy | 2 Comments
Filed under:

Hyper-V Script: Validate VHD

Hyper-V provides a handy scripting interface that allows you to validate a virtual hard disk.  You can use this for two main purposes:

  1. To confirm that a standard VHD file is correctly structured and not corrupted.
  2. To confirm that a differencing disk has all of its parent disks present.

Here is a sample PoweShell script:

# Prompt for the Hyper-V Server to use
$HyperVServer = Read-Host "Specify the Hyper-V Server to use (enter '.' for the local computer)"
 
# Get name for VHD
$VHDName = Read-Host "Specify the name of the virtual had disk to validate"
 
# Get the Msvm_ImageManagementService object
$ImageManagementService = gwmi Msvm_ImageManagementService -namespace "root\virtualization" -computername $HyperVServer
 
# Validate the VHD
$result = $ImageManagementService.ValidateVirtualHardDisk($VHDName)
 
#Return success if the return value is "0"
if ($Result.ReturnValue -eq 0)
   {write-host "The virtual hard disk is valid."} 
 
#If the return value is not "0" or "4096" then the operation failed
ElseIf ($Result.ReturnValue -ne 4096)
   {write-host "The virtual hard disk is not valid.  Error value:" $Result.ReturnValue}
 
  Else
   {#Get the job object
    $job=[WMI]$Result.job
 
    #Provide updates if the jobstate is "3" (starting) or "4" (running)
    while ($job.JobState -eq 3 -or $job.JobState -eq 4)
      {write-host "Validating. "$job.PercentComplete "% complete"
       start-sleep 1
 
       #Refresh the job object
       $job=[WMI]$Result.job}
 
     #A jobstate of "7" means success
    if ($job.JobState -eq 7)
       {write-host "The virtual hard disk is valid."}
      Else
       {write-host "The virtual hard disk is not valid."
        write-host "ErrorCode:" $job.ErrorCode
        write-host "ErrorDescription" $job.ErrorDescription}
   }

And a VBScript sample:

Option Explicit
 
Dim HyperVServer
Dim VHDName
Dim WMIService
Dim Msvm_ImageManagementService
Dim Result
Dim Job
Dim InParam
Dim OutParam
 
'Prompt for the Hyper-V Server to use
HyperVServer = InputBox("Specify the Hyper-V Server to create the virtual machine on:")
 
'Get name for VHD
VHDName = InputBox("Specify the name of the virtual had disk to validate:")
 
'Get an instance of the WMI Service in the virtualization namespace.
Set WMIService = GetObject("winmgmts:\\" & HyperVServer & "\root\virtualization")
 
'Get the Msvm_ImageManagementService object
Set Msvm_ImageManagementService = WMIService.ExecQuery("SELECT * FROM Msvm_ImageManagementService").ItemIndex(0)
 
'Setup the input parameter list