[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 32/41] virtio-net: split virtio_net_post_load
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 32/41] virtio-net: split virtio_net_post_load |
Date: |
Wed, 2 Dec 2009 13:04:30 +0100 |
Signed-off-by: Juan Quintela <address@hidden>
---
hw/virtio-net.c | 79 ++++++++++++++++++++++++++++++++-----------------------
1 files changed, 46 insertions(+), 33 deletions(-)
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 550a814..4434827 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -703,6 +703,51 @@ static void virtio_net_tx_timer(void *opaque)
virtio_net_flush_tx(n, n->tx_vq);
}
+static int virtio_net_post_load(void *opaque, int version_id)
+{
+ VirtIONet *n = opaque;
+ int i;
+
+ if (version_id >= 7) {
+ if (n->has_vnet_hdr && !peer_has_vnet_hdr(n)) {
+ qemu_error("virtio-net: saved image requires vnet_hdr=on\n");
+ return -1;
+ }
+
+ if (n->has_vnet_hdr) {
+ tap_using_vnet_hdr(n->vc->peer, 1);
+ tap_set_offload(n->vc->peer,
+ (n->vdev.features >> VIRTIO_NET_F_GUEST_CSUM) & 1,
+ (n->vdev.features >> VIRTIO_NET_F_GUEST_TSO4) & 1,
+ (n->vdev.features >> VIRTIO_NET_F_GUEST_TSO6) & 1,
+ (n->vdev.features >> VIRTIO_NET_F_GUEST_ECN) & 1,
+ (n->vdev.features >> VIRTIO_NET_F_GUEST_UFO) & 1);
+ }
+ }
+
+ if (version_id >= 11) {
+ if (n->has_ufo && !peer_has_ufo(n)) {
+ qemu_error("virtio-net: saved image requires TUN_F_UFO support\n");
+ return -1;
+ }
+ }
+
+ /* Find the first multicast entry in the saved MAC filter */
+ for (i = 0; i < n->mac_table.in_use; i++) {
+ if (n->mac_table.macs[i * ETH_ALEN] & 1) {
+ break;
+ }
+ }
+ n->mac_table.first_multi = i;
+
+ if (n->tx_timer_active) {
+ qemu_mod_timer(n->tx_timer,
+ qemu_get_clock(vm_clock) + TX_TIMER_INTERVAL);
+ }
+
+ return 0;
+}
+
static void virtio_net_save(QEMUFile *f, void *opaque)
{
VirtIONet *n = opaque;
@@ -731,7 +776,6 @@ static void virtio_net_save(QEMUFile *f, void *opaque)
static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
{
VirtIONet *n = opaque;
- int i;
if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
return -EINVAL;
@@ -766,20 +810,6 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int
version_id)
if (version_id >= 7) {
qemu_get_be32s(f, &n->has_vnet_hdr);
- if (n->has_vnet_hdr && !peer_has_vnet_hdr(n)) {
- qemu_error("virtio-net: saved image requires vnet_hdr=on\n");
- return -1;
- }
-
- if (n->has_vnet_hdr) {
- tap_using_vnet_hdr(n->vc->peer, 1);
- tap_set_offload(n->vc->peer,
- (n->vdev.features >> VIRTIO_NET_F_GUEST_CSUM) & 1,
- (n->vdev.features >> VIRTIO_NET_F_GUEST_TSO4) & 1,
- (n->vdev.features >> VIRTIO_NET_F_GUEST_TSO6) & 1,
- (n->vdev.features >> VIRTIO_NET_F_GUEST_ECN) & 1,
- (n->vdev.features >> VIRTIO_NET_F_GUEST_UFO) & 1);
- }
}
if (version_id >= 9) {
@@ -796,26 +826,9 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int
version_id)
if (version_id >= 11) {
qemu_get_8s(f, &n->has_ufo);
- if (n->has_ufo && !peer_has_ufo(n)) {
- qemu_error("virtio-net: saved image requires TUN_F_UFO support\n");
- return -1;
- }
}
- /* Find the first multicast entry in the saved MAC filter */
- for (i = 0; i < n->mac_table.in_use; i++) {
- if (n->mac_table.macs[i * ETH_ALEN] & 1) {
- break;
- }
- }
- n->mac_table.first_multi = i;
-
- if (n->tx_timer_active) {
- qemu_mod_timer(n->tx_timer,
- qemu_get_clock(vm_clock) + TX_TIMER_INTERVAL);
- }
-
- return 0;
+ return virtio_net_post_load(n, version_id);
}
static void virtio_net_cleanup(VLANClientState *vc)
--
1.6.5.2
- [Qemu-devel] Re: [PATCH 27/41] virtio-net: abstract vlans operations, (continued)
[Qemu-devel] [PATCH 30/41] virtio-net: use save/load type chek functions for has_vent_hdr, Juan Quintela, 2009/12/02
[Qemu-devel] [PATCH 32/41] virtio-net: split virtio_net_post_load,
Juan Quintela <=
[Qemu-devel] [PATCH 31/41] virtio-net: we know macs size at compile time, make it static, Juan Quintela, 2009/12/02
[Qemu-devel] [PATCH 33/41] virtio-net: port to vmstate, Juan Quintela, 2009/12/02
[Qemu-devel] Re: [PATCH 33/41] virtio-net: port to vmstate, Michael S. Tsirkin, 2009/12/02