shim_ipc.h 18 KB

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