From patchwork Fri May 27 10:53:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 9138145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 221846075C for ; Fri, 27 May 2016 10:58:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14B112793B for ; Fri, 27 May 2016 10:58:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09C4F28135; Fri, 27 May 2016 10:58:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id B626A2793B for ; Fri, 27 May 2016 10:58:36 +0000 (UTC) Received: from localhost ([::1]:45245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6FTP-0007xj-Tm for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 May 2016 06:58:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6FPi-0004mg-Pc for qemu-devel@nongnu.org; Fri, 27 May 2016 06:54:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6FPb-0002Kw-KO for qemu-devel@nongnu.org; Fri, 27 May 2016 06:54:45 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:20558 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6FPb-00026Y-D6; Fri, 27 May 2016 06:54:39 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2D/AQDmJkhX/5tjdVtcHAGDHIFTjSWYEQEBAQEBAQUBgQ8Bjm+CH4IPAQ2BeIYRAoE7OBQBAQEBAQEBZSeERAIEJ1IQUTwbGYgzAcQMAQEBBwIlhV+CRodZhQ4FiASQM44gjxxFjwceAQFCggYcgU06MooIAQEB X-IPAS-Result: A2D/AQDmJkhX/5tjdVtcHAGDHIFTjSWYEQEBAQEBAQUBgQ8Bjm+CH4IPAQ2BeIYRAoE7OBQBAQEBAQEBZSeERAIEJ1IQUTwbGYgzAcQMAQEBBwIlhV+CRodZhQ4FiASQM44gjxxFjwceAQFCggYcgU06MooIAQEB X-IronPort-AV: E=Sophos;i="5.26,373,1459807200"; d="scan'208";a="64793579" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 27 May 2016 12:53:57 +0200 Received: from maestria.local.igalia.com ([192.168.10.14] helo=mail.igalia.com) by fanzine.igalia.com with esmtps (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1b6FOv-00066F-AF; Fri, 27 May 2016 12:53:57 +0200 Received: from ip159.dynamic.igalia.com ([192.168.10.159] helo=perseus.local) by mail.igalia.com with esmtps (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1b6FOv-0002O7-5Z; Fri, 27 May 2016 12:53:57 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1b6FOv-0002Sw-2b; Fri, 27 May 2016 13:53:57 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 12:53:37 +0200 Message-Id: X-Mailer: git-send-email 2.8.1 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 Subject: [Qemu-devel] [PATCH 2/4] block: use the block job list in qmp_query_block_jobs() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- blockdev.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/blockdev.c b/blockdev.c index 717785e..ca7fa82 100644 --- a/blockdev.c +++ b/blockdev.c @@ -4141,22 +4141,18 @@ void qmp_x_blockdev_change(const char *parent, bool has_child, BlockJobInfoList *qmp_query_block_jobs(Error **errp) { BlockJobInfoList *head = NULL, **p_next = &head; - BlockDriverState *bs; - BdrvNextIterator it; + BlockJob *job; - for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { - 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 = blk_get_aio_context(job->blk); 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;