qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] vhost-net: Do not set features for backend when peer was deleted
Date: Tue, 26 Oct 2010 19:22:14 +0200	[thread overview]
Message-ID: <20101026172213.GA16645@redhat.com> (raw)
In-Reply-To: <20101026164351.12358.73838.stgit@localhost6.localdomain6>

On Wed, Oct 27, 2010 at 12:43:51AM +0800, Jason Wang wrote:
> When hot-unplug a virtio nic with vhost-net backend, guest may
> continue to program the nic even if its peer have been deleted. We can
> not set features at this time as vhost_net_ack_features() may still
> try to use the tap related vhost_net structure which have been freed
> in tap_cleanup(). And setting offload features for a deleted backend
> is also meaningless in this situation
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>

Hmm. Actually, this is not enough.
We really must stop and cleanup vhost net.

Two issues are 
1. vhost_net_stop needs virtio device pointer
2. virtio net has a vhost_started flag

Two ways to fix it that I see:
1. add a callback in nic and invoke when peer_deleted is set
2. add vhost_started and virtio device pointers in vhost

Path 1 seems easier ...

MST

> ---
>  hw/virtio-net.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> index 7e1688c..68c8e48 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -245,6 +245,9 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features)
>  {
>      VirtIONet *n = to_virtio_net(vdev);
>  
> +    if (n->nic->peer_deleted)
> +        return;
> +
>      n->mergeable_rx_bufs = !!(features & (1 << VIRTIO_NET_F_MRG_RXBUF));
>  
>      if (n->has_vnet_hdr) {

  reply	other threads:[~2010-10-26 17:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-26 16:43 [Qemu-devel] [PATCH] vhost-net: Do not set features for backend when peer was deleted Jason Wang
2010-10-26 17:22 ` Michael S. Tsirkin [this message]
2010-10-27  6:59   ` [Qemu-devel] " Jason Wang
2010-10-27 13:26     ` Michael S. Tsirkin
2010-10-27 18:09       ` Michael S. Tsirkin

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=20101026172213.GA16645@redhat.com \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).