[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] virtio-net: require that config size is initial

From: KONRAD Frédéric
Subject: Re: [Qemu-devel] [PATCH] virtio-net: require that config size is initialized
Date: Tue, 07 May 2013 14:29:38 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4


I think it is not a good idea, as we wanted to make VirtIODevice hot-pluggable for virtio-mmio.

Maybe we can use a callback which is called by virtio-bus before plugging, to ensure that this
config size is computed?

On 07/05/2013 12:22, Michael S. Tsirkin wrote:
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 <address@hidden>

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,
@@ -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[] = {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]