virtio/vhost_user: set NEEDS_RESET status bit if necessary
This protects against brute-force initialization that virtio is not really prepared for. Most importantly, this behavior makes us Virtio spec compliant (3.1 Device Init.). Change-Id: I6d26f3d8b5cce488a71068777531b78538489662 Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/405917 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
8ac087613c
commit
91bdec96c7
@ -236,14 +236,23 @@ static void
|
||||
virtio_user_set_status(struct virtio_dev *vdev, uint8_t status)
|
||||
{
|
||||
struct virtio_user_dev *dev = vdev->ctx;
|
||||
int rc = 0;
|
||||
|
||||
if (status & VIRTIO_CONFIG_S_DRIVER_OK) {
|
||||
virtio_user_start_device(vdev);
|
||||
if ((dev->status & VIRTIO_CONFIG_S_NEEDS_RESET) &&
|
||||
status != VIRTIO_CONFIG_S_RESET) {
|
||||
rc = -1;
|
||||
} else if (status & VIRTIO_CONFIG_S_DRIVER_OK) {
|
||||
rc = virtio_user_start_device(vdev);
|
||||
} else if (status == VIRTIO_CONFIG_S_RESET &&
|
||||
(dev->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
|
||||
virtio_user_stop_device(vdev);
|
||||
rc = virtio_user_stop_device(vdev);
|
||||
}
|
||||
|
||||
if (rc != 0) {
|
||||
dev->status |= VIRTIO_CONFIG_S_NEEDS_RESET;
|
||||
} else {
|
||||
dev->status = status;
|
||||
}
|
||||
dev->status = status;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
|
Loading…
Reference in New Issue
Block a user