qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: Ashijeet Acharya <ashijeetacharya@gmail.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"John Snow" <jsnow@redhat.com>,
	"Amit Shah" <amit.shah@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Juan Quintela" <quintela@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v4 4/4] migration: Fail migration blocker for --only-migratble
Date: Thu, 12 Jan 2017 12:16:23 +0100	[thread overview]
Message-ID: <20170112121623.6b92a336@bahia.lan> (raw)
In-Reply-To: <CAC2QTZYnL--Uyab7mmnzUQjE6UFWJWqJq2kBdxBbtef2Mpp7Tg@mail.gmail.com>

On Thu, 12 Jan 2017 16:15:28 +0530
Ashijeet Acharya <ashijeetacharya@gmail.com> wrote:

> On Tuesday, 10 January 2017, Peter Maydell <peter.maydell@linaro.org> wrote:
> 
> > On 9 January 2017 at 17:02, Ashijeet Acharya <ashijeetacharya@gmail.com
> > <javascript:;>> wrote:
> > > migrate_add_blocker should rightly fail if the '--only-migratable'
> > > option was specified and the device in use should not be able to
> > > perform the action which results in an unmigratable VM.
> > >
> > > Make migrate_add_blocker return -EACCES in this case.
> >
> > > diff --git a/block/qcow.c b/block/qcow.c
> > > index 11526a1..bdc6446 100644
> > > --- a/block/qcow.c
> > > +++ b/block/qcow.c
> > > @@ -254,7 +254,10 @@ static int qcow_open(BlockDriverState *bs, QDict
> > *options, int flags,
> > >                 bdrv_get_device_or_node_name(bs));
> > >      ret = migrate_add_blocker(s->migration_blocker, errp);
> > >      if (ret < 0) {
> > > -        error_free(s->migration_blocker);
> > > +        if (ret == -EACCES) {
> > > +            error_append_hint(errp, "Cannot use a node with qcow format
> > as "
> > > +                              "it does not support live migration");
> > > +        }
> > >          goto fail;
> > >      }
> > >
> >
> > The error handling for these call sites should look just like
> > that for any other function call that takes an Error**:
> >
> >     Error *local_err = NULL;
> >     [...]
> >     migrate_add_blocker(s->migration_blocker, &local_err);
> >     if (local_err) {
> >         error_propagate(errp, local_err);
> >         return; // or otherwise handle failure appropriately
> >     }
> 
> 
> One more reason Peter I found for returning an error value is that in cases
> like 9pfs where we do not set errp inside migrate_add_blocker() (as
> suggested by Greg) and other similar ones where we pass NULL for errp, we
> cannot rely on checking for
> "if (local_err)" as it will never be set and always be NULL.
> Thus we will never fail appropriately at the caller sites when we fail to
> add migration blocker.
> Sounds right?
> 

The need for 9pfs is just to return an error to the guest, which will end
up being the errno for the failed mount(). And we don't want to print out
any error message to avoid a stupid guest to fill the QEMU log in case it
would loop over mount().

The only reason I see for migration_add_blocker() to return an error
would be to differentiate between the --only-migratable and the migration
in progress cases... But honestly, I don't care that much and something
like the following would be perfectly ok:

    Error *local_err = NULL;
    [...]
    migrate_add_blocker(s->migration_blocker, &local_err);
    if (local_err) {
        error_free(local_err);
        err = -EBUSY
        goto out_nofid;
    }

> Ashijeet
> 
> >
> > migrate_add_blocker() should just internally construct
> > the error text and extra hint lines by looking at the
> > text it can fish out of the s->migration_blocker argument
> > and calling error_append_hint() itself.
> >
> > The patch is also a bit odd because the error_free() calls
> > were only added in patch 3/4, right? Generally adding
> > lines of code in one patch and deleting them in the next
> > is a bad idea.
> >
> > thanks
> > -- PMM
> >

  reply	other threads:[~2017-01-12 11:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-09 17:02 [Qemu-devel] [PATCH v4 0/4] Introduce a new --only-migratable option Ashijeet Acharya
2017-01-09 17:02 ` [Qemu-devel] [PATCH v4 1/4] migration: Add a new option to enable only-migratable Ashijeet Acharya
2017-01-10 11:02   ` Dr. David Alan Gilbert
2017-01-09 17:02 ` [Qemu-devel] [PATCH v4 2/4] migration: Allow "device add" options to only add migratable devices Ashijeet Acharya
2017-01-10 11:23   ` Dr. David Alan Gilbert
2017-01-09 17:02 ` [Qemu-devel] [PATCH v4 3/4] migration: disallow migrate_add_blocker during migration Ashijeet Acharya
2017-01-10  8:25   ` Greg Kurz
2017-01-10 12:01   ` Dr. David Alan Gilbert
2017-01-10 18:33     ` Ashijeet Acharya
2017-01-09 17:02 ` [Qemu-devel] [PATCH v4 4/4] migration: Fail migration blocker for --only-migratble Ashijeet Acharya
2017-01-09 21:01   ` Eric Blake
2017-01-10 12:11   ` Dr. David Alan Gilbert
2017-01-10 17:15   ` Peter Maydell
2017-01-11  5:43     ` Ashijeet Acharya
2017-01-12 10:45     ` Ashijeet Acharya
2017-01-12 11:16       ` Greg Kurz [this message]
2017-01-12 11:50         ` Ashijeet Acharya
2017-01-09 17:27 ` [Qemu-devel] [PATCH v4 0/4] Introduce a new --only-migratable option no-reply

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=20170112121623.6b92a336@bahia.lan \
    --to=groug@kaod.org \
    --cc=amit.shah@redhat.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=armbru@redhat.com \
    --cc=ashijeetacharya@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.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).