1 /* 2 Domain communications for Xen Store Daemon. 3 Copyright (C) 2005 Rusty Russell IBM Corporation 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef _XENSTORED_DOMAIN_H 20 #define _XENSTORED_DOMAIN_H 21 22 void handle_event(void); 23 24 /* domid, mfn, eventchn, path */ 25 int do_introduce(struct connection *conn, struct buffered_data *in); 26 27 /* domid */ 28 int do_is_domain_introduced(struct connection *conn, struct buffered_data *in); 29 30 /* domid */ 31 int do_release(struct connection *conn, struct buffered_data *in); 32 33 /* domid */ 34 int do_resume(struct connection *conn, struct buffered_data *in); 35 36 /* domid, target */ 37 int do_set_target(struct connection *conn, struct buffered_data *in); 38 39 /* domid */ 40 int do_get_domain_path(struct connection *conn, struct buffered_data *in); 41 42 /* Allow guest to reset all watches */ 43 int do_reset_watches(struct connection *conn, struct buffered_data *in); 44 45 void domain_init(void); 46 47 /* Returns the implicit path of a connection (only domains have this) */ 48 const char *get_implicit_path(const struct connection *conn); 49 50 /* Read existing connection information from store. */ 51 void restore_existing_connections(void); 52 53 /* Can connection attached to domain read/write. */ 54 bool domain_can_read(struct connection *conn); 55 bool domain_can_write(struct connection *conn); 56 57 bool domain_is_unprivileged(struct connection *conn); 58 59 /* Quota manipulation */ 60 void domain_entry_inc(struct connection *conn, struct node *); 61 void domain_entry_dec(struct connection *conn, struct node *); 62 int domain_entry_fix(unsigned int domid, int num, bool update); 63 int domain_entry(struct connection *conn); 64 void domain_watch_inc(struct connection *conn); 65 void domain_watch_dec(struct connection *conn); 66 int domain_watch(struct connection *conn); 67 68 /* Write rate limiting */ 69 70 #define WRL_FACTOR 1000 /* for fixed-point arithmetic */ 71 #define WRL_RATE 200 72 #define WRL_DBURST 10 73 #define WRL_GBURST 1000 74 #define WRL_NEWDOMS 5 75 #define WRL_LOGEVERY 120 /* seconds */ 76 77 struct wrl_timestampt { 78 time_t sec; 79 int msec; 80 }; 81 82 extern long wrl_ntransactions; 83 84 void wrl_gettime_now(struct wrl_timestampt *now_ts); 85 void wrl_domain_new(struct domain *domain); 86 void wrl_domain_destroy(struct domain *domain); 87 void wrl_credit_update(struct domain *domain, struct wrl_timestampt now); 88 void wrl_check_timeout(struct domain *domain, 89 struct wrl_timestampt now, 90 int *ptimeout); 91 void wrl_log_periodic(struct wrl_timestampt now); 92 void wrl_apply_debit_direct(struct connection *conn); 93 void wrl_apply_debit_trans_commit(struct connection *conn); 94 95 #endif /* _XENSTORED_DOMAIN_H */ 96