xs_wire.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* SPDX-License-Identifier: GPL-2.0 */
  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_DEBUG,
  12. XS_DIRECTORY,
  13. XS_READ,
  14. XS_GET_PERMS,
  15. XS_WATCH,
  16. XS_UNWATCH,
  17. XS_TRANSACTION_START,
  18. XS_TRANSACTION_END,
  19. XS_INTRODUCE,
  20. XS_RELEASE,
  21. XS_GET_DOMAIN_PATH,
  22. XS_WRITE,
  23. XS_MKDIR,
  24. XS_RM,
  25. XS_SET_PERMS,
  26. XS_WATCH_EVENT,
  27. XS_ERROR,
  28. XS_IS_DOMAIN_INTRODUCED,
  29. XS_RESUME,
  30. XS_SET_TARGET,
  31. XS_RESTRICT,
  32. XS_RESET_WATCHES,
  33. };
  34. #define XS_WRITE_NONE "NONE"
  35. #define XS_WRITE_CREATE "CREATE"
  36. #define XS_WRITE_CREATE_EXCL "CREATE|EXCL"
  37. /* We hand errors as strings, for portability. */
  38. struct xsd_errors
  39. {
  40. int errnum;
  41. const char *errstring;
  42. };
  43. #define XSD_ERROR(x) { x, #x }
  44. static struct xsd_errors xsd_errors[] __attribute__((unused)) = {
  45. XSD_ERROR(EINVAL),
  46. XSD_ERROR(EACCES),
  47. XSD_ERROR(EEXIST),
  48. XSD_ERROR(EISDIR),
  49. XSD_ERROR(ENOENT),
  50. XSD_ERROR(ENOMEM),
  51. XSD_ERROR(ENOSPC),
  52. XSD_ERROR(EIO),
  53. XSD_ERROR(ENOTEMPTY),
  54. XSD_ERROR(ENOSYS),
  55. XSD_ERROR(EROFS),
  56. XSD_ERROR(EBUSY),
  57. XSD_ERROR(EAGAIN),
  58. XSD_ERROR(EISCONN)
  59. };
  60. struct xsd_sockmsg
  61. {
  62. uint32_t type; /* XS_??? */
  63. uint32_t req_id;/* Request identifier, echoed in daemon's response. */
  64. uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
  65. uint32_t len; /* Length of data following this. */
  66. /* Generally followed by nul-terminated string(s). */
  67. };
  68. enum xs_watch_type
  69. {
  70. XS_WATCH_PATH = 0,
  71. XS_WATCH_TOKEN
  72. };
  73. /* Inter-domain shared memory communications. */
  74. #define XENSTORE_RING_SIZE 1024
  75. typedef uint32_t XENSTORE_RING_IDX;
  76. #define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1))
  77. struct xenstore_domain_interface {
  78. char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */
  79. char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */
  80. XENSTORE_RING_IDX req_cons, req_prod;
  81. XENSTORE_RING_IDX rsp_cons, rsp_prod;
  82. };
  83. /* Violating this is very bad. See docs/misc/xenstore.txt. */
  84. #define XENSTORE_PAYLOAD_MAX 4096
  85. #endif /* _XS_WIRE_H */