Patchwork [24/41] virtio-net: use type checking version of qemu_put/get-*

login
register
mail settings
Submitter Juan Quintela
Date Dec. 2, 2009, 12:04 p.m.
Message ID <4f2dc736eeb34f2a79ec65cabbcbfe860abac47a.1259754427.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/40029/
State New
Headers show

Comments

Juan Quintela - Dec. 2, 2009, 12:04 p.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/virtio-net.c |   41 +++++++++++++++++++++--------------------
 1 files changed, 21 insertions(+), 20 deletions(-)

Patch

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 4ad5edd..57ad20b 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -695,20 +695,20 @@  static void virtio_net_save(QEMUFile *f, void *opaque)
     qemu_put_buffer(f, n->mac, ETH_ALEN);
     qemu_put_be32s(f, &n->tx_timer_active);
     qemu_put_be32s(f, &n->mergeable_rx_bufs);
-    qemu_put_be16(f, n->status);
-    qemu_put_byte(f, n->promisc);
-    qemu_put_byte(f, n->allmulti);
+    qemu_put_be16s(f, &n->status);
+    qemu_put_8s(f, &n->promisc);
+    qemu_put_8s(f, &n->allmulti);
     qemu_put_be32(f, n->mac_table.in_use);
     qemu_put_buffer(f, n->mac_table.macs, n->mac_table.in_use * ETH_ALEN);
     qemu_put_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3);
     qemu_put_be32(f, n->has_vnet_hdr);
-    qemu_put_byte(f, n->mac_table.multi_overflow);
-    qemu_put_byte(f, n->mac_table.uni_overflow);
-    qemu_put_byte(f, n->alluni);
-    qemu_put_byte(f, n->nomulti);
-    qemu_put_byte(f, n->nouni);
-    qemu_put_byte(f, n->nobcast);
-    qemu_put_byte(f, n->has_ufo);
+    qemu_put_8s(f, &n->mac_table.multi_overflow);
+    qemu_put_8s(f, &n->mac_table.uni_overflow);
+    qemu_put_8s(f, &n->alluni);
+    qemu_put_8s(f, &n->nomulti);
+    qemu_put_8s(f, &n->nouni);
+    qemu_put_8s(f, &n->nobcast);
+    qemu_put_8s(f, &n->has_ufo);
 }

 static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
@@ -726,15 +726,15 @@  static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
     qemu_get_be32s(f, &n->mergeable_rx_bufs);

     if (version_id >= 3)
-        n->status = qemu_get_be16(f);
+        qemu_get_be16s(f, &n->status);

     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);
+            qemu_get_8s(f, &n->promisc);
+            qemu_get_8s(f, &n->allmulti);
         }
     }

@@ -772,19 +772,20 @@  static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
     }

     if (version_id >= 9) {
-        n->mac_table.multi_overflow = qemu_get_byte(f);
-        n->mac_table.uni_overflow = qemu_get_byte(f);
+        qemu_get_8s(f, &n->mac_table.multi_overflow);
+        qemu_get_8s(f, &n->mac_table.uni_overflow);
     }

     if (version_id >= 10) {
-        n->alluni = qemu_get_byte(f);
-        n->nomulti = qemu_get_byte(f);
-        n->nouni = qemu_get_byte(f);
-        n->nobcast = qemu_get_byte(f);
+        qemu_get_8s(f, &n->alluni);
+        qemu_get_8s(f, &n->nomulti);
+        qemu_get_8s(f, &n->nouni);
+        qemu_get_8s(f, &n->nobcast);
     }

     if (version_id >= 11) {
-        if (qemu_get_byte(f) && !peer_has_ufo(n)) {
+        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;
         }