qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Jens Freimann <jfreimann@redhat.com>
Cc: ehabkost@redhat.com, mst@redhat.com, aadam@redhat.com,
	qemu-devel@nongnu.org, alex.williamson@redhat.com,
	laine@redhat.com, ailan@redhat.com, parav@mellanox.com
Subject: Re: [PATCH v3 07/10] migration: add new migration state wait-unplug
Date: Tue, 15 Oct 2019 11:50:08 +0100	[thread overview]
Message-ID: <20191015105008.GE3073@work-vm> (raw)
In-Reply-To: <20191015094525.zqq4534ghe3l2ngr@jenstp.localdomain>

* Jens Freimann (jfreimann@redhat.com) wrote:
> On Fri, Oct 11, 2019 at 06:11:33PM +0100, Dr. David Alan Gilbert wrote:
> > * Jens Freimann (jfreimann@redhat.com) wrote:
> > > This patch adds a new migration state called wait-unplug.  It is entered
> > > after the SETUP state and will transition into ACTIVE once all devices
> > > were succesfully unplugged from the guest.
> > > 
> > > So if a guest doesn't respond or takes long to honor the unplug request
> > > the user will see the migration state 'wait-unplug'.
> > > 
> > > In the migration thread we query failover devices if they're are still
> > > pending the guest unplug. When all are unplugged the migration
> > > continues. We give it a defined number of iterations including small
> > > waiting periods before we proceed.
> > > 
> > > Signed-off-by: Jens Freimann <jfreimann@redhat.com>
> [..]
> > > @@ -3260,6 +3271,27 @@ static void *migration_thread(void *opaque)
> > > 
> > >      qemu_savevm_state_setup(s->to_dst_file);
> > > 
> > > +    migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
> > > +                      MIGRATION_STATUS_WAIT_UNPLUG);
> > 
> > I think I'd prefer if you only went into this state if you had any
> > devices that were going to need unplugging.
> 
> Sure, that makes sense. I'll change it.
> 
> > > +    while (i < FAILOVER_UNPLUG_RETRIES &&
> > > +           s->state == MIGRATION_STATUS_WAIT_UNPLUG) {
> > > +        i++;
> > > +        qemu_sem_timedwait(&s->wait_unplug_sem, FAILOVER_GUEST_UNPLUG_WAIT);
> > > +        all_unplugged = qemu_savevm_state_guest_unplug_pending();
> > > +        if (all_unplugged) {
> > > +            break;
> > > +        }
> > > +    }
> > > +
> > > +    if (all_unplugged) {
> > > +        migrate_set_state(&s->state, MIGRATION_STATUS_WAIT_UNPLUG,
> > > +                MIGRATION_STATUS_ACTIVE);
> > > +    } else {
> > > +        migrate_set_state(&s->state, MIGRATION_STATUS_WAIT_UNPLUG,
> > > +                          MIGRATION_STATUS_CANCELLING);
> > > +    }
> > 
> > I think you can get rid of both the timeout and the count and just make
> > sure that migrate_cancel works at this point.
> 
> I see, I need to add the new state to migration_is_setup_or_active() or
> a cancel won't work.

You probably need to do that anyway given all the other places
is_setup_or_active is called.

> > This pushes the problem up a layer, which I think is fine.
> 
> Seems good to me. To be clear, you're saying I should just poll on
> the device unplugged state? Like
> 
>         while (s->state == MIGRATION_STATUS_WAIT_UNPLUG &&
>                !qemu_savevm_state_guest_unplug_pending()) {
> _            /* This block intentionally left blank */
>         }

I'd keep the qemu_sem_timedwait in there, but with a short time out
(e.g. 250ms say); that way it doesn't eat cpu, but also the cancel still
happens quickly.

Dave

> 
> regards,
> Jens
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


  reply	other threads:[~2019-10-15 10:53 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 11:20 [PATCH v3 0/10] add failover feature for assigned network devices Jens Freimann
2019-10-11 11:20 ` [PATCH v3 01/10] qdev/qbus: add hidden device support Jens Freimann
2019-10-14  9:46   ` Cornelia Huck
2019-10-14 12:02     ` Jens Freimann
2019-10-15 19:19   ` Alex Williamson
2019-10-16  7:04     ` Jens Freimann
2019-10-11 11:20 ` [PATCH v3 02/10] pci: mark devices partially unplugged Jens Freimann
2019-10-16  1:53   ` Alex Williamson
2019-10-11 11:20 ` [PATCH v3 03/10] pci: mark device having guest unplug request pending Jens Freimann
2019-10-11 11:20 ` [PATCH v3 04/10] qapi: add unplug primary event Jens Freimann
2019-10-11 11:20 ` [PATCH v3 05/10] qapi: add failover negotiated event Jens Freimann
2019-10-11 11:20 ` [PATCH v3 06/10] migration: allow unplug during migration for failover devices Jens Freimann
2019-10-11 11:20 ` [PATCH v3 07/10] migration: add new migration state wait-unplug Jens Freimann
2019-10-11 12:57   ` Michael S. Tsirkin
2019-10-11 14:22     ` Jens Freimann
2019-10-11 16:49   ` Dr. David Alan Gilbert
2019-10-11 17:11   ` Dr. David Alan Gilbert
2019-10-15  9:45     ` Jens Freimann
2019-10-15 10:50       ` Dr. David Alan Gilbert [this message]
2019-10-16  7:07         ` Jens Freimann
2019-10-11 11:20 ` [PATCH v3 08/10] libqos: tolerate wait-unplug migration state Jens Freimann
2019-10-11 11:20 ` [PATCH v3 09/10] net/virtio: add failover support Jens Freimann
2019-10-11 11:20 ` [PATCH v3 10/10] vfio: unplug failover primary device before migration Jens Freimann
2019-10-14 10:05   ` Cornelia Huck
2019-10-16  1:52   ` Alex Williamson
2019-10-16 20:18     ` Jens Freimann
2019-10-17  0:39       ` Alex Williamson
2019-10-17  7:45         ` Jens Freimann
2019-10-11 14:28 ` [PATCH v3 0/10] add failover feature for assigned network devices Michael S. Tsirkin
2019-10-11 16:04 ` no-reply
2019-10-15 19:03 ` Alex Williamson
2019-10-15 21:17   ` Michael S. Tsirkin
2019-10-17 10:33   ` Jens Freimann
2019-10-17 12:51     ` Alex Williamson
2019-10-17 14:04       ` Jens Freimann

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=20191015105008.GE3073@work-vm \
    --to=dgilbert@redhat.com \
    --cc=aadam@redhat.com \
    --cc=ailan@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=jfreimann@redhat.com \
    --cc=laine@redhat.com \
    --cc=mst@redhat.com \
    --cc=parav@mellanox.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).