From: Kevin Wolf <kwolf@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
Jeff Cody <jcody@redhat.com>, Max Reitz <mreitz@redhat.com>,
jtc@redhat.com, Markus Armbruster <armbru@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Eric Blake <eblake@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 01/21] jobs: canonize Error object
Date: Wed, 8 Aug 2018 18:02:52 +0200 [thread overview]
Message-ID: <20180808160240.GE15410@localhost.localdomain> (raw)
In-Reply-To: <3983d933-42c4-1786-5aec-1de76da3d68a@redhat.com>
Am 08.08.2018 um 17:50 hat John Snow geschrieben:
>
>
> On 08/08/2018 10:57 AM, Kevin Wolf wrote:
> > Am 07.08.2018 um 06:33 hat John Snow geschrieben:
> >> Jobs presently use both an Error object in the case of the create job,
> >> and char strings in the case of generic errors elsewhere.
> >>
> >> Unify the two paths as just j->err, and remove the extra argument from
> >> job_completed.
> >>
> >> Signed-off-by: John Snow <jsnow@redhat.com>
> >
> > Hm, not sure. Overall, this feels like a step backwards.
> >
> >> diff --git a/include/qemu/job.h b/include/qemu/job.h
> >> index 18c9223e31..845ad00c03 100644
> >> --- a/include/qemu/job.h
> >> +++ b/include/qemu/job.h
> >> @@ -124,12 +124,12 @@ typedef struct Job {
> >> /** Estimated progress_current value at the completion of the job */
> >> int64_t progress_total;
> >>
> >> - /** Error string for a failed job (NULL if, and only if, job->ret == 0) */
> >> - char *error;
> >> -
> >> /** ret code passed to job_completed. */
> >> int ret;
> >>
> >> + /** Error object for a failed job **/
> >> + Error *err;
> >> +
> >> /** The completion function that will be called when the job completes. */
> >> BlockCompletionFunc *cb;
> >
> > This is the change that I could agree with, though I don't think it
> > makes a big difference: Whether you store the string immediately or an
> > Error object from which you get the string later, doesn't really make a
> > big difference.
> >
> > Maybe we find more uses and having an Error object is common practice in
> > QEMU, so no objections to this change.
> >
> >> @@ -484,15 +484,13 @@ void job_transition_to_ready(Job *job);
> >> /**
> >> * @job: The job being completed.
> >> * @ret: The status code.
> >> - * @error: The error message for a failing job (only with @ret < 0). If @ret is
> >> - * negative, but NULL is given for @error, strerror() is used.
> >> *
> >> * Marks @job as completed. If @ret is non-zero, the job transaction it is part
> >> * of is aborted. If @ret is zero, the job moves into the WAITING state. If it
> >> * is the last job to complete in its transaction, all jobs in the transaction
> >> * move from WAITING to PENDING.
> >> */
> >> -void job_completed(Job *job, int ret, Error *error);
> >> +void job_completed(Job *job, int ret);
> >
> > I don't like this one, though.
> >
> > Before this change, job_completed(..., NULL) was a clear sign that the
> > error message probably needed an improvement, because an errno string
> > doesn't usually describe error situations very well. We may not have a
> > much better message in some cases, but in most cases we just don't pass
> > one because an error message after job creation is still a quite new
> > thing in the QAPI schema.
> >
> > What we should get rid of in the long term is the int ret, not the Error
> > *error. I suspect callers really just distinguish success/error without
> > actually looking at the error code.
> >
> > With this change applied, what's your new conversion plan for making
> > sure that every failing caller of job_completed() has set job->error
> > first?
> >
>
> Getting rid of job_completed and moving to our fairly ubiquitous "ret &
> Error *" combo.
Yup, with the context of the discussion for patch 2, if you make .start
(or .run) take an Error **errp, that sounds like a good plan to me.
> >> @@ -666,8 +665,8 @@ static void job_update_rc(Job *job)
> >> job->ret = -ECANCELED;
> >> }
> >> if (job->ret) {
> >> - if (!job->error) {
> >> - job->error = g_strdup(strerror(-job->ret));
> >> + if (!job->err) {
> >> + error_setg_errno(&job->err, -job->ret, "job failed");
> >> }
> >> job_state_transition(job, JOB_STATUS_ABORTING);
> >> }
> >
> > This hunk just makes the error message more verbose with a "job failed"
> > prefix that doesn't add information. If it's the error string for a job,
> > of course the job failed.
> >
> > Kevin
> >
>
> Yeah, it's not a good prefix, but if I wanted to use the error object in
> a general way across all jobs, I needed _some_ kind of prefix there...
Shouldn't this one work?
error_setg(&job->err, strerror(-job->ret));
Kevin
next prev parent reply other threads:[~2018-08-08 16:03 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-07 4:33 [Qemu-devel] [PATCH 00/21] jobs: defer graph changes until finalize John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 01/21] jobs: canonize Error object John Snow
2018-08-08 14:57 ` Kevin Wolf
2018-08-08 15:50 ` John Snow
2018-08-08 16:02 ` Kevin Wolf [this message]
2018-08-07 4:33 ` [Qemu-devel] [PATCH 02/21] jobs: add exit shim John Snow
2018-08-08 4:02 ` Jeff Cody
2018-08-08 13:55 ` John Snow
2018-08-08 15:23 ` Kevin Wolf
2018-08-08 15:38 ` John Snow
2018-08-08 15:47 ` Kevin Wolf
2018-08-07 4:33 ` [Qemu-devel] [PATCH 03/21] block/backup: utilize job_exit shim John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 04/21] block/commit: " John Snow
2018-08-08 3:41 ` Jeff Cody
2018-08-08 14:00 ` John Snow
2018-08-08 16:29 ` Kevin Wolf
2018-08-15 20:52 ` John Snow
2018-08-16 6:41 ` Kevin Wolf
2018-08-07 4:33 ` [Qemu-devel] [PATCH 05/21] block/mirror: " John Snow
2018-08-08 3:47 ` Jeff Cody
2018-08-07 4:33 ` [Qemu-devel] [PATCH 06/21] block/stream: " John Snow
2018-08-08 3:47 ` Jeff Cody
2018-08-07 4:33 ` [Qemu-devel] [PATCH 07/21] block/create: " John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 08/21] tests/test-blockjob-txn: " John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 09/21] tests/test-blockjob: " John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 10/21] tests/test-bdrv-drain: " John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 11/21] jobs: remove job_defer_to_main_loop John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 12/21] jobs: allow entrypoints to return status code John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 13/21] block/commit: add block job creation flags John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 14/21] block/mirror: " John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 15/21] block/stream: " John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 16/21] block/commit: refactor commit to use job callbacks John Snow
2018-08-09 15:12 ` Kevin Wolf
2018-08-09 16:22 ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2018-08-15 21:17 ` [Qemu-devel] " John Snow
2018-08-16 6:52 ` Kevin Wolf
2018-08-07 4:33 ` [Qemu-devel] [PATCH 17/21] block/mirror: conservative mirror_exit refactor John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 18/21] block/commit: refactor stream to use job callbacks John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 19/21] qapi/block-commit: expose new job properties John Snow
2018-08-07 14:52 ` Eric Blake
2018-08-07 18:11 ` John Snow
2018-08-10 11:47 ` Kevin Wolf
2018-08-07 4:33 ` [Qemu-devel] [PATCH 20/21] qapi/block-mirror: " John Snow
2018-08-07 4:33 ` [Qemu-devel] [PATCH 21/21] qapi/block-stream: " John Snow
2018-08-15 14:44 ` [Qemu-devel] [Qemu-block] [PATCH 00/21] jobs: defer graph changes until finalize Peter Krempa
2018-08-15 15:00 ` Kevin Wolf
2018-08-15 15:04 ` Peter Krempa
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=20180808160240.GE15410@localhost.localdomain \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=jtc@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--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.