qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio-net: require that config size is initialized
@ 2013-05-07 10:22 Michael S. Tsirkin
  2013-05-07 12:29 ` KONRAD Frédéric
  0 siblings, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2013-05-07 10:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Anthony Liguori, Jason Wang, Stefan Hajnoczi,
	fred.konrad

All buses do this, and if they don't they get subtle
bugs related to cross version migration.
Let's add an assert to catch these bugs early.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

Just a cleanup so not 1.5 material.
Seems to work fine here - any opinions?

 hw/net/virtio-net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 908e7b8..f0a9272 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1282,6 +1282,8 @@ static int virtio_net_device_init(VirtIODevice *vdev)
     DeviceState *qdev = DEVICE(vdev);
     VirtIONet *n = VIRTIO_NET(vdev);
 
+    /* Verify that config size has been initialized */
+    assert(n->config_size != (size_t)-1);
     virtio_init(VIRTIO_DEVICE(n), "virtio-net", VIRTIO_ID_NET,
                                   n->config_size);
 
@@ -1386,10 +1388,9 @@ static void virtio_net_instance_init(Object *obj)
     VirtIONet *n = VIRTIO_NET(obj);
 
     /*
-     * The default config_size is sizeof(struct virtio_net_config).
-     * Can be overriden with virtio_net_set_config_size.
+     * The config_size must be set later with virtio_net_set_config_size.
      */
-    n->config_size = sizeof(struct virtio_net_config);
+    n->config_size = (size_t)-1;
 }
 
 static Property virtio_net_properties[] = {
-- 
MST

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-05-07 15:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-07 10:22 [Qemu-devel] [PATCH] virtio-net: require that config size is initialized Michael S. Tsirkin
2013-05-07 12:29 ` KONRAD Frédéric
2013-05-07 12:33   ` Michael S. Tsirkin
2013-05-07 12:54     ` KONRAD Frédéric
2013-05-07 14:00       ` Michael S. Tsirkin
2013-05-07 15:29         ` KONRAD Frédéric
2013-05-07 15:55           ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).