Skip to content

Commit

Permalink
virtio: meet virtio spec by finalizing features before using device
Browse files Browse the repository at this point in the history
Virtio devices are supposed to negotiate features before they start using
the device, but the current code doesn't do this.  This is because the
driver's probe() function invariably has to add buffers to a virtqueue,
or probe the disk (virtio_blk).

This currently doesn't matter since no existing backend is strict about
the feature negotiation.  But it's possible to imagine a future feature
which completely changes how a device operates: in this case, we'd need
to acknowledge it before using the device.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Rusty Russell committed Jun 12, 2009
1 parent 20f77f5 commit ef688e1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,14 @@ static int virtio_dev_probe(struct device *_d)
if (device_features & (1 << i))
set_bit(i, dev->features);

dev->config->finalize_features(dev);

err = drv->probe(dev);
if (err)
add_status(dev, VIRTIO_CONFIG_S_FAILED);
else {
dev->config->finalize_features(dev);
else
add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
}

return err;
}

Expand Down

0 comments on commit ef688e1

Please sign in to comment.