From patchwork Mon Apr 4 13:43:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 8741171 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 65A499F39A for ; Mon, 4 Apr 2016 13:48:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC7D62024F for ; Mon, 4 Apr 2016 13:48:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 299DF20166 for ; Mon, 4 Apr 2016 13:48:57 +0000 (UTC) Received: from localhost ([::1]:58765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an4sC-0008Mi-Km for patchwork-qemu-devel@patchwork.kernel.org; Mon, 04 Apr 2016 09:48:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an4og-0001zH-V1 for qemu-devel@nongnu.org; Mon, 04 Apr 2016 09:45:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1an4oe-0000AN-N1 for qemu-devel@nongnu.org; Mon, 04 Apr 2016 09:45:18 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:65131 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1an4oe-0000AC-GE; Mon, 04 Apr 2016 09:45:16 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CTAwCybgJX/5tjdVtdgzeBUKcVAQEBAQEFAYERAY5PgheCDwENgXKGDQKBMzgUAQEBAQEBAWUnhEIBAQQnUhA/EjwbGYgrAb0HAQEIIIVYgkWHWIUKBYdvhk6JRI4IiTqFVUSOVh4BAUKDammIJgEBAQ X-IPAS-Result: A2CTAwCybgJX/5tjdVtdgzeBUKcVAQEBAQEFAYERAY5PgheCDwENgXKGDQKBMzgUAQEBAQEBAWUnhEIBAQQnUhA/EjwbGYgrAb0HAQEIIIVYgkWHWIUKBYdvhk6JRI4IiTqFVUSOVh4BAUKDammIJgEBAQ X-IronPort-AV: E=Sophos;i="5.24,440,1454972400"; d="scan'208";a="39334342" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 04 Apr 2016 15:44:37 +0200 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1an4o1-00050v-5G; Mon, 04 Apr 2016 15:44:37 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1an4nj-0003vK-0a; Mon, 04 Apr 2016 16:44:19 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Mon, 4 Apr 2016 16:43:53 +0300 Message-Id: <401077e94fe70110ecf66ae36474e029d8919c92.1459776815.git.berto@igalia.com> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v9 03/11] block: use the block job list in qmp_query_block_jobs() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP qmp_query_block_jobs() uses bdrv_next() to look for block jobs, but this function can only find those in top-level BlockDriverStates. This patch uses block_job_next() instead. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz Reviewed-by: Kevin Wolf --- blockdev.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/blockdev.c b/blockdev.c index e50e8ea..edbcc19 100644 --- a/blockdev.c +++ b/blockdev.c @@ -4083,21 +4083,18 @@ out: BlockJobInfoList *qmp_query_block_jobs(Error **errp) { BlockJobInfoList *head = NULL, **p_next = &head; - BlockDriverState *bs; + BlockJob *job; - for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) { - AioContext *aio_context = bdrv_get_aio_context(bs); + for (job = block_job_next(NULL); job; job = block_job_next(job)) { + BlockJobInfoList *elem = g_new0(BlockJobInfoList, 1); + AioContext *aio_context = bdrv_get_aio_context(job->bs); aio_context_acquire(aio_context); - - if (bs->job) { - BlockJobInfoList *elem = g_new0(BlockJobInfoList, 1); - elem->value = block_job_query(bs->job); - *p_next = elem; - p_next = &elem->next; - } - + elem->value = block_job_query(job); aio_context_release(aio_context); + + *p_next = elem; + p_next = &elem->next; } return head;