PageRenderTime 59ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/arm-eabi/libc/usr/include/linux/hyperv.h

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