aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/hyperv.h
diff options
context:
space:
mode:
authorBjarke Istrup Pedersen <gurligebis@gentoo.org>2014-01-22 04:16:58 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-07 18:18:31 -0500
commit5267cf02c7794953d89e9593a0d497bf43e3790d (patch)
tree177bb2d6533bee863515171fde18e437bb0a13d1 /include/linux/hyperv.h
parente2527ec3690bc820e5b4288577f79945f4a22d77 (diff)
hv: Add hyperv.h to uapi headers
This patch adds the hyperv.h header to the uapi folder, and adds it to the Kbuild file. Doing this enables compiling userspace Hyper-V tools using the installed headers. Version 2: Split UAPI parts into new header, instead of duplicating. Signed-off-by: Bjarke Istrup Pedersen <gurligebis@gentoo.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/hyperv.h')
-rw-r--r--include/linux/hyperv.h321
1 files changed, 2 insertions, 319 deletions
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 15da677478dd..167ef47e3d6e 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -25,325 +25,9 @@
25#ifndef _HYPERV_H 25#ifndef _HYPERV_H
26#define _HYPERV_H 26#define _HYPERV_H
27 27
28#include <linux/types.h> 28#include <uapi/linux/hyperv.h>
29
30/*
31 * Framework version for util services.
32 */
33#define UTIL_FW_MINOR 0
34
35#define UTIL_WS2K8_FW_MAJOR 1
36#define UTIL_WS2K8_FW_VERSION (UTIL_WS2K8_FW_MAJOR << 16 | UTIL_FW_MINOR)
37
38#define UTIL_FW_MAJOR 3
39#define UTIL_FW_VERSION (UTIL_FW_MAJOR << 16 | UTIL_FW_MINOR)
40
41
42/*
43 * Implementation of host controlled snapshot of the guest.
44 */
45
46#define VSS_OP_REGISTER 128
47
48enum hv_vss_op {
49 VSS_OP_CREATE = 0,
50 VSS_OP_DELETE,
51 VSS_OP_HOT_BACKUP,
52 VSS_OP_GET_DM_INFO,
53 VSS_OP_BU_COMPLETE,
54 /*
55 * Following operations are only supported with IC version >= 5.0
56 */
57 VSS_OP_FREEZE, /* Freeze the file systems in the VM */
58 VSS_OP_THAW, /* Unfreeze the file systems */
59 VSS_OP_AUTO_RECOVER,
60 VSS_OP_COUNT /* Number of operations, must be last */
61};
62
63
64/*
65 * Header for all VSS messages.
66 */
67struct hv_vss_hdr {
68 __u8 operation;
69 __u8 reserved[7];
70} __attribute__((packed));
71
72
73/*
74 * Flag values for the hv_vss_check_feature. Linux supports only
75 * one value.
76 */
77#define VSS_HBU_NO_AUTO_RECOVERY 0x00000005
78
79struct hv_vss_check_feature {
80 __u32 flags;
81} __attribute__((packed));
82
83struct hv_vss_check_dm_info {
84 __u32 flags;
85} __attribute__((packed));
86
87struct hv_vss_msg {
88 union {
89 struct hv_vss_hdr vss_hdr;
90 int error;
91 };
92 union {
93 struct hv_vss_check_feature vss_cf;
94 struct hv_vss_check_dm_info dm_info;
95 };
96} __attribute__((packed));
97
98/*
99 * An implementation of HyperV key value pair (KVP) functionality for Linux.
100 *
101 *
102 * Copyright (C) 2010, Novell, Inc.
103 * Author : K. Y. Srinivasan <ksrinivasan@novell.com>
104 *
105 */
106
107/*
108 * Maximum value size - used for both key names and value data, and includes
109 * any applicable NULL terminators.
110 *
111 * Note: This limit is somewhat arbitrary, but falls easily within what is
112 * supported for all native guests (back to Win 2000) and what is reasonable
113 * for the IC KVP exchange functionality. Note that Windows Me/98/95 are
114 * limited to 255 character key names.
115 *
116 * MSDN recommends not storing data values larger than 2048 bytes in the
117 * registry.
118 *
119 * Note: This value is used in defining the KVP exchange message - this value
120 * cannot be modified without affecting the message size and compatibility.
121 */
122
123/*
124 * bytes, including any null terminators
125 */
126#define HV_KVP_EXCHANGE_MAX_VALUE_SIZE (2048)
127
128
129/*
130 * Maximum key size - the registry limit for the length of an entry name
131 * is 256 characters, including the null terminator
132 */
133
134#define HV_KVP_EXCHANGE_MAX_KEY_SIZE (512)
135 29
136/* 30#include <linux/types.h>
137 * In Linux, we implement the KVP functionality in two components:
138 * 1) The kernel component which is packaged as part of the hv_utils driver
139 * is responsible for communicating with the host and responsible for
140 * implementing the host/guest protocol. 2) A user level daemon that is
141 * responsible for data gathering.
142 *
143 * Host/Guest Protocol: The host iterates over an index and expects the guest
144 * to assign a key name to the index and also return the value corresponding to
145 * the key. The host will have atmost one KVP transaction outstanding at any
146 * given point in time. The host side iteration stops when the guest returns
147 * an error. Microsoft has specified the following mapping of key names to
148 * host specified index:
149 *
150 * Index Key Name
151 * 0 FullyQualifiedDomainName
152 * 1 IntegrationServicesVersion
153 * 2 NetworkAddressIPv4
154 * 3 NetworkAddressIPv6
155 * 4 OSBuildNumber
156 * 5 OSName
157 * 6 OSMajorVersion
158 * 7 OSMinorVersion
159 * 8 OSVersion
160 * 9 ProcessorArchitecture
161 *
162 * The Windows host expects the Key Name and Key Value to be encoded in utf16.
163 *
164 * Guest Kernel/KVP Daemon Protocol: As noted earlier, we implement all of the
165 * data gathering functionality in a user mode daemon. The user level daemon
166 * is also responsible for binding the key name to the index as well. The
167 * kernel and user-level daemon communicate using a connector channel.
168 *
169 * The user mode component first registers with the
170 * the kernel component. Subsequently, the kernel component requests, data
171 * for the specified keys. In response to this message the user mode component
172 * fills in the value corresponding to the specified key. We overload the
173 * sequence field in the cn_msg header to define our KVP message types.
174 *
175 *
176 * The kernel component simply acts as a conduit for communication between the
177 * Windows host and the user-level daemon. The kernel component passes up the
178 * index received from the Host to the user-level daemon. If the index is
179 * valid (supported), the corresponding key as well as its
180 * value (both are strings) is returned. If the index is invalid
181 * (not supported), a NULL key string is returned.
182 */
183
184
185/*
186 * Registry value types.
187 */
188
189#define REG_SZ 1
190#define REG_U32 4
191#define REG_U64 8
192
193/*
194 * As we look at expanding the KVP functionality to include
195 * IP injection functionality, we need to maintain binary
196 * compatibility with older daemons.
197 *
198 * The KVP opcodes are defined by the host and it was unfortunate
199 * that I chose to treat the registration operation as part of the
200 * KVP operations defined by the host.
201 * Here is the level of compatibility
202 * (between the user level daemon and the kernel KVP driver) that we
203 * will implement:
204 *
205 * An older daemon will always be supported on a newer driver.
206 * A given user level daemon will require a minimal version of the
207 * kernel driver.
208 * If we cannot handle the version differences, we will fail gracefully
209 * (this can happen when we have a user level daemon that is more
210 * advanced than the KVP driver.
211 *
212 * We will use values used in this handshake for determining if we have
213 * workable user level daemon and the kernel driver. We begin by taking the
214 * registration opcode out of the KVP opcode namespace. We will however,
215 * maintain compatibility with the existing user-level daemon code.
216 */
217
218/*
219 * Daemon code not supporting IP injection (legacy daemon).
220 */
221
222#define KVP_OP_REGISTER 4
223
224/*
225 * Daemon code supporting IP injection.
226 * The KVP opcode field is used to communicate the
227 * registration information; so define a namespace that
228 * will be distinct from the host defined KVP opcode.
229 */
230
231#define KVP_OP_REGISTER1 100
232
233enum hv_kvp_exchg_op {
234 KVP_OP_GET = 0,
235 KVP_OP_SET,
236 KVP_OP_DELETE,
237 KVP_OP_ENUMERATE,
238 KVP_OP_GET_IP_INFO,
239 KVP_OP_SET_IP_INFO,
240 KVP_OP_COUNT /* Number of operations, must be last. */
241};
242
243enum hv_kvp_exchg_pool {
244 KVP_POOL_EXTERNAL = 0,
245 KVP_POOL_GUEST,
246 KVP_POOL_AUTO,
247 KVP_POOL_AUTO_EXTERNAL,
248 KVP_POOL_AUTO_INTERNAL,
249 KVP_POOL_COUNT /* Number of pools, must be last. */
250};
251
252/*
253 * Some Hyper-V status codes.
254 */
255
256#define HV_S_OK 0x00000000
257#define HV_E_FAIL 0x80004005
258#define HV_S_CONT 0x80070103
259#define HV_ERROR_NOT_SUPPORTED 0x80070032
260#define HV_ERROR_MACHINE_LOCKED 0x800704F7
261#define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F
262#define HV_INVALIDARG 0x80070057
263#define HV_GUID_NOTFOUND 0x80041002
264
265#define ADDR_FAMILY_NONE 0x00
266#define ADDR_FAMILY_IPV4 0x01
267#define ADDR_FAMILY_IPV6 0x02
268
269#define MAX_ADAPTER_ID_SIZE 128
270#define MAX_IP_ADDR_SIZE 1024
271#define MAX_GATEWAY_SIZE 512
272
273
274struct hv_kvp_ipaddr_value {
275 __u16 adapter_id[MAX_ADAPTER_ID_SIZE];
276 __u8 addr_family;
277 __u8 dhcp_enabled;
278 __u16 ip_addr[MAX_IP_ADDR_SIZE];
279 __u16 sub_net[MAX_IP_ADDR_SIZE];
280 __u16 gate_way[MAX_GATEWAY_SIZE];
281 __u16 dns_addr[MAX_IP_ADDR_SIZE];
282} __attribute__((packed));
283
284
285struct hv_kvp_hdr {
286 __u8 operation;
287 __u8 pool;
288 __u16 pad;
289} __attribute__((packed));
290
291struct hv_kvp_exchg_msg_value {
292 __u32 value_type;
293 __u32 key_size;
294 __u32 value_size;
295 __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
296 union {
297 __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
298 __u32 value_u32;
299 __u64 value_u64;
300 };
301} __attribute__((packed));
302
303struct hv_kvp_msg_enumerate {
304 __u32 index;
305 struct hv_kvp_exchg_msg_value data;
306} __attribute__((packed));
307
308struct hv_kvp_msg_get {
309 struct hv_kvp_exchg_msg_value data;
310};
311
312struct hv_kvp_msg_set {
313 struct hv_kvp_exchg_msg_value data;
314};
315
316struct hv_kvp_msg_delete {
317 __u32 key_size;
318 __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
319};
320
321struct hv_kvp_register {
322 __u8 version[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
323};
324
325struct hv_kvp_msg {
326 union {
327 struct hv_kvp_hdr kvp_hdr;
328 int error;
329 };
330 union {
331 struct hv_kvp_msg_get kvp_get;
332 struct hv_kvp_msg_set kvp_set;
333 struct hv_kvp_msg_delete kvp_delete;
334 struct hv_kvp_msg_enumerate kvp_enum_data;
335 struct hv_kvp_ipaddr_value kvp_ip_val;
336 struct hv_kvp_register kvp_register;
337 } body;
338} __attribute__((packed));
339
340struct hv_kvp_ip_msg {
341 __u8 operation;
342 __u8 pool;
343 struct hv_kvp_ipaddr_value kvp_ip_val;
344} __attribute__((packed));
345
346#ifdef __KERNEL__
347#include <linux/scatterlist.h> 31#include <linux/scatterlist.h>
348#include <linux/list.h> 32#include <linux/list.h>
349#include <linux/uuid.h> 33#include <linux/uuid.h>
@@ -1465,5 +1149,4 @@ void hv_vss_onchannelcallback(void *);
1465 1149
1466extern __u32 vmbus_proto_version; 1150extern __u32 vmbus_proto_version;
1467 1151
1468#endif /* __KERNEL__ */
1469#endif /* _HYPERV_H */ 1152#endif /* _HYPERV_H */