3 * Copyright (c) 2011, Microsoft Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
25 #ifndef _UAPI_HYPERV_H
26 #define _UAPI_HYPERV_H
28 #include <linux/uuid.h>
31 * Framework version for util services.
33 #define UTIL_FW_MINOR 0
35 #define UTIL_WS2K8_FW_MAJOR 1
36 #define UTIL_WS2K8_FW_VERSION (UTIL_WS2K8_FW_MAJOR << 16 | UTIL_FW_MINOR)
38 #define UTIL_FW_MAJOR 3
39 #define UTIL_FW_VERSION (UTIL_FW_MAJOR << 16 | UTIL_FW_MINOR)
43 * Implementation of host controlled snapshot of the guest.
46 #define VSS_OP_REGISTER 128
55 * Following operations are only supported with IC version >= 5.0
57 VSS_OP_FREEZE, /* Freeze the file systems in the VM */
58 VSS_OP_THAW, /* Unfreeze the file systems */
60 VSS_OP_COUNT /* Number of operations, must be last */
65 * Header for all VSS messages.
70 } __attribute__((packed));
74 * Flag values for the hv_vss_check_feature. Linux supports only
77 #define VSS_HBU_NO_AUTO_RECOVERY 0x00000005
79 struct hv_vss_check_feature {
81 } __attribute__((packed));
83 struct hv_vss_check_dm_info {
85 } __attribute__((packed));
89 struct hv_vss_hdr vss_hdr;
93 struct hv_vss_check_feature vss_cf;
94 struct hv_vss_check_dm_info dm_info;
96 } __attribute__((packed));
99 * Implementation of a host to guest copy facility.
102 #define FCOPY_VERSION_0 0
103 #define FCOPY_CURRENT_VERSION FCOPY_VERSION_0
104 #define W_MAX_PATH 260
113 struct hv_fcopy_hdr {
115 uuid_le service_id0; /* currently unused */
116 uuid_le service_id1; /* currently unused */
117 } __attribute__((packed));
119 #define OVER_WRITE 0x1
120 #define CREATE_PATH 0x2
122 struct hv_start_fcopy {
123 struct hv_fcopy_hdr hdr;
124 __u16 file_name[W_MAX_PATH];
125 __u16 path_name[W_MAX_PATH];
128 } __attribute__((packed));
131 * The file is chunked into fragments.
133 #define DATA_FRAGMENT (6 * 1024)
136 struct hv_fcopy_hdr hdr;
139 __u8 data[DATA_FRAGMENT];
143 * An implementation of HyperV key value pair (KVP) functionality for Linux.
146 * Copyright (C) 2010, Novell, Inc.
152 * Maximum value size - used for both key names and value data, and includes
153 * any applicable NULL terminators.
155 * Note: This limit is somewhat arbitrary, but falls easily within what is
156 * supported for all native guests (back to Win 2000) and what is reasonable
157 * for the IC KVP exchange functionality. Note that Windows Me/98/95 are
158 * limited to 255 character key names.
160 * MSDN recommends not storing data values larger than 2048 bytes in the
163 * Note: This value is used in defining the KVP exchange message - this value
164 * cannot be modified without affecting the message size and compatibility.
168 * bytes, including any null terminators
170 #define HV_KVP_EXCHANGE_MAX_VALUE_SIZE (2048)
174 * Maximum key size - the registry limit for the length of an entry name
175 * is 256 characters, including the null terminator
178 #define HV_KVP_EXCHANGE_MAX_KEY_SIZE (512)
181 * In Linux, we implement the KVP functionality in two components:
182 * 1) The kernel component which is packaged as part of the hv_utils driver
183 * is responsible for communicating with the host and responsible for
184 * implementing the host/guest protocol. 2) A user level daemon that is
185 * responsible for data gathering.
187 * Host/Guest Protocol: The host iterates over an index and expects the guest
188 * to assign a key name to the index and also return the value corresponding to
189 * the key. The host will have atmost one KVP transaction outstanding at any
190 * given point in time. The host side iteration stops when the guest returns
191 * an error. Microsoft has specified the following mapping of key names to
192 * host specified index:
195 * 0 FullyQualifiedDomainName
196 * 1 IntegrationServicesVersion
197 * 2 NetworkAddressIPv4
198 * 3 NetworkAddressIPv6
204 * 9 ProcessorArchitecture
206 * The Windows host expects the Key Name and Key Value to be encoded in utf16.
208 * Guest Kernel/KVP Daemon Protocol: As noted earlier, we implement all of the
209 * data gathering functionality in a user mode daemon. The user level daemon
210 * is also responsible for binding the key name to the index as well. The
211 * kernel and user-level daemon communicate using a connector channel.
213 * The user mode component first registers with the
214 * the kernel component. Subsequently, the kernel component requests, data
215 * for the specified keys. In response to this message the user mode component
216 * fills in the value corresponding to the specified key. We overload the
217 * sequence field in the cn_msg header to define our KVP message types.
220 * The kernel component simply acts as a conduit for communication between the
221 * Windows host and the user-level daemon. The kernel component passes up the
222 * index received from the Host to the user-level daemon. If the index is
223 * valid (supported), the corresponding key as well as its
224 * value (both are strings) is returned. If the index is invalid
225 * (not supported), a NULL key string is returned.
230 * Registry value types.
238 * As we look at expanding the KVP functionality to include
239 * IP injection functionality, we need to maintain binary
240 * compatibility with older daemons.
242 * The KVP opcodes are defined by the host and it was unfortunate
243 * that I chose to treat the registration operation as part of the
244 * KVP operations defined by the host.
245 * Here is the level of compatibility
246 * (between the user level daemon and the kernel KVP driver) that we
249 * An older daemon will always be supported on a newer driver.
250 * A given user level daemon will require a minimal version of the
252 * If we cannot handle the version differences, we will fail gracefully
253 * (this can happen when we have a user level daemon that is more
254 * advanced than the KVP driver.
256 * We will use values used in this handshake for determining if we have
257 * workable user level daemon and the kernel driver. We begin by taking the
258 * registration opcode out of the KVP opcode namespace. We will however,
259 * maintain compatibility with the existing user-level daemon code.
263 * Daemon code not supporting IP injection (legacy daemon).
266 #define KVP_OP_REGISTER 4
269 * Daemon code supporting IP injection.
270 * The KVP opcode field is used to communicate the
271 * registration information; so define a namespace that
272 * will be distinct from the host defined KVP opcode.
275 #define KVP_OP_REGISTER1 100
277 enum hv_kvp_exchg_op {
284 KVP_OP_COUNT /* Number of operations, must be last. */
287 enum hv_kvp_exchg_pool {
288 KVP_POOL_EXTERNAL = 0,
291 KVP_POOL_AUTO_EXTERNAL,
292 KVP_POOL_AUTO_INTERNAL,
293 KVP_POOL_COUNT /* Number of pools, must be last. */
297 * Some Hyper-V status codes.
300 #define HV_S_OK 0x00000000
301 #define HV_E_FAIL 0x80004005
302 #define HV_S_CONT 0x80070103
303 #define HV_ERROR_NOT_SUPPORTED 0x80070032
304 #define HV_ERROR_MACHINE_LOCKED 0x800704F7
305 #define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F
306 #define HV_INVALIDARG 0x80070057
307 #define HV_GUID_NOTFOUND 0x80041002
308 #define HV_ERROR_ALREADY_EXISTS 0x80070050
310 #define ADDR_FAMILY_NONE 0x00
311 #define ADDR_FAMILY_IPV4 0x01
312 #define ADDR_FAMILY_IPV6 0x02
314 #define MAX_ADAPTER_ID_SIZE 128
315 #define MAX_IP_ADDR_SIZE 1024
316 #define MAX_GATEWAY_SIZE 512
319 struct hv_kvp_ipaddr_value {
320 __u16 adapter_id[MAX_ADAPTER_ID_SIZE];
323 __u16 ip_addr[MAX_IP_ADDR_SIZE];
324 __u16 sub_net[MAX_IP_ADDR_SIZE];
325 __u16 gate_way[MAX_GATEWAY_SIZE];
326 __u16 dns_addr[MAX_IP_ADDR_SIZE];
327 } __attribute__((packed));
334 } __attribute__((packed));
336 struct hv_kvp_exchg_msg_value {
340 __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
342 __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
346 } __attribute__((packed));
348 struct hv_kvp_msg_enumerate {
350 struct hv_kvp_exchg_msg_value data;
351 } __attribute__((packed));
353 struct hv_kvp_msg_get {
354 struct hv_kvp_exchg_msg_value data;
357 struct hv_kvp_msg_set {
358 struct hv_kvp_exchg_msg_value data;
361 struct hv_kvp_msg_delete {
363 __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
366 struct hv_kvp_register {
367 __u8 version[HV_KVP_EXCHANGE_MAX_KEY_SIZE];
372 struct hv_kvp_hdr kvp_hdr;
376 struct hv_kvp_msg_get kvp_get;
377 struct hv_kvp_msg_set kvp_set;
378 struct hv_kvp_msg_delete kvp_delete;
379 struct hv_kvp_msg_enumerate kvp_enum_data;
380 struct hv_kvp_ipaddr_value kvp_ip_val;
381 struct hv_kvp_register kvp_register;
383 } __attribute__((packed));
385 struct hv_kvp_ip_msg {
388 struct hv_kvp_ipaddr_value kvp_ip_val;
389 } __attribute__((packed));
391 #endif /* _UAPI_HYPERV_H */