Commit 9d6271b8a049372efd6b06bbb794f278777f7b86
1 parent
b580763f
qemu:virtio-net: Save status and add some save infrastructure (Alex Williamson)
The status register should probably be saved since its guest visible. Also add a little bit if infrastructure for handling various save revisions. Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6533 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
8 additions
and
2 deletions
hw/virtio-net.c
@@ -16,6 +16,8 @@ | @@ -16,6 +16,8 @@ | ||
16 | #include "qemu-timer.h" | 16 | #include "qemu-timer.h" |
17 | #include "virtio-net.h" | 17 | #include "virtio-net.h" |
18 | 18 | ||
19 | +#define VIRTIO_NET_VM_VERSION 3 | ||
20 | + | ||
19 | typedef struct VirtIONet | 21 | typedef struct VirtIONet |
20 | { | 22 | { |
21 | VirtIODevice vdev; | 23 | VirtIODevice vdev; |
@@ -292,13 +294,14 @@ static void virtio_net_save(QEMUFile *f, void *opaque) | @@ -292,13 +294,14 @@ static void virtio_net_save(QEMUFile *f, void *opaque) | ||
292 | qemu_put_buffer(f, n->mac, 6); | 294 | qemu_put_buffer(f, n->mac, 6); |
293 | qemu_put_be32(f, n->tx_timer_active); | 295 | qemu_put_be32(f, n->tx_timer_active); |
294 | qemu_put_be32(f, n->mergeable_rx_bufs); | 296 | qemu_put_be32(f, n->mergeable_rx_bufs); |
297 | + qemu_put_be16(f, n->status); | ||
295 | } | 298 | } |
296 | 299 | ||
297 | static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) | 300 | static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) |
298 | { | 301 | { |
299 | VirtIONet *n = opaque; | 302 | VirtIONet *n = opaque; |
300 | 303 | ||
301 | - if (version_id != 2) | 304 | + if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION) |
302 | return -EINVAL; | 305 | return -EINVAL; |
303 | 306 | ||
304 | virtio_load(&n->vdev, f); | 307 | virtio_load(&n->vdev, f); |
@@ -307,6 +310,9 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) | @@ -307,6 +310,9 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) | ||
307 | n->tx_timer_active = qemu_get_be32(f); | 310 | n->tx_timer_active = qemu_get_be32(f); |
308 | n->mergeable_rx_bufs = qemu_get_be32(f); | 311 | n->mergeable_rx_bufs = qemu_get_be32(f); |
309 | 312 | ||
313 | + if (version_id >= 3) | ||
314 | + n->status = qemu_get_be16(f); | ||
315 | + | ||
310 | if (n->tx_timer_active) { | 316 | if (n->tx_timer_active) { |
311 | qemu_mod_timer(n->tx_timer, | 317 | qemu_mod_timer(n->tx_timer, |
312 | qemu_get_clock(vm_clock) + TX_TIMER_INTERVAL); | 318 | qemu_get_clock(vm_clock) + TX_TIMER_INTERVAL); |
@@ -348,6 +354,6 @@ void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) | @@ -348,6 +354,6 @@ void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) | ||
348 | n->tx_timer_active = 0; | 354 | n->tx_timer_active = 0; |
349 | n->mergeable_rx_bufs = 0; | 355 | n->mergeable_rx_bufs = 0; |
350 | 356 | ||
351 | - register_savevm("virtio-net", virtio_net_id++, 2, | 357 | + register_savevm("virtio-net", virtio_net_id++, VIRTIO_NET_VM_VERSION, |
352 | virtio_net_save, virtio_net_load, n); | 358 | virtio_net_save, virtio_net_load, n); |
353 | } | 359 | } |