Skip to content
Snippets Groups Projects
Commit f45fd95e authored by Hawkins Jiawei's avatar Hawkins Jiawei Committed by Michael S. Tsirkin
Browse files

vdpa: Return -EIO if device ack is VIRTIO_NET_ERR in _load_mq()


According to VirtIO standard, "The class, command and
command-specific-data are set by the driver,
and the device sets the ack byte.
There is little it can do except issue a diagnostic
if ack is not VIRTIO_NET_OK."

Therefore, QEMU should stop sending the queued SVQ commands and
cancel the device startup if the device's ack is not VIRTIO_NET_OK.

Yet the problem is that, vhost_vdpa_net_load_mq() returns 1 based on
`*s->status != VIRTIO_NET_OK` when the device's ack is VIRTIO_NET_ERR.
As a result, net->nc->info->load() also returns 1, this makes
vhost_net_start_one() incorrectly assume the device state is
successfully loaded by vhost_vdpa_net_load() and return 0, instead of
goto `fail` label to cancel the device startup, as vhost_net_start_one()
only cancels the device startup when net->nc->info->load() returns a
negative value.

This patch fixes this problem by returning -EIO when the device's
ack is not VIRTIO_NET_OK.

Fixes: f64c7cda ("vdpa: Add vhost_vdpa_net_load_mq")
Signed-off-by: default avatarHawkins Jiawei <yin31149@gmail.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Acked-by: default avatarEugenio Pérez <eperezma@redhat.com>
Message-Id: <ec515ebb0b4f56368751b9e318e245a5d994fa72.1688438055.git.yin31149@gmail.com>
Tested-by: default avatarLei Yang <leiyang@redhat.com>
Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent b479bc3c
No related branches found
No related tags found
No related merge requests found
......@@ -677,8 +677,11 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,
if (unlikely(dev_written < 0)) {
return dev_written;
}
if (*s->status != VIRTIO_NET_OK) {
return -EIO;
}
return *s->status != VIRTIO_NET_OK;
return 0;
}
static int vhost_vdpa_net_load_offloads(VhostVDPAState *s,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment