static int qemu_chr_fe_write_buffer(CharDriverState *s, const uint8_t *buf, int len, int *offset)

{

    int res = 0;

    *offset = 0;



    qemu_mutex_lock(&s->chr_write_lock);

    while (*offset < len) {

        do {

            res = s->chr_write(s, buf + *offset, len - *offset);

            if (res == -1 && errno == EAGAIN) {

                g_usleep(100);

            }

        } while (res == -1 && errno == EAGAIN);



        if (res <= 0) {

            break;

        }



        *offset += res;

    }

    if (*offset > 0) {

        qemu_chr_fe_write_log(s, buf, *offset);

    }

    qemu_mutex_unlock(&s->chr_write_lock);



    return res;

}

static int qemu_chr_fe_write_buffer(CharDriverState *s, const uint8_t *buf, int len, int *offset)

{

    int res = 0;

    *offset = 0;



    qemu_mutex_lock(&s->chr_write_lock);

    while (*offset < len) {

        do {

            res = s->chr_write(s, buf + *offset, len - *offset);

            if (res == -1 && errno == EAGAIN) {

                g_usleep(100);

            }

        } while (res == -1 && errno == EAGAIN);



        if (res <= 0) {

            break;

        }



        *offset += res;

    }

    if (*offset > 0) {

        qemu_chr_fe_write_log(s, buf, *offset);

    }

    qemu_mutex_unlock(&s->chr_write_lock);



    return res;

}

        do {                 g_usleep(100);         do {             res = s->chr_write(s, buf + *offset, len - *offset);             if (res == -1 && errno == EAGAIN) {                 g_usleep(100);         } while (res == -1 && errno == EAGAIN);         do {             if (res == -1 && errno == EAGAIN) {                 g_usleep(100);         } while (res == -1 && errno == EAGAIN);
static int FUNC_0(CharDriverState *VAR_0, const uint8_t *VAR_1, int VAR_2, int *VAR_3)

{

    int VAR_4 = 0;

    *VAR_3 = 0;



    qemu_mutex_lock(&VAR_0->chr_write_lock);

    while (*VAR_3 < VAR_2) {

        do {

            VAR_4 = VAR_0->chr_write(VAR_0, VAR_1 + *VAR_3, VAR_2 - *VAR_3);

            if (VAR_4 == -1 && errno == EAGAIN) {

                g_usleep(100);

            }

        } while (VAR_4 == -1 && errno == EAGAIN);



        if (VAR_4 <= 0) {

            break;

        }



        *VAR_3 += VAR_4;

    }

    if (*VAR_3 > 0) {

        qemu_chr_fe_write_log(VAR_0, VAR_1, *VAR_3);

    }

    qemu_mutex_unlock(&VAR_0->chr_write_lock);



    return VAR_4;

}

static int FUNC_0(CharDriverState *VAR_0, const uint8_t *VAR_1, int VAR_2, int *VAR_3)
{ int VAR_4 = 0; *VAR_3 = 0; qemu_mutex_lock(&VAR_0->chr_write_lock); while (*VAR_3 < VAR_2) { do { VAR_4 = VAR_0->chr_write(VAR_0, VAR_1 + *VAR_3, VAR_2 - *VAR_3); if (VAR_4 == -1 && errno == EAGAIN) { g_usleep(100); } } while (VAR_4 == -1 && errno == EAGAIN); if (VAR_4 <= 0) { break; } *VAR_3 += VAR_4; } if (*VAR_3 > 0) { qemu_chr_fe_write_log(VAR_0, VAR_1, *VAR_3); } qemu_mutex_unlock(&VAR_0->chr_write_lock); return VAR_4; }