Patchwork [28/41] virtio-net: use qemu_get_buffer() in a temp buffer

login
register
mail settings
Submitter Juan Quintela
Date Sept. 21, 2012, 8:47 a.m.
Message ID <1348217255-22441-29-git-send-email-quintela@redhat.com>
Download mbox | patch
Permalink /patch/185647/
State New
Headers show

Comments

Juan Quintela - Sept. 21, 2012, 8:47 a.m.
qemu_fseek() is known to be wrong.  Would be removed on the next
commit.  This code should never been used (value has been
MAC_TABLE_ENTRIES since 2009).

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/virtio-net.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Paolo Bonzini - Sept. 21, 2012, 12:45 p.m.
Il 21/09/2012 10:47, Juan Quintela ha scritto:
> qemu_fseek() is known to be wrong.  Would be removed on the next
> commit.  This code should never been used (value has been
> MAC_TABLE_ENTRIES since 2009).
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  hw/virtio-net.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> index 6490743..e8c43af 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -921,7 +921,9 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
>              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);
> +            uint8_t *buf = g_malloc0(n->mac_table.in_use);
> +            qemu_get_buffer(f, buf, n->mac_table.in_use * ETH_ALEN);
> +            g_free(buf);
>              n->mac_table.multi_overflow = n->mac_table.uni_overflow = 1;
>              n->mac_table.in_use = 0;
>          }
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Patch

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 6490743..e8c43af 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -921,7 +921,9 @@  static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
             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);
+            uint8_t *buf = g_malloc0(n->mac_table.in_use);
+            qemu_get_buffer(f, buf, n->mac_table.in_use * ETH_ALEN);
+            g_free(buf);
             n->mac_table.multi_overflow = n->mac_table.uni_overflow = 1;
             n->mac_table.in_use = 0;
         }