From d1b4259f1ab18af24e6a297edb6a8f71691f3256 Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Tue, 13 Sep 2016 15:30:30 +0200 Subject: virtio-bus: Plug devices after features are negotiated Currently, devices are plugged before features are negotiated. If the backend doesn't support VIRTIO_F_VERSION_1, the transport needs to rewind some settings. This is the case for CCW, for which a post_plugged callback had been introduced, where max_rev field is just updated if VIRTIO_F_VERSION_1 is not supported by the backend. For PCI, implementing post_plugged would be much more complicated, so it needs to know whether the backend supports VIRTIO_F_VERSION_1 at plug time. Currently, nothing is done for PCI. Modern capabilities get exposed to the guest even if VIRTIO_F_VERSION_1 is not supported by the backend, which confuses the guest. This patch replaces existing post_plugged solution with an approach that fits with both transports. Features negotiation is performed before ->device_plugged() call. A pre_plugged callback is introduced so that the transports can set their supported features. Cc: Michael S. Tsirkin Cc: qemu-stable@nongnu.org Tested-by: Cornelia Huck [ccw] Reviewed-by: Cornelia Huck Reviewed-by: Marcel Apfelbaum Signed-off-by: Maxime Coquelin --- include/hw/virtio/virtio-bus.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include/hw/virtio') diff --git a/include/hw/virtio/virtio-bus.h b/include/hw/virtio/virtio-bus.h index f3e5ef3f5b..24caa0a6e5 100644 --- a/include/hw/virtio/virtio-bus.h +++ b/include/hw/virtio/virtio-bus.h @@ -53,16 +53,16 @@ typedef struct VirtioBusClass { bool (*query_guest_notifiers)(DeviceState *d); int (*set_guest_notifiers)(DeviceState *d, int nvqs, bool assign); void (*vmstate_change)(DeviceState *d, bool running); + /* + * Expose the features the transport layer supports before + * the negotiation takes place. + */ + void (*pre_plugged)(DeviceState *d, Error **errp); /* * transport independent init function. * This is called by virtio-bus just after the device is plugged. */ void (*device_plugged)(DeviceState *d, Error **errp); - /* - * Re-evaluate setup after feature bits have been validated - * by the device backend. - */ - void (*post_plugged)(DeviceState *d, Error **errp); /* * transport independent exit function. * This is called by virtio-bus just before the device is unplugged. -- cgit v1.2.3-55-g7522