From: "Michael S. Tsirkin" <mst@redhat.com>
To: Gautam Dawar <gautam.dawar@amd.com>
Cc: jasowang@redhat.com, qemu-devel@nongnu.org, eperezma@redhat.com,
linux-net-drivers@amd.com, harpreet.anand@amd.com,
tanuj.kamde@amd.com, koushik.dutta@amd.com
Subject: Re: [PATCH] vdpa: fix emulated guest announce feature status handling
Date: Fri, 3 Mar 2023 07:17:01 -0500 [thread overview]
Message-ID: <20230303071555-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20230303115810.7482-1-gautam.dawar@amd.com>
On Fri, Mar 03, 2023 at 05:28:10PM +0530, Gautam Dawar wrote:
> Guest announce capability is emulated by qemu in the .avail_handler
> shadow virtqueue operation. It updates the status to success in
> `*s->status` but incorrectly fetches the command execution
> status from local variable `status` later in call to iov_from_buf().
> As `status` is initialized to VIRTIO_NET_ERR, it results in a
> warning "Failed to ack link announce" in virtio_net driver's
> virtnet_ack_link_announce() function after VM Live Migration.
> Also, I noticed an invalid check in vhost_vdpa_net_handle_ctrl_avail()
> that reports an error because status is not updated in call to
> virtio_net_handle_ctrl_iov():
>
> virtio_net_handle_ctrl_iov(svq->vdev, &in, 1, &out, 1);
> if (status != VIRTIO_NET_OK) {
> error_report("Bad CVQ processing in model");
> }
> Adding an optional OUT status parameter to virtio_net_handle_ctrl_iov()
> would help resolving this issue and also send the correct status
> value to the virtio-net driver.
>
> Signed-off-by: Gautam Dawar <gautam.dawar@amd.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Jason your tree right?
> ---
> hw/net/virtio-net.c | 9 +++++++--
> include/hw/virtio/virtio-net.h | 3 ++-
> net/vhost-vdpa.c | 3 +--
> 3 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 3ae909041a..36a75592da 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -1503,7 +1503,8 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd,
> size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
> const struct iovec *in_sg, unsigned in_num,
> const struct iovec *out_sg,
> - unsigned out_num)
> + unsigned out_num,
> + virtio_net_ctrl_ack *status_out)
> {
> VirtIONet *n = VIRTIO_NET(vdev);
> struct virtio_net_ctrl_hdr ctrl;
> @@ -1514,6 +1515,8 @@ size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
> if (iov_size(in_sg, in_num) < sizeof(status) ||
> iov_size(out_sg, out_num) < sizeof(ctrl)) {
> virtio_error(vdev, "virtio-net ctrl missing headers");
> + if (status_out)
> + *status_out = status;
> return 0;
> }
>
> @@ -1540,6 +1543,8 @@ size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
> assert(s == sizeof(status));
>
> g_free(iov2);
> + if (status_out)
> + *status_out = status;
> return sizeof(status);
> }
>
> @@ -1555,7 +1560,7 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
> }
>
> written = virtio_net_handle_ctrl_iov(vdev, elem->in_sg, elem->in_num,
> - elem->out_sg, elem->out_num);
> + elem->out_sg, elem->out_num, NULL);
> if (written > 0) {
> virtqueue_push(vq, elem, written);
> virtio_notify(vdev, vq);
> diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
> index ef234ffe7e..da76cc414d 100644
> --- a/include/hw/virtio/virtio-net.h
> +++ b/include/hw/virtio/virtio-net.h
> @@ -224,7 +224,8 @@ struct VirtIONet {
> size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
> const struct iovec *in_sg, unsigned in_num,
> const struct iovec *out_sg,
> - unsigned out_num);
> + unsigned out_num,
> + virtio_net_ctrl_ack *status);
> void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
> const char *type);
>
> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> index de5ed8ff22..c72b338633 100644
> --- a/net/vhost-vdpa.c
> +++ b/net/vhost-vdpa.c
> @@ -638,8 +638,7 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
> return VIRTIO_NET_ERR;
> }
>
> - status = VIRTIO_NET_ERR;
> - virtio_net_handle_ctrl_iov(svq->vdev, &in, 1, &out, 1);
> + virtio_net_handle_ctrl_iov(svq->vdev, &in, 1, &out, 1, &status);
> if (status != VIRTIO_NET_OK) {
> error_report("Bad CVQ processing in model");
> }
> --
> 2.30.1
next prev parent reply other threads:[~2023-03-03 12:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-03 11:58 [PATCH] vdpa: fix emulated guest announce feature status handling Gautam Dawar
2023-03-03 12:17 ` Michael S. Tsirkin [this message]
2023-03-03 14:58 ` Eugenio Perez Martin
2023-03-15 17:31 ` Gautam Dawar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230303071555-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=eperezma@redhat.com \
--cc=gautam.dawar@amd.com \
--cc=harpreet.anand@amd.com \
--cc=jasowang@redhat.com \
--cc=koushik.dutta@amd.com \
--cc=linux-net-drivers@amd.com \
--cc=qemu-devel@nongnu.org \
--cc=tanuj.kamde@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).