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