| Bjarke Istrup Pedersen | 5267cf0 | 2014-01-22 09:16:58 +0000 | [diff] [blame] | 1 | /* | 
|  | 2 | * | 
|  | 3 | * Copyright (c) 2011, Microsoft Corporation. | 
|  | 4 | * | 
|  | 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. | 
|  | 8 | * | 
|  | 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 | 
|  | 12 | * more details. | 
|  | 13 | * | 
|  | 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. | 
|  | 17 | * | 
|  | 18 | * Authors: | 
|  | 19 | *   Haiyang Zhang <haiyangz@microsoft.com> | 
|  | 20 | *   Hank Janssen  <hjanssen@microsoft.com> | 
|  | 21 | *   K. Y. Srinivasan <kys@microsoft.com> | 
|  | 22 | * | 
|  | 23 | */ | 
|  | 24 |  | 
|  | 25 | #ifndef _UAPI_HYPERV_H | 
|  | 26 | #define _UAPI_HYPERV_H | 
|  | 27 |  | 
| K. Y. Srinivasan | 01325476 | 2014-02-16 11:34:30 -0800 | [diff] [blame] | 28 | #include <linux/uuid.h> | 
|  | 29 |  | 
| Bjarke Istrup Pedersen | 5267cf0 | 2014-01-22 09:16:58 +0000 | [diff] [blame] | 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 |  | 
|  | 48 | enum 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 | */ | 
|  | 67 | struct 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 |  | 
|  | 79 | struct hv_vss_check_feature { | 
|  | 80 | __u32 flags; | 
|  | 81 | } __attribute__((packed)); | 
|  | 82 |  | 
|  | 83 | struct hv_vss_check_dm_info { | 
|  | 84 | __u32 flags; | 
|  | 85 | } __attribute__((packed)); | 
|  | 86 |  | 
|  | 87 | struct 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 | /* | 
| K. Y. Srinivasan | 01325476 | 2014-02-16 11:34:30 -0800 | [diff] [blame] | 99 | * Implementation of a host to guest copy facility. | 
|  | 100 | */ | 
|  | 101 |  | 
|  | 102 | #define FCOPY_VERSION_0 0 | 
|  | 103 | #define FCOPY_CURRENT_VERSION FCOPY_VERSION_0 | 
|  | 104 | #define W_MAX_PATH 260 | 
|  | 105 |  | 
|  | 106 | enum hv_fcopy_op { | 
|  | 107 | START_FILE_COPY = 0, | 
|  | 108 | WRITE_TO_FILE, | 
|  | 109 | COMPLETE_FCOPY, | 
|  | 110 | CANCEL_FCOPY, | 
|  | 111 | }; | 
|  | 112 |  | 
|  | 113 | struct hv_fcopy_hdr { | 
|  | 114 | __u32 operation; | 
|  | 115 | uuid_le service_id0; /* currently unused */ | 
|  | 116 | uuid_le service_id1; /* currently unused */ | 
|  | 117 | } __attribute__((packed)); | 
|  | 118 |  | 
|  | 119 | #define OVER_WRITE	0x1 | 
|  | 120 | #define CREATE_PATH	0x2 | 
|  | 121 |  | 
|  | 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]; | 
|  | 126 | __u32 copy_flags; | 
|  | 127 | __u64 file_size; | 
|  | 128 | } __attribute__((packed)); | 
|  | 129 |  | 
|  | 130 | /* | 
|  | 131 | * The file is chunked into fragments. | 
|  | 132 | */ | 
|  | 133 | #define DATA_FRAGMENT	(6 * 1024) | 
|  | 134 |  | 
|  | 135 | struct hv_do_fcopy { | 
|  | 136 | struct hv_fcopy_hdr hdr; | 
| Vitaly Kuznetsov | 31d4ea1 | 2014-10-24 12:20:27 +0200 | [diff] [blame] | 137 | __u32   pad; | 
| K. Y. Srinivasan | 01325476 | 2014-02-16 11:34:30 -0800 | [diff] [blame] | 138 | __u64	offset; | 
|  | 139 | __u32	size; | 
|  | 140 | __u8	data[DATA_FRAGMENT]; | 
| K. Y. Srinivasan | bc5a5b0 | 2014-09-02 19:21:47 -0700 | [diff] [blame] | 141 | } __attribute__((packed)); | 
| K. Y. Srinivasan | 01325476 | 2014-02-16 11:34:30 -0800 | [diff] [blame] | 142 |  | 
|  | 143 | /* | 
| Bjarke Istrup Pedersen | 5267cf0 | 2014-01-22 09:16:58 +0000 | [diff] [blame] | 144 | * An implementation of HyperV key value pair (KVP) functionality for Linux. | 
|  | 145 | * | 
|  | 146 | * | 
|  | 147 | * Copyright (C) 2010, Novell, Inc. | 
|  | 148 | * Author : K. Y. Srinivasan <ksrinivasan@novell.com> | 
|  | 149 | * | 
|  | 150 | */ | 
|  | 151 |  | 
|  | 152 | /* | 
|  | 153 | * Maximum value size - used for both key names and value data, and includes | 
|  | 154 | * any applicable NULL terminators. | 
|  | 155 | * | 
|  | 156 | * Note:  This limit is somewhat arbitrary, but falls easily within what is | 
|  | 157 | * supported for all native guests (back to Win 2000) and what is reasonable | 
|  | 158 | * for the IC KVP exchange functionality.  Note that Windows Me/98/95 are | 
|  | 159 | * limited to 255 character key names. | 
|  | 160 | * | 
|  | 161 | * MSDN recommends not storing data values larger than 2048 bytes in the | 
|  | 162 | * registry. | 
|  | 163 | * | 
|  | 164 | * Note:  This value is used in defining the KVP exchange message - this value | 
|  | 165 | * cannot be modified without affecting the message size and compatibility. | 
|  | 166 | */ | 
|  | 167 |  | 
|  | 168 | /* | 
|  | 169 | * bytes, including any null terminators | 
|  | 170 | */ | 
|  | 171 | #define HV_KVP_EXCHANGE_MAX_VALUE_SIZE          (2048) | 
|  | 172 |  | 
|  | 173 |  | 
|  | 174 | /* | 
|  | 175 | * Maximum key size - the registry limit for the length of an entry name | 
|  | 176 | * is 256 characters, including the null terminator | 
|  | 177 | */ | 
|  | 178 |  | 
|  | 179 | #define HV_KVP_EXCHANGE_MAX_KEY_SIZE            (512) | 
|  | 180 |  | 
|  | 181 | /* | 
|  | 182 | * In Linux, we implement the KVP functionality in two components: | 
|  | 183 | * 1) The kernel component which is packaged as part of the hv_utils driver | 
|  | 184 | * is responsible for communicating with the host and responsible for | 
|  | 185 | * implementing the host/guest protocol. 2) A user level daemon that is | 
|  | 186 | * responsible for data gathering. | 
|  | 187 | * | 
|  | 188 | * Host/Guest Protocol: The host iterates over an index and expects the guest | 
|  | 189 | * to assign a key name to the index and also return the value corresponding to | 
|  | 190 | * the key. The host will have atmost one KVP transaction outstanding at any | 
|  | 191 | * given point in time. The host side iteration stops when the guest returns | 
|  | 192 | * an error. Microsoft has specified the following mapping of key names to | 
|  | 193 | * host specified index: | 
|  | 194 | * | 
|  | 195 | *	Index		Key Name | 
|  | 196 | *	0		FullyQualifiedDomainName | 
|  | 197 | *	1		IntegrationServicesVersion | 
|  | 198 | *	2		NetworkAddressIPv4 | 
|  | 199 | *	3		NetworkAddressIPv6 | 
|  | 200 | *	4		OSBuildNumber | 
|  | 201 | *	5		OSName | 
|  | 202 | *	6		OSMajorVersion | 
|  | 203 | *	7		OSMinorVersion | 
|  | 204 | *	8		OSVersion | 
|  | 205 | *	9		ProcessorArchitecture | 
|  | 206 | * | 
|  | 207 | * The Windows host expects the Key Name and Key Value to be encoded in utf16. | 
|  | 208 | * | 
|  | 209 | * Guest Kernel/KVP Daemon Protocol: As noted earlier, we implement all of the | 
|  | 210 | * data gathering functionality in a user mode daemon. The user level daemon | 
|  | 211 | * is also responsible for binding the key name to the index as well. The | 
|  | 212 | * kernel and user-level daemon communicate using a connector channel. | 
|  | 213 | * | 
|  | 214 | * The user mode component first registers with the | 
|  | 215 | * the kernel component. Subsequently, the kernel component requests, data | 
|  | 216 | * for the specified keys. In response to this message the user mode component | 
|  | 217 | * fills in the value corresponding to the specified key. We overload the | 
|  | 218 | * sequence field in the cn_msg header to define our KVP message types. | 
|  | 219 | * | 
|  | 220 | * | 
|  | 221 | * The kernel component simply acts as a conduit for communication between the | 
|  | 222 | * Windows host and the user-level daemon. The kernel component passes up the | 
|  | 223 | * index received from the Host to the user-level daemon. If the index is | 
|  | 224 | * valid (supported), the corresponding key as well as its | 
|  | 225 | * value (both are strings) is returned. If the index is invalid | 
|  | 226 | * (not supported), a NULL key string is returned. | 
|  | 227 | */ | 
|  | 228 |  | 
|  | 229 |  | 
|  | 230 | /* | 
|  | 231 | * Registry value types. | 
|  | 232 | */ | 
|  | 233 |  | 
|  | 234 | #define REG_SZ 1 | 
|  | 235 | #define REG_U32 4 | 
|  | 236 | #define REG_U64 8 | 
|  | 237 |  | 
|  | 238 | /* | 
|  | 239 | * As we look at expanding the KVP functionality to include | 
|  | 240 | * IP injection functionality, we need to maintain binary | 
|  | 241 | * compatibility with older daemons. | 
|  | 242 | * | 
|  | 243 | * The KVP opcodes are defined by the host and it was unfortunate | 
|  | 244 | * that I chose to treat the registration operation as part of the | 
|  | 245 | * KVP operations defined by the host. | 
|  | 246 | * Here is the level of compatibility | 
|  | 247 | * (between the user level daemon and the kernel KVP driver) that we | 
|  | 248 | * will implement: | 
|  | 249 | * | 
|  | 250 | * An older daemon will always be supported on a newer driver. | 
|  | 251 | * A given user level daemon will require a minimal version of the | 
|  | 252 | * kernel driver. | 
|  | 253 | * If we cannot handle the version differences, we will fail gracefully | 
|  | 254 | * (this can happen when we have a user level daemon that is more | 
|  | 255 | * advanced than the KVP driver. | 
|  | 256 | * | 
|  | 257 | * We will use values used in this handshake for determining if we have | 
|  | 258 | * workable user level daemon and the kernel driver. We begin by taking the | 
|  | 259 | * registration opcode out of the KVP opcode namespace. We will however, | 
|  | 260 | * maintain compatibility with the existing user-level daemon code. | 
|  | 261 | */ | 
|  | 262 |  | 
|  | 263 | /* | 
|  | 264 | * Daemon code not supporting IP injection (legacy daemon). | 
|  | 265 | */ | 
|  | 266 |  | 
|  | 267 | #define KVP_OP_REGISTER	4 | 
|  | 268 |  | 
|  | 269 | /* | 
|  | 270 | * Daemon code supporting IP injection. | 
|  | 271 | * The KVP opcode field is used to communicate the | 
|  | 272 | * registration information; so define a namespace that | 
|  | 273 | * will be distinct from the host defined KVP opcode. | 
|  | 274 | */ | 
|  | 275 |  | 
|  | 276 | #define KVP_OP_REGISTER1 100 | 
|  | 277 |  | 
|  | 278 | enum hv_kvp_exchg_op { | 
|  | 279 | KVP_OP_GET = 0, | 
|  | 280 | KVP_OP_SET, | 
|  | 281 | KVP_OP_DELETE, | 
|  | 282 | KVP_OP_ENUMERATE, | 
|  | 283 | KVP_OP_GET_IP_INFO, | 
|  | 284 | KVP_OP_SET_IP_INFO, | 
|  | 285 | KVP_OP_COUNT /* Number of operations, must be last. */ | 
|  | 286 | }; | 
|  | 287 |  | 
|  | 288 | enum hv_kvp_exchg_pool { | 
|  | 289 | KVP_POOL_EXTERNAL = 0, | 
|  | 290 | KVP_POOL_GUEST, | 
|  | 291 | KVP_POOL_AUTO, | 
|  | 292 | KVP_POOL_AUTO_EXTERNAL, | 
|  | 293 | KVP_POOL_AUTO_INTERNAL, | 
|  | 294 | KVP_POOL_COUNT /* Number of pools, must be last. */ | 
|  | 295 | }; | 
|  | 296 |  | 
|  | 297 | /* | 
|  | 298 | * Some Hyper-V status codes. | 
|  | 299 | */ | 
|  | 300 |  | 
|  | 301 | #define HV_S_OK				0x00000000 | 
|  | 302 | #define HV_E_FAIL			0x80004005 | 
|  | 303 | #define HV_S_CONT			0x80070103 | 
|  | 304 | #define HV_ERROR_NOT_SUPPORTED		0x80070032 | 
|  | 305 | #define HV_ERROR_MACHINE_LOCKED		0x800704F7 | 
|  | 306 | #define HV_ERROR_DEVICE_NOT_CONNECTED	0x8007048F | 
|  | 307 | #define HV_INVALIDARG			0x80070057 | 
|  | 308 | #define HV_GUID_NOTFOUND		0x80041002 | 
| K. Y. Srinivasan | 314672a | 2014-04-09 17:24:16 -0700 | [diff] [blame] | 309 | #define HV_ERROR_ALREADY_EXISTS		0x80070050 | 
| Bjarke Istrup Pedersen | 5267cf0 | 2014-01-22 09:16:58 +0000 | [diff] [blame] | 310 |  | 
|  | 311 | #define ADDR_FAMILY_NONE	0x00 | 
|  | 312 | #define ADDR_FAMILY_IPV4	0x01 | 
|  | 313 | #define ADDR_FAMILY_IPV6	0x02 | 
|  | 314 |  | 
|  | 315 | #define MAX_ADAPTER_ID_SIZE	128 | 
|  | 316 | #define MAX_IP_ADDR_SIZE	1024 | 
|  | 317 | #define MAX_GATEWAY_SIZE	512 | 
|  | 318 |  | 
|  | 319 |  | 
|  | 320 | struct hv_kvp_ipaddr_value { | 
|  | 321 | __u16	adapter_id[MAX_ADAPTER_ID_SIZE]; | 
|  | 322 | __u8	addr_family; | 
|  | 323 | __u8	dhcp_enabled; | 
|  | 324 | __u16	ip_addr[MAX_IP_ADDR_SIZE]; | 
|  | 325 | __u16	sub_net[MAX_IP_ADDR_SIZE]; | 
|  | 326 | __u16	gate_way[MAX_GATEWAY_SIZE]; | 
|  | 327 | __u16	dns_addr[MAX_IP_ADDR_SIZE]; | 
|  | 328 | } __attribute__((packed)); | 
|  | 329 |  | 
|  | 330 |  | 
|  | 331 | struct hv_kvp_hdr { | 
|  | 332 | __u8 operation; | 
|  | 333 | __u8 pool; | 
|  | 334 | __u16 pad; | 
|  | 335 | } __attribute__((packed)); | 
|  | 336 |  | 
|  | 337 | struct hv_kvp_exchg_msg_value { | 
|  | 338 | __u32 value_type; | 
|  | 339 | __u32 key_size; | 
|  | 340 | __u32 value_size; | 
|  | 341 | __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | 
|  | 342 | union { | 
|  | 343 | __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; | 
|  | 344 | __u32 value_u32; | 
|  | 345 | __u64 value_u64; | 
|  | 346 | }; | 
|  | 347 | } __attribute__((packed)); | 
|  | 348 |  | 
|  | 349 | struct hv_kvp_msg_enumerate { | 
|  | 350 | __u32 index; | 
|  | 351 | struct hv_kvp_exchg_msg_value data; | 
|  | 352 | } __attribute__((packed)); | 
|  | 353 |  | 
|  | 354 | struct hv_kvp_msg_get { | 
|  | 355 | struct hv_kvp_exchg_msg_value data; | 
|  | 356 | }; | 
|  | 357 |  | 
|  | 358 | struct hv_kvp_msg_set { | 
|  | 359 | struct hv_kvp_exchg_msg_value data; | 
|  | 360 | }; | 
|  | 361 |  | 
|  | 362 | struct hv_kvp_msg_delete { | 
|  | 363 | __u32 key_size; | 
|  | 364 | __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | 
|  | 365 | }; | 
|  | 366 |  | 
|  | 367 | struct hv_kvp_register { | 
|  | 368 | __u8 version[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; | 
|  | 369 | }; | 
|  | 370 |  | 
|  | 371 | struct hv_kvp_msg { | 
|  | 372 | union { | 
|  | 373 | struct hv_kvp_hdr	kvp_hdr; | 
|  | 374 | int error; | 
|  | 375 | }; | 
|  | 376 | union { | 
|  | 377 | struct hv_kvp_msg_get		kvp_get; | 
|  | 378 | struct hv_kvp_msg_set		kvp_set; | 
|  | 379 | struct hv_kvp_msg_delete	kvp_delete; | 
|  | 380 | struct hv_kvp_msg_enumerate	kvp_enum_data; | 
|  | 381 | struct hv_kvp_ipaddr_value      kvp_ip_val; | 
|  | 382 | struct hv_kvp_register		kvp_register; | 
|  | 383 | } body; | 
|  | 384 | } __attribute__((packed)); | 
|  | 385 |  | 
|  | 386 | struct hv_kvp_ip_msg { | 
|  | 387 | __u8 operation; | 
|  | 388 | __u8 pool; | 
|  | 389 | struct hv_kvp_ipaddr_value      kvp_ip_val; | 
|  | 390 | } __attribute__((packed)); | 
|  | 391 |  | 
|  | 392 | #endif /* _UAPI_HYPERV_H */ |