Home | History | Annotate | Download | only in qemu

Lines Matching defs:aiocb

121 static ssize_t handle_aiocb_ioctl(struct qemu_paiocb *aiocb)
125 ret = ioctl(aiocb->aio_fildes, aiocb->aio_ioctl_cmd, aiocb->aio_ioctl_buf);
137 return aiocb->aio_nbytes;
140 static ssize_t handle_aiocb_flush(struct qemu_paiocb *aiocb)
144 ret = qemu_fdatasync(aiocb->aio_fildes);
180 static ssize_t handle_aiocb_rw_vector(struct qemu_paiocb *aiocb)
186 if (aiocb->aio_type & QEMU_AIO_WRITE)
187 len = qemu_pwritev(aiocb->aio_fildes,
188 aiocb->aio_iov,
189 aiocb->aio_niov,
190 aiocb->aio_offset + offset);
192 len = qemu_preadv(aiocb->aio_fildes,
193 aiocb->aio_iov,
194 aiocb->aio_niov,
195 aiocb->aio_offset + offset);
203 static ssize_t handle_aiocb_rw_linear(struct qemu_paiocb *aiocb, char *buf)
208 while (offset < aiocb->aio_nbytes) {
209 if (aiocb->aio_type & QEMU_AIO_WRITE)
210 len = pwrite(aiocb->aio_fildes,
212 aiocb->aio_nbytes - offset,
213 aiocb->aio_offset + offset);
215 len = pread(aiocb->aio_fildes,
217 aiocb->aio_nbytes - offset,
218 aiocb->aio_offset + offset);
234 static ssize_t handle_aiocb_rw(struct qemu_paiocb *aiocb)
239 if (!(aiocb->aio_type & QEMU_AIO_MISALIGNED)) {
244 if (aiocb->aio_niov == 1)
245 return handle_aiocb_rw_linear(aiocb, aiocb->aio_iov->iov_base);
254 nbytes = handle_aiocb_rw_vector(aiocb);
255 if (nbytes == aiocb->aio_nbytes)
273 buf = qemu_blockalign(aiocb->common.bs, aiocb->aio_nbytes);
274 if (aiocb->aio_type & QEMU_AIO_WRITE) {
278 for (i = 0; i < aiocb->aio_niov; ++i) {
279 memcpy(p, aiocb->aio_iov[i].iov_base, aiocb->aio_iov[i].iov_len);
280 p += aiocb->aio_iov[i].iov_len;
284 nbytes = handle_aiocb_rw_linear(aiocb, buf);
285 if (!(aiocb->aio_type & QEMU_AIO_WRITE)) {
287 size_t count = aiocb->aio_nbytes, copy;
290 for (i = 0; i < aiocb->aio_niov && count; ++i) {
292 if (copy > aiocb->aio_iov[i].iov_len)
293 copy = aiocb->aio_iov[i].iov_len;
294 memcpy(aiocb->aio_iov[i].iov_base, p, copy);
311 struct qemu_paiocb *aiocb;
330 aiocb = QTAILQ_FIRST(&request_list);
331 QTAILQ_REMOVE(&request_list, aiocb, node);
332 aiocb->active = 1;
336 switch (aiocb->aio_type & QEMU_AIO_TYPE_MASK) {
339 ret = handle_aiocb_rw(aiocb);
342 ret = handle_aiocb_flush(aiocb);
345 ret = handle_aiocb_ioctl(aiocb);
348 fprintf(stderr, "invalid aio request (0x%x)\n", aiocb->aio_type);
354 aiocb->ret = ret;
358 if (kill(pid, aiocb->ev_signo)) die("kill failed");
384 static void qemu_paio_submit(struct qemu_paiocb *aiocb)
386 aiocb->ret = -EINPROGRESS;
387 aiocb->active = 0;
391 QTAILQ_INSERT_TAIL(&request_list, aiocb, node);
396 static ssize_t qemu_paio_return(struct qemu_paiocb *aiocb)
401 ret = aiocb->ret;
407 static int qemu_paio_error(struct qemu_paiocb *aiocb)
409 ssize_t ret = qemu_paio_return(aiocb);