The virtio-net driver can determine the required size of the config struct
dynamically by inspecting the feature bits in host_features. The natural
place to perform this calculation is within the driver's init routine.
However, host_features isn't set until later when the device is plugged
into a bus.

VirtioBusClass includes a callback method, device_plugged(), that allows
the bus to perform additional setup tasks when a device is plugged into the
bus. This patch set similarly extends VirtioDeviceClass to add a callback,
bus_plugged(), to allow devices the same setup opportunity.

This allows virtio-net to defer the config size calculation until
host_features is available, which I think will be a better long-term fix to
the problem addressed in e9016ee2bda1b7757072b856b2196f691aee3388.

 [PATCH 1/3] virtio: add bus_plugged() callback to VirtioDeviceClass
 [PATCH 2/3] virtio-net: implement bus_plugged()
 [PATCH 3/3] virtio-net: revert MAC address workaround

 hw/net/virtio-net.c        | 20 +++++++++++++++++++-
 hw/virtio/virtio.c         |  3 +++
 include/hw/virtio/virtio.h |  1 +
 3 files changed, 23 insertions(+), 1 deletion(-)


Reply via email to