page hit counter
Welcome to MSDN Blogs Sign in | Join | Help

Taylor Brown's Blog

Test Lead for Windows Core OS Division on the Hyper-V Team.

Syndication

News

Welcome to the professional blog of Taylor Brown.  I am a test lead on the core virtualization team (Hyper-V) at Microsoft.

This blog will contain information about virtualization, Microsoft, Hyper-V, operating systems, testing, and whatever else I end up talking about...

 

Standard Microsoft Disclaimer:
"This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use."

-Taylor Brown


Hyper-V WMI: KVP Exchange aka Data Exchange (Adding New Items From Parent/Host)

I have gotten a ton of questions about the KVP Exchange or Data Exchange Integration Component…  So what is it and how do I use it?  The KVP Integration component allows the guest and host to query and provide information to each via pairs of Key’s and Value’s. The KVP integration component provides some basic Key’s and Value’s for you, I talked about the host accessible ones in a previous post Hyper-V WMI Using PowerShell Scripts – Part 3 (KVP's - Guest OS Version) these include things like the fully qualified name, OS version, Processor Architecture etc…  There are also some guest accessible values that provide some information on the parent (host) such as HostName, PhysicalHostName, PhysicalHostNameFullyQualified, and VirtualMachineName.  These values are located in registry under “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters”.  The other thing you can do via the KVP is write registry key’s from the parent (host) and read guest provided registry key’s from the parent (host).  Today I am going to show how to write key’s from the parent into the guest.

Add-KVP.ps1 Script

The AddKvpItems method returns a WMI Job Object see Hyper-V WMI- Rich Error Messages for Non-Zero ReturnValue (no more 32773, 32768, 32700…) for very helpful method to provide rich error messages.

$ComputerName = "localhost"

$VMManagementService = Get-WmiObject -class "Msvm_VirtualSystemManagementService" -namespace "root\virtualization" -ComputerName $ComputerName
$Vm = Get-WmiObject -Namespace root\virtualization -ComputerName $ComputerName -Query "Select * From Msvm_ComputerSystem Where ElementName='Vista'"
$Kvp = Get-WmiObject -Namespace root\virtualization -ComputerName $ComputerName -Query "Associators of {$Vm} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent"

$Msvm_KvpExchangeDataItemPath = "\\$ComputerName\root\virtualization:Msvm_KvpExchangeDataItem"
$Msvm_KvpExchangeDateItem = ([WmiClass]$Msvm_KvpExchangeDataItemPath).CreateInstance()
$Msvm_KvpExchangeDateItem.Name = "Test4"
$Msvm_KvpExchangeDateItem.Data = "Testing"
$Msvm_KvpExchangeDateItem.Source = 0

$VMManagementService.AddKvpItems($Vm, $Msvm_KvpExchangeDateItem.PSBase.GetText(1))

And as you can see I have a new registry entry… (btw 64bit Vista SHWEEET!)

clip_image001

 

 

Taylor Brown
Hyper-V Integration Test Lead
http://blogs.msdn.com/taylorb

clip_image001

Published Sunday, July 06, 2008 3:35 PM by taylorb

Filed under: , ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# a-foton » Hyper-V WMI: KVP Exchange aka Data Exchange (Adding New Items From Parent/Host) @ Sunday, July 06, 2008 6:57 PM

PingBack from http://blog.a-foton.ru/2008/07/hyper-v-wmi-kvp-exchange-aka-data-exchange-adding-new-items-from-parenthost/

a-foton » Hyper-V WMI: KVP Exchange aka Data Exchange (Adding New Items From Parent/Host)

# re: Hyper-V WMI: KVP Exchange aka Data Exchange (Adding New Items From Parent/Host) @ Thursday, July 10, 2008 10:50 PM

It is strange that I am able to get this to work intermittently.  It seems that it will work once, but then not work for a while, and then start working again.

Do you have any C#, or VBScript examples that do the same thing?

thanks,

Geoff  

Geoff Nordli

# re: Hyper-V WMI: KVP Exchange aka Data Exchange (Adding New Items From Parent/Host) @ Thursday, July 17, 2008 6:09 AM

Hi Mr. Taylor,

I have not tried this yet. But, considering that this works, is there a way in which I can do the same data exchange with linux guests?

I want to exchange data with windows and linux guests launched on a hyper v server. Please help me with this.

- Anil

Anil

# re: Hyper-V WMI: KVP Exchange aka Data Exchange (Adding New Items From Parent/Host) @ Thursday, July 24, 2008 10:11 AM

Taylor, this sounds sort of scary -- if the parent can modify any Registry value in the child VM, that seems to contradict Jeff Woolsey's claims about Hyper-V's security.

Are there limits to what keys can be modified? Is there a list of those limits somewhere?

Many thanks in advance.

Mark Minasi

Mark M

# re: Hyper-V WMI: KVP Exchange aka Data Exchange (Adding New Items From Parent/Host) @ Tuesday, July 29, 2008 12:27 AM

Anil,

Currently there is not a KVP integration component for Linux.  This is something we might consider for future releases.

Mark,

The host can only modify the "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Virtual Machine\Guest\" section in the registry.  And the guest can only provide data to the host via the same registy locaiton.  Additionaly this functionality can be disabled on the host via the Virtual Machine Setting UI.

-Taylor

taylorb

# re: Hyper-V WMI: KVP Exchange aka Data Exchange (Adding New Items From Parent/Host) @ Monday, August 25, 2008 9:02 AM

I have to create many VMs. These virtual machines will be built based on a same VHD. So the OS in these machines have the same computer name. I hope the computer name of these VM machine could be modified. But I don't know how to do it. Could you give me some iedas? Thanks very much.

shache

# re: Hyper-V WMI: KVP Exchange aka Data Exchange (Adding New Items From Parent/Host) @ Wednesday, January 14, 2009 5:14 PM

Thanks for this great info, I wrote some C# to allow you to call these powershell functions from C#.

http://otherchrismartin.com/blog/view.php?entry=44

Chris Martin

Leave a Comment

(required) 
required 
(required) 
Page view tracker