xs_wire.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Details of the "wire" protocol between Xen Store Daemon and client
  4. * library or guest kernel.
  5. * Copyright (C) 2005 Rusty Russell IBM Corporation
  6. */
  7. #ifndef _XS_WIRE_H
  8. #define _XS_WIRE_H
  9. enum xsd_sockmsg_type
  10. {
  11. XS_CONTROL,
  12. #define XS_DEBUG XS_CONTROL
  13. XS_DIRECTORY,
  14. XS_READ,
  15. XS_GET_PERMS,
  16. XS_WATCH,
  17. XS_UNWATCH,
  18. XS_TRANSACTION_START,
  19. XS_TRANSACTION_END,
  20. XS_INTRODUCE,
  21. XS_RELEASE,
  22. XS_GET_DOMAIN_PATH,
  23. XS_WRITE,
  24. XS_MKDIR,
  25. XS_RM,
  26. XS_SET_PERMS,
  27. XS_WATCH_EVENT,
  28. XS_ERROR,
  29. XS_IS_DOMAIN_INTRODUCED,
  30. XS_RESUME,
  31. XS_SET_TARGET,
  32. /* XS_RESTRICT has been removed */
  33. XS_RESET_WATCHES = XS_SET_TARGET + 2,
  34. XS_DIRECTORY_PART,
  35. XS_TYPE_COUNT, /* Number of valid types. */
  36. XS_INVALID = 0xffff /* Guaranteed to remain an invalid type */
  37. };
  38. #define XS_WRITE_NONE "NONE"
  39. #define XS_WRITE_CREATE "CREATE"
  40. #define XS_WRITE_CREATE_EXCL "CREATE|EXCL"
  41. /* We hand errors as strings, for portability. */
  42. struct xsd_errors
  43. {
  44. int errnum;
  45. const char *errstring;
  46. };
  47. #define XSD_ERROR(x) { x, #x }
  48. static struct xsd_errors xsd_errors[] __attribute__((unused)) = {
  49. XSD_ERROR(EINVAL),
  50. XSD_ERROR(EACCES),
  51. XSD_ERROR(EEXIST),
  52. XSD_ERROR(EISDIR),
  53. XSD_ERROR(ENOENT),
  54. XSD_ERROR(ENOMEM),
  55. XSD_ERROR(ENOSPC),
  56. XSD_ERROR(EIO),
  57. XSD_ERROR(ENOTEMPTY),
  58. XSD_ERROR(ENOSYS),
  59. XSD_ERROR(EROFS),
  60. XSD_ERROR(EBUSY),
  61. XSD_ERROR(EAGAIN),
  62. XSD_ERROR(EISCONN),
  63. XSD_ERROR(E2BIG)
  64. };
  65. struct xsd_sockmsg
  66. {
  67. uint32_t type; /* XS_??? */
  68. uint32_t req_id;/* Request identifier, echoed in daemon's response. */
  69. uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
  70. uint32_t len; /* Length of data following this. */
  71. /* Generally followed by nul-terminated string(s). */
  72. };
  73. enum xs_watch_type
  74. {
  75. XS_WATCH_PATH = 0,
  76. XS_WATCH_TOKEN
  77. };
  78. /* Inter-domain shared memory communications. */
  79. #define XENSTORE_RING_SIZE 1024
  80. typedef uint32_t XENSTORE_RING_IDX;
  81. #define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1))
  82. struct xenstore_domain_interface {
  83. char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */
  84. char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */
  85. XENSTORE_RING_IDX req_cons, req_prod;
  86. XENSTORE_RING_IDX rsp_cons, rsp_prod;
  87. uint32_t server_features; /* Bitmap of features supported by the server */
  88. uint32_t connection;
  89. uint32_t error;
  90. };
  91. /* Violating this is very bad. See docs/misc/xenstore.txt. */
  92. #define XENSTORE_PAYLOAD_MAX 4096
  93. /* Violating these just gets you an error back */
  94. #define XENSTORE_ABS_PATH_MAX 3072
  95. #define XENSTORE_REL_PATH_MAX 2048
  96. /* The ability to reconnect a ring */
  97. #define XENSTORE_SERVER_FEATURE_RECONNECTION 1
  98. /* The presence of the "error" field in the ring page */
  99. #define XENSTORE_SERVER_FEATURE_ERROR 2
  100. /* Valid values for the connection field */
  101. #define XENSTORE_CONNECTED 0 /* the steady-state */
  102. #define XENSTORE_RECONNECT 1 /* guest has initiated a reconnect */
  103. /* Valid values for the error field */
  104. #define XENSTORE_ERROR_NONE 0 /* No error */
  105. #define XENSTORE_ERROR_COMM 1 /* Communication problem */
  106. #define XENSTORE_ERROR_RINGIDX 2 /* Invalid ring index */
  107. #define XENSTORE_ERROR_PROTO 3 /* Protocol violation (payload too long) */
  108. #endif /* _XS_WIRE_H */