From nobody Fri May 17 01:43:54 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 1625570761314710.7595751938077; Tue, 6 Jul 2021 04:26:01 -0700 (PDT) Received: from localhost ([::1]:60346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0jDE-00068x-9F for importer@patchew.org; Tue, 06 Jul 2021 07:26:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0jBW-0003Jk-4c for qemu-devel@nongnu.org; Tue, 06 Jul 2021 07:24:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0jBM-0000fs-NR for qemu-devel@nongnu.org; Tue, 06 Jul 2021 07:24:13 -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-152-OibjECFeNvyem_PdF4ntJQ-1; Tue, 06 Jul 2021 07:24:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41C59C740A; Tue, 6 Jul 2021 11:23:46 +0000 (UTC) Received: from merkur.redhat.com (ovpn-113-253.ams2.redhat.com [10.36.113.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01B5660E3A; Tue, 6 Jul 2021 11:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625570644; 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=xmg7NdZ8n9UDUL99RDPfnI1r25/UyjiLO+BorYSDbps=; b=VKq9UZuGs2aFS4LGyBFzyRxvL95QJC1qqr1vf90qHdDOSW3Ty6+5nFKbpLXAr1IK/PTA4R z8agOGdnT3oMXdB1BPMkb9Y8nI3fBCG03si4glYsT+Qb6GbR+OKn46RFIIZj4YJBkysg3L ZbtI20AJoPVflcWPuKuE5mL5jWO2Dlg= X-MC-Unique: OibjECFeNvyem_PdF4ntJQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v5 1/6] qcow2: Fix dangling pointer after reopen for 'file' Date: Tue, 6 Jul 2021 13:23:35 +0200 Message-Id: <20210706112340.223334-2-kwolf@redhat.com> In-Reply-To: <20210706112340.223334-1-kwolf@redhat.com> References: <20210706112340.223334-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.442, 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: 1625570762328100001 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: Vladimir Sementsov-Ogievskiy --- block/qcow2.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index ee4530cdbd..cb459ef6a6 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -962,6 +962,7 @@ static bool read_cache_sizes(BlockDriverState *bs, Qemu= Opts *opts, } =20 typedef struct Qcow2ReopenState { + bool had_data_file; Qcow2Cache *l2_table_cache; Qcow2Cache *refcount_block_cache; int l2_slice_size; /* Number of entries in a slice of the L2 table */ @@ -1932,6 +1933,8 @@ static int qcow2_reopen_prepare(BDRVReopenState *stat= e, r =3D g_new0(Qcow2ReopenState, 1); state->opaque =3D r; =20 + r->had_data_file =3D has_data_file(state->bs); + ret =3D qcow2_update_options_prepare(state->bs, r, state->options, state->flags, errp); if (ret < 0) { @@ -1966,7 +1969,18 @@ fail: =20 static void qcow2_reopen_commit(BDRVReopenState *state) { + BDRVQcow2State *s =3D state->bs->opaque; + Qcow2ReopenState *r =3D state->opaque; + qcow2_update_options_commit(state->bs, state->opaque); + if (!r->had_data_file && s->data_file !=3D state->bs->file) { + /* + * If s->data_file is just a second pointer to bs->file (which is = the + * case without an external data file), it may need to be updated. + */ + s->data_file =3D state->bs->file; + assert(!has_data_file(state->bs)); + } g_free(state->opaque); } =20 --=20 2.31.1 From nobody Fri May 17 01:43:54 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 1625570761495734.1865547170967; Tue, 6 Jul 2021 04:26:01 -0700 (PDT) Received: from localhost ([::1]:60322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0jDE-00068G-AG for importer@patchew.org; Tue, 06 Jul 2021 07:26:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0jBW-0003Lo-NG for qemu-devel@nongnu.org; Tue, 06 Jul 2021 07:24:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0jBO-0000hQ-AU for qemu-devel@nongnu.org; Tue, 06 Jul 2021 07:24:14 -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-433-zo17VrccPeimnrBFeHkODw-1; Tue, 06 Jul 2021 07:24:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C760F193F568; Tue, 6 Jul 2021 11:23:47 +0000 (UTC) Received: from merkur.redhat.com (ovpn-113-253.ams2.redhat.com [10.36.113.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8888360CC9; Tue, 6 Jul 2021 11:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625570645; 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=Y09AgW3opNoxOB+wgC79ShDM6m6z7IyBXNTolDQl6aU=; b=bNNhExs0TfQqHQdlow8sQ4qpJPfQ7J8pV0zklODxWLs2c5nn5t0LMrBtzs8U63R9pef5Jn 70dIPD54L96KqwN2yY3ctcy0TKXbAbFfmwf1VT6ZXCXRv84rouu27ulTx7/cxQoHAjw2tF FZt0bZknBDiRHB2W1DPaGsaUC65VfVs= X-MC-Unique: zo17VrccPeimnrBFeHkODw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v5 2/6] block: Add bdrv_reopen_queue_free() Date: Tue, 6 Jul 2021 13:23:36 +0200 Message-Id: <20210706112340.223334-3-kwolf@redhat.com> In-Reply-To: <20210706112340.223334-1-kwolf@redhat.com> References: <20210706112340.223334-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.442, 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: 1625570762537100003 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 avoids memory leaks as we saw them in two recent patches. ] 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 01:43:54 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 1625570886387716.3900396882905; Tue, 6 Jul 2021 04:28:06 -0700 (PDT) Received: from localhost ([::1]:38342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0jFF-0001wS-3L for importer@patchew.org; Tue, 06 Jul 2021 07:28:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0jBU-0003Gp-GE for qemu-devel@nongnu.org; Tue, 06 Jul 2021 07:24:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58182) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0jBM-0000dn-0e for qemu-devel@nongnu.org; Tue, 06 Jul 2021 07:24:12 -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-193-_TRXMHkYMoe6q3uoaEp-fQ-1; Tue, 06 Jul 2021 07:24:00 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72B2F101C8A9; Tue, 6 Jul 2021 11:23:49 +0000 (UTC) Received: from merkur.redhat.com (ovpn-113-253.ams2.redhat.com [10.36.113.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C0AA60E3A; Tue, 6 Jul 2021 11:23:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625570641; 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=iQRWd9ms48wcNm/gqHA+POP+vt52RpZg02BjrIgMZpo=; b=O4QoAZAIveRg44EpCisdyaLq4fgZ5WfW1HGu+atuQVUCiy2BnaXK2ZqwX6ucIEHQ/Qr6l0 /DViYia756McuvSbjLNEm24PlXYC7O0EjT+DPgvAMgKOTdS2ZMrLUuSNVUoal2Mpt5bIzm 0XdHmUvZxCOhcMOmo98epJM6oaG5MRY= X-MC-Unique: _TRXMHkYMoe6q3uoaEp-fQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v5 3/6] block: Acquire AioContexts during bdrv_reopen_multiple() Date: Tue, 6 Jul 2021 13:23:37 +0200 Message-Id: <20210706112340.223334-4-kwolf@redhat.com> In-Reply-To: <20210706112340.223334-1-kwolf@redhat.com> References: <20210706112340.223334-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.442, 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: 1625570888430100002 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 01:43:54 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 1625570891196925.0910952145064; Tue, 6 Jul 2021 04:28:11 -0700 (PDT) Received: from localhost ([::1]:38610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0jFJ-00027U-Sl for importer@patchew.org; Tue, 06 Jul 2021 07:28:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0jBX-0003NN-5A for qemu-devel@nongnu.org; Tue, 06 Jul 2021 07:24:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29200) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0jBN-0000g0-7b for qemu-devel@nongnu.org; Tue, 06 Jul 2021 07:24:14 -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-228-Fdz27V1UO82pt-_PWCoj8Q-1; Tue, 06 Jul 2021 07:24:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F3468C7433; Tue, 6 Jul 2021 11:23:56 +0000 (UTC) Received: from merkur.redhat.com (ovpn-113-253.ams2.redhat.com [10.36.113.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id A43D260CC9; Tue, 6 Jul 2021 11:23:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625570644; 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=wkMb1uFktyNNUvajeGJi6fVGkiw2bw3+SlhbHvvDkx4=; b=MNDsYqgt3jyXPciz7Be/pvzXXOdScDoQvi0GtDQu2ykIPmB/fB+ZYlhovCIHJLKATmVT4k MlETmP7u5Tsb/lBrCBmBdRQud0BzN0JoYqp/pK9vav15jlhZ403vCiM3uFtC5j+NcLHZZz 3gMVEoCkeXCSItkY5TDt/66B3JlTWLc= X-MC-Unique: Fdz27V1UO82pt-_PWCoj8Q-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v5 4/6] block: Support multiple reopening with x-blockdev-reopen Date: Tue, 6 Jul 2021 13:23:38 +0200 Message-Id: <20210706112340.223334-5-kwolf@redhat.com> In-Reply-To: <20210706112340.223334-1-kwolf@redhat.com> References: <20210706112340.223334-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.442, 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: 1625570892022100001 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..1e8c946828 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; - - /* Check for the selected node name */ - if (!options->has_node_name) { - error_setg(errp, "node-name not specified"); - goto fail; - } +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 - bs =3D bdrv_find_node(options->node_name); - if (!bs) { - error_setg(errp, "Failed to find node with node-name=3D'%s'", + 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; - } + goto fail; + } =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); + /* 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 - qdict_flatten(qdict); + qdict =3D qobject_to(QDict, obj); =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); + qdict_flatten(qdict); =20 - 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); =20 - ctx =3D bdrv_get_aio_context(bs); - aio_context_acquire(ctx); - bdrv_subtree_drained_end(bs); - aio_context_release(ctx); + bdrv_subtree_drained_begin(bs); + queue =3D bdrv_reopen_queue(queue, bs, qdict, false); + drained =3D g_slist_prepend(drained, bs); + + 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..3400b0312a 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..57aa88ecae 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..b81fde8f12 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 =3D False, o= ptions =3D opts) + 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..74b74511b6 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..4efdb35b91 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 01:43:54 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 1625571004820497.37824393174026; Tue, 6 Jul 2021 04:30:04 -0700 (PDT) Received: from localhost ([::1]:44870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0jH9-0006K6-Gt for importer@patchew.org; Tue, 06 Jul 2021 07:30:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0jBW-0003Lp-N6 for qemu-devel@nongnu.org; Tue, 06 Jul 2021 07:24:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0jBL-0000dl-N7 for qemu-devel@nongnu.org; Tue, 06 Jul 2021 07:24:14 -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-23-NwPcz8EDNj6uUjI0zmUFkw-1; Tue, 06 Jul 2021 07:23:59 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8655B101F005; Tue, 6 Jul 2021 11:23:58 +0000 (UTC) Received: from merkur.redhat.com (ovpn-113-253.ams2.redhat.com [10.36.113.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id 477E160E3A; Tue, 6 Jul 2021 11:23:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625570641; 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=8iG9zy1p5JRPY7FWIgreir70GQghbFVFI2c9rtrqHh4=; b=SbZ4SirFvkyT/crq6/2PFAZYvMTqVXpXEoV/H/Duzf6Ct12T7F1dBfaXN5lYxwShVp3E+M LK3mLDw8sC/SGTX1bCrOcLwbsmsP1mWY1yCUE7kT3xjRYYe/vRB0vUEZmCHUjcHSEmbkoK GeO8MNQcLQ9qXb+7TgQTRXZ/UXRGkKg= X-MC-Unique: NwPcz8EDNj6uUjI0zmUFkw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v5 5/6] iotests: Test reopening multiple devices at the same time Date: Tue, 6 Jul 2021 13:23:39 +0200 Message-Id: <20210706112340.223334-6-kwolf@redhat.com> In-Reply-To: <20210706112340.223334-1-kwolf@redhat.com> References: <20210706112340.223334-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.442, 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: 1625571005704100005 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 b81fde8f12..6eff352099 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 01:43:54 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 1625571007413515.5584204389861; Tue, 6 Jul 2021 04:30:07 -0700 (PDT) Received: from localhost ([::1]:45006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0jHC-0006PT-3u for importer@patchew.org; Tue, 06 Jul 2021 07:30:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0jBY-0003Rh-D1 for qemu-devel@nongnu.org; Tue, 06 Jul 2021 07:24:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49794) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0jBP-0000iM-0R for qemu-devel@nongnu.org; Tue, 06 Jul 2021 07:24:16 -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-7-1ijALHDpMGCPik4GoNWDzQ-1; Tue, 06 Jul 2021 07:24:05 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3FB00193F598; Tue, 6 Jul 2021 11:24:00 +0000 (UTC) Received: from merkur.redhat.com (ovpn-113-253.ams2.redhat.com [10.36.113.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE56D60CC9; Tue, 6 Jul 2021 11:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625570646; 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=tsRtgrJMMwT25pSXyctNDCNZ+oJh564je2oy/bdluHE=; b=YKg3DxuoIq7kJwDxiHBMsQDDuWS3AqzmBqeAK8ZQs3OsO+xXZ+GpWZCHOANuOUvtm7KuwJ Am9LITdpdPnqJkpZisbgGSWckD6LDNPAd3Lg6LlIDsjuFZZE/gi7F+j/wcWv0P44E7krec 1jMxoXgxnz6QBivPpcXk0mxnq/XhF/4= X-MC-Unique: 1ijALHDpMGCPik4GoNWDzQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH v5 6/6] block: Make blockdev-reopen stable API Date: Tue, 6 Jul 2021 13:23:40 +0200 Message-Id: <20210706112340.223334-7-kwolf@redhat.com> In-Reply-To: <20210706112340.223334-1-kwolf@redhat.com> References: <20210706112340.223334-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.442, 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: 1625571008403100001 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 1e8c946828..7639f2108e 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 3400b0312a..fec43d662d 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 57aa88ecae..92a431315b 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 6eff352099..28a116a6aa 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 =3D False, o= ptions =3D opts) + result =3D self.vm.qmp('blockdev-reopen', conv_keys =3D False, opt= ions =3D opts) 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 74b74511b6..9206ddb954 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 4efdb35b91..b4d8bd9b55 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