static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)

{

    VirtIONet *n = opaque;



    if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)

        return -EINVAL;



    virtio_load(&n->vdev, f);



    qemu_get_buffer(f, n->mac, ETH_ALEN);

    n->tx_timer_active = qemu_get_be32(f);

    n->mergeable_rx_bufs = qemu_get_be32(f);



    if (version_id >= 3)

        n->status = qemu_get_be16(f);



    if (version_id >= 4) {

        if (version_id < 8) {

            n->promisc = qemu_get_be32(f);

            n->allmulti = qemu_get_be32(f);

        } else {

            n->promisc = qemu_get_byte(f);

            n->allmulti = qemu_get_byte(f);

        }

    }



    if (version_id >= 5) {

        n->mac_table.in_use = qemu_get_be32(f);

        /* MAC_TABLE_ENTRIES may be different from the saved image */

        if (n->mac_table.in_use <= MAC_TABLE_ENTRIES) {

            qemu_get_buffer(f, n->mac_table.macs,

                            n->mac_table.in_use * ETH_ALEN);

        } else if (n->mac_table.in_use) {

            qemu_fseek(f, n->mac_table.in_use * ETH_ALEN, SEEK_CUR);

            n->promisc = 1;

            n->mac_table.in_use = 0;

        }

    }

 

    if (version_id >= 6)

        qemu_get_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3);



    if (version_id >= 7 && qemu_get_be32(f)) {

        fprintf(stderr,

                "virtio-net: saved image requires vnet header support\n");

        exit(1);

    }



    if (n->tx_timer_active) {

        qemu_mod_timer(n->tx_timer,

                       qemu_get_clock(vm_clock) + TX_TIMER_INTERVAL);

    }



    return 0;

}

static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)

{

    VirtIONet *n = opaque;



    if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)

        return -EINVAL;



    virtio_load(&n->vdev, f);



    qemu_get_buffer(f, n->mac, ETH_ALEN);

    n->tx_timer_active = qemu_get_be32(f);

    n->mergeable_rx_bufs = qemu_get_be32(f);



    if (version_id >= 3)

        n->status = qemu_get_be16(f);



    if (version_id >= 4) {

        if (version_id < 8) {

            n->promisc = qemu_get_be32(f);

            n->allmulti = qemu_get_be32(f);

        } else {

            n->promisc = qemu_get_byte(f);

            n->allmulti = qemu_get_byte(f);

        }

    }



    if (version_id >= 5) {

        n->mac_table.in_use = qemu_get_be32(f);

        

        if (n->mac_table.in_use <= MAC_TABLE_ENTRIES) {

            qemu_get_buffer(f, n->mac_table.macs,

                            n->mac_table.in_use * ETH_ALEN);

        } else if (n->mac_table.in_use) {

            qemu_fseek(f, n->mac_table.in_use * ETH_ALEN, SEEK_CUR);

            n->promisc = 1;

            n->mac_table.in_use = 0;

        }

    }

 

    if (version_id >= 6)

        qemu_get_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3);



    if (version_id >= 7 && qemu_get_be32(f)) {

        fprintf(stderr,

                "virtio-net: saved image requires vnet header support\n");

        exit(1);

    }



    if (n->tx_timer_active) {

        qemu_mod_timer(n->tx_timer,

                       qemu_get_clock(vm_clock) + TX_TIMER_INTERVAL);

    }



    return 0;

}

            n->promisc = 1;
static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, int VAR_2)

{

    VirtIONet *n = VAR_1;



    if (VAR_2 < 2 || VAR_2 > VIRTIO_NET_VM_VERSION)

        return -EINVAL;



    virtio_load(&n->vdev, VAR_0);



    qemu_get_buffer(VAR_0, n->mac, ETH_ALEN);

    n->tx_timer_active = qemu_get_be32(VAR_0);

    n->mergeable_rx_bufs = qemu_get_be32(VAR_0);



    if (VAR_2 >= 3)

        n->status = qemu_get_be16(VAR_0);



    if (VAR_2 >= 4) {

        if (VAR_2 < 8) {

            n->promisc = qemu_get_be32(VAR_0);

            n->allmulti = qemu_get_be32(VAR_0);

        } else {

            n->promisc = qemu_get_byte(VAR_0);

            n->allmulti = qemu_get_byte(VAR_0);

        }

    }



    if (VAR_2 >= 5) {

        n->mac_table.in_use = qemu_get_be32(VAR_0);

        

        if (n->mac_table.in_use <= MAC_TABLE_ENTRIES) {

            qemu_get_buffer(VAR_0, n->mac_table.macs,

                            n->mac_table.in_use * ETH_ALEN);

        } else if (n->mac_table.in_use) {

            qemu_fseek(VAR_0, n->mac_table.in_use * ETH_ALEN, SEEK_CUR);

            n->promisc = 1;

            n->mac_table.in_use = 0;

        }

    }

 

    if (VAR_2 >= 6)

        qemu_get_buffer(VAR_0, (uint8_t *)n->vlans, MAX_VLAN >> 3);



    if (VAR_2 >= 7 && qemu_get_be32(VAR_0)) {

        fprintf(stderr,

                "virtio-net: saved image requires vnet header support\n");

        exit(1);

    }



    if (n->tx_timer_active) {

        qemu_mod_timer(n->tx_timer,

                       qemu_get_clock(vm_clock) + TX_TIMER_INTERVAL);

    }



    return 0;

}

static int FUNC_0(QEMUFile *VAR_0, void *VAR_1, int VAR_2)
{ VirtIONet *n = VAR_1; if (VAR_2 < 2 || VAR_2 > VIRTIO_NET_VM_VERSION)
return -EINVAL; virtio_load(&n->vdev, VAR_0); qemu_get_buffer(VAR_0, n->mac, ETH_ALEN); n->tx_timer_active = qemu_get_be32(VAR_0); n->mergeable_rx_bufs = qemu_get_be32(VAR_0); if (VAR_2 >= 3)
n->status = qemu_get_be16(VAR_0); if (VAR_2 >= 4) { if (VAR_2 < 8) { n->promisc = qemu_get_be32(VAR_0); n->allmulti = qemu_get_be32(VAR_0); } else { n->promisc = qemu_get_byte(VAR_0); n->allmulti = qemu_get_byte(VAR_0); } } if (VAR_2 >= 5) { n->mac_table.in_use = qemu_get_be32(VAR_0); if (n->mac_table.in_use <= MAC_TABLE_ENTRIES) { qemu_get_buffer(VAR_0, n->mac_table.macs,
n->mac_table.in_use * ETH_ALEN); } else if (n->mac_table.in_use) { qemu_fseek(VAR_0, n->mac_table.in_use * ETH_ALEN, SEEK_CUR); n->promisc = 1; n->mac_table.in_use = 0; } } if (VAR_2 >= 6)
qemu_get_buffer(VAR_0, (uint8_t *)n->vlans, MAX_VLAN >> 3); if (VAR_2 >= 7 && qemu_get_be32(VAR_0)) { fprintf(stderr,
"virtio-net: saved image requires vnet header support\n"); exit(1); } if (n->tx_timer_active) { qemu_mod_timer(n->tx_timer,
qemu_get_clock(vm_clock) + TX_TIMER_INTERVAL); } return 0; }