From: John Snow <jsnow@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, jcody@redhat.com, John Snow <jsnow@redhat.com>,
armbru@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/5] block: Allow stream_start to return job references
Date: Mon, 11 Jan 2016 19:36:09 -0500 [thread overview]
Message-ID: <1452558972-20316-3-git-send-email-jsnow@redhat.com> (raw)
In-Reply-To: <1452558972-20316-1-git-send-email-jsnow@redhat.com>
stream_start now picks up a reference for its return value, a copy of
the job started. callers are responsible for putting it down when they
are done with it.
This removes a minor reference to bs->job in qmp_block_stream, for
a simple tracing function.
Signed-off-by: John Snow <jsnow@redhat.com>
---
block/stream.c | 8 +++++---
blockdev.c | 8 +++++---
include/block/block_int.h | 9 +++++----
3 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/block/stream.c b/block/stream.c
index 25af7ef..1dfeac0 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -213,7 +213,7 @@ static const BlockJobDriver stream_job_driver = {
.set_speed = stream_set_speed,
};
-void stream_start(BlockDriverState *bs, BlockDriverState *base,
+BlockJob *stream_start(BlockDriverState *bs, BlockDriverState *base,
const char *backing_file_str, int64_t speed,
BlockdevOnError on_error,
BlockCompletionFunc *cb,
@@ -225,19 +225,21 @@ void stream_start(BlockDriverState *bs, BlockDriverState *base,
on_error == BLOCKDEV_ON_ERROR_ENOSPC) &&
(!bs->blk || !blk_iostatus_is_enabled(bs->blk))) {
error_setg(errp, QERR_INVALID_PARAMETER, "on-error");
- return;
+ return NULL;
}
s = block_job_create(&stream_job_driver, bs, speed, cb, opaque, errp);
if (!s) {
- return;
+ return NULL;
}
s->base = base;
s->backing_file_str = g_strdup(backing_file_str);
s->on_error = on_error;
+ block_job_ref(&s->common);
s->common.co = qemu_coroutine_create(stream_run);
trace_stream_start(bs, base, s, s->common.co, opaque);
qemu_coroutine_enter(s->common.co, s);
+ return &s->common;
}
diff --git a/blockdev.c b/blockdev.c
index d31bb03..f66cac8 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2884,6 +2884,7 @@ void qmp_block_stream(const char *device,
BlockBackend *blk;
BlockDriverState *bs;
BlockDriverState *base_bs = NULL;
+ BlockJob *job;
AioContext *aio_context;
Error *local_err = NULL;
const char *base_name = NULL;
@@ -2933,14 +2934,15 @@ void qmp_block_stream(const char *device,
/* backing_file string overrides base bs filename */
base_name = has_backing_file ? backing_file : base_name;
- stream_start(bs, base_bs, base_name, has_speed ? speed : 0,
- on_error, block_job_cb, bs, &local_err);
+ job = stream_start(bs, base_bs, base_name, has_speed ? speed : 0,
+ on_error, block_job_cb, bs, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto out;
}
- trace_qmp_block_stream(bs, bs->job);
+ trace_qmp_block_stream(bs, job);
+ block_job_unref(job);
out:
aio_context_release(aio_context);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index a68c7dc..ea3b06b 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -597,10 +597,11 @@ int is_windows_drive(const char *filename);
* streaming job, the backing file of @bs will be changed to
* @base_id in the written image and to @base in the live BlockDriverState.
*/
-void stream_start(BlockDriverState *bs, BlockDriverState *base,
- const char *base_id, int64_t speed, BlockdevOnError on_error,
- BlockCompletionFunc *cb,
- void *opaque, Error **errp);
+BlockJob *stream_start(BlockDriverState *bs, BlockDriverState *base,
+ const char *base_id, int64_t speed,
+ BlockdevOnError on_error,
+ BlockCompletionFunc *cb,
+ void *opaque, Error **errp);
/**
* commit_start:
--
2.4.3
next prev parent reply other threads:[~2016-01-12 0:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-12 0:36 [Qemu-devel] [PATCH 0/5] block: reduce reliance on bs->job pointer John Snow
2016-01-12 0:36 ` [Qemu-devel] [PATCH 1/5] block: Allow mirror_start to return job references John Snow
2016-01-12 0:36 ` John Snow [this message]
2016-01-12 0:36 ` [Qemu-devel] [PATCH 3/5] block: allow backup_start " John Snow
2016-01-12 0:36 ` [Qemu-devel] [PATCH 4/5] block/backup: Add subclassed notifier John Snow
2016-01-12 8:46 ` Paolo Bonzini
2016-01-12 17:57 ` John Snow
2016-01-12 18:01 ` Paolo Bonzini
2016-01-12 18:02 ` John Snow
2016-01-18 14:29 ` Kevin Wolf
2016-01-18 16:20 ` John Snow
2016-01-12 0:36 ` [Qemu-devel] [PATCH 5/5] blockjob: add Job parameter to BlockCompletionFunc John Snow
2016-01-18 14:25 ` Kevin Wolf
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=1452558972-20316-3-git-send-email-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=armbru@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@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 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).