All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] net: delay peer host device delete
Date: Mon, 20 Sep 2010 18:47:58 +0200	[thread overview]
Message-ID: <20100920164758.GB29862@redhat.com> (raw)
In-Reply-To: <4C978EC9.20907@codemonkey.ws>

On Mon, Sep 20, 2010 at 11:41:45AM -0500, Anthony Liguori wrote:
> On 09/20/2010 11:30 AM, Michael S. Tsirkin wrote:
> >With -netdev, virtio devices present offload
> >features to guest, depending on the backend used.
> >Thus, removing host ntedev peer while guest is
> >active leads to guest-visible inconsistency and/or crashes.
> >See e.g. https://bugzilla.redhat.com/show_bug.cgi?id=623735
> >
> >As a solution, while guest (NIC) peer device exists,
> >we must prevent the host peer from being deleted.
> >
> >This patch does this by adding peer_deleted flag in nic state:
> >if host device is going away while guest device
> >is around, set this flag and keep host device around
> >for as long as guest device exists.
> 
> Having an unclear life cycle really worries me.
> 
> Wouldn't the more correct solution be to avoid removing the netdev
> device until after the peer has successfully been removed?
> 
> Regards,
> 
> Anthony Liguori

This is exactly what the patch does.


> >Signed-off-by: Michael S. Tsirkin<mst@redhat.com>
> >---
> >  net.c |   21 ++++++++++++++++++++-
> >  net.h |    1 +
> >  2 files changed, 21 insertions(+), 1 deletions(-)
> >
> >diff --git a/net.c b/net.c
> >index 3d0fde7..10855d1 100644
> >--- a/net.c
> >+++ b/net.c
> >@@ -286,12 +286,31 @@ void qemu_del_vlan_client(VLANClientState *vc)
> >      if (vc->vlan) {
> >          QTAILQ_REMOVE(&vc->vlan->clients, vc, next);
> >      } else {
> >+        /* Even if client will not be deleted yet, remove it from list so it
> >+         * does not appear in monitor.  */
> >+        QTAILQ_REMOVE(&non_vlan_clients, vc, next);
> >+        /* Detect that guest-visible (NIC) peer is active, and delay deletion.
> >+         * */
> >+        if (vc->peer&&  vc->peer->info->type == NET_CLIENT_TYPE_NIC) {
> >+            NICState *nic = DO_UPCAST(NICState, nc, vc->peer);
> >+            assert(!nic->peer_deleted);
> >+            nic->peer_deleted = true;
> >+            return;
> >+        }
> >          if (vc->send_queue) {
> >              qemu_del_net_queue(vc->send_queue);
> >          }
> >-        QTAILQ_REMOVE(&non_vlan_clients, vc, next);
> >          if (vc->peer) {
> >              vc->peer->peer = NULL;
> >+            /* If this is a guest-visible (NIC) device,
> >+             * and peer has already been removed from monitor,
> >+             * delete it here. */
> >+            if (vc->info->type == NET_CLIENT_TYPE_NIC) {
> >+                NICState *nic = DO_UPCAST(NICState, nc, vc);
> >+                if (nic->peer_deleted) {
> >+                    qemu_del_vlan_client(vc->peer);
> >+                }
> >+            }
> >          }
> >      }
> >
> >diff --git a/net.h b/net.h
> >index 518cf9c..44c31a9 100644
> >--- a/net.h
> >+++ b/net.h
> >@@ -72,6 +72,7 @@ typedef struct NICState {
> >      VLANClientState nc;
> >      NICConf *conf;
> >      void *opaque;
> >+    bool peer_deleted;
> >  } NICState;
> >
> >  struct VLANState {

  reply	other threads:[~2010-09-20 16:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-20 16:30 [Qemu-devel] [PATCH] net: delay peer host device delete Michael S. Tsirkin
2010-09-20 16:41 ` Anthony Liguori
2010-09-20 16:47   ` Michael S. Tsirkin [this message]
2010-09-20 16:56     ` Anthony Liguori
2010-09-20 17:14       ` Michael S. Tsirkin
2010-09-20 18:14         ` Anthony Liguori
2010-09-20 18:19           ` Anthony Liguori
2010-09-20 18:59             ` [Qemu-devel] " Michael S. Tsirkin
2010-09-20 19:22               ` Anthony Liguori
2010-09-20 19:37                 ` Michael S. Tsirkin
2010-09-20 20:15                   ` Anthony Liguori
2010-09-20 20:15                     ` Michael S. Tsirkin
2010-09-21  8:58                   ` Daniel P. Berrange
2010-09-21  9:20                     ` Michael S. Tsirkin
2010-09-21 12:47                       ` Anthony Liguori
2010-09-20 18:24           ` Michael S. Tsirkin
2010-09-20 18:39             ` Anthony Liguori
2010-09-20 19:15               ` Michael S. Tsirkin
2010-09-20 19:28                 ` Anthony Liguori
2010-09-20 19:44                   ` Michael S. Tsirkin
2010-09-20 20:20                     ` Anthony Liguori
2010-09-20 20:27                       ` Michael S. Tsirkin
2010-09-20 20:38                         ` Anthony Liguori
2010-09-20 20:37                           ` Michael S. Tsirkin
2010-09-20 20:50                             ` Anthony Liguori
2010-09-21  9:18                               ` Michael S. Tsirkin
2010-09-21 12:42                                 ` Anthony Liguori

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=20100920164758.GB29862@redhat.com \
    --to=mst@redhat.com \
    --cc=anthony@codemonkey.ws \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.