![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 0002 /* 0003 * 0004 * Copyright (c) 2011, Microsoft Corporation. 0005 * 0006 * This program is free software; you can redistribute it and/or modify it 0007 * under the terms and conditions of the GNU General Public License, 0008 * version 2, as published by the Free Software Foundation. 0009 * 0010 * This program is distributed in the hope it will be useful, but WITHOUT 0011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 0013 * more details. 0014 * 0015 * You should have received a copy of the GNU General Public License along with 0016 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple 0017 * Place - Suite 330, Boston, MA 02111-1307 USA. 0018 * 0019 * Authors: 0020 * Haiyang Zhang <haiyangz@microsoft.com> 0021 * Hank Janssen <hjanssen@microsoft.com> 0022 * K. Y. Srinivasan <kys@microsoft.com> 0023 * 0024 */ 0025 0026 #ifndef _UAPI_HYPERV_H 0027 #define _UAPI_HYPERV_H 0028 0029 #include <linux/types.h> 0030 0031 /* 0032 * Framework version for util services. 0033 */ 0034 #define UTIL_FW_MINOR 0 0035 0036 #define UTIL_WS2K8_FW_MAJOR 1 0037 #define UTIL_WS2K8_FW_VERSION (UTIL_WS2K8_FW_MAJOR << 16 | UTIL_FW_MINOR) 0038 0039 #define UTIL_FW_MAJOR 3 0040 #define UTIL_FW_VERSION (UTIL_FW_MAJOR << 16 | UTIL_FW_MINOR) 0041 0042 0043 /* 0044 * Implementation of host controlled snapshot of the guest. 0045 */ 0046 0047 #define VSS_OP_REGISTER 128 0048 0049 /* 0050 Daemon code with full handshake support. 0051 */ 0052 #define VSS_OP_REGISTER1 129 0053 0054 enum hv_vss_op { 0055 VSS_OP_CREATE = 0, 0056 VSS_OP_DELETE, 0057 VSS_OP_HOT_BACKUP, 0058 VSS_OP_GET_DM_INFO, 0059 VSS_OP_BU_COMPLETE, 0060 /* 0061 * Following operations are only supported with IC version >= 5.0 0062 */ 0063 VSS_OP_FREEZE, /* Freeze the file systems in the VM */ 0064 VSS_OP_THAW, /* Unfreeze the file systems */ 0065 VSS_OP_AUTO_RECOVER, 0066 VSS_OP_COUNT /* Number of operations, must be last */ 0067 }; 0068 0069 0070 /* 0071 * Header for all VSS messages. 0072 */ 0073 struct hv_vss_hdr { 0074 __u8 operation; 0075 __u8 reserved[7]; 0076 } __attribute__((packed)); 0077 0078 0079 /* 0080 * Flag values for the hv_vss_check_feature. Linux supports only 0081 * one value. 0082 */ 0083 #define VSS_HBU_NO_AUTO_RECOVERY 0x00000005 0084 0085 struct hv_vss_check_feature { 0086 __u32 flags; 0087 } __attribute__((packed)); 0088 0089 struct hv_vss_check_dm_info { 0090 __u32 flags; 0091 } __attribute__((packed)); 0092 0093 /* 0094 * struct hv_vss_msg encodes the fields that the Linux VSS 0095 * driver accesses. However, FREEZE messages from Hyper-V contain 0096 * additional LUN information that Linux doesn't use and are not 0097 * represented in struct hv_vss_msg. A received FREEZE message may 0098 * be as large as 6,260 bytes, so the driver must allocate at least 0099 * that much space, not sizeof(struct hv_vss_msg). Other messages 0100 * such as AUTO_RECOVER may be as large as 12,500 bytes. However, 0101 * because the Linux VSS driver responds that it doesn't support 0102 * auto-recovery, it should not receive such messages. 0103 */ 0104 struct hv_vss_msg { 0105 union { 0106 struct hv_vss_hdr vss_hdr; 0107 int error; 0108 }; 0109 union { 0110 struct hv_vss_check_feature vss_cf; 0111 struct hv_vss_check_dm_info dm_info; 0112 }; 0113 } __attribute__((packed)); 0114 0115 /* 0116 * Implementation of a host to guest copy facility. 0117 */ 0118 0119 #define FCOPY_VERSION_0 0 0120 #define FCOPY_VERSION_1 1 0121 #define FCOPY_CURRENT_VERSION FCOPY_VERSION_1 0122 #define W_MAX_PATH 260 0123 0124 enum hv_fcopy_op { 0125 START_FILE_COPY = 0, 0126 WRITE_TO_FILE, 0127 COMPLETE_FCOPY, 0128 CANCEL_FCOPY, 0129 }; 0130 0131 struct hv_fcopy_hdr { 0132 __u32 operation; 0133 __u8 service_id0[16]; /* currently unused */ 0134 __u8 service_id1[16]; /* currently unused */ 0135 } __attribute__((packed)); 0136 0137 #define OVER_WRITE 0x1 0138 #define CREATE_PATH 0x2 0139 0140 struct hv_start_fcopy { 0141 struct hv_fcopy_hdr hdr; 0142 __u16 file_name[W_MAX_PATH]; 0143 __u16 path_name[W_MAX_PATH]; 0144 __u32 copy_flags; 0145 __u64 file_size; 0146 } __attribute__((packed)); 0147 0148 /* 0149 * The file is chunked into fragments. 0150 */ 0151 #define DATA_FRAGMENT (6 * 1024) 0152 0153 struct hv_do_fcopy { 0154 struct hv_fcopy_hdr hdr; 0155 __u32 pad; 0156 __u64 offset; 0157 __u32 size; 0158 __u8 data[DATA_FRAGMENT]; 0159 } __attribute__((packed)); 0160 0161 /* 0162 * An implementation of HyperV key value pair (KVP) functionality for Linux. 0163 * 0164 * 0165 * Copyright (C) 2010, Novell, Inc. 0166 * Author : K. Y. Srinivasan <ksrinivasan@novell.com> 0167 * 0168 */ 0169 0170 /* 0171 * Maximum value size - used for both key names and value data, and includes 0172 * any applicable NULL terminators. 0173 * 0174 * Note: This limit is somewhat arbitrary, but falls easily within what is 0175 * supported for all native guests (back to Win 2000) and what is reasonable 0176 * for the IC KVP exchange functionality. Note that Windows Me/98/95 are 0177 * limited to 255 character key names. 0178 * 0179 * MSDN recommends not storing data values larger than 2048 bytes in the 0180 * registry. 0181 * 0182 * Note: This value is used in defining the KVP exchange message - this value 0183 * cannot be modified without affecting the message size and compatibility. 0184 */ 0185 0186 /* 0187 * bytes, including any null terminators 0188 */ 0189 #define HV_KVP_EXCHANGE_MAX_VALUE_SIZE (2048) 0190 0191 0192 /* 0193 * Maximum key size - the registry limit for the length of an entry name 0194 * is 256 characters, including the null terminator 0195 */ 0196 0197 #define HV_KVP_EXCHANGE_MAX_KEY_SIZE (512) 0198 0199 /* 0200 * In Linux, we implement the KVP functionality in two components: 0201 * 1) The kernel component which is packaged as part of the hv_utils driver 0202 * is responsible for communicating with the host and responsible for 0203 * implementing the host/guest protocol. 2) A user level daemon that is 0204 * responsible for data gathering. 0205 * 0206 * Host/Guest Protocol: The host iterates over an index and expects the guest 0207 * to assign a key name to the index and also return the value corresponding to 0208 * the key. The host will have atmost one KVP transaction outstanding at any 0209 * given point in time. The host side iteration stops when the guest returns 0210 * an error. Microsoft has specified the following mapping of key names to 0211 * host specified index: 0212 * 0213 * Index Key Name 0214 * 0 FullyQualifiedDomainName 0215 * 1 IntegrationServicesVersion 0216 * 2 NetworkAddressIPv4 0217 * 3 NetworkAddressIPv6 0218 * 4 OSBuildNumber 0219 * 5 OSName 0220 * 6 OSMajorVersion 0221 * 7 OSMinorVersion 0222 * 8 OSVersion 0223 * 9 ProcessorArchitecture 0224 * 0225 * The Windows host expects the Key Name and Key Value to be encoded in utf16. 0226 * 0227 * Guest Kernel/KVP Daemon Protocol: As noted earlier, we implement all of the 0228 * data gathering functionality in a user mode daemon. The user level daemon 0229 * is also responsible for binding the key name to the index as well. The 0230 * kernel and user-level daemon communicate using a connector channel. 0231 * 0232 * The user mode component first registers with the 0233 * kernel component. Subsequently, the kernel component requests, data 0234 * for the specified keys. In response to this message the user mode component 0235 * fills in the value corresponding to the specified key. We overload the 0236 * sequence field in the cn_msg header to define our KVP message types. 0237 * 0238 * 0239 * The kernel component simply acts as a conduit for communication between the 0240 * Windows host and the user-level daemon. The kernel component passes up the 0241 * index received from the Host to the user-level daemon. If the index is 0242 * valid (supported), the corresponding key as well as its 0243 * value (both are strings) is returned. If the index is invalid 0244 * (not supported), a NULL key string is returned. 0245 */ 0246 0247 0248 /* 0249 * Registry value types. 0250 */ 0251 0252 #define REG_SZ 1 0253 #define REG_U32 4 0254 #define REG_U64 8 0255 0256 /* 0257 * As we look at expanding the KVP functionality to include 0258 * IP injection functionality, we need to maintain binary 0259 * compatibility with older daemons. 0260 * 0261 * The KVP opcodes are defined by the host and it was unfortunate 0262 * that I chose to treat the registration operation as part of the 0263 * KVP operations defined by the host. 0264 * Here is the level of compatibility 0265 * (between the user level daemon and the kernel KVP driver) that we 0266 * will implement: 0267 * 0268 * An older daemon will always be supported on a newer driver. 0269 * A given user level daemon will require a minimal version of the 0270 * kernel driver. 0271 * If we cannot handle the version differences, we will fail gracefully 0272 * (this can happen when we have a user level daemon that is more 0273 * advanced than the KVP driver. 0274 * 0275 * We will use values used in this handshake for determining if we have 0276 * workable user level daemon and the kernel driver. We begin by taking the 0277 * registration opcode out of the KVP opcode namespace. We will however, 0278 * maintain compatibility with the existing user-level daemon code. 0279 */ 0280 0281 /* 0282 * Daemon code not supporting IP injection (legacy daemon). 0283 */ 0284 0285 #define KVP_OP_REGISTER 4 0286 0287 /* 0288 * Daemon code supporting IP injection. 0289 * The KVP opcode field is used to communicate the 0290 * registration information; so define a namespace that 0291 * will be distinct from the host defined KVP opcode. 0292 */ 0293 0294 #define KVP_OP_REGISTER1 100 0295 0296 enum hv_kvp_exchg_op { 0297 KVP_OP_GET = 0, 0298 KVP_OP_SET, 0299 KVP_OP_DELETE, 0300 KVP_OP_ENUMERATE, 0301 KVP_OP_GET_IP_INFO, 0302 KVP_OP_SET_IP_INFO, 0303 KVP_OP_COUNT /* Number of operations, must be last. */ 0304 }; 0305 0306 enum hv_kvp_exchg_pool { 0307 KVP_POOL_EXTERNAL = 0, 0308 KVP_POOL_GUEST, 0309 KVP_POOL_AUTO, 0310 KVP_POOL_AUTO_EXTERNAL, 0311 KVP_POOL_AUTO_INTERNAL, 0312 KVP_POOL_COUNT /* Number of pools, must be last. */ 0313 }; 0314 0315 /* 0316 * Some Hyper-V status codes. 0317 */ 0318 0319 #define HV_S_OK 0x00000000 0320 #define HV_E_FAIL 0x80004005 0321 #define HV_S_CONT 0x80070103 0322 #define HV_ERROR_NOT_SUPPORTED 0x80070032 0323 #define HV_ERROR_MACHINE_LOCKED 0x800704F7 0324 #define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F 0325 #define HV_INVALIDARG 0x80070057 0326 #define HV_GUID_NOTFOUND 0x80041002 0327 #define HV_ERROR_ALREADY_EXISTS 0x80070050 0328 #define HV_ERROR_DISK_FULL 0x80070070 0329 0330 #define ADDR_FAMILY_NONE 0x00 0331 #define ADDR_FAMILY_IPV4 0x01 0332 #define ADDR_FAMILY_IPV6 0x02 0333 0334 #define MAX_ADAPTER_ID_SIZE 128 0335 #define MAX_IP_ADDR_SIZE 1024 0336 #define MAX_GATEWAY_SIZE 512 0337 0338 0339 struct hv_kvp_ipaddr_value { 0340 __u16 adapter_id[MAX_ADAPTER_ID_SIZE]; 0341 __u8 addr_family; 0342 __u8 dhcp_enabled; 0343 __u16 ip_addr[MAX_IP_ADDR_SIZE]; 0344 __u16 sub_net[MAX_IP_ADDR_SIZE]; 0345 __u16 gate_way[MAX_GATEWAY_SIZE]; 0346 __u16 dns_addr[MAX_IP_ADDR_SIZE]; 0347 } __attribute__((packed)); 0348 0349 0350 struct hv_kvp_hdr { 0351 __u8 operation; 0352 __u8 pool; 0353 __u16 pad; 0354 } __attribute__((packed)); 0355 0356 struct hv_kvp_exchg_msg_value { 0357 __u32 value_type; 0358 __u32 key_size; 0359 __u32 value_size; 0360 __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; 0361 union { 0362 __u8 value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; 0363 __u32 value_u32; 0364 __u64 value_u64; 0365 }; 0366 } __attribute__((packed)); 0367 0368 struct hv_kvp_msg_enumerate { 0369 __u32 index; 0370 struct hv_kvp_exchg_msg_value data; 0371 } __attribute__((packed)); 0372 0373 struct hv_kvp_msg_get { 0374 struct hv_kvp_exchg_msg_value data; 0375 }; 0376 0377 struct hv_kvp_msg_set { 0378 struct hv_kvp_exchg_msg_value data; 0379 }; 0380 0381 struct hv_kvp_msg_delete { 0382 __u32 key_size; 0383 __u8 key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; 0384 }; 0385 0386 struct hv_kvp_register { 0387 __u8 version[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; 0388 }; 0389 0390 struct hv_kvp_msg { 0391 union { 0392 struct hv_kvp_hdr kvp_hdr; 0393 int error; 0394 }; 0395 union { 0396 struct hv_kvp_msg_get kvp_get; 0397 struct hv_kvp_msg_set kvp_set; 0398 struct hv_kvp_msg_delete kvp_delete; 0399 struct hv_kvp_msg_enumerate kvp_enum_data; 0400 struct hv_kvp_ipaddr_value kvp_ip_val; 0401 struct hv_kvp_register kvp_register; 0402 } body; 0403 } __attribute__((packed)); 0404 0405 struct hv_kvp_ip_msg { 0406 __u8 operation; 0407 __u8 pool; 0408 struct hv_kvp_ipaddr_value kvp_ip_val; 0409 } __attribute__((packed)); 0410 0411 #endif /* _UAPI_HYPERV_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |