xs_wire.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. };
  29. #define XS_WRITE_NONE "NONE"
  30. #define XS_WRITE_CREATE "CREATE"
  31. #define XS_WRITE_CREATE_EXCL "CREATE|EXCL"
  32. /* We hand errors as strings, for portability. */
  33. struct xsd_errors
  34. {
  35. int errnum;
  36. const char *errstring;
  37. };
  38. #define XSD_ERROR(x) { x, #x }
  39. static struct xsd_errors xsd_errors[] __attribute__((unused)) = {
  40. XSD_ERROR(EINVAL),
  41. XSD_ERROR(EACCES),
  42. XSD_ERROR(EEXIST),
  43. XSD_ERROR(EISDIR),
  44. XSD_ERROR(ENOENT),
  45. XSD_ERROR(ENOMEM),
  46. XSD_ERROR(ENOSPC),
  47. XSD_ERROR(EIO),
  48. XSD_ERROR(ENOTEMPTY),
  49. XSD_ERROR(ENOSYS),
  50. XSD_ERROR(EROFS),
  51. XSD_ERROR(EBUSY),
  52. XSD_ERROR(EAGAIN),
  53. XSD_ERROR(EISCONN)
  54. };
  55. struct xsd_sockmsg
  56. {
  57. uint32_t type; /* XS_??? */
  58. uint32_t req_id;/* Request identifier, echoed in daemon's response. */
  59. uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
  60. uint32_t len; /* Length of data following this. */
  61. /* Generally followed by nul-terminated string(s). */
  62. };
  63. enum xs_watch_type
  64. {
  65. XS_WATCH_PATH = 0,
  66. XS_WATCH_TOKEN
  67. };
  68. /* Inter-domain shared memory communications. */
  69. #define XENSTORE_RING_SIZE 1024
  70. typedef uint32_t XENSTORE_RING_IDX;
  71. #define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1))
  72. struct xenstore_domain_interface {
  73. char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */
  74. char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */
  75. XENSTORE_RING_IDX req_cons, req_prod;
  76. XENSTORE_RING_IDX rsp_cons, rsp_prod;
  77. };
  78. #endif /* _XS_WIRE_H */