/* This function won't work with non-blocking fd's. Any of the possibilities with non-bloking fd's is bad: */
ssize_t qemu_recv_full(int fd, void *buf, size_t count, int flags)
/* This function won't work with non-blocking fd's. Any of the possibilities with non-bloking fd's is bad: */
ssize_t qemu_recv_full(int fd, void *buf, size_t count, int flags)
{
    ssize_t ret = 0;
    ssize_t total = 0;
    while (count) {
        ret = qemu_recv(fd, buf, count, flags);
        if (ret <= 0) {
            if (ret < 0 && errno == EINTR) {
                continue;
            }
            break;
        }
        count -= ret;
        buf += ret;
        total += ret;
    }
    return total;
}