Patchwork [3/3] migration: block migration when streaming block jobs are running.

login
register
mail settings
Submitter Benoit Canet
Date July 20, 2012, 7:32 p.m.
Message ID <1342812757-2651-4-git-send-email-benoit@irqsave.net>
Download mbox | patch
Permalink /patch/172348/
State New
Headers show

Comments

Benoit Canet - July 20, 2012, 7:32 p.m.
From: Benoît Canet <benoit@irqsave.net>

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 migration.c |    5 +++++
 1 file changed, 5 insertions(+)
Stefan Hajnoczi - July 23, 2012, 9:55 a.m.
On Fri, Jul 20, 2012 at 8:32 PM,  <benoit.canet@gmail.com> wrote:
> From: Benoît Canet <benoit@irqsave.net>
>
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> ---
>  migration.c |    5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/migration.c b/migration.c
> index 8db1b43..dfce680 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -425,6 +425,11 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
>          return;
>      }
>
> +    if (bdrv_have_block_jobs()) {
> +        error_set(errp, QERR_STREAMING_BLOCKS_MIGRATION);
> +        return;
> +    }

I think bdrv_have_block_jobs() is too specific and would use
bdrv_in_use(bs) here to give basically an EBUSY-type error.

Stefan
Benoît Canet - July 23, 2012, 10:17 a.m.
Would

int bdrv_are_busy(void)
{
    BlockDriverState *bs;

    QTAILQ_FOREACH(bs, &bdrv_states, list) {
        if (bs->job || bdrv_in_use(bs)) {
            return -EBUSY;
        }
    }

    return 0;
}

be more acceptable ?

Benoît

Le Monday 23 Jul 2012 à 10:55:41 (+0100), Stefan Hajnoczi a écrit :
> On Fri, Jul 20, 2012 at 8:32 PM,  <benoit.canet@gmail.com> wrote:
> > From: Benoît Canet <benoit@irqsave.net>
> >
> > Signed-off-by: Benoit Canet <benoit@irqsave.net>
> > ---
> >  migration.c |    5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/migration.c b/migration.c
> > index 8db1b43..dfce680 100644
> > --- a/migration.c
> > +++ b/migration.c
> > @@ -425,6 +425,11 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
> >          return;
> >      }
> >
> > +    if (bdrv_have_block_jobs()) {
> > +        error_set(errp, QERR_STREAMING_BLOCKS_MIGRATION);
> > +        return;
> > +    }
> 
> I think bdrv_have_block_jobs() is too specific and would use
> bdrv_in_use(bs) here to give basically an EBUSY-type error.
> 
> Stefan
Stefan Hajnoczi - July 23, 2012, 10:43 a.m.
On Mon, Jul 23, 2012 at 11:17 AM, Benoît Canet <benoit.canet@irqsave.net> wrote:
> Would
>
> int bdrv_are_busy(void)
> {
>     BlockDriverState *bs;
>
>     QTAILQ_FOREACH(bs, &bdrv_states, list) {
>         if (bs->job || bdrv_in_use(bs)) {
>             return -EBUSY;
>         }
>     }
>
>     return 0;
> }
>
> be more acceptable ?

Looks fine to me.

Stefan

Patch

diff --git a/migration.c b/migration.c
index 8db1b43..dfce680 100644
--- a/migration.c
+++ b/migration.c
@@ -425,6 +425,11 @@  void qmp_migrate(const char *uri, bool has_blk, bool blk,
         return;
     }
 
+    if (bdrv_have_block_jobs()) {
+        error_set(errp, QERR_STREAMING_BLOCKS_MIGRATION);
+        return;
+    }
+
     s = migrate_init(&params);
 
     if (strstart(uri, "tcp:", &p)) {