-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
WmiDocumentation.txt
145 lines (100 loc) · 5.23 KB
/
WmiDocumentation.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
The Windows Guest WMI Interface
===============================
The Windows Guest WMI interface is intended to replace as the mechanism of
choice for communicating with xenstore (and other hypervisor interfaces). It
is provided by the device driver xeniface.sys, which forms part of the Windows PV
Drivers. Access to this interface is available to those users which have been
granted to the root\wmi namespace - which is to say the device driver namespace.
By default this is administrators only.
The WMI Interface provides a base singleton object which can be used to generate
individual session objects. These session objects represent individual applications
(or functions of an application), and are the objects used to interact with
xenstore - to read write, set and unset watches. Sessions may also take advantage
of the transaction semantics to ensure atomicity of xenstore operations.
The lifetime of watches and transactions are limited by the lifetime of the session
object which creates them.
For branding purposes an object name PREFIX can be set at build time using the
OBJECT_PREFIX environment variable.
On driverload, one object is made available via WMI:
<PREFIX>XenStoreBase
A singleton object representing xenstore
Properties:
Uint64 XenTime:
LocalTime as set by windows for the VM, and then adjusted by the
Hypervisor's clock.
Methods:
AddSession(String Id) returns SessionId:
Add a <PREFIX>XenStoreSession object to the WMI namespace
The returned value (session id) is a unique value whcih can be used to
identify the session which has been created (in case multiple sessions
have the same string identifier)
<PREFIX>XenStoreSession
Each instance represents a single session of communication with xenstore
Properties:
String ID:
A string to identify the use of the session, which can be used to
determine if any sessions which have been left open can be closed
Uint32 SessionId:
An integer, unique amongst all sessions. This is the same as the value
returned at the time the session was created with AddSession
Methods:
StartTransaction:
Until the transaction is ended, all activities on this session
occur within a transaction (hence will not affect xenstore until
they are comitted)
CommitTransaction:
Attempt to commit the current session's transaction. If this fails,
the transaction has not succeded, and may need to be retried.
EndTransaction:
Cancel the current transaction without committing
GetValue(String Pathname) returns String: return the value stored at
the path PathName in xenStore
GetChildren(String Pathname) returns children{ NoOfChildNodes, string[NoOfChildNodes]ChildNodes}:
For a given node (at PathName), this returns an object containing the
number of child nodes, and an array of strings, where each string
is the full pathname of a child node.
RemoveValue(string PathName):
Removes an entry from xenstore (and, if they exist, all descendent
entries)
SetValue(string Pathname, String value):
set the value at a give pathname to value
Log(string): Outputs a log message to the hypervisor
SetWatch(string pathname):
register your interest in receiving an event when a particular
xenstore entry (at pathname) changes. Note that multiple changes of
the same entry occurring soon after one another may be coalesced
into one WMI event (which will be received after all changes
referenced by the coalesced event occur)
RemoveWatch(string pathname):
indicate you no longer want to receive an event when a particular
xenstore entry (at pathname) changes.
EndSession():
Terminate this session. Remove the session object from the WMI namespace.
All watches and transactions associated with the session will be ended.
About events:
<PREFIX>XenStoreWatchEvent:
Event emitted when a particular xenstore entry has changed. Registering your interest in receiving such an event can be done by calling <PREFIX>XenStoreSession.SetWatch(pathname)
string EventId : The pathname of the xen store value which has changed
<PREFIX>XenStoreUnsuspendedEvent:
Event emitted whenever a vm resumes from being suspended.
Use:
(The following example uses powershell to show how the xenstore wmi
interface can be scripted)
Locate the base object
$base = gwmi -n root\wmi -cl <PREFIX>XenStoreBase
Create a session
$sid = $base.AddSession("MyNewSession")
$session = gwmi -n root\wmi -q "select * from <PREFIX>XenStoreSession where SessionId=$($sid.SessionId)"
Write a value
$session.SetValue("data/TempValue","This is a string")
Read a value
$session.GetValue("data/TempValue").value
Remove a value
$session.RemoveValue("data/TempValue")
Examine Children
$session.GetChildren("data").children
Set Watch
$watch = Register-WMiEvent -n root\wmi -q "select * from <PREFIX>XenStoreWatchEvent where EventId='data/TempValue'" -action {write $session.getvalue("data/TempValue") }
$session.setvalue("data/TempValue","HELLO")
$session.setvalue("data/TempValue","WORLD")
$watch.action.output