root/include/uapi/linux/hyperv.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


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

/* [<][>][^][v][top][bottom][index][help] */