qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: kwolf@redhat.com, Jeff Cody <jcody@redhat.com>,
	qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH] block: mirror - insure that errp is not NULL
Date: Thu, 13 Feb 2014 14:46:35 +0800	[thread overview]
Message-ID: <20140213064635.GA22443@T430.nay.redhat.com> (raw)
In-Reply-To: <87ob2b7by4.fsf@blackfin.pond.sub.org>

On Thu, 02/13 07:40, Markus Armbruster wrote:
> Jeff Cody <jcody@redhat.com> writes:
> 
> > When starting a block job, commit_active_start() relies on whether *errp
> > is set by mirror_start_job.  This allows it to determine if the mirror
> > job start failed, so that it can clean up any changes to open flags from
> > the bdrv_reopen().  If errp is NULL, then it will not be able to
> > determine if mirror_start_job failed or not.
> >
> > Reported-by: Markus Armbruster <armbru@redhat.com>
> > Signed-off-by: Jeff Cody <jcody@redhat.com>
> > ---
> >  block/mirror.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/block/mirror.c b/block/mirror.c
> > index 2a43334..41bb83c 100644
> > --- a/block/mirror.c
> > +++ b/block/mirror.c
> > @@ -634,6 +634,8 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
> >      int64_t length, base_length;
> >      int orig_base_flags;
> >  
> > +    assert(errp != NULL);
> > +
> >      orig_base_flags = bdrv_get_flags(base);
> >  
> >      if (bdrv_reopen(base, bs->open_flags, errp)) {
> 
> Needed, because:
> 
>        mirror_start_job(bs, base, speed, 0, 0,
>                         on_error, on_error, cb, opaque, errp,
>                         &commit_active_job_driver, false, base);
>        if (error_is_set(errp)) {
> 
> When your callers may legitimately ignore errors, you have to do
> something like
> 
>        local_err = NULL;
>        mirror_start_job(bs, base, speed, 0, 0,
>                         on_error, on_error, cb, opaque, &local_err,
>                         &commit_active_job_driver, false, base);
>        error_propagate(errp, local_err);
>        if (local_err) {
> 
> But here, the assertion should do fine.

Thanks for the explanation!

Reviewed-by: Fam Zheng <famz@redhat.com>

  reply	other threads:[~2014-02-13  6:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-12 19:46 [Qemu-devel] [PATCH] block: mirror - insure that errp is not NULL Jeff Cody
2014-02-12 19:55 ` Eric Blake
2014-02-13  6:43   ` Markus Armbruster
2014-02-13  6:40 ` Markus Armbruster
2014-02-13  6:46   ` Fam Zheng [this message]
2014-02-13  8:41 ` Kevin Wolf
2014-02-14 15:14   ` Stefan Hajnoczi
2014-02-14 15:17 ` Stefan Hajnoczi

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=20140213064635.GA22443@T430.nay.redhat.com \
    --to=famz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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).