static void virtio_serial_save_device(VirtIODevice *vdev, QEMUFile *f)

{

    VirtIOSerial *s = VIRTIO_SERIAL(vdev);

    VirtIOSerialPort *port;

    uint32_t nr_active_ports;

    unsigned int i, max_nr_ports;

    struct virtio_console_config config;



    /* The config space (ignored on the far end in current versions) */

    get_config(vdev, (uint8_t *)&config);

    qemu_put_be16s(f, &config.cols);

    qemu_put_be16s(f, &config.rows);

    qemu_put_be32s(f, &config.max_nr_ports);



    /* The ports map */

    max_nr_ports = s->serial.max_virtserial_ports;

    for (i = 0; i < (max_nr_ports + 31) / 32; i++) {

        qemu_put_be32s(f, &s->ports_map[i]);

    }



    /* Ports */



    nr_active_ports = 0;

    QTAILQ_FOREACH(port, &s->ports, next) {

        nr_active_ports++;

    }



    qemu_put_be32s(f, &nr_active_ports);



    /*

     * Items in struct VirtIOSerialPort.

     */

    QTAILQ_FOREACH(port, &s->ports, next) {

        uint32_t elem_popped;



        qemu_put_be32s(f, &port->id);

        qemu_put_byte(f, port->guest_connected);

        qemu_put_byte(f, port->host_connected);



	elem_popped = 0;

        if (port->elem.out_num) {

            elem_popped = 1;

        }

        qemu_put_be32s(f, &elem_popped);

        if (elem_popped) {

            qemu_put_be32s(f, &port->iov_idx);

            qemu_put_be64s(f, &port->iov_offset);



            qemu_put_buffer(f, (unsigned char *)&port->elem,

                            sizeof(port->elem));

        }

    }

}

static void virtio_serial_save_device(VirtIODevice *vdev, QEMUFile *f)

{

    VirtIOSerial *s = VIRTIO_SERIAL(vdev);

    VirtIOSerialPort *port;

    uint32_t nr_active_ports;

    unsigned int i, max_nr_ports;

    struct virtio_console_config config;



    

    get_config(vdev, (uint8_t *)&config);

    qemu_put_be16s(f, &config.cols);

    qemu_put_be16s(f, &config.rows);

    qemu_put_be32s(f, &config.max_nr_ports);



    

    max_nr_ports = s->serial.max_virtserial_ports;

    for (i = 0; i < (max_nr_ports + 31) / 32; i++) {

        qemu_put_be32s(f, &s->ports_map[i]);

    }



    



    nr_active_ports = 0;

    QTAILQ_FOREACH(port, &s->ports, next) {

        nr_active_ports++;

    }



    qemu_put_be32s(f, &nr_active_ports);



    





    QTAILQ_FOREACH(port, &s->ports, next) {

        uint32_t elem_popped;



        qemu_put_be32s(f, &port->id);

        qemu_put_byte(f, port->guest_connected);

        qemu_put_byte(f, port->host_connected);



	elem_popped = 0;

        if (port->elem.out_num) {

            elem_popped = 1;

        }

        qemu_put_be32s(f, &elem_popped);

        if (elem_popped) {

            qemu_put_be32s(f, &port->iov_idx);

            qemu_put_be64s(f, &port->iov_offset);



            qemu_put_buffer(f, (unsigned char *)&port->elem,

                            sizeof(port->elem));

        }

    }

}

static void FUNC_0(VirtIODevice *VAR_0, QEMUFile *VAR_1)

{

    VirtIOSerial *s = VIRTIO_SERIAL(VAR_0);

    VirtIOSerialPort *port;

    uint32_t nr_active_ports;

    unsigned int VAR_2, VAR_3;

    struct virtio_console_config VAR_4;



    

    get_config(VAR_0, (uint8_t *)&VAR_4);

    qemu_put_be16s(VAR_1, &VAR_4.cols);

    qemu_put_be16s(VAR_1, &VAR_4.rows);

    qemu_put_be32s(VAR_1, &VAR_4.VAR_3);



    

    VAR_3 = s->serial.max_virtserial_ports;

    for (VAR_2 = 0; VAR_2 < (VAR_3 + 31) / 32; VAR_2++) {

        qemu_put_be32s(VAR_1, &s->ports_map[VAR_2]);

    }



    



    nr_active_ports = 0;

    QTAILQ_FOREACH(port, &s->ports, next) {

        nr_active_ports++;

    }



    qemu_put_be32s(VAR_1, &nr_active_ports);



    





    QTAILQ_FOREACH(port, &s->ports, next) {

        uint32_t elem_popped;



        qemu_put_be32s(VAR_1, &port->id);

        qemu_put_byte(VAR_1, port->guest_connected);

        qemu_put_byte(VAR_1, port->host_connected);



	elem_popped = 0;

        if (port->elem.out_num) {

            elem_popped = 1;

        }

        qemu_put_be32s(VAR_1, &elem_popped);

        if (elem_popped) {

            qemu_put_be32s(VAR_1, &port->iov_idx);

            qemu_put_be64s(VAR_1, &port->iov_offset);



            qemu_put_buffer(VAR_1, (unsigned char *)&port->elem,

                            sizeof(port->elem));

        }

    }

}

static void FUNC_0(VirtIODevice *VAR_0, QEMUFile *VAR_1)
{ VirtIOSerial *s = VIRTIO_SERIAL(VAR_0); VirtIOSerialPort *port; uint32_t nr_active_ports; unsigned int VAR_2, VAR_3; struct virtio_console_config VAR_4; get_config(VAR_0, (uint8_t *)&VAR_4); qemu_put_be16s(VAR_1, &VAR_4.cols); qemu_put_be16s(VAR_1, &VAR_4.rows); qemu_put_be32s(VAR_1, &VAR_4.VAR_3); VAR_3 = s->serial.max_virtserial_ports; for (VAR_2 = 0; VAR_2 < (VAR_3 + 31) / 32; VAR_2++) { qemu_put_be32s(VAR_1, &s->ports_map[VAR_2]); } nr_active_ports = 0; QTAILQ_FOREACH(port, &s->ports, next) { nr_active_ports++; } qemu_put_be32s(VAR_1, &nr_active_ports); QTAILQ_FOREACH(port, &s->ports, next) { uint32_t elem_popped; qemu_put_be32s(VAR_1, &port->id); qemu_put_byte(VAR_1, port->guest_connected); qemu_put_byte(VAR_1, port->host_connected); elem_popped = 0; if (port->elem.out_num) { elem_popped = 1; } qemu_put_be32s(VAR_1, &elem_popped); if (elem_popped) { qemu_put_be32s(VAR_1, &port->iov_idx); qemu_put_be64s(VAR_1, &port->iov_offset); qemu_put_buffer(VAR_1, (unsigned char *)&port->elem,
sizeof(port->elem)); } } }