Freigeben über


Virtual System Management Services

Introduction

Msvm_VirtualSystemManagementService is a WMI object that Hyper-V uses to perform Virtual System Management related operations. The service codes are implemented in vmms.exe which is in %windows%\system32 directory. Hyper-V Manager UI also uses these WMI operations to perform VM management operations. I will briefly describe what these methods are designed for and map them against Hyper-V Manager UI. Hopefully this will help us to have a top level view of these methods.

There are 24 methods defined in VMMS. I will group them into the following 9 categories:

 

VM Operation

 

As the method names indicated, these three methods allow us to create, delete and modify a VM. Creating a VM is the first thing that we need to do when we working with Hyper-V. Destroy method will delete a VM that is no longer needed. Modify method will change the property values that are defined in Msvm_VirtualSystemSettingData and Msvm_VirtualSystemGlobalSettingData.

 

(Diagram 1)

 

VM Resource Operation

 

When a VM is created, certain virtual devices are added by default, such as virtual processor, virtual memory, virtual motherboard, virtual keyboard, etc. It’s just like when you purchase a physical bare bone machine; the system comes with CPU, motherboard, etc. There are additional components that you can add, remove and modify once a VM is created. The good news is that you don’t pay for them; but you need to understand these resource operation methods to manage them.

Most resource management related operations require the virtual machine in a stop state. There are few exceptions, such as attaché an ISO image, remap network connection, etc.

From Hyper-V UI, these operations are performed through the Settings dialog box:

 

(Diagram 2)

 

Snapshots

 

One of benefits of a virtual machine is that it allows you to go back to a point of time in the past. The concept is difference from the Last Known Good in Windows. The Last Know Good can only bring the operating system back to a state that was working last time. It restores the operating system related system objects, such as Registry Key, system files, device configurations, etc.

We can snapshot a VM as long as it’s not in critical error state. By default, snapshot data are stored at: %systemdrive%\ProgramData\Microsoft\Windows\Hyper-V\Snapshots. The directory contains all the snapshots of this host machine.

 

(Diagram 3)

Import and Export

 

In the traditional physical machine world, it’s almost impossible to move an operating system on a physical machine A to a machine B. If machine A is having hardware issues, machine B needs to have a complete identical set of software to keep the business apps running.

With Hyper-V import and export, moving a virtual machine is as simple as mouse button clicks. Unlike snapshot, ExportVirtualSystem will make a copy of the entire virtual machine, include its snapshots. The export directory can be found at: %ExportDirectoryYouSpecified%\[VM ElementName].

In the following diagram 4, I specified my export directory as “C:\exports” for WinX64. My exported data was put into c:\exports\WinX64 directory.

 

(Diagram 4)

 

Kvp Items

 

Kvp exchange items allow the communications between the host and guests. AddKvpItems method will add a registry key pair into client registry at: HKEY_LOCAL_MACHINE\SOFTWARE\Micrsoft\Virtual Machine\External. The added registry key can only have REG_SZ type.

Guest can read the values that was added by the host and perform based on the actions that host has requested.

Guest can also add registry key values that can be retrieved by host from Msvm_KvpExchangeComponents object.

As you may have noticed, there are predefined values on guest HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Virtual Machine\Auto. “Getting the Virtual System DNS Name” sample on MSDN (https://msdn.microsoft.com/en-us/library/cc723870(VS.85).aspx) demonstrated how FullyQualifiedDomainName registry key value was retrieved from host.

Of course, the Kvp IC components need to be installed on the guest for the Kvp exchange items working properly.

These methods are not used by Hyper-V Manager UI.

Service Settings

 

ModifyServiceSettings method can modify the values that are defined in Msvm_VirtualSystemManagementSeviceSettingData. For example, we can call this method to change the default location for our Virtual Hard Disk; or we can change the default location of our VM configuration files.

 

(Diagram 5)

 

 

(Diagram 6)

 

VM Info

 

As method name indicated, GetSummaryInformation is a method that allows us to retrieve commonly used VM information with integer values. Otherwise, we have to traverse these information pieces that are stored in different objects by ourselves. It has much better performance than we query each object separately.

 

(Diagram 7)

 

One thing that you may be wondering, GetSummaryInformation already can retrieve the thumbnail image with the following values, why do we need GetVirtualSystemThumbnailImage method?

Small Thumbnail Image (80x60)

5

Medium Thumbnail Image (160x120)

6

Large Thumbnail Image (320x240)

7

 

GetSummaryInformation only retrieve fix size Thumbnails. GetVirtualSystemThumbnailImage allow us to get a thumbnail image by specifying width and height. It becomes really handy if we want to get a full screen shot of a VM.

 

(Diagram 8)

 

Unsupported Methods

 

These methods were inherited from their ancestor schema definitions. VMMS service can’t be started or stopped with StartService or StopService methods. VMMS service can only be started and stopped through Service Control Manager. For example, “net stop vmms”, “net start vmms” commands at DOS prompt with administrators privileges will stop and start VMMS service.

All these three methods will return 1 in their “ReturnValue”, which means “Unsupported Methods”.

 

Unimplemented Methods

 

These methods are defined in the Msvm_VirtualSystemManagementService, but there are no implementations for these methods. These probably are the optional methods from DMTF that don’t match with our product features.

Comments

  • Anonymous
    January 01, 2003
    Please check out the MSDN samples at: http://msdn.microsoft.com/en-us/library/cc136977(VS.85).aspx

  • Anonymous
    November 24, 2008
    Howard Thanks much for writing details explanation on Hyper-V WMI.I read yoru blog with great interest! One quick question: Do you have any examples of calling the method TearDownSwitch of Msvm_VirtualSwitchmanagementService? I can't find any working example of this Thanks! /Dung

  • Anonymous
    January 09, 2009
    This is a fabulous post.  Thank you for taking the time to do this. A quick question for you.  Is it possible to set the boot time of a child partition (similar to what was done in VS with the <time_bytes> node) programmatically in Hyper-V?  I've got some demos with expiring certs that I'd like to show while travelling.  One of the demos requires a reboot. Any notions on where to start? Thanks again, -Mezzrow