/* Completes an AIO request (calls the callback and frees the ACB).  */
static void qemu_laio_process_completion(struct qemu_laio_state *s, struct qemu_laiocb *laiocb)
/* Completes an AIO request (calls the callback and frees the ACB).  */
static void qemu_laio_process_completion(struct qemu_laio_state *s, struct qemu_laiocb *laiocb)
{
    int ret;
    ret = laiocb->ret;
    if (ret != -ECANCELED) {
        if (ret == laiocb->nbytes) {
            ret = 0;
        } else if (ret >= 0) {
            if (laiocb->is_read) {
                qemu_iovec_memset(laiocb->qiov, ret, 0,
                    laiocb->qiov->size - ret);
            } else {
                ret = -EINVAL;
            }
        }
        laiocb->common.cb(laiocb->common.opaque, ret);
    }
    qemu_aio_release(laiocb);
}