From nobody Mon Apr 14 04:07:48 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513608779461886.9861224481941; Mon, 18 Dec 2017 06:52:59 -0800 (PST) Received: from localhost ([::1]:41622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQwmh-0003uo-CJ for importer@patchew.org; Mon, 18 Dec 2017 09:52:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQwXZ-0007Hn-FX for qemu-devel@nongnu.org; Mon, 18 Dec 2017 09:37:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQwXV-0007ik-Cj for qemu-devel@nongnu.org; Mon, 18 Dec 2017 09:37:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:27770) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eQwXV-0007hr-6t for qemu-devel@nongnu.org; Mon, 18 Dec 2017 09:37:09 -0500 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 mx1.redhat.com (Postfix) with ESMTPS id 61A5F3D9EF; Mon, 18 Dec 2017 14:37:08 +0000 (UTC) Received: from localhost (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id E70127C801; Mon, 18 Dec 2017 14:37:07 +0000 (UTC) From: Stefan Hajnoczi To: Date: Mon, 18 Dec 2017 14:35:27 +0000 Message-Id: <20171218143530.12082-21-stefanha@redhat.com> In-Reply-To: <20171218143530.12082-1-stefanha@redhat.com> References: <20171218143530.12082-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 18 Dec 2017 14:37:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 20/23] blockdev: add x-blockdev-set-iothread force boolean X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When a node is already associated with a BlockBackend the x-blockdev-set-iothread command refuses to set the IOThread. This is to prevent accidentally changing the IOThread when the nodes are in use. When the nodes are created with -drive they automatically get a BlockBackend. In that case we know nothing is using them yet and it's safe to set the IOThread. Add a force boolean to override the check. Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake Message-id: 20171207201320.19284-4-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- qapi/block-core.json | 6 +++++- blockdev.c | 11 ++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 741d6c4367..a8cdbc300b 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3962,6 +3962,9 @@ # # @iothread: the name of the IOThread object or null for the main loop # +# @force: true if the node and its children should be moved when a BlockBa= ckend +# is already attached +# # Note: this command is experimental and intended for test cases that need # control over IOThreads only. # @@ -3984,4 +3987,5 @@ ## { 'command': 'x-blockdev-set-iothread', 'data' : { 'node-name': 'str', - 'iothread': 'StrOrNull' } } + 'iothread': 'StrOrNull', + '*force': 'bool' } } diff --git a/blockdev.c b/blockdev.c index f75c01f664..9c3a430cfb 100644 --- a/blockdev.c +++ b/blockdev.c @@ -4131,7 +4131,7 @@ BlockJobInfoList *qmp_query_block_jobs(Error **errp) } =20 void qmp_x_blockdev_set_iothread(const char *node_name, StrOrNull *iothrea= d, - Error **errp) + bool has_force, bool force, Error **errp) { AioContext *old_context; AioContext *new_context; @@ -4143,10 +4143,11 @@ void qmp_x_blockdev_set_iothread(const char *node_n= ame, StrOrNull *iothread, return; } =20 - /* If we want to allow more extreme test scenarios this guard could be - * removed. For now it protects against accidents. */ - if (bdrv_has_blk(bs)) { - error_setg(errp, "Node %s is in use", node_name); + /* Protects against accidents. */ + if (!(has_force && force) && bdrv_has_blk(bs)) { + error_setg(errp, "Node %s is associated with a BlockBackend and co= uld " + "be in use (use force=3Dtrue to override this che= ck)", + node_name); return; } =20 --=20 2.14.3