xs_wire.h 2.2 KB

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