From nobody Fri May 17 02:41:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625745026779373.9414388782343; Thu, 8 Jul 2021 04:50:26 -0700 (PDT) Received: from localhost ([::1]:51706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1SXx-0006mn-Ee for importer@patchew.org; Thu, 08 Jul 2021 07:50:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1SUz-0003rv-Rn for qemu-devel@nongnu.org; Thu, 08 Jul 2021 07:47:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37862) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1SUw-0001Qc-Cl for qemu-devel@nongnu.org; Thu, 08 Jul 2021 07:47:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-324-W0wsrIojMfqGCAYogNDMdQ-1; Thu, 08 Jul 2021 07:47:16 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A2B20102CC32; Thu, 8 Jul 2021 11:47:15 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-143.ams2.redhat.com [10.36.114.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24E1560843; Thu, 8 Jul 2021 11:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625744837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D4cXd+TLbkbp1fXcYqMN/i9xFVY1Uok3yhO668JM73s=; b=H//930616C1Krx71vSnMYgWeDSEzWttb6tr6jb04ky1dWwmw9jvQaTtFlNglDGMxW72Tpr mAp7i+OlgbToFRn416t1O5/Q2MBKz9wAIoV+lvPFiDYyruDcyly//VYdPz/uK/zzUGVOSw lmvYgq2No1reRanYr0v0Q2DRjKmhSeQ= X-MC-Unique: W0wsrIojMfqGCAYogNDMdQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v6 1/6] qcow2: Fix dangling pointer after reopen for 'file' Date: Thu, 8 Jul 2021 13:47:04 +0200 Message-Id: <20210708114709.206487-2-kwolf@redhat.com> In-Reply-To: <20210708114709.206487-1-kwolf@redhat.com> References: <20210708114709.206487-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.45, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1625745029049100005 Content-Type: text/plain; charset="utf-8" Without an external data file, s->data_file is a second pointer with the same value as bs->file. When changing bs->file to a different BdrvChild and freeing the old BdrvChild, s->data_file must also be updated, otherwise it points to freed memory and causes crashes. This problem was caught by iotests case 245. Fixes: df2b7086f169239ebad5d150efa29c9bb6d4f820 Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index ee4530cdbd..9126127633 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1926,6 +1926,7 @@ static void qcow2_refresh_limits(BlockDriverState *bs= , Error **errp) static int qcow2_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { + BDRVQcow2State *s =3D state->bs->opaque; Qcow2ReopenState *r; int ret; =20 @@ -1956,6 +1957,16 @@ static int qcow2_reopen_prepare(BDRVReopenState *sta= te, } } =20 + /* + * Without an external data file, s->data_file points to the same Bdrv= Child + * as bs->file. It needs to be resynced after reopen because bs->file = may + * be changed. We can't use it in the meantime. + */ + if (!has_data_file(state->bs)) { + assert(s->data_file =3D=3D state->bs->file); + s->data_file =3D NULL; + } + return 0; =20 fail: @@ -1966,7 +1977,16 @@ fail: =20 static void qcow2_reopen_commit(BDRVReopenState *state) { + BDRVQcow2State *s =3D state->bs->opaque; + qcow2_update_options_commit(state->bs, state->opaque); + if (!s->data_file) { + /* + * If we don't have an external data file, s->data_file was cleare= d by + * qcow2_reopen_prepare() and needs to be updated. + */ + s->data_file =3D state->bs->file; + } g_free(state->opaque); } =20 @@ -1990,6 +2010,15 @@ static void qcow2_reopen_commit_post(BDRVReopenState= *state) =20 static void qcow2_reopen_abort(BDRVReopenState *state) { + BDRVQcow2State *s =3D state->bs->opaque; + + if (!s->data_file) { + /* + * If we don't have an external data file, s->data_file was cleare= d by + * qcow2_reopen_prepare() and needs to be restored. + */ + s->data_file =3D state->bs->file; + } qcow2_update_options_abort(state->bs, state->opaque); g_free(state->opaque); } --=20 2.31.1 From nobody Fri May 17 02:41:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625745026706405.52555694317607; Thu, 8 Jul 2021 04:50:26 -0700 (PDT) Received: from localhost ([::1]:51696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1SXx-0006mJ-MA for importer@patchew.org; Thu, 08 Jul 2021 07:50:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1SV2-0003sg-E8 for qemu-devel@nongnu.org; Thu, 08 Jul 2021 07:47:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25083) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1SUz-0001Qx-Jj for qemu-devel@nongnu.org; Thu, 08 Jul 2021 07:47:24 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-138-KrBSVD2vMnidtBZOTyn0aQ-1; Thu, 08 Jul 2021 07:47:18 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33EDE102CB7D; Thu, 8 Jul 2021 11:47:17 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-143.ams2.redhat.com [10.36.114.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA9F960843; Thu, 8 Jul 2021 11:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625744840; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Nxjmqf9IhhxRz10b1qva0SYNXGwh1eMNIcvrFIuxy8=; b=Ie14e8vMYRS2Wj7xXtkKqyCQK4eA46L6J1vuhTYFOg/9CRVg5TK3bbVTgeDV+eugSK23aH pKuhRF6tCwlJn9QzCvlYDkpBdY2OJZCvJr0JMxJYGRvBDYJWaUxo+ej5Vu4sIW1XRneynj mMZtkeUpxv+ly7fUOGSx1YgvjQOIK/s= X-MC-Unique: KrBSVD2vMnidtBZOTyn0aQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v6 2/6] block: Add bdrv_reopen_queue_free() Date: Thu, 8 Jul 2021 13:47:05 +0200 Message-Id: <20210708114709.206487-3-kwolf@redhat.com> In-Reply-To: <20210708114709.206487-1-kwolf@redhat.com> References: <20210708114709.206487-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.45, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1625745027298100001 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia Move the code to free a BlockReopenQueue to a separate function. It will be used in a subsequent patch. [ kwolf: Also free explicit_options and options, and explicitly qobject_ref() the value when it continues to be used. This makes future memory leaks less likely. ] Signed-off-by: Alberto Garcia Signed-off-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/block/block.h | 1 + block.c | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 7ec77ecb1a..6d42992985 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -386,6 +386,7 @@ BlockDriverState *bdrv_new_open_driver(BlockDriver *drv= , const char *node_name, BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, BlockDriverState *bs, QDict *options, bool keep_old_opts); +void bdrv_reopen_queue_free(BlockReopenQueue *bs_queue); int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp); int bdrv_reopen_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); diff --git a/block.c b/block.c index acd35cb0cb..ee9b46e95e 100644 --- a/block.c +++ b/block.c @@ -4095,6 +4095,19 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue= *bs_queue, NULL, 0, keep_old_opts); } =20 +void bdrv_reopen_queue_free(BlockReopenQueue *bs_queue) +{ + if (bs_queue) { + BlockReopenQueueEntry *bs_entry, *next; + QTAILQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) { + qobject_unref(bs_entry->state.explicit_options); + qobject_unref(bs_entry->state.options); + g_free(bs_entry); + } + g_free(bs_queue); + } +} + /* * Reopen multiple BlockDriverStates atomically & transactionally. * @@ -4197,15 +4210,10 @@ abort: if (bs_entry->prepared) { bdrv_reopen_abort(&bs_entry->state); } - qobject_unref(bs_entry->state.explicit_options); - qobject_unref(bs_entry->state.options); } =20 cleanup: - QTAILQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) { - g_free(bs_entry); - } - g_free(bs_queue); + bdrv_reopen_queue_free(bs_queue); =20 return ret; } @@ -4573,6 +4581,8 @@ static void bdrv_reopen_commit(BDRVReopenState *reope= n_state) /* set BDS specific flags now */ qobject_unref(bs->explicit_options); qobject_unref(bs->options); + qobject_ref(reopen_state->explicit_options); + qobject_ref(reopen_state->options); =20 bs->explicit_options =3D reopen_state->explicit_options; bs->options =3D reopen_state->options; --=20 2.31.1 From nobody Fri May 17 02:41:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625745220203314.3539178866157; Thu, 8 Jul 2021 04:53:40 -0700 (PDT) Received: from localhost ([::1]:60424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1Sb5-0004JK-3T for importer@patchew.org; Thu, 08 Jul 2021 07:53:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1SV6-0003uV-MJ for qemu-devel@nongnu.org; Thu, 08 Jul 2021 07:47:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38347) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1SV2-0001RY-5s for qemu-devel@nongnu.org; Thu, 08 Jul 2021 07:47:28 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-205-rj8yGVSRNL-bHuuCfUYLiA-1; Thu, 08 Jul 2021 07:47:20 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CF21919251A0; Thu, 8 Jul 2021 11:47:18 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-143.ams2.redhat.com [10.36.114.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C5E760843; Thu, 8 Jul 2021 11:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625744843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ld+9hp5ik8tNIh+Y7VpxHJHDO168ucmKncl70hoxjX0=; b=E05wxROyN7VKFhNzGHJ6qgWaZe/bpxTGJp5jdNV/bMxSfv8/LYZi4R0GqeZRfA8NeggCBE WlVrTJH6dBN3WVleB4LzETrsWqI97P1k+hiq+oR+e8sVA6rVgMvG9oLDkPJ+bUAHrZB/JW ovw/EcznODDaO36Or2fZyykE7MM6JLU= X-MC-Unique: rj8yGVSRNL-bHuuCfUYLiA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v6 3/6] block: Acquire AioContexts during bdrv_reopen_multiple() Date: Thu, 8 Jul 2021 13:47:06 +0200 Message-Id: <20210708114709.206487-4-kwolf@redhat.com> In-Reply-To: <20210708114709.206487-1-kwolf@redhat.com> References: <20210708114709.206487-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.45, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1625745224242100003 Content-Type: text/plain; charset="utf-8" As the BlockReopenQueue can contain nodes in multiple AioContexts, only one of which may be locked when AIO_WAIT_WHILE() can be called, we can't let the caller lock the right contexts. Instead, individually lock the AioContext of a single node when iterating the queue. Reintroduce bdrv_reopen() as a wrapper for reopening a single node that drains the node and temporarily drops the AioContext lock for bdrv_reopen_multiple(). Signed-off-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/block/block.h | 2 ++ block.c | 49 ++++++++++++++++++++++++++++++++++++------- block/replication.c | 7 +++++++ blockdev.c | 5 +++++ qemu-io-cmds.c | 7 +------ 5 files changed, 57 insertions(+), 13 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 6d42992985..3477290f9a 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -388,6 +388,8 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *b= s_queue, bool keep_old_opts); void bdrv_reopen_queue_free(BlockReopenQueue *bs_queue); int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp); +int bdrv_reopen(BlockDriverState *bs, QDict *opts, bool keep_old_opts, + Error **errp); int bdrv_reopen_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, diff --git a/block.c b/block.c index ee9b46e95e..06fb69df5c 100644 --- a/block.c +++ b/block.c @@ -4124,19 +4124,26 @@ void bdrv_reopen_queue_free(BlockReopenQueue *bs_qu= eue) * * All affected nodes must be drained between bdrv_reopen_queue() and * bdrv_reopen_multiple(). + * + * To be called from the main thread, with all other AioContexts unlocked. */ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp) { int ret =3D -1; BlockReopenQueueEntry *bs_entry, *next; + AioContext *ctx; Transaction *tran =3D tran_new(); g_autoptr(GHashTable) found =3D NULL; g_autoptr(GSList) refresh_list =3D NULL; =20 + assert(qemu_get_current_aio_context() =3D=3D qemu_get_aio_context()); assert(bs_queue !=3D NULL); =20 QTAILQ_FOREACH(bs_entry, bs_queue, entry) { + ctx =3D bdrv_get_aio_context(bs_entry->state.bs); + aio_context_acquire(ctx); ret =3D bdrv_flush(bs_entry->state.bs); + aio_context_release(ctx); if (ret < 0) { error_setg_errno(errp, -ret, "Error flushing drive"); goto abort; @@ -4145,7 +4152,10 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue,= Error **errp) =20 QTAILQ_FOREACH(bs_entry, bs_queue, entry) { assert(bs_entry->state.bs->quiesce_counter > 0); + ctx =3D bdrv_get_aio_context(bs_entry->state.bs); + aio_context_acquire(ctx); ret =3D bdrv_reopen_prepare(&bs_entry->state, bs_queue, tran, errp= ); + aio_context_release(ctx); if (ret < 0) { goto abort; } @@ -4188,7 +4198,10 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue,= Error **errp) * to first element. */ QTAILQ_FOREACH_REVERSE(bs_entry, bs_queue, entry) { + ctx =3D bdrv_get_aio_context(bs_entry->state.bs); + aio_context_acquire(ctx); bdrv_reopen_commit(&bs_entry->state); + aio_context_release(ctx); } =20 tran_commit(tran); @@ -4197,7 +4210,10 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue,= Error **errp) BlockDriverState *bs =3D bs_entry->state.bs; =20 if (bs->drv->bdrv_reopen_commit_post) { + ctx =3D bdrv_get_aio_context(bs); + aio_context_acquire(ctx); bs->drv->bdrv_reopen_commit_post(&bs_entry->state); + aio_context_release(ctx); } } =20 @@ -4208,7 +4224,10 @@ abort: tran_abort(tran); QTAILQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) { if (bs_entry->prepared) { + ctx =3D bdrv_get_aio_context(bs_entry->state.bs); + aio_context_acquire(ctx); bdrv_reopen_abort(&bs_entry->state); + aio_context_release(ctx); } } =20 @@ -4218,23 +4237,39 @@ cleanup: return ret; } =20 -int bdrv_reopen_set_read_only(BlockDriverState *bs, bool read_only, - Error **errp) +int bdrv_reopen(BlockDriverState *bs, QDict *opts, bool keep_old_opts, + Error **errp) { - int ret; + AioContext *ctx =3D bdrv_get_aio_context(bs); BlockReopenQueue *queue; - QDict *opts =3D qdict_new(); - - qdict_put_bool(opts, BDRV_OPT_READ_ONLY, read_only); + int ret; =20 bdrv_subtree_drained_begin(bs); - queue =3D bdrv_reopen_queue(NULL, bs, opts, true); + if (ctx !=3D qemu_get_aio_context()) { + aio_context_release(ctx); + } + + queue =3D bdrv_reopen_queue(NULL, bs, opts, keep_old_opts); ret =3D bdrv_reopen_multiple(queue, errp); + + if (ctx !=3D qemu_get_aio_context()) { + aio_context_acquire(ctx); + } bdrv_subtree_drained_end(bs); =20 return ret; } =20 +int bdrv_reopen_set_read_only(BlockDriverState *bs, bool read_only, + Error **errp) +{ + QDict *opts =3D qdict_new(); + + qdict_put_bool(opts, BDRV_OPT_READ_ONLY, read_only); + + return bdrv_reopen(bs, opts, true, errp); +} + /* * Take a BDRVReopenState and check if the value of 'backing' in the * reopen_state->options QDict is valid or not. diff --git a/block/replication.c b/block/replication.c index 52163f2d1f..774e15df16 100644 --- a/block/replication.c +++ b/block/replication.c @@ -390,7 +390,14 @@ static void reopen_backing_file(BlockDriverState *bs, = bool writable, } =20 if (reopen_queue) { + AioContext *ctx =3D bdrv_get_aio_context(bs); + if (ctx !=3D qemu_get_aio_context()) { + aio_context_release(ctx); + } bdrv_reopen_multiple(reopen_queue, errp); + if (ctx !=3D qemu_get_aio_context()) { + aio_context_acquire(ctx); + } } =20 bdrv_subtree_drained_end(s->hidden_disk->bs); diff --git a/blockdev.c b/blockdev.c index f08192deda..f657d090d3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3593,8 +3593,13 @@ void qmp_x_blockdev_reopen(BlockdevOptions *options,= Error **errp) ctx =3D bdrv_get_aio_context(bs); aio_context_acquire(ctx); bdrv_subtree_drained_begin(bs); + aio_context_release(ctx); + queue =3D bdrv_reopen_queue(NULL, bs, qdict, false); bdrv_reopen_multiple(queue, errp); + + ctx =3D bdrv_get_aio_context(bs); + aio_context_acquire(ctx); bdrv_subtree_drained_end(bs); aio_context_release(ctx); =20 diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index e8d862a426..46593d632d 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -2116,8 +2116,6 @@ static int reopen_f(BlockBackend *blk, int argc, char= **argv) bool writethrough =3D !blk_enable_write_cache(blk); bool has_rw_option =3D false; bool has_cache_option =3D false; - - BlockReopenQueue *brq; Error *local_err =3D NULL; =20 while ((c =3D getopt(argc, argv, "c:o:rw")) !=3D -1) { @@ -2210,10 +2208,7 @@ static int reopen_f(BlockBackend *blk, int argc, cha= r **argv) qdict_put_bool(opts, BDRV_OPT_CACHE_NO_FLUSH, flags & BDRV_O_NO_FL= USH); } =20 - bdrv_subtree_drained_begin(bs); - brq =3D bdrv_reopen_queue(NULL, bs, opts, true); - bdrv_reopen_multiple(brq, &local_err); - bdrv_subtree_drained_end(bs); + bdrv_reopen(bs, opts, true, &local_err); =20 if (local_err) { error_report_err(local_err); --=20 2.31.1 From nobody Fri May 17 02:41:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625745334892532.9957958494; Thu, 8 Jul 2021 04:55:34 -0700 (PDT) Received: from localhost ([::1]:39350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1Scv-0000b5-GX for importer@patchew.org; Thu, 08 Jul 2021 07:55:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1SV9-0003wB-Ed for qemu-devel@nongnu.org; Thu, 08 Jul 2021 07:47:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58112) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1SV4-0001Rr-1P for qemu-devel@nongnu.org; Thu, 08 Jul 2021 07:47:31 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-378-xWN0gNsdMuq4Hu-jmqh17A-1; Thu, 08 Jul 2021 07:47:21 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8666B80006E; Thu, 8 Jul 2021 11:47:20 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-143.ams2.redhat.com [10.36.114.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2356560843; Thu, 8 Jul 2021 11:47:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625744844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8bONWI951KGXc0D+byxSbr5E5ZjAQf6jNca6ePmDF1w=; b=GVqYBxTXof5pVmZUCwc0uFrsPXqfECBdorUX3y4G/vR1XMfEoROPmYFiXNORLxYqELr3YQ LyHfTGlYAphl/gsma2JTIOaI44aG0nj93TEu+q0vJ+EUg81xjlGrTPAgiA0laHZE+q6uRz B55RYtQkauN26BOPGubR6UZ5g0i8v+Q= X-MC-Unique: xWN0gNsdMuq4Hu-jmqh17A-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v6 4/6] block: Support multiple reopening with x-blockdev-reopen Date: Thu, 8 Jul 2021 13:47:07 +0200 Message-Id: <20210708114709.206487-5-kwolf@redhat.com> In-Reply-To: <20210708114709.206487-1-kwolf@redhat.com> References: <20210708114709.206487-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.45, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1625745336658100001 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia [ kwolf: Fixed AioContext locking ] Signed-off-by: Alberto Garcia Signed-off-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 18 +++-- blockdev.c | 81 ++++++++++--------- tests/qemu-iotests/155 | 9 ++- tests/qemu-iotests/165 | 4 +- tests/qemu-iotests/245 | 27 ++++--- tests/qemu-iotests/248 | 2 +- tests/qemu-iotests/248.out | 2 +- tests/qemu-iotests/296 | 9 ++- tests/qemu-iotests/298 | 4 +- .../tests/remove-bitmap-from-backing | 18 +++-- 10 files changed, 99 insertions(+), 75 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 4a46552816..052520331e 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4221,13 +4221,15 @@ ## # @x-blockdev-reopen: # -# Reopens a block device using the given set of options. Any option -# not specified will be reset to its default value regardless of its -# previous status. If an option cannot be changed or a particular +# Reopens one or more block devices using the given set of options. +# Any option not specified will be reset to its default value regardless +# of its previous status. If an option cannot be changed or a particular # driver does not support reopening then the command will return an -# error. +# error. All devices in the list are reopened in one transaction, so +# if one of them fails then the whole transaction is cancelled. # -# The top-level @node-name option (from BlockdevOptions) must be +# The command receives a list of block devices to reopen. For each one +# of them, the top-level @node-name option (from BlockdevOptions) must be # specified and is used to select the block device to be reopened. # Other @node-name options must be either omitted or set to the # current name of the appropriate node. This command won't change any @@ -4247,8 +4249,8 @@ # # 4) NULL: the current child (if any) is detached. # -# Options (1) and (2) are supported in all cases, but at the moment -# only @backing allows replacing or detaching an existing child. +# Options (1) and (2) are supported in all cases. Option (3) is +# supported for @file and @backing, and option (4) for @backing only. # # Unlike with blockdev-add, the @backing option must always be present # unless the node being reopened does not have a backing file and its @@ -4258,7 +4260,7 @@ # Since: 4.0 ## { 'command': 'x-blockdev-reopen', - 'data': 'BlockdevOptions', 'boxed': true } + 'data': { 'options': ['BlockdevOptions'] } } =20 ## # @blockdev-del: diff --git a/blockdev.c b/blockdev.c index f657d090d3..fddcccbdbd 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3560,51 +3560,60 @@ fail: visit_free(v); } =20 -void qmp_x_blockdev_reopen(BlockdevOptions *options, Error **errp) -{ - BlockDriverState *bs; - AioContext *ctx; - QObject *obj; - Visitor *v =3D qobject_output_visitor_new(&obj); - BlockReopenQueue *queue; - QDict *qdict; +void qmp_x_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp) +{ + BlockReopenQueue *queue =3D NULL; + GSList *drained =3D NULL; + + /* Add each one of the BDS that we want to reopen to the queue */ + for (; reopen_list !=3D NULL; reopen_list =3D reopen_list->next) { + BlockdevOptions *options =3D reopen_list->value; + BlockDriverState *bs; + AioContext *ctx; + QObject *obj; + Visitor *v; + QDict *qdict; + + /* Check for the selected node name */ + if (!options->has_node_name) { + error_setg(errp, "node-name not specified"); + goto fail; + } =20 - /* Check for the selected node name */ - if (!options->has_node_name) { - error_setg(errp, "node-name not specified"); - goto fail; - } + bs =3D bdrv_find_node(options->node_name); + if (!bs) { + error_setg(errp, "Failed to find node with node-name=3D'%s'", + options->node_name); + goto fail; + } =20 - bs =3D bdrv_find_node(options->node_name); - if (!bs) { - error_setg(errp, "Failed to find node with node-name=3D'%s'", - options->node_name); - goto fail; - } + /* Put all options in a QDict and flatten it */ + v =3D qobject_output_visitor_new(&obj); + visit_type_BlockdevOptions(v, NULL, &options, &error_abort); + visit_complete(v, &obj); + visit_free(v); =20 - /* Put all options in a QDict and flatten it */ - visit_type_BlockdevOptions(v, NULL, &options, &error_abort); - visit_complete(v, &obj); - qdict =3D qobject_to(QDict, obj); + qdict =3D qobject_to(QDict, obj); =20 - qdict_flatten(qdict); + qdict_flatten(qdict); =20 - /* Perform the reopen operation */ - ctx =3D bdrv_get_aio_context(bs); - aio_context_acquire(ctx); - bdrv_subtree_drained_begin(bs); - aio_context_release(ctx); + ctx =3D bdrv_get_aio_context(bs); + aio_context_acquire(ctx); =20 - queue =3D bdrv_reopen_queue(NULL, bs, qdict, false); - bdrv_reopen_multiple(queue, errp); + bdrv_subtree_drained_begin(bs); + queue =3D bdrv_reopen_queue(queue, bs, qdict, false); + drained =3D g_slist_prepend(drained, bs); =20 - ctx =3D bdrv_get_aio_context(bs); - aio_context_acquire(ctx); - bdrv_subtree_drained_end(bs); - aio_context_release(ctx); + aio_context_release(ctx); + } + + /* Perform the reopen operation */ + bdrv_reopen_multiple(queue, errp); + queue =3D NULL; =20 fail: - visit_free(v); + bdrv_reopen_queue_free(queue); + g_slist_free_full(drained, (GDestroyNotify) bdrv_subtree_drained_end); } =20 void qmp_blockdev_del(const char *node_name, Error **errp) diff --git a/tests/qemu-iotests/155 b/tests/qemu-iotests/155 index bafef9dd9a..2947bfb81a 100755 --- a/tests/qemu-iotests/155 +++ b/tests/qemu-iotests/155 @@ -261,9 +261,12 @@ class TestBlockdevMirrorReopen(MirrorBaseClass): result =3D self.vm.qmp('blockdev-add', node_name=3D"backing", driver=3D"null-co") self.assert_qmp(result, 'return', {}) - result =3D self.vm.qmp('x-blockdev-reopen', node_name=3D"targe= t", - driver=3Diotests.imgfmt, file=3D"target-f= ile", - backing=3D"backing") + result =3D self.vm.qmp('x-blockdev-reopen', options=3D[{ + 'node-name': "target", + 'driver': iotests.imgfmt, + 'file': "target-file", + 'backing': "backing" + }]) self.assert_qmp(result, 'return', {}) =20 class TestBlockdevMirrorReopenIothread(TestBlockdevMirrorReopen): diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165 index abc4ffadd5..ef4cf14516 100755 --- a/tests/qemu-iotests/165 +++ b/tests/qemu-iotests/165 @@ -137,7 +137,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): assert sha256_1 =3D=3D self.getSha256() =20 # Reopen to RW - result =3D self.vm.qmp('x-blockdev-reopen', **{ + result =3D self.vm.qmp('x-blockdev-reopen', options=3D[{ 'node-name': 'node0', 'driver': iotests.imgfmt, 'file': { @@ -145,7 +145,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): 'filename': disk }, 'read-only': False - }) + }]) self.assert_qmp(result, 'return', {}) =20 # Check that bitmap is reopened to RW and we can write to it. diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245 index 0295129cbb..ca08955207 100755 --- a/tests/qemu-iotests/245 +++ b/tests/qemu-iotests/245 @@ -85,8 +85,18 @@ class TestBlockdevReopen(iotests.QMPTestCase): "Expected output of %d qemu-io commands, found %d= " % (found, self.total_io_cmds)) =20 - # Run x-blockdev-reopen with 'opts' but applying 'newopts' - # on top of it. The original 'opts' dict is unmodified + # Run x-blockdev-reopen on a list of block devices + def reopenMultiple(self, opts, errmsg =3D None): + result =3D self.vm.qmp('x-blockdev-reopen', conv_keys=3DFalse, opt= ions=3Dopts) + if errmsg: + self.assert_qmp(result, 'error/class', 'GenericError') + self.assert_qmp(result, 'error/desc', errmsg) + else: + self.assert_qmp(result, 'return', {}) + + # Run x-blockdev-reopen on a single block device (specified by + # 'opts') but applying 'newopts' on top of it. The original 'opts' + # dict is unmodified def reopen(self, opts, newopts =3D {}, errmsg =3D None): opts =3D copy.deepcopy(opts) =20 @@ -101,12 +111,7 @@ class TestBlockdevReopen(iotests.QMPTestCase): subdict =3D opts[prefix] subdict[key] =3D value =20 - result =3D self.vm.qmp('x-blockdev-reopen', conv_keys =3D False, *= *opts) - if errmsg: - self.assert_qmp(result, 'error/class', 'GenericError') - self.assert_qmp(result, 'error/desc', errmsg) - else: - self.assert_qmp(result, 'return', {}) + self.reopenMultiple([ opts ], errmsg) =20 =20 # Run query-named-block-nodes and return the specified entry @@ -142,10 +147,10 @@ class TestBlockdevReopen(iotests.QMPTestCase): # We cannot change any of these self.reopen(opts, {'node-name': 'not-found'}, "Failed to find node= with node-name=3D'not-found'") self.reopen(opts, {'node-name': ''}, "Failed to find node with nod= e-name=3D''") - self.reopen(opts, {'node-name': None}, "Invalid parameter type for= 'node-name', expected: string") + self.reopen(opts, {'node-name': None}, "Invalid parameter type for= 'options[0].node-name', expected: string") self.reopen(opts, {'driver': 'raw'}, "Cannot change the option 'dr= iver'") self.reopen(opts, {'driver': ''}, "Invalid parameter ''") - self.reopen(opts, {'driver': None}, "Invalid parameter type for 'd= river', expected: string") + self.reopen(opts, {'driver': None}, "Invalid parameter type for 'o= ptions[0].driver', expected: string") self.reopen(opts, {'file': 'not-found'}, "Cannot find device=3D'' = nor node-name=3D'not-found'") self.reopen(opts, {'file': ''}, "Cannot find device=3D'' nor node-= name=3D''") self.reopen(opts, {'file': None}, "Invalid parameter type for 'fil= e', expected: BlockdevRef") @@ -154,7 +159,7 @@ class TestBlockdevReopen(iotests.QMPTestCase): self.reopen(opts, {'file.filename': hd_path[1]}, "Cannot change th= e option 'filename'") self.reopen(opts, {'file.aio': 'native'}, "Cannot change the optio= n 'aio'") self.reopen(opts, {'file.locking': 'off'}, "Cannot change the opti= on 'locking'") - self.reopen(opts, {'file.filename': None}, "Invalid parameter type= for 'file.filename', expected: string") + self.reopen(opts, {'file.filename': None}, "Invalid parameter type= for 'options[0].file.filename', expected: string") =20 # node-name is optional in BlockdevOptions, but x-blockdev-reopen = needs it del opts['node-name'] diff --git a/tests/qemu-iotests/248 b/tests/qemu-iotests/248 index 4daaed1530..03911333c4 100755 --- a/tests/qemu-iotests/248 +++ b/tests/qemu-iotests/248 @@ -63,7 +63,7 @@ vm.get_qmp_events() =20 del blockdev_opts['file']['size'] vm.qmp_log('x-blockdev-reopen', filters=3D[filter_qmp_testfiles], - **blockdev_opts) + options =3D [ blockdev_opts ]) =20 vm.qmp_log('block-job-resume', device=3D'drive0') vm.event_wait('JOB_STATUS_CHANGE', timeout=3D1.0, diff --git a/tests/qemu-iotests/248.out b/tests/qemu-iotests/248.out index 369b25bf26..893f625347 100644 --- a/tests/qemu-iotests/248.out +++ b/tests/qemu-iotests/248.out @@ -2,7 +2,7 @@ {"return": {}} {"execute": "blockdev-mirror", "arguments": {"device": "drive0", "on-targe= t-error": "enospc", "sync": "full", "target": "target"}} {"return": {}} -{"execute": "x-blockdev-reopen", "arguments": {"driver": "qcow2", "file": = {"driver": "raw", "file": {"driver": "file", "filename": "TEST_DIR/PID-targ= et"}}, "node-name": "target"}} +{"execute": "x-blockdev-reopen", "arguments": {"options": [{"driver": "qco= w2", "file": {"driver": "raw", "file": {"driver": "file", "filename": "TEST= _DIR/PID-target"}}, "node-name": "target"}]}} {"return": {}} {"execute": "block-job-resume", "arguments": {"device": "drive0"}} {"return": {}} diff --git a/tests/qemu-iotests/296 b/tests/qemu-iotests/296 index 7c65e987a1..fa07b98bb4 100755 --- a/tests/qemu-iotests/296 +++ b/tests/qemu-iotests/296 @@ -120,8 +120,7 @@ class EncryptionSetupTestCase(iotests.QMPTestCase): =20 command =3D 'x-blockdev-reopen' if reOpen else 'blockdev-add' =20 - result =3D vm.qmp(command, ** - { + opts =3D { 'driver': iotests.imgfmt, 'node-name': id, 'read-only': readOnly, @@ -131,7 +130,11 @@ class EncryptionSetupTestCase(iotests.QMPTestCase): 'filename': test_img, } } - ) + + if reOpen: + result =3D vm.qmp(command, options=3D[opts]) + else: + result =3D vm.qmp(command, **opts) self.assert_qmp(result, 'return', {}) =20 =20 diff --git a/tests/qemu-iotests/298 b/tests/qemu-iotests/298 index d535946b5f..a5b0d91224 100755 --- a/tests/qemu-iotests/298 +++ b/tests/qemu-iotests/298 @@ -98,7 +98,7 @@ class TestPreallocateFilter(TestPreallocateBase): self.check_big() =20 def test_reopen_opts(self): - result =3D self.vm.qmp('x-blockdev-reopen', **{ + result =3D self.vm.qmp('x-blockdev-reopen', options=3D[{ 'node-name': 'disk', 'driver': iotests.imgfmt, 'file': { @@ -112,7 +112,7 @@ class TestPreallocateFilter(TestPreallocateBase): 'filename': disk } } - }) + }]) self.assert_qmp(result, 'return', {}) =20 self.vm.hmp_qemu_io('drive0', 'write 0 1M') diff --git a/tests/qemu-iotests/tests/remove-bitmap-from-backing b/tests/qe= mu-iotests/tests/remove-bitmap-from-backing index 0ea4c36507..0b07f7e836 100755 --- a/tests/qemu-iotests/tests/remove-bitmap-from-backing +++ b/tests/qemu-iotests/tests/remove-bitmap-from-backing @@ -41,13 +41,15 @@ log('Trying to remove persistent bitmap from r-o base n= ode, should fail:') vm.qmp_log('block-dirty-bitmap-remove', node=3D'base', name=3D'bitmap0') =20 new_base_opts =3D { - 'node-name': 'base', - 'driver': 'qcow2', - 'file': { - 'driver': 'file', - 'filename': base - }, - 'read-only': False + 'options': [{ + 'node-name': 'base', + 'driver': 'qcow2', + 'file': { + 'driver': 'file', + 'filename': base + }, + 'read-only': False + }] } =20 # Don't want to bother with filtering qmp_log for reopen command @@ -58,7 +60,7 @@ if result !=3D {'return': {}}: log('Remove persistent bitmap from base node reopened to RW:') vm.qmp_log('block-dirty-bitmap-remove', node=3D'base', name=3D'bitmap0') =20 -new_base_opts['read-only'] =3D True +new_base_opts['options'][0]['read-only'] =3D True result =3D vm.qmp('x-blockdev-reopen', **new_base_opts) if result !=3D {'return': {}}: log('Failed to reopen: ' + str(result)) --=20 2.31.1 From nobody Fri May 17 02:41:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625745208870156.67473499672485; Thu, 8 Jul 2021 04:53:28 -0700 (PDT) Received: from localhost ([::1]:59446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1Sar-0003gJ-6h for importer@patchew.org; Thu, 08 Jul 2021 07:53:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1SV7-0003v2-Hf for qemu-devel@nongnu.org; Thu, 08 Jul 2021 07:47:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60863) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1SV4-0001Rv-1Z for qemu-devel@nongnu.org; Thu, 08 Jul 2021 07:47:28 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-233-se-XjPvHOeOg1SkPflwPCQ-1; Thu, 08 Jul 2021 07:47:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 17BFF8015F5; Thu, 8 Jul 2021 11:47:22 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-143.ams2.redhat.com [10.36.114.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE7AE60843; Thu, 8 Jul 2021 11:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625744845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tttWUckygg3NEPKNtz8ctJtdFGgk9p1pQ6dqttriVps=; b=iID01xoGAo5RzkeqrbPj8O53lzegT/SJevBilzQISE/X9SM6RqAY3e6NPPtGMTL6KqJ4qd rqXSI0IAr6kAVN2UwBOKrIVttK1pdhbRzEwK1zWxA93sh0wSdmksDyAPIx2sOQuxgQjtkI pbhI9v1F0n/ltafdZXoMYsjnMH+Pgdw= X-MC-Unique: se-XjPvHOeOg1SkPflwPCQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v6 5/6] iotests: Test reopening multiple devices at the same time Date: Thu, 8 Jul 2021 13:47:08 +0200 Message-Id: <20210708114709.206487-6-kwolf@redhat.com> In-Reply-To: <20210708114709.206487-1-kwolf@redhat.com> References: <20210708114709.206487-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.45, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1625745214428100001 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This test swaps the images used by two active block devices. This is now possible thanks to the new ability to run x-blockdev-reopen on multiple devices at the same time. Signed-off-by: Alberto Garcia Signed-off-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/245 | 47 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/245.out | 4 ++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245 index ca08955207..8bc8101e6d 100755 --- a/tests/qemu-iotests/245 +++ b/tests/qemu-iotests/245 @@ -649,6 +649,53 @@ class TestBlockdevReopen(iotests.QMPTestCase): '-c', 'read -P 0x40 0x40008 1', '-c', 'read -P 0x80 0x40010 1', h= d_path[0]) =20 + # Swap the disk images of two active block devices + def test_swap_files(self): + # Add hd0 and hd2 (none of them with backing files) + opts0 =3D hd_opts(0) + result =3D self.vm.qmp('blockdev-add', conv_keys =3D False, **opts= 0) + self.assert_qmp(result, 'return', {}) + + opts2 =3D hd_opts(2) + result =3D self.vm.qmp('blockdev-add', conv_keys =3D False, **opts= 2) + self.assert_qmp(result, 'return', {}) + + # Write different data to both block devices + self.run_qemu_io("hd0", "write -P 0xa0 0 1k") + self.run_qemu_io("hd2", "write -P 0xa2 0 1k") + + # Check that the data reads correctly + self.run_qemu_io("hd0", "read -P 0xa0 0 1k") + self.run_qemu_io("hd2", "read -P 0xa2 0 1k") + + # It's not possible to make a block device use an image that + # is already being used by the other device. + self.reopen(opts0, {'file': 'hd2-file'}, + "Permission conflict on node 'hd2-file': permissions " + "'write, resize' are both required by node 'hd2' (uses= " + "node 'hd2-file' as 'file' child) and unshared by node= " + "'hd0' (uses node 'hd2-file' as 'file' child).") + self.reopen(opts2, {'file': 'hd0-file'}, + "Permission conflict on node 'hd0-file': permissions " + "'write, resize' are both required by node 'hd0' (uses= " + "node 'hd0-file' as 'file' child) and unshared by node= " + "'hd2' (uses node 'hd0-file' as 'file' child).") + + # But we can swap the images if we reopen both devices at the + # same time + opts0['file'] =3D 'hd2-file' + opts2['file'] =3D 'hd0-file' + self.reopenMultiple([opts0, opts2]) + self.run_qemu_io("hd0", "read -P 0xa2 0 1k") + self.run_qemu_io("hd2", "read -P 0xa0 0 1k") + + # And we can of course come back to the original state + opts0['file'] =3D 'hd0-file' + opts2['file'] =3D 'hd2-file' + self.reopenMultiple([opts0, opts2]) + self.run_qemu_io("hd0", "read -P 0xa0 0 1k") + self.run_qemu_io("hd2", "read -P 0xa2 0 1k") + # Misc reopen tests with different block drivers @iotests.skip_if_unsupported(['quorum', 'throttle']) def test_misc_drivers(self): diff --git a/tests/qemu-iotests/245.out b/tests/qemu-iotests/245.out index daf1e51922..4eced19294 100644 --- a/tests/qemu-iotests/245.out +++ b/tests/qemu-iotests/245.out @@ -17,8 +17,8 @@ read 1/1 bytes at offset 262152 read 1/1 bytes at offset 262160 1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 -.............. +............... ---------------------------------------------------------------------- -Ran 24 tests +Ran 25 tests =20 OK --=20 2.31.1 From nobody Fri May 17 02:41:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625745522972588.7262261725502; Thu, 8 Jul 2021 04:58:42 -0700 (PDT) Received: from localhost ([::1]:46416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1Sfx-0005nJ-O2 for importer@patchew.org; Thu, 08 Jul 2021 07:58:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1SVA-0003y5-Pb for qemu-devel@nongnu.org; Thu, 08 Jul 2021 07:47:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49694) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1SV5-0001SR-VW for qemu-devel@nongnu.org; Thu, 08 Jul 2021 07:47:32 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-76-Smi2jGWTOTm3cK6ldGgz8g-1; Thu, 08 Jul 2021 07:47:24 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9F4D4801107; Thu, 8 Jul 2021 11:47:23 +0000 (UTC) Received: from merkur.redhat.com (ovpn-114-143.ams2.redhat.com [10.36.114.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 607D860843; Thu, 8 Jul 2021 11:47:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625744846; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kC2PcNuhUA/zeSvuW+QVuu/y54raVUoOeY9SCc7GRKE=; b=cj6q9VFeD4VjMHLtMy2XCctluwxCPE6T6C3ZNy0Fjm0nHRaR1nyCWmmdnpFQfeVOnaJagv 16Bko0UNKYd5nDt5xXcqXbZnbdmn02dgXWRSVUxFku6vYOWDSAtjjxEh5k+pxexuZayzBi ol6lvpeNMBSdI+q4rlda+E9QJOzd0vM= X-MC-Unique: Smi2jGWTOTm3cK6ldGgz8g-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v6 6/6] block: Make blockdev-reopen stable API Date: Thu, 8 Jul 2021 13:47:09 +0200 Message-Id: <20210708114709.206487-7-kwolf@redhat.com> In-Reply-To: <20210708114709.206487-1-kwolf@redhat.com> References: <20210708114709.206487-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.45, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1625745523619100005 Content-Type: text/plain; charset="utf-8" From: Alberto Garcia This patch drops the 'x-' prefix from x-blockdev-reopen. Signed-off-by: Alberto Garcia Signed-off-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 6 +++--- blockdev.c | 2 +- tests/qemu-iotests/155 | 2 +- tests/qemu-iotests/165 | 2 +- tests/qemu-iotests/245 | 10 +++++----- tests/qemu-iotests/248 | 2 +- tests/qemu-iotests/248.out | 2 +- tests/qemu-iotests/296 | 2 +- tests/qemu-iotests/298 | 2 +- tests/qemu-iotests/tests/remove-bitmap-from-backing | 4 ++-- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 052520331e..2eb399f0d4 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4219,7 +4219,7 @@ { 'command': 'blockdev-add', 'data': 'BlockdevOptions', 'boxed': true } =20 ## -# @x-blockdev-reopen: +# @blockdev-reopen: # # Reopens one or more block devices using the given set of options. # Any option not specified will be reset to its default value regardless @@ -4257,9 +4257,9 @@ # image does not have a default backing file name as part of its # metadata. # -# Since: 4.0 +# Since: 6.0 ## -{ 'command': 'x-blockdev-reopen', +{ 'command': 'blockdev-reopen', 'data': { 'options': ['BlockdevOptions'] } } =20 ## diff --git a/blockdev.c b/blockdev.c index fddcccbdbd..6466a106f4 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3560,7 +3560,7 @@ fail: visit_free(v); } =20 -void qmp_x_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp) +void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp) { BlockReopenQueue *queue =3D NULL; GSList *drained =3D NULL; diff --git a/tests/qemu-iotests/155 b/tests/qemu-iotests/155 index 2947bfb81a..eadda52615 100755 --- a/tests/qemu-iotests/155 +++ b/tests/qemu-iotests/155 @@ -261,7 +261,7 @@ class TestBlockdevMirrorReopen(MirrorBaseClass): result =3D self.vm.qmp('blockdev-add', node_name=3D"backing", driver=3D"null-co") self.assert_qmp(result, 'return', {}) - result =3D self.vm.qmp('x-blockdev-reopen', options=3D[{ + result =3D self.vm.qmp('blockdev-reopen', options=3D[{ 'node-name': "target", 'driver': iotests.imgfmt, 'file': "target-file", diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165 index ef4cf14516..ce499946b8 100755 --- a/tests/qemu-iotests/165 +++ b/tests/qemu-iotests/165 @@ -137,7 +137,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): assert sha256_1 =3D=3D self.getSha256() =20 # Reopen to RW - result =3D self.vm.qmp('x-blockdev-reopen', options=3D[{ + result =3D self.vm.qmp('blockdev-reopen', options=3D[{ 'node-name': 'node0', 'driver': iotests.imgfmt, 'file': { diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245 index 8bc8101e6d..bf8261eec0 100755 --- a/tests/qemu-iotests/245 +++ b/tests/qemu-iotests/245 @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # group: rw # -# Test cases for the QMP 'x-blockdev-reopen' command +# Test cases for the QMP 'blockdev-reopen' command # # Copyright (C) 2018-2019 Igalia, S.L. # Author: Alberto Garcia @@ -85,16 +85,16 @@ class TestBlockdevReopen(iotests.QMPTestCase): "Expected output of %d qemu-io commands, found %d= " % (found, self.total_io_cmds)) =20 - # Run x-blockdev-reopen on a list of block devices + # Run blockdev-reopen on a list of block devices def reopenMultiple(self, opts, errmsg =3D None): - result =3D self.vm.qmp('x-blockdev-reopen', conv_keys=3DFalse, opt= ions=3Dopts) + result =3D self.vm.qmp('blockdev-reopen', conv_keys=3DFalse, optio= ns=3Dopts) if errmsg: self.assert_qmp(result, 'error/class', 'GenericError') self.assert_qmp(result, 'error/desc', errmsg) else: self.assert_qmp(result, 'return', {}) =20 - # Run x-blockdev-reopen on a single block device (specified by + # Run blockdev-reopen on a single block device (specified by # 'opts') but applying 'newopts' on top of it. The original 'opts' # dict is unmodified def reopen(self, opts, newopts =3D {}, errmsg =3D None): @@ -161,7 +161,7 @@ class TestBlockdevReopen(iotests.QMPTestCase): self.reopen(opts, {'file.locking': 'off'}, "Cannot change the opti= on 'locking'") self.reopen(opts, {'file.filename': None}, "Invalid parameter type= for 'options[0].file.filename', expected: string") =20 - # node-name is optional in BlockdevOptions, but x-blockdev-reopen = needs it + # node-name is optional in BlockdevOptions, but blockdev-reopen ne= eds it del opts['node-name'] self.reopen(opts, {}, "node-name not specified") =20 diff --git a/tests/qemu-iotests/248 b/tests/qemu-iotests/248 index 03911333c4..2ec2416e8a 100755 --- a/tests/qemu-iotests/248 +++ b/tests/qemu-iotests/248 @@ -62,7 +62,7 @@ vm.event_wait('JOB_STATUS_CHANGE', timeout=3D3.0, vm.get_qmp_events() =20 del blockdev_opts['file']['size'] -vm.qmp_log('x-blockdev-reopen', filters=3D[filter_qmp_testfiles], +vm.qmp_log('blockdev-reopen', filters=3D[filter_qmp_testfiles], options =3D [ blockdev_opts ]) =20 vm.qmp_log('block-job-resume', device=3D'drive0') diff --git a/tests/qemu-iotests/248.out b/tests/qemu-iotests/248.out index 893f625347..66e94ccd7e 100644 --- a/tests/qemu-iotests/248.out +++ b/tests/qemu-iotests/248.out @@ -2,7 +2,7 @@ {"return": {}} {"execute": "blockdev-mirror", "arguments": {"device": "drive0", "on-targe= t-error": "enospc", "sync": "full", "target": "target"}} {"return": {}} -{"execute": "x-blockdev-reopen", "arguments": {"options": [{"driver": "qco= w2", "file": {"driver": "raw", "file": {"driver": "file", "filename": "TEST= _DIR/PID-target"}}, "node-name": "target"}]}} +{"execute": "blockdev-reopen", "arguments": {"options": [{"driver": "qcow2= ", "file": {"driver": "raw", "file": {"driver": "file", "filename": "TEST_D= IR/PID-target"}}, "node-name": "target"}]}} {"return": {}} {"execute": "block-job-resume", "arguments": {"device": "drive0"}} {"return": {}} diff --git a/tests/qemu-iotests/296 b/tests/qemu-iotests/296 index fa07b98bb4..099a3eeaa5 100755 --- a/tests/qemu-iotests/296 +++ b/tests/qemu-iotests/296 @@ -118,7 +118,7 @@ class EncryptionSetupTestCase(iotests.QMPTestCase): def openImageQmp(self, vm, id, file, secret, readOnly =3D False, reOpen =3D False): =20 - command =3D 'x-blockdev-reopen' if reOpen else 'blockdev-add' + command =3D 'blockdev-reopen' if reOpen else 'blockdev-add' =20 opts =3D { 'driver': iotests.imgfmt, diff --git a/tests/qemu-iotests/298 b/tests/qemu-iotests/298 index a5b0d91224..fae72211b1 100755 --- a/tests/qemu-iotests/298 +++ b/tests/qemu-iotests/298 @@ -98,7 +98,7 @@ class TestPreallocateFilter(TestPreallocateBase): self.check_big() =20 def test_reopen_opts(self): - result =3D self.vm.qmp('x-blockdev-reopen', options=3D[{ + result =3D self.vm.qmp('blockdev-reopen', options=3D[{ 'node-name': 'disk', 'driver': iotests.imgfmt, 'file': { diff --git a/tests/qemu-iotests/tests/remove-bitmap-from-backing b/tests/qe= mu-iotests/tests/remove-bitmap-from-backing index 0b07f7e836..8d48fc0f3c 100755 --- a/tests/qemu-iotests/tests/remove-bitmap-from-backing +++ b/tests/qemu-iotests/tests/remove-bitmap-from-backing @@ -53,7 +53,7 @@ new_base_opts =3D { } =20 # Don't want to bother with filtering qmp_log for reopen command -result =3D vm.qmp('x-blockdev-reopen', **new_base_opts) +result =3D vm.qmp('blockdev-reopen', **new_base_opts) if result !=3D {'return': {}}: log('Failed to reopen: ' + str(result)) =20 @@ -61,7 +61,7 @@ log('Remove persistent bitmap from base node reopened to = RW:') vm.qmp_log('block-dirty-bitmap-remove', node=3D'base', name=3D'bitmap0') =20 new_base_opts['options'][0]['read-only'] =3D True -result =3D vm.qmp('x-blockdev-reopen', **new_base_opts) +result =3D vm.qmp('blockdev-reopen', **new_base_opts) if result !=3D {'return': {}}: log('Failed to reopen: ' + str(result)) =20 --=20 2.31.1