Skip to content

Commit

Permalink
net/virtio-user: fix device starting failure handling
Browse files Browse the repository at this point in the history
[ upstream commit c1a6f787b04e470ebe9b5a3891022195eb2bc555 ]

If the device fails to start, read the status from the
device and return early.

Fixes: 5791282 ("net/virtio-user: support vhost status setting")

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  • Loading branch information
mcoquelin authored and bluca committed Feb 22, 2023
1 parent d1e390e commit 7b89a68
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/net/virtio/virtio_user_ethdev.c
Expand Up @@ -317,10 +317,15 @@ virtio_user_set_status(struct virtio_hw *hw, uint8_t status)
if (status & VIRTIO_CONFIG_STATUS_FEATURES_OK &&
~old_status & VIRTIO_CONFIG_STATUS_FEATURES_OK)
virtio_user_dev_set_features(dev);
if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK)
virtio_user_start_device(dev);
else if (status == VIRTIO_CONFIG_STATUS_RESET)

if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK) {
if (virtio_user_start_device(dev)) {
virtio_user_dev_update_status(dev);
return;
}
} else if (status == VIRTIO_CONFIG_STATUS_RESET) {
virtio_user_reset(hw);
}

virtio_user_dev_set_status(dev, status);
}
Expand Down

0 comments on commit 7b89a68

Please sign in to comment.