From: Eric Blake <eblake@redhat.com>
To: Alberto Garcia <berto@igalia.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>,
Kevin Wolf <kwolf@redhat.com>, Jeff Cody <jcody@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 04/15] block: Simplify find_block_job() and make it accept a job ID
Date: Mon, 20 Jun 2016 12:53:08 -0600 [thread overview]
Message-ID: <57683B94.2060902@redhat.com> (raw)
In-Reply-To: <fdae47df8af588bd661cfff0b6b61aba7344fe8d.1465459496.git.berto@igalia.com>
[-- Attachment #1: Type: text/plain, Size: 2456 bytes --]
On 06/09/2016 02:20 AM, Alberto Garcia wrote:
> find_block_job() looks for a block backend with a specified name,
> checks whether it has a block job and acquires its AioContext. This
> patch uses block_job_next() and iterate directly over the block jobs.
>
> In addition to that we want to identify jobs primarily by their ID, so
> this patch updates find_block_job() to allow IDs too. Only one of ID
> and device name can be specified when looking for a block job.
>
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
> blockdev.c | 66 +++++++++++++++++++++++++++++++++-----------------------------
> 1 file changed, 35 insertions(+), 31 deletions(-)
>
> diff --git a/blockdev.c b/blockdev.c
> index 52ec4ae..bd0d5a1 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -3689,48 +3689,52 @@ void qmp_blockdev_mirror(const char *device, const char *target,
> aio_context_release(aio_context);
> }
>
> -/* Get the block job for a given device name and acquire its AioContext */
> -static BlockJob *find_block_job(const char *device, AioContext **aio_context,
> - Error **errp)
> +/* Get a block job using its ID or device name and acquire its AioContext */
> +static BlockJob *find_block_job(const char *id, const char *device,
> + AioContext **aio_context, Error **errp)
Can this signature just be const char *id_or_device, rather than two
parameters,...
> {
> - BlockBackend *blk;
> - BlockDriverState *bs;
> + BlockJob *job = NULL;
>
> *aio_context = NULL;
>
> - blk = blk_by_name(device);
> - if (!blk) {
> - goto notfound;
> + if ((id && device) || (!id && !device)) {
> + error_setg(errp, "Only one of ID or device name "
> + "must be specified when looking for a block job");
> + return NULL;
> }
If you keep this check, you could simplify it to:
if (!id == !device) {
...at which point you don't need this check,...
>
> - *aio_context = blk_get_aio_context(blk);
> - aio_context_acquire(*aio_context);
> -
> - if (!blk_is_available(blk)) {
> - goto notfound;
> + if (id) {
> + job = block_job_get(id);
> + } else {
...and this would become:
job = block_job_get(id);
if (!job) {
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-06-20 18:53 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-09 8:20 [Qemu-devel] [PATCH 00/15] Add an 'id' field to block jobs Alberto Garcia
2016-06-09 8:20 ` [Qemu-devel] [PATCH 01/15] stream: Fix prototype of stream_start() Alberto Garcia
2016-06-20 16:07 ` Max Reitz
2016-06-09 8:20 ` [Qemu-devel] [PATCH 02/15] blockjob: Decouple the ID from the device name in the BlockJob struct Alberto Garcia
2016-06-20 16:17 ` Max Reitz
2016-06-21 11:42 ` Alberto Garcia
2016-06-09 8:20 ` [Qemu-devel] [PATCH 03/15] blockjob: Add block_job_get() Alberto Garcia
2016-06-20 16:24 ` Max Reitz
2016-06-20 18:48 ` Eric Blake
2016-06-20 19:06 ` Max Reitz
2016-06-21 12:09 ` Alberto Garcia
2016-06-09 8:20 ` [Qemu-devel] [PATCH 04/15] block: Simplify find_block_job() and make it accept a job ID Alberto Garcia
2016-06-20 16:40 ` Max Reitz
2016-06-20 18:29 ` Max Reitz
2016-06-21 12:59 ` Alberto Garcia
2016-06-20 18:53 ` Eric Blake [this message]
2016-06-21 12:27 ` Alberto Garcia
2016-06-21 21:36 ` Eric Blake
2016-06-22 7:32 ` Alberto Garcia
2016-06-09 8:20 ` [Qemu-devel] [PATCH 05/15] blockjob: Add 'job_id' parameter to block_job_create() Alberto Garcia
2016-06-20 17:11 ` Max Reitz
2016-06-09 8:20 ` [Qemu-devel] [PATCH 06/15] mirror: Add 'job-id' parameter to 'blockdev-mirror' and 'drive-mirror' Alberto Garcia
2016-06-20 17:33 ` Max Reitz
2016-06-20 17:34 ` Max Reitz
2016-06-20 18:56 ` Eric Blake
2016-06-09 8:20 ` [Qemu-devel] [PATCH 07/15] backup: Add 'job-id' parameter to 'blockdev-backup' and 'drive-backup' Alberto Garcia
2016-06-20 18:14 ` Max Reitz
2016-06-09 8:20 ` [Qemu-devel] [PATCH 08/15] stream: Add 'job-id' parameter to 'block-stream' Alberto Garcia
2016-06-20 18:16 ` Max Reitz
2016-06-09 8:20 ` [Qemu-devel] [PATCH 09/15] stream: Add 'job-id' parameter to 'block-commit' Alberto Garcia
2016-06-20 18:22 ` Max Reitz
2016-06-09 8:20 ` [Qemu-devel] [PATCH 10/15] blockjob: Add 'id' parameter to 'block-job-set-speed' Alberto Garcia
2016-06-20 18:31 ` Max Reitz
2016-06-09 8:20 ` [Qemu-devel] [PATCH 11/15] blockjob: Add 'id' parameter to 'block-job-cancel' Alberto Garcia
2016-06-20 18:32 ` Max Reitz
2016-06-09 8:20 ` [Qemu-devel] [PATCH 12/15] blockjob: Add 'id' parameter to 'block-job-pause' Alberto Garcia
2016-06-20 18:34 ` Max Reitz
2016-06-09 8:20 ` [Qemu-devel] [PATCH 13/15] blockjob: Add 'id' parameter to 'block-job-resume' Alberto Garcia
2016-06-20 18:36 ` Max Reitz
2016-06-09 8:20 ` [Qemu-devel] [PATCH 14/15] blockjob: Add 'id' parameter to 'block-job-complete' Alberto Garcia
2016-06-20 18:37 ` Max Reitz
2016-06-09 8:20 ` [Qemu-devel] [PATCH 15/15] blockjob: Add 'id' field to 'BlockJobInfo' and all BLOCK_JOB_* events Alberto Garcia
2016-06-20 19:14 ` Max Reitz
2016-06-21 14:23 ` Alberto Garcia
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=57683B94.2060902@redhat.com \
--to=eblake@redhat.com \
--cc=berto@igalia.com \
--cc=jcody@redhat.com \
--cc=kwolf@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 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).