shim_ipc.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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. #ifdef PROFILE
  135. unsigned long time;
  136. #endif
  137. } __attribute__((packed));
  138. int ipc_cld_exit_send (IDTYPE ppid, IDTYPE tid, unsigned int exitcode);
  139. int ipc_cld_exit_callback (IPC_CALLBACK_ARGS);
  140. /* CLD_JOIN: child join the parent group */
  141. int ipc_cld_join_send (IDTYPE dest);
  142. int ipc_cld_join_callback (IPC_CALLBACK_ARGS);
  143. #ifdef PROFILE
  144. # include <shim_profile.h>
  145. struct shim_ipc_cld_profile {
  146. unsigned long time;
  147. int nprofile;
  148. struct profile_val profile[];
  149. } __attribute__((packed));
  150. int ipc_cld_profile_send (void);
  151. int ipc_cld_profile_callback (IPC_CALLBACK_ARGS);
  152. #endif
  153. /* Message code to namespace manager */
  154. #define IPC_PID_BASE IPC_CLD_BOUND
  155. #define NS pid
  156. #define NS_CAP PID
  157. #include "shim_ipc_ns.h"
  158. enum {
  159. IPC_PID_KILL = IPC_PID_TEMPLATE_BOUND,
  160. IPC_PID_GETSTATUS,
  161. IPC_PID_RETSTATUS,
  162. IPC_PID_GETMETA,
  163. IPC_PID_RETMETA,
  164. IPC_PID_NOP,
  165. IPC_PID_SENDRPC,
  166. IPC_PID_BOUND,
  167. };
  168. enum kill_type { KILL_THREAD, KILL_PROCESS, KILL_PGROUP, KILL_ALL };
  169. /* PID_KILL: send signal to certain pid */
  170. struct shim_ipc_pid_kill {
  171. IDTYPE sender;
  172. enum kill_type type;
  173. IDTYPE id;
  174. int signum;
  175. } __attribute__((packed));
  176. int ipc_pid_kill_send (IDTYPE sender, IDTYPE id, enum kill_type type,
  177. int signum);
  178. int ipc_pid_kill_callback (IPC_CALLBACK_ARGS);
  179. struct pid_status {
  180. IDTYPE pid, tgid, pgid;
  181. } __attribute__((packed));
  182. /* PID_GETSTATUS: check if certain pid(s) exists */
  183. struct shim_ipc_pid_getstatus {
  184. int npids;
  185. IDTYPE pids[];
  186. } __attribute__((packed));
  187. int ipc_pid_getstatus_send (struct shim_ipc_port * port, IDTYPE dest,
  188. int npids, IDTYPE * pids,
  189. struct pid_status ** status);
  190. int ipc_pid_getstatus_callback (IPC_CALLBACK_ARGS);
  191. /* PID_RETSTATUS: return status of pid(s) */
  192. struct shim_ipc_pid_retstatus {
  193. int nstatus;
  194. struct pid_status status[];
  195. } __attribute__((packed));
  196. int ipc_pid_retstatus_send (struct shim_ipc_port * port, IDTYPE dest,
  197. int nstatus, struct pid_status * status,
  198. unsigned long seq);
  199. int ipc_pid_retstatus_callback (IPC_CALLBACK_ARGS);
  200. /* PID_GETMETA: get metadata of certain pid */
  201. enum pid_meta_code {
  202. PID_META_CRED,
  203. PID_META_EXEC,
  204. PID_META_CWD,
  205. PID_META_ROOT,
  206. };
  207. struct shim_ipc_pid_getmeta {
  208. IDTYPE pid;
  209. enum pid_meta_code code;
  210. } __attribute__((packed));
  211. int ipc_pid_getmeta_send (IDTYPE pid, enum pid_meta_code code,
  212. void ** data);
  213. int ipc_pid_getmeta_callback (IPC_CALLBACK_ARGS);
  214. /* PID_RETMETA: return metadata of certain pid */
  215. struct shim_ipc_pid_retmeta {
  216. IDTYPE pid;
  217. enum pid_meta_code code;
  218. int datasize;
  219. char data[];
  220. } __attribute__((packed));
  221. int ipc_pid_retmeta_send (struct shim_ipc_port * port, IDTYPE dest,
  222. IDTYPE pid, enum pid_meta_code code,
  223. const void * data, int datasize,
  224. unsigned long seq);
  225. int ipc_pid_retmeta_callback (IPC_CALLBACK_ARGS);
  226. /* PID_NOP: send junk message (for benchmarking) */
  227. struct shim_ipc_pid_nop {
  228. int count;
  229. char payload[];
  230. } __attribute__((packed));
  231. int ipc_pid_nop_send (struct shim_ipc_port * port, IDTYPE dest, int count,
  232. const void * buf, int len);
  233. int ipc_pid_nop_callback(IPC_CALLBACK_ARGS);
  234. /* PID_SENDRPC: send arbitary message (for benchmarking) */
  235. struct shim_ipc_pid_sendrpc {
  236. IDTYPE sender;
  237. int len;
  238. char payload[];
  239. } __attribute__((packed));
  240. int ipc_pid_sendrpc_send (IDTYPE pid, IDTYPE sender, const void * buf,
  241. int len);
  242. int ipc_pid_sendrpc_callback (IPC_CALLBACK_ARGS);
  243. #define IPC_SYSV_BASE IPC_PID_BOUND
  244. struct sysv_key {
  245. unsigned long key;
  246. enum sysv_type type;
  247. };
  248. #define NS sysv
  249. #define NS_CAP SYSV
  250. #define NS_KEY struct sysv_key
  251. #include "shim_ipc_ns.h"
  252. enum {
  253. IPC_SYSV_DELRES = IPC_SYSV_TEMPLATE_BOUND,
  254. IPC_SYSV_MOVRES,
  255. IPC_SYSV_MSGSND,
  256. IPC_SYSV_MSGRCV,
  257. IPC_SYSV_MSGMOV,
  258. IPC_SYSV_SEMOP,
  259. IPC_SYSV_SEMCTL,
  260. IPC_SYSV_SEMRET,
  261. IPC_SYSV_SEMMOV,
  262. #ifdef USE_SHARED_SEMAPHORE
  263. IPC_SYSV_SEMQUERY,
  264. IPC_SYSV_SEMREPLY,
  265. #endif
  266. IPC_SYSV_BOUND,
  267. };
  268. /* SYSV_DELRES */
  269. struct shim_ipc_sysv_delres {
  270. IDTYPE resid;
  271. enum sysv_type type;
  272. } __attribute__((packed));
  273. int ipc_sysv_delres_send (struct shim_ipc_port * port, IDTYPE dest,
  274. IDTYPE resid, enum sysv_type type);
  275. int ipc_sysv_delres_callback (IPC_CALLBACK_ARGS);
  276. /* SYSV_MOVRES */
  277. struct shim_ipc_sysv_movres {
  278. IDTYPE resid;
  279. enum sysv_type type;
  280. IDTYPE owner;
  281. LEASETYPE lease;
  282. char uri[1];
  283. } __attribute__((packed));
  284. int ipc_sysv_movres_send (struct sysv_client * client, IDTYPE owner,
  285. const char * uri, LEASETYPE lease, IDTYPE resid,
  286. enum sysv_type type);
  287. int ipc_sysv_movres_callback (IPC_CALLBACK_ARGS);
  288. /* SYSV_MSGSND */
  289. struct shim_ipc_sysv_msgsnd {
  290. IDTYPE msgid;
  291. long msgtype;
  292. char msg[];
  293. } __attribute__((packed));
  294. int ipc_sysv_msgsnd_send (struct shim_ipc_port * port, IDTYPE dest,
  295. IDTYPE msgid, long msgtype,
  296. const void * buf, size_t size, unsigned long seq);
  297. int ipc_sysv_msgsnd_callback (IPC_CALLBACK_ARGS);
  298. /* SYSV_MSGRCV */
  299. struct shim_ipc_sysv_msgrcv {
  300. IDTYPE msgid;
  301. long msgtype;
  302. int size;
  303. int flags;
  304. } __attribute__((packed));
  305. int ipc_sysv_msgrcv_send (IDTYPE msgid, long msgtype, int flags, void * buf,
  306. size_t size);
  307. int ipc_sysv_msgrcv_callback (IPC_CALLBACK_ARGS);
  308. /* SYSV_MSGMOV */
  309. struct shim_ipc_sysv_msgmov {
  310. IDTYPE msgid;
  311. LEASETYPE lease;
  312. unsigned short nscores;
  313. struct sysv_score scores[];
  314. } __attribute__((packed));
  315. int ipc_sysv_msgmov_send (struct shim_ipc_port * port, IDTYPE dest,
  316. IDTYPE msgid, LEASETYPE lease,
  317. struct sysv_score * scores, int nscores);
  318. int ipc_sysv_msgmov_callback (IPC_CALLBACK_ARGS);
  319. /* SYSV_SEMOP */
  320. struct shim_ipc_sysv_semop {
  321. IDTYPE semid;
  322. unsigned long timeout;
  323. int nsops;
  324. struct sembuf sops[];
  325. } __attribute__((packed));
  326. #define IPC_SEM_NOTIMEOUT ((unsigned long) -1)
  327. int ipc_sysv_semop_send (IDTYPE semid, struct sembuf * sops, int nsops,
  328. unsigned long timeout, unsigned long * seq);
  329. int ipc_sysv_semop_callback (IPC_CALLBACK_ARGS);
  330. /* SYSV_SEMCTL */
  331. struct shim_ipc_sysv_semctl {
  332. IDTYPE semid;
  333. int semnum;
  334. int cmd;
  335. int valsize;
  336. unsigned char vals[];
  337. } __attribute__((packed));
  338. int ipc_sysv_semctl_send (IDTYPE semid, int semnum, int cmd, void * vals,
  339. int valsize);
  340. int ipc_sysv_semctl_callback (IPC_CALLBACK_ARGS);
  341. /* SYSV_SEMRET */
  342. struct shim_ipc_sysv_semret {
  343. int valsize;
  344. unsigned char vals[];
  345. } __attribute__((packed));
  346. int ipc_sysv_semret_send (struct shim_ipc_port * port, IDTYPE dest,
  347. void * vals, int valsize, unsigned long seq);
  348. int ipc_sysv_semret_callback (IPC_CALLBACK_ARGS);
  349. /* SYSV_SEMMOV */
  350. struct shim_ipc_sysv_semmov {
  351. IDTYPE semid;
  352. LEASETYPE lease;
  353. unsigned short nsems, nsrcs, nscores;
  354. struct sem_backup sems[];
  355. } __attribute__((packed));
  356. int ipc_sysv_semmov_send (struct shim_ipc_port * port, IDTYPE dest,
  357. IDTYPE semid, LEASETYPE lease,
  358. struct sem_backup * sems, int nsems,
  359. struct sem_client_backup * srcs, int nsrcs,
  360. struct sysv_score * scores, int nscores);
  361. int ipc_sysv_semmov_callback (IPC_CALLBACK_ARGS);
  362. #ifdef USE_SHARED_SEMAPHORE
  363. /* SYSV_SEMQUERY */
  364. struct shim_ipc_sysv_semquery {
  365. IDTYPE semid;
  366. } __attribute__((packed));
  367. int ipc_sysv_semquery_send (IDTYPE semid, int * nsems, PAL_NUM ** host_sem_ids);
  368. int ipc_sysv_semquery_callback (IPC_CALLBACK_ARGS);
  369. /* SYSV_SEMREPLY */
  370. struct shim_ipc_sysv_semreply {
  371. IDTYPE semid;
  372. int nsems;
  373. PAL_NUM host_sem_ids[];
  374. } __attribute__((packed));
  375. int ipc_sysv_semreply_send (struct shim_ipc_port * port, IDTYPE dest,
  376. IDTYPE semid, int nsems, PAL_NUM * host_sem_ids,
  377. unsigned long seq);
  378. int ipc_sysv_semreply_callback (IPC_CALLBACK_ARGS);
  379. #endif
  380. #define IPC_CODE_NUM IPC_SYSV_BOUND
  381. /* functions and routines */
  382. int init_ipc (void);
  383. int init_ipc_helper (void);
  384. struct shim_process * create_new_process (bool inherit_parent);
  385. void destroy_process (struct shim_process * proc);
  386. struct shim_ipc_info * create_ipc_port (IDTYPE vmid, bool listen);
  387. int create_ipc_location (struct shim_ipc_info ** pinfo);
  388. enum {
  389. LISTEN, /* listening */
  390. SERVER, /* connect as a server */
  391. KEEPALIVE, /* keep the connetion alive */
  392. DIRCLD, /* direct child */
  393. DIRPRT, /* direct parent */
  394. NS_PORT_CONSTS(PID)
  395. NS_PORT_CONSTS(SYSV)
  396. };
  397. enum {
  398. IPC_PORT_LISTEN = 1<<LISTEN,
  399. IPC_PORT_SERVER = 1<<SERVER,
  400. IPC_PORT_KEEPALIVE = 1<<KEEPALIVE,
  401. IPC_PORT_DIRCLD = 1<<DIRCLD,
  402. IPC_PORT_DIRPRT = 1<<DIRPRT,
  403. NS_PORT_TYPES(PID)
  404. NS_PORT_TYPES(SYSV)
  405. };
  406. #define IPC_PORT_IFPOLL (IPC_PORT_SERVER|IPC_PORT_LISTEN)
  407. /* general-purpose routines */
  408. void add_ipc_port_by_id (IDTYPE vmid, PAL_HANDLE hdl, int type,
  409. port_fini fini,
  410. struct shim_ipc_port ** portptr);
  411. void add_ipc_port (struct shim_ipc_port * port, IDTYPE vmid, int type,
  412. port_fini fini);
  413. void del_ipc_port_by_id (IDTYPE vm_pid, int type);
  414. void del_ipc_port (struct shim_ipc_port * port, int type);
  415. void del_ipc_port_fini (struct shim_ipc_port * port, unsigned int exitcode);
  416. struct shim_ipc_port * lookup_ipc_port (IDTYPE vmid, int type);
  417. void get_ipc_port (struct shim_ipc_port * port);
  418. void put_ipc_port (struct shim_ipc_port * port);
  419. void del_all_ipc_ports (int type);
  420. struct shim_ipc_info * get_new_ipc_info (IDTYPE vmid, const char * uri,
  421. size_t len);
  422. void get_ipc_info(struct shim_ipc_info * port);
  423. void put_ipc_info(struct shim_ipc_info * port);
  424. struct shim_ipc_info * lookup_and_alloc_client (IDTYPE vmid, const char * uri);
  425. void put_client (struct shim_ipc_info * info);
  426. struct shim_ipc_info * discover_client (struct shim_ipc_port * port,
  427. IDTYPE vmid);
  428. #define IPC_MSG_SIZE(extra) \
  429. ({ int _size = (extra) + sizeof(struct shim_ipc_msg); \
  430. _size > IPC_MSG_MINIMAL_SIZE ? _size : IPC_MSG_MINIMAL_SIZE; })
  431. #define IPC_MSGOBJ_SIZE(extra) \
  432. ({ int _size = (extra) + sizeof(struct shim_ipc_msg); \
  433. (_size > IPC_MSG_MINIMAL_SIZE ? _size : IPC_MSG_MINIMAL_SIZE) + \
  434. (sizeof(struct shim_ipc_msg_obj) - sizeof(struct shim_ipc_msg)); })
  435. int __init_ipc_msg (struct shim_ipc_msg * msg, int code, int size, IDTYPE dest);
  436. struct shim_ipc_msg * create_ipc_msg (int code, int size, IDTYPE dest);
  437. static_inline
  438. struct shim_ipc_msg * create_ipc_msg_on_stack (int code, int size, IDTYPE dest)
  439. {
  440. struct shim_ipc_msg * msg = __alloca(IPC_MSG_SIZE(size));
  441. return (!__init_ipc_msg(msg, code, size, dest)) ? msg : NULL;
  442. }
  443. int __init_ipc_msg_duplex (struct shim_ipc_msg_obj * msg, int code, int size,
  444. IDTYPE dest);
  445. struct shim_ipc_msg_obj *
  446. create_ipc_msg_duplex (int code, int size, IDTYPE dest);
  447. static_inline
  448. struct shim_ipc_msg_obj *
  449. create_ipc_msg_duplex_on_stack (int code, int size, IDTYPE dest)
  450. {
  451. struct shim_ipc_msg_obj * msg = __alloca(IPC_MSGOBJ_SIZE(size));
  452. return (!__init_ipc_msg_duplex(msg, code, size, dest)) ?
  453. msg : NULL;
  454. }
  455. int __init_ipc_resp_msg (struct shim_ipc_msg * resp, int ret,
  456. unsigned long seq);
  457. struct shim_ipc_msg *
  458. create_ipc_resp_msg (int ret, IDTYPE dest, unsigned long seq);
  459. static_inline
  460. struct shim_ipc_msg *
  461. create_ipc_resp_msg_on_stack (int ret, IDTYPE dest, unsigned long seq)
  462. {
  463. struct shim_ipc_msg * resp = create_ipc_msg_on_stack(IPC_RESP,
  464. sizeof(struct shim_ipc_resp), dest);
  465. return (resp && !__init_ipc_resp_msg(resp, ret, seq)) ? resp : NULL;
  466. }
  467. int send_ipc_message (struct shim_ipc_msg * msg, struct shim_ipc_port * port);
  468. int send_ipc_message_duplex (struct shim_ipc_msg_obj * msg,
  469. struct shim_ipc_port * port, bool save,
  470. void * private_data);
  471. int close_ipc_message_duplex (struct shim_ipc_msg_obj * msg,
  472. struct shim_ipc_port * port);
  473. int broadcast_ipc (struct shim_ipc_msg * msg, struct shim_ipc_port ** exclude,
  474. int exsize, int target_type);
  475. struct shim_ipc_msg_obj * find_ipc_msg_duplex (struct shim_ipc_port * port,
  476. unsigned long seq);
  477. int receive_ipc_message (struct shim_ipc_port * port, unsigned long seq,
  478. struct shim_ipc_msg ** msg);
  479. /* for convenience */
  480. int __response_ipc_message (struct shim_ipc_port * port, IDTYPE dest,
  481. int ret, unsigned long seq);
  482. int do_ipc_duplex (struct shim_ipc_msg_obj * msg,
  483. struct shim_ipc_port * port, unsigned long * seq,
  484. void * private_data);
  485. void ipc_parent_exit (struct shim_ipc_port * port, IDTYPE vmid,
  486. unsigned int exitcode);
  487. void ipc_child_exit (struct shim_ipc_port * port, IDTYPE vmid,
  488. unsigned int exitcode);
  489. int create_ipc_helper (void);
  490. int exit_with_ipc_helper (bool handover);
  491. #define IPC_FORCE_RECONNECT ((void *) -1)
  492. int prepare_ns_leaders (void);
  493. #endif /* _SHIM_IPC_H_ */