Lines Matching +full:fail +full:- +full:safe

7  * See the COPYING file in the top-level directory.
14 #include "hw/remote/mpqemu-link.h"
17 #include "qemu/error-report.h"
18 #include "qemu/main-loop.h"
25 * This function is safe to call from:
26 * - main loop in co-routine context. Will block the main loop if not in
27 * co-routine context;
28 * - vCPU thread with no co-routine context and if the channel is not part
30 * - IOThread within co-routine context, outside of co-routine context
46 send[1].iov_base = (void *)&msg->data; in mpqemu_msg_send()
47 send[1].iov_len = msg->size; in mpqemu_msg_send()
49 if (msg->num_fds) { in mpqemu_msg_send()
50 nfds = msg->num_fds; in mpqemu_msg_send()
51 fds = msg->fds; in mpqemu_msg_send()
55 * Dont use in IOThread out of co-routine context as in mpqemu_msg_send()
62 * in co-routine context. Co-routine context is asserted above in mpqemu_msg_send()
64 * Also skip lock handling while in a co-routine in the main context. in mpqemu_msg_send()
74 trace_mpqemu_send_io_error(msg->cmd, msg->size, nfds); in mpqemu_msg_send()
87 * This function is safe to call from:
88 * - From main loop in co-routine context. Will block the main loop if not in
89 * co-routine context;
90 * - From vCPU thread with no co-routine context and if the channel is not part
92 * - From IOThread within co-routine context, outside of co-routine context
101 int ret = -1; in mpqemu_read()
104 * Dont use in IOThread out of co-routine context as in mpqemu_read()
132 goto fail; in mpqemu_msg_recv()
135 goto fail; in mpqemu_msg_recv()
138 if (msg->size > sizeof(msg->data)) { in mpqemu_msg_recv()
140 goto fail; in mpqemu_msg_recv()
143 if (!msg->size) { in mpqemu_msg_recv()
147 len = mpqemu_read(ioc, &msg->data, msg->size, NULL, NULL, errp); in mpqemu_msg_recv()
149 goto fail; in mpqemu_msg_recv()
151 if (len != msg->size) { in mpqemu_msg_recv()
153 goto fail; in mpqemu_msg_recv()
157 msg->num_fds = nfds; in mpqemu_msg_recv()
158 if (nfds > G_N_ELEMENTS(msg->fds)) { in mpqemu_msg_recv()
162 goto fail; in mpqemu_msg_recv()
165 memcpy(msg->fds, fds, nfds * sizeof(int)); in mpqemu_msg_recv()
170 fail: in mpqemu_msg_recv()
172 trace_mpqemu_recv_io_error(msg->cmd, msg->size, nfds); in mpqemu_msg_recv()
175 close(fds[nfds - 1]); in mpqemu_msg_recv()
176 nfds--; in mpqemu_msg_recv()
186 * Called from VCPU thread in non-coroutine context.
197 QEMU_LOCK_GUARD(&pdev->io_mutex); in mpqemu_msg_send_and_await_reply()
198 if (!mpqemu_msg_send(msg, pdev->ioc, errp)) { in mpqemu_msg_send_and_await_reply()
202 if (!mpqemu_msg_recv(&msg_reply, pdev->ioc, errp)) { in mpqemu_msg_send_and_await_reply()
208 msg->cmd); in mpqemu_msg_send_and_await_reply()
217 if (msg->cmd >= MPQEMU_CMD_MAX || msg->cmd < 0) { in mpqemu_msg_valid()
222 if (msg->num_fds >= REMOTE_MAX_FDS) { in mpqemu_msg_valid()
226 if (msg->num_fds > 0) { in mpqemu_msg_valid()
227 for (int i = 0; i < msg->num_fds; i++) { in mpqemu_msg_valid()
228 if (fcntl(msg->fds[i], F_GETFL) == -1) { in mpqemu_msg_valid()
235 switch (msg->cmd) { in mpqemu_msg_valid()
237 if (msg->num_fds == 0 || msg->size != sizeof(SyncSysmemMsg)) { in mpqemu_msg_valid()
243 if (msg->size != sizeof(PciConfDataMsg)) { in mpqemu_msg_valid()
249 if ((msg->size != sizeof(BarAccessMsg)) || (msg->num_fds != 0)) { in mpqemu_msg_valid()
254 if (msg->size || (msg->num_fds != 2)) { in mpqemu_msg_valid()