Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: MIT */
0002 /*
0003  * Details of the "wire" protocol between Xen Store Daemon and client
0004  * library or guest kernel.
0005  * Copyright (C) 2005 Rusty Russell IBM Corporation
0006  */
0007 
0008 #ifndef _XS_WIRE_H
0009 #define _XS_WIRE_H
0010 
0011 enum xsd_sockmsg_type
0012 {
0013     XS_CONTROL,
0014 #define XS_DEBUG XS_CONTROL
0015     XS_DIRECTORY,
0016     XS_READ,
0017     XS_GET_PERMS,
0018     XS_WATCH,
0019     XS_UNWATCH,
0020     XS_TRANSACTION_START,
0021     XS_TRANSACTION_END,
0022     XS_INTRODUCE,
0023     XS_RELEASE,
0024     XS_GET_DOMAIN_PATH,
0025     XS_WRITE,
0026     XS_MKDIR,
0027     XS_RM,
0028     XS_SET_PERMS,
0029     XS_WATCH_EVENT,
0030     XS_ERROR,
0031     XS_IS_DOMAIN_INTRODUCED,
0032     XS_RESUME,
0033     XS_SET_TARGET,
0034     /* XS_RESTRICT has been removed */
0035     XS_RESET_WATCHES = XS_SET_TARGET + 2,
0036     XS_DIRECTORY_PART,
0037 
0038     XS_TYPE_COUNT,      /* Number of valid types. */
0039 
0040     XS_INVALID = 0xffff /* Guaranteed to remain an invalid type */
0041 };
0042 
0043 #define XS_WRITE_NONE "NONE"
0044 #define XS_WRITE_CREATE "CREATE"
0045 #define XS_WRITE_CREATE_EXCL "CREATE|EXCL"
0046 
0047 /* We hand errors as strings, for portability. */
0048 struct xsd_errors
0049 {
0050     int errnum;
0051     const char *errstring;
0052 };
0053 #define XSD_ERROR(x) { x, #x }
0054 static struct xsd_errors xsd_errors[] __attribute__((unused)) = {
0055     XSD_ERROR(EINVAL),
0056     XSD_ERROR(EACCES),
0057     XSD_ERROR(EEXIST),
0058     XSD_ERROR(EISDIR),
0059     XSD_ERROR(ENOENT),
0060     XSD_ERROR(ENOMEM),
0061     XSD_ERROR(ENOSPC),
0062     XSD_ERROR(EIO),
0063     XSD_ERROR(ENOTEMPTY),
0064     XSD_ERROR(ENOSYS),
0065     XSD_ERROR(EROFS),
0066     XSD_ERROR(EBUSY),
0067     XSD_ERROR(EAGAIN),
0068     XSD_ERROR(EISCONN),
0069     XSD_ERROR(E2BIG)
0070 };
0071 
0072 struct xsd_sockmsg
0073 {
0074     uint32_t type;  /* XS_??? */
0075     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
0076     uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
0077     uint32_t len;   /* Length of data following this. */
0078 
0079     /* Generally followed by nul-terminated string(s). */
0080 };
0081 
0082 enum xs_watch_type
0083 {
0084     XS_WATCH_PATH = 0,
0085     XS_WATCH_TOKEN
0086 };
0087 
0088 /* Inter-domain shared memory communications. */
0089 #define XENSTORE_RING_SIZE 1024
0090 typedef uint32_t XENSTORE_RING_IDX;
0091 #define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1))
0092 struct xenstore_domain_interface {
0093     char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */
0094     char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */
0095     XENSTORE_RING_IDX req_cons, req_prod;
0096     XENSTORE_RING_IDX rsp_cons, rsp_prod;
0097     uint32_t server_features; /* Bitmap of features supported by the server */
0098     uint32_t connection;
0099     uint32_t error;
0100 };
0101 
0102 /* Violating this is very bad.  See docs/misc/xenstore.txt. */
0103 #define XENSTORE_PAYLOAD_MAX 4096
0104 
0105 /* Violating these just gets you an error back */
0106 #define XENSTORE_ABS_PATH_MAX 3072
0107 #define XENSTORE_REL_PATH_MAX 2048
0108 
0109 /* The ability to reconnect a ring */
0110 #define XENSTORE_SERVER_FEATURE_RECONNECTION 1
0111 /* The presence of the "error" field in the ring page */
0112 #define XENSTORE_SERVER_FEATURE_ERROR        2
0113 
0114 /* Valid values for the connection field */
0115 #define XENSTORE_CONNECTED 0 /* the steady-state */
0116 #define XENSTORE_RECONNECT 1 /* guest has initiated a reconnect */
0117 
0118 /* Valid values for the error field */
0119 #define XENSTORE_ERROR_NONE    0 /* No error */
0120 #define XENSTORE_ERROR_COMM    1 /* Communication problem */
0121 #define XENSTORE_ERROR_RINGIDX 2 /* Invalid ring index */
0122 #define XENSTORE_ERROR_PROTO   3 /* Protocol violation (payload too long) */
0123 
0124 #endif /* _XS_WIRE_H */