shim_ipc.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. /* Copyright (C) 2014 Stony Brook University
  2. This file is part of Graphene Library OS.
  3. Graphene Library OS is free software: you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public License
  5. as published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. Graphene Library OS is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. /*
  14. * shim_ipc.h
  15. *
  16. * Definitions of types and functions for IPC bookkeeping.
  17. */
  18. #ifndef _SHIM_IPC_H_
  19. #define _SHIM_IPC_H_
  20. #include <shim_types.h>
  21. #include <shim_defs.h>
  22. #include <shim_handle.h>
  23. #include <shim_thread.h>
  24. #include <shim_sysv.h>
  25. #include <pal.h>
  26. #include <list.h>
  27. DEFINE_LIST(shim_ipc_info);
  28. struct shim_ipc_info {
  29. IDTYPE vmid;
  30. struct shim_ipc_port * port;
  31. PAL_HANDLE pal_handle;
  32. struct shim_qstr uri;
  33. LIST_TYPE(shim_ipc_info) hlist;
  34. REFTYPE ref_count;
  35. };
  36. enum { PID_NS, SYSV_NS, TOTAL_NS };
  37. struct shim_process {
  38. IDTYPE vmid;
  39. struct shim_lock lock;
  40. int exit_code;
  41. struct shim_ipc_info * self, * parent;
  42. struct shim_ipc_info * ns[TOTAL_NS];
  43. };
  44. extern struct shim_process cur_process;
  45. #define IPC_MSG_MINIMAL_SIZE 48
  46. #define IPC_MSG_READAHEAD 96
  47. struct shim_ipc_msg {
  48. unsigned char code;
  49. unsigned int size;
  50. IDTYPE src, dst;
  51. unsigned long seq;
  52. #ifdef PROFILE
  53. unsigned long time;
  54. #endif
  55. char msg[];
  56. } __attribute__((packed));
  57. struct shim_ipc_port;
  58. struct shim_thread;
  59. DEFINE_LIST(shim_ipc_msg_obj);
  60. struct shim_ipc_msg_obj {
  61. struct shim_thread * thread;
  62. LIST_TYPE(shim_ipc_msg_obj) list;
  63. int retval;
  64. void * private;
  65. struct shim_ipc_msg msg;
  66. };
  67. typedef void (*port_fini) (struct shim_ipc_port *, IDTYPE vmid,
  68. unsigned int exitcode);
  69. #define MAX_IPC_PORT_FINI_CB 3
  70. DEFINE_LIST(shim_ipc_port);
  71. DEFINE_LISTP(shim_ipc_msg_obj);
  72. struct shim_ipc_port {
  73. PAL_HANDLE pal_handle;
  74. REFTYPE ref_count;
  75. LIST_TYPE(shim_ipc_port) hlist;
  76. LIST_TYPE(shim_ipc_port) list;
  77. LISTP_TYPE(shim_ipc_msg_obj) msgs;
  78. struct shim_lock msgs_lock;
  79. port_fini fini[MAX_IPC_PORT_FINI_CB];
  80. bool update, recent;
  81. struct {
  82. IDTYPE type;
  83. IDTYPE vmid;
  84. } info, private;
  85. };
  86. #define IPC_CALLBACK_ARGS \
  87. struct shim_ipc_msg * msg, struct shim_ipc_port * port
  88. /* if callback return RESPONSE_CALLBACK, send a response even if the callback
  89. succeed. */
  90. #define RESPONSE_CALLBACK 1
  91. typedef int (*ipc_callback) (IPC_CALLBACK_ARGS);
  92. /* Messagge code to response the connection */
  93. enum {
  94. IPC_RESP = 0,
  95. IPC_FINDURI,
  96. IPC_TELLURI,
  97. IPC_CHECKPOINT,
  98. IPC_BASE_BOUND,
  99. };
  100. /* IPC_RESP: response for incoming messages */
  101. struct shim_ipc_resp {
  102. int retval;
  103. } __attribute__((packed));
  104. /* IPC_FINDURI: request a URI from a connect process */
  105. int ipc_finduri_send (struct shim_ipc_port * port, IDTYPE dest,
  106. struct shim_ipc_info ** info);
  107. int ipc_finduri_callback (IPC_CALLBACK_ARGS);
  108. /* IPC_TELLURI: replying with a connectable URI */
  109. struct shim_ipc_telluri {
  110. char uri[1];
  111. } __attribute__((packed));
  112. int ipc_telluri_send (struct shim_ipc_port * port, IDTYPE dest,
  113. struct shim_ipc_info * info);
  114. int ipc_telluri_callback (IPC_CALLBACK_ARGS);
  115. /* PID_CHECKPOINT: broadcast checkpointing */
  116. struct shim_ipc_checkpoint {
  117. IDTYPE cpsession;
  118. char cpdir[1];
  119. } __attribute__((packed));
  120. int ipc_checkpoint_send (const char * cpdir, IDTYPE cpsession);
  121. int ipc_checkpoint_callback (IPC_CALLBACK_ARGS);
  122. /* Message code from child to parent */
  123. #define IPC_CLD_BASE IPC_BASE_BOUND
  124. enum {
  125. IPC_CLD_EXIT = IPC_CLD_BASE,
  126. IPC_CLD_JOIN,
  127. #ifdef PROFILE
  128. IPC_CLD_PROFILE,
  129. #endif
  130. IPC_CLD_BOUND,
  131. };
  132. /* CLD_EXIT: thread exit */
  133. struct shim_ipc_cld_exit {
  134. IDTYPE ppid, tid;
  135. unsigned int exitcode;
  136. unsigned int term_signal;
  137. #ifdef PROFILE
  138. unsigned long time;
  139. #endif
  140. } __attribute__((packed));
  141. int ipc_cld_exit_send (IDTYPE ppid, IDTYPE tid, unsigned int exitcode, unsigned int term_signal);
  142. int ipc_cld_exit_callback (IPC_CALLBACK_ARGS);
  143. /* CLD_JOIN: child join the parent group */
  144. int ipc_cld_join_send (IDTYPE dest);
  145. int ipc_cld_join_callback (IPC_CALLBACK_ARGS);
  146. #ifdef PROFILE
  147. # include <shim_profile.h>
  148. struct shim_ipc_cld_profile {
  149. unsigned long time;
  150. int nprofile;
  151. struct profile_val profile[];
  152. } __attribute__((packed));
  153. int ipc_cld_profile_send (void);
  154. int ipc_cld_profile_callback (IPC_CALLBACK_ARGS);
  155. #endif
  156. /* Message code to namespace manager */
  157. #define IPC_PID_BASE IPC_CLD_BOUND
  158. #define NS pid
  159. #define NS_CAP PID
  160. #include "shim_ipc_ns.h"
  161. enum {
  162. IPC_PID_KILL = IPC_PID_TEMPLATE_BOUND,
  163. IPC_PID_GETSTATUS,
  164. IPC_PID_RETSTATUS,
  165. IPC_PID_GETMETA,
  166. IPC_PID_RETMETA,
  167. IPC_PID_NOP,
  168. IPC_PID_SENDRPC,
  169. IPC_PID_BOUND,
  170. };
  171. enum kill_type { KILL_THREAD, KILL_PROCESS, KILL_PGROUP, KILL_ALL };
  172. /* PID_KILL: send signal to certain pid */
  173. struct shim_ipc_pid_kill {
  174. IDTYPE sender;
  175. enum kill_type type;
  176. IDTYPE id;
  177. int signum;
  178. } __attribute__((packed));
  179. int ipc_pid_kill_send (IDTYPE sender, IDTYPE id, enum kill_type type,
  180. int signum);
  181. int ipc_pid_kill_callback (IPC_CALLBACK_ARGS);
  182. struct pid_status {
  183. IDTYPE pid, tgid, pgid;
  184. } __attribute__((packed));
  185. /* PID_GETSTATUS: check if certain pid(s) exists */
  186. struct shim_ipc_pid_getstatus {
  187. int npids;
  188. IDTYPE pids[];
  189. } __attribute__((packed));
  190. int ipc_pid_getstatus_send (struct shim_ipc_port * port, IDTYPE dest,
  191. int npids, IDTYPE * pids,
  192. struct pid_status ** status);
  193. int ipc_pid_getstatus_callback (IPC_CALLBACK_ARGS);
  194. /* PID_RETSTATUS: return status of pid(s) */
  195. struct shim_ipc_pid_retstatus {
  196. int nstatus;
  197. struct pid_status status[];
  198. } __attribute__((packed));
  199. int ipc_pid_retstatus_send (struct shim_ipc_port * port, IDTYPE dest,
  200. int nstatus, struct pid_status * status,
  201. unsigned long seq);
  202. int ipc_pid_retstatus_callback (IPC_CALLBACK_ARGS);
  203. /* PID_GETMETA: get metadata of certain pid */
  204. enum pid_meta_code {
  205. PID_META_CRED,
  206. PID_META_EXEC,
  207. PID_META_CWD,
  208. PID_META_ROOT,
  209. };
  210. struct shim_ipc_pid_getmeta {
  211. IDTYPE pid;
  212. enum pid_meta_code code;
  213. } __attribute__((packed));
  214. int ipc_pid_getmeta_send (IDTYPE pid, enum pid_meta_code code,
  215. void ** data);
  216. int ipc_pid_getmeta_callback (IPC_CALLBACK_ARGS);
  217. /* PID_RETMETA: return metadata of certain pid */
  218. struct shim_ipc_pid_retmeta {
  219. IDTYPE pid;
  220. enum pid_meta_code code;
  221. int datasize;
  222. char data[];
  223. } __attribute__((packed));
  224. int ipc_pid_retmeta_send (struct shim_ipc_port * port, IDTYPE dest,
  225. IDTYPE pid, enum pid_meta_code code,
  226. const void * data, int datasize,
  227. unsigned long seq);
  228. int ipc_pid_retmeta_callback (IPC_CALLBACK_ARGS);
  229. /* PID_NOP: send junk message (for benchmarking) */
  230. struct shim_ipc_pid_nop {
  231. int count;
  232. char payload[];
  233. } __attribute__((packed));
  234. int ipc_pid_nop_send (struct shim_ipc_port * port, IDTYPE dest, int count,
  235. const void * buf, int len);
  236. int ipc_pid_nop_callback(IPC_CALLBACK_ARGS);
  237. /* PID_SENDRPC: send arbitary message (for benchmarking) */
  238. struct shim_ipc_pid_sendrpc {
  239. IDTYPE sender;
  240. int len;
  241. char payload[];
  242. } __attribute__((packed));
  243. int ipc_pid_sendrpc_send (IDTYPE pid, IDTYPE sender, const void * buf,
  244. int len);
  245. int ipc_pid_sendrpc_callback (IPC_CALLBACK_ARGS);
  246. #define IPC_SYSV_BASE IPC_PID_BOUND
  247. struct sysv_key {
  248. unsigned long key;
  249. enum sysv_type type;
  250. };
  251. #define NS sysv
  252. #define NS_CAP SYSV
  253. #define NS_KEY struct sysv_key
  254. #include "shim_ipc_ns.h"
  255. enum {
  256. IPC_SYSV_DELRES = IPC_SYSV_TEMPLATE_BOUND,
  257. IPC_SYSV_MOVRES,
  258. IPC_SYSV_MSGSND,
  259. IPC_SYSV_MSGRCV,
  260. IPC_SYSV_MSGMOV,
  261. IPC_SYSV_SEMOP,
  262. IPC_SYSV_SEMCTL,
  263. IPC_SYSV_SEMRET,
  264. IPC_SYSV_SEMMOV,
  265. #ifdef USE_SHARED_SEMAPHORE
  266. IPC_SYSV_SEMQUERY,
  267. IPC_SYSV_SEMREPLY,
  268. #endif
  269. IPC_SYSV_BOUND,
  270. };
  271. /* SYSV_DELRES */
  272. struct shim_ipc_sysv_delres {
  273. IDTYPE resid;
  274. enum sysv_type type;
  275. } __attribute__((packed));
  276. int ipc_sysv_delres_send (struct shim_ipc_port * port, IDTYPE dest,
  277. IDTYPE resid, enum sysv_type type);
  278. int ipc_sysv_delres_callback (IPC_CALLBACK_ARGS);
  279. /* SYSV_MOVRES */
  280. struct shim_ipc_sysv_movres {
  281. IDTYPE resid;
  282. enum sysv_type type;
  283. IDTYPE owner;
  284. LEASETYPE lease;
  285. char uri[1];
  286. } __attribute__((packed));
  287. int ipc_sysv_movres_send (struct sysv_client * client, IDTYPE owner,
  288. const char * uri, LEASETYPE lease, IDTYPE resid,
  289. enum sysv_type type);
  290. int ipc_sysv_movres_callback (IPC_CALLBACK_ARGS);
  291. /* SYSV_MSGSND */
  292. struct shim_ipc_sysv_msgsnd {
  293. IDTYPE msgid;
  294. long msgtype;
  295. char msg[];
  296. } __attribute__((packed));
  297. int ipc_sysv_msgsnd_send (struct shim_ipc_port * port, IDTYPE dest,
  298. IDTYPE msgid, long msgtype,
  299. const void * buf, size_t size, unsigned long seq);
  300. int ipc_sysv_msgsnd_callback (IPC_CALLBACK_ARGS);
  301. /* SYSV_MSGRCV */
  302. struct shim_ipc_sysv_msgrcv {
  303. IDTYPE msgid;
  304. long msgtype;
  305. size_t size;
  306. int flags;
  307. } __attribute__((packed));
  308. int ipc_sysv_msgrcv_send (IDTYPE msgid, long msgtype, int flags, void * buf,
  309. size_t size);
  310. int ipc_sysv_msgrcv_callback (IPC_CALLBACK_ARGS);
  311. /* SYSV_MSGMOV */
  312. struct shim_ipc_sysv_msgmov {
  313. IDTYPE msgid;
  314. LEASETYPE lease;
  315. unsigned short nscores;
  316. struct sysv_score scores[];
  317. } __attribute__((packed));
  318. int ipc_sysv_msgmov_send (struct shim_ipc_port * port, IDTYPE dest,
  319. IDTYPE msgid, LEASETYPE lease,
  320. struct sysv_score * scores, int nscores);
  321. int ipc_sysv_msgmov_callback (IPC_CALLBACK_ARGS);
  322. /* SYSV_SEMOP */
  323. struct shim_ipc_sysv_semop {
  324. IDTYPE semid;
  325. unsigned long timeout;
  326. int nsops;
  327. struct sembuf sops[];
  328. } __attribute__((packed));
  329. #define IPC_SEM_NOTIMEOUT ((unsigned long)-1)
  330. int ipc_sysv_semop_send (IDTYPE semid, struct sembuf * sops, int nsops,
  331. unsigned long timeout, unsigned long * seq);
  332. int ipc_sysv_semop_callback (IPC_CALLBACK_ARGS);
  333. /* SYSV_SEMCTL */
  334. struct shim_ipc_sysv_semctl {
  335. IDTYPE semid;
  336. int semnum;
  337. int cmd;
  338. size_t valsize;
  339. unsigned char vals[];
  340. } __attribute__((packed));
  341. int ipc_sysv_semctl_send (IDTYPE semid, int semnum, int cmd, void * vals,
  342. size_t valsize);
  343. int ipc_sysv_semctl_callback (IPC_CALLBACK_ARGS);
  344. /* SYSV_SEMRET */
  345. struct shim_ipc_sysv_semret {
  346. size_t valsize;
  347. unsigned char vals[];
  348. } __attribute__((packed));
  349. int ipc_sysv_semret_send (struct shim_ipc_port * port, IDTYPE dest,
  350. void * vals, size_t valsize, unsigned long seq);
  351. int ipc_sysv_semret_callback (IPC_CALLBACK_ARGS);
  352. /* SYSV_SEMMOV */
  353. struct shim_ipc_sysv_semmov {
  354. IDTYPE semid;
  355. LEASETYPE lease;
  356. unsigned short nsems, nsrcs, nscores;
  357. struct sem_backup sems[];
  358. } __attribute__((packed));
  359. int ipc_sysv_semmov_send (struct shim_ipc_port * port, IDTYPE dest,
  360. IDTYPE semid, LEASETYPE lease,
  361. struct sem_backup * sems, int nsems,
  362. struct sem_client_backup * srcs, int nsrcs,
  363. struct sysv_score * scores, int nscores);
  364. int ipc_sysv_semmov_callback (IPC_CALLBACK_ARGS);
  365. #ifdef USE_SHARED_SEMAPHORE
  366. /* SYSV_SEMQUERY */
  367. struct shim_ipc_sysv_semquery {
  368. IDTYPE semid;
  369. } __attribute__((packed));
  370. int ipc_sysv_semquery_send (IDTYPE semid, int * nsems, PAL_NUM ** host_sem_ids);
  371. int ipc_sysv_semquery_callback (IPC_CALLBACK_ARGS);
  372. /* SYSV_SEMREPLY */
  373. struct shim_ipc_sysv_semreply {
  374. IDTYPE semid;
  375. int nsems;
  376. PAL_NUM host_sem_ids[];
  377. } __attribute__((packed));
  378. int ipc_sysv_semreply_send (struct shim_ipc_port * port, IDTYPE dest,
  379. IDTYPE semid, int nsems, PAL_NUM * host_sem_ids,
  380. unsigned long seq);
  381. int ipc_sysv_semreply_callback (IPC_CALLBACK_ARGS);
  382. #endif
  383. #define IPC_CODE_NUM IPC_SYSV_BOUND
  384. /* functions and routines */
  385. int init_ipc (void);
  386. int init_ipc_helper (void);
  387. struct shim_process * create_new_process (bool inherit_parent);
  388. void destroy_process (struct shim_process * proc);
  389. struct shim_ipc_info * create_ipc_port (IDTYPE vmid, bool listen);
  390. int create_ipc_location (struct shim_ipc_info ** pinfo);
  391. enum {
  392. LISTEN, /* listening */
  393. SERVER, /* connect as a server */
  394. KEEPALIVE, /* keep the connetion alive */
  395. DIRCLD, /* direct child */
  396. DIRPRT, /* direct parent */
  397. NS_PORT_CONSTS(PID)
  398. NS_PORT_CONSTS(SYSV)
  399. };
  400. enum {
  401. IPC_PORT_LISTEN = 1<<LISTEN,
  402. IPC_PORT_SERVER = 1<<SERVER,
  403. IPC_PORT_KEEPALIVE = 1<<KEEPALIVE,
  404. IPC_PORT_DIRCLD = 1<<DIRCLD,
  405. IPC_PORT_DIRPRT = 1<<DIRPRT,
  406. NS_PORT_TYPES(PID)
  407. NS_PORT_TYPES(SYSV)
  408. };
  409. #define IPC_PORT_IFPOLL (IPC_PORT_SERVER|IPC_PORT_LISTEN)
  410. /* general-purpose routines */
  411. void add_ipc_port_by_id (IDTYPE vmid, PAL_HANDLE hdl, IDTYPE type,
  412. port_fini fini,
  413. struct shim_ipc_port ** portptr);
  414. void add_ipc_port (struct shim_ipc_port * port, IDTYPE vmid, IDTYPE type,
  415. port_fini fini);
  416. void del_ipc_port_by_id (IDTYPE vm_pid, IDTYPE type);
  417. void del_ipc_port (struct shim_ipc_port * port, IDTYPE type);
  418. void del_ipc_port_fini (struct shim_ipc_port * port, unsigned int exitcode);
  419. struct shim_ipc_port * lookup_ipc_port (IDTYPE vmid, IDTYPE type);
  420. void get_ipc_port (struct shim_ipc_port * port);
  421. void put_ipc_port (struct shim_ipc_port * port);
  422. void del_all_ipc_ports (IDTYPE type);
  423. struct shim_ipc_info * get_new_ipc_info (IDTYPE vmid, const char * uri,
  424. size_t len);
  425. void get_ipc_info(struct shim_ipc_info * port);
  426. void put_ipc_info(struct shim_ipc_info * port);
  427. struct shim_ipc_info * lookup_and_alloc_client (IDTYPE vmid, const char * uri);
  428. void put_client (struct shim_ipc_info * info);
  429. struct shim_ipc_info * discover_client (struct shim_ipc_port * port,
  430. IDTYPE vmid);
  431. #define IPC_MSG_SIZE(extra) \
  432. ({ int _size = (extra) + sizeof(struct shim_ipc_msg); \
  433. _size > IPC_MSG_MINIMAL_SIZE ? _size : IPC_MSG_MINIMAL_SIZE; })
  434. #define IPC_MSGOBJ_SIZE(extra) \
  435. ({ int _size = (extra) + sizeof(struct shim_ipc_msg); \
  436. (_size > IPC_MSG_MINIMAL_SIZE ? _size : IPC_MSG_MINIMAL_SIZE) + \
  437. (sizeof(struct shim_ipc_msg_obj) - sizeof(struct shim_ipc_msg)); })
  438. int __init_ipc_msg (struct shim_ipc_msg * msg, int code, int size, IDTYPE dest);
  439. struct shim_ipc_msg * create_ipc_msg (int code, int size, IDTYPE dest);
  440. static_always_inline
  441. struct shim_ipc_msg * create_ipc_msg_on_stack (int code, int size, IDTYPE dest)
  442. {
  443. struct shim_ipc_msg * msg = __alloca(IPC_MSG_SIZE(size));
  444. return (!__init_ipc_msg(msg, code, size, dest)) ? msg : NULL;
  445. }
  446. int __init_ipc_msg_duplex (struct shim_ipc_msg_obj * msg, int code, int size,
  447. IDTYPE dest);
  448. struct shim_ipc_msg_obj *
  449. create_ipc_msg_duplex (int code, int size, IDTYPE dest);
  450. static_always_inline
  451. struct shim_ipc_msg_obj *
  452. create_ipc_msg_duplex_on_stack (int code, int size, IDTYPE dest)
  453. {
  454. struct shim_ipc_msg_obj * msg = __alloca(IPC_MSGOBJ_SIZE(size));
  455. return (!__init_ipc_msg_duplex(msg, code, size, dest)) ?
  456. msg : NULL;
  457. }
  458. int __init_ipc_resp_msg (struct shim_ipc_msg * resp, int ret,
  459. unsigned long seq);
  460. struct shim_ipc_msg *
  461. create_ipc_resp_msg (int ret, IDTYPE dest, unsigned long seq);
  462. static_always_inline
  463. struct shim_ipc_msg *
  464. create_ipc_resp_msg_on_stack (int ret, IDTYPE dest, unsigned long seq)
  465. {
  466. struct shim_ipc_msg * resp = create_ipc_msg_on_stack(IPC_RESP,
  467. sizeof(struct shim_ipc_resp), dest);
  468. return (resp && !__init_ipc_resp_msg(resp, ret, seq)) ? resp : NULL;
  469. }
  470. int send_ipc_message (struct shim_ipc_msg * msg, struct shim_ipc_port * port);
  471. int send_ipc_message_duplex (struct shim_ipc_msg_obj * msg,
  472. struct shim_ipc_port * port, bool save,
  473. void * private_data);
  474. int close_ipc_message_duplex (struct shim_ipc_msg_obj * msg,
  475. struct shim_ipc_port * port);
  476. int broadcast_ipc (struct shim_ipc_msg * msg, struct shim_ipc_port ** exclude,
  477. int exsize, int target_type);
  478. struct shim_ipc_msg_obj * find_ipc_msg_duplex (struct shim_ipc_port * port,
  479. unsigned long seq);
  480. int receive_ipc_message (struct shim_ipc_port * port, unsigned long seq,
  481. struct shim_ipc_msg ** msg);
  482. /* for convenience */
  483. int __response_ipc_message (struct shim_ipc_port * port, IDTYPE dest,
  484. int ret, unsigned long seq);
  485. int do_ipc_duplex (struct shim_ipc_msg_obj * msg,
  486. struct shim_ipc_port * port, unsigned long * seq,
  487. void * private_data);
  488. void ipc_child_exit (struct shim_ipc_port * port, IDTYPE vmid,
  489. unsigned int exitcode);
  490. int exit_with_ipc_helper (bool handover, struct shim_thread ** ret);
  491. #define IPC_FORCE_RECONNECT ((void*)-1)
  492. int prepare_ns_leaders (void);
  493. #endif /* _SHIM_IPC_H_ */