From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642168644; cv=none; d=zohomail.com; s=zohoarc; b=V2oJFhXT9NrOGwm+KHIESPGVaZ81+pBbOOYYY3I2TUBsVObT1kRTSsUFlpMvpAnfDZbQrT+I6A2TIEi/NLGjxH3+N0C1jbwgRSRuS8+vo6UPCim1tVrAbhDWHJBo/F0EIV56xarC5F6eOGS/SXMaU81sF+7b7SJmUFFmoydQGBM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642168644; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qDph2gJgYxtgR/6PoCzp5OqdfOLhd/8KOxlUVaV2tjQ=; b=LWAfrOOHNuvy2ShZtSz0fFRtI+uqUwOtJaw8cn8aReUAFaOiFwuxV9cTOnUuTTTY8yc3bFiAaH0teabfQpvNRMkwyk0lpNHhjuzNwM9cPD2/YdHrZfN4dXiu4TSgi3lz5qs8LC4/NVbUA0U4WD+qPSTsvqjp4p6rsmUk6CcB2Eg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642168644028995.8451236387671; Fri, 14 Jan 2022 05:57:24 -0800 (PST) Received: from localhost ([::1]:55488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8N4y-0000r6-PP for importer@patchew.org; Fri, 14 Jan 2022 08:57:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0R-0002yB-SN for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26232) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0O-0000IA-1U for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:39 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-zINkcw8CNbi7jZsZziNmYw-1; Fri, 14 Jan 2022 08:52:33 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1E381023F4E; Fri, 14 Jan 2022 13:52:31 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4ADB105B213; Fri, 14 Jan 2022 13:52:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168354; 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=qDph2gJgYxtgR/6PoCzp5OqdfOLhd/8KOxlUVaV2tjQ=; b=dk6tHolnShsQKs/Psh/1oYjFnnYr8bJnAvR3vQEfTuNOwmCWlKVXfN1yVIvW+9KeFrfGrl jGn/1Q3a2+6kwhv0mPJSvuSL+/3S20R6srEbDrQ6v5K9ln863DzAyl43PB25QZXBkNSKJ5 nRDk42gtxLjFSOAQdgKbiegrWi05ZY4= X-MC-Unique: zINkcw8CNbi7jZsZziNmYw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 01/16] block_int: make bdrv_backing_overridden static Date: Fri, 14 Jan 2022 14:52:11 +0100 Message-Id: <20220114135226.185407-2-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642168645636100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito bdrv_backing_overridden is only used in block.c, so there is no need to leave it in block_int.h Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Stefan Hajnoczi Message-Id: <20211215121140.456939-2-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block_int.h | 3 --- block.c | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index f4c75e8ba9..27008cfb22 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1122,9 +1122,6 @@ BlockDriver *bdrv_probe_all(const uint8_t *buf, int b= uf_size, void bdrv_parse_filename_strip_prefix(const char *filename, const char *pr= efix, QDict *options); =20 -bool bdrv_backing_overridden(BlockDriverState *bs); - - /** * bdrv_add_aio_context_notifier: * diff --git a/block.c b/block.c index 0ac5b163d2..10346b5011 100644 --- a/block.c +++ b/block.c @@ -103,6 +103,8 @@ static int bdrv_reopen_prepare(BDRVReopenState *reopen_= state, static void bdrv_reopen_commit(BDRVReopenState *reopen_state); static void bdrv_reopen_abort(BDRVReopenState *reopen_state); =20 +static bool bdrv_backing_overridden(BlockDriverState *bs); + /* If non-zero, use only whitelisted block drivers */ static int use_bdrv_whitelist; =20 @@ -7475,7 +7477,7 @@ static bool append_strong_runtime_options(QDict *d, B= lockDriverState *bs) /* Note: This function may return false positives; it may return true * even if opening the backing file specified by bs's image header * would result in exactly bs->backing. */ -bool bdrv_backing_overridden(BlockDriverState *bs) +static bool bdrv_backing_overridden(BlockDriverState *bs) { if (bs->backing) { return strcmp(bs->auto_backing_file, --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642169357; cv=none; d=zohomail.com; s=zohoarc; b=fqNlkSubEhTibR8U8aLTrQv6+MoOHPDL+XcIt7rc6XVaYMy/dN8yNR8KrMM2xvXC8jyZH5+L5scsl8UI3/N8haPbVoQ64w/ij79gfvRnjQ5/YOjhgwnM4P65x/6VfyQe40Vt3y/K3rsut6vwL1+3K0zYCBXyxTTJRrKVN0Ebuqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642169357; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6HK6/MrM6x/JLY9aKJOmZao7CGx6tGt4z6ZGtdfcmzg=; b=asD0qTP3hq+fPGj2nRvSwOI8O50YRRJSPcQeW33lgehrgL6LGRHutCJjpsWxHU6DIv1wnRQkqpuM1jM3e/69o5O9L+lTDtZKdZKt7DPmW1SYPSOsyDL37bhTKUgRMRhvUfuXlT4MeeiS8LBgnPBuDmuBJNrnGiokTfjyp2/bknQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642169357598628.651365621499; Fri, 14 Jan 2022 06:09:17 -0800 (PST) Received: from localhost ([::1]:47088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8NGW-0007SJ-JG for importer@patchew.org; Fri, 14 Jan 2022 09:09:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0R-0002yE-Sx for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21981) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0P-0000It-Va for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:39 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-218-rwjYRH6MN86UKqcBjo2ZhQ-1; Fri, 14 Jan 2022 08:52:34 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 442111054F90; Fri, 14 Jan 2022 13:52:33 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4161D105B213; Fri, 14 Jan 2022 13:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168357; 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=6HK6/MrM6x/JLY9aKJOmZao7CGx6tGt4z6ZGtdfcmzg=; b=YNJqcOGxzm7lzcANO1Sv2DTpFUbbsUvFFQ256MiZcgxOcsMFalINSshRvPfKAZ2w5aCq2t 9HVJ0G2mCdL4DENSVyqCs5ld/amAlZ6lC4CI9rlKS2zeh7Ekz4m/YK4CvW0TYY55hi04Fi P2z55Unp9ODInW51DxlT8y1eABiAksk= X-MC-Unique: rwjYRH6MN86UKqcBjo2ZhQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 02/16] include/sysemu/blockdev.h: remove drive_mark_claimed_by_board and inline drive_def Date: Fri, 14 Jan 2022 14:52:12 +0100 Message-Id: <20220114135226.185407-3-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642169360113100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito drive_def is only a particular use case of qemu_opts_parse_noisily, so it can be inlined. Also remove drive_mark_claimed_by_board, as it is only defined but not implemented (nor used) anywhere. Signed-off-by: Emanuele Giuseppe Esposito Message-Id: <20211215121140.456939-3-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- include/sysemu/blockdev.h | 2 -- block/monitor/block-hmp-cmds.c | 2 +- blockdev.c | 7 +------ softmmu/vl.c | 4 +++- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index a750f99b79..ea35c42f5c 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@ -45,13 +45,11 @@ BlockBackend *blk_by_legacy_dinfo(DriveInfo *dinfo); void override_max_devs(BlockInterfaceType type, int max_devs); =20 DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit); -void drive_mark_claimed_by_board(void); void drive_check_orphaned(void); DriveInfo *drive_get_by_index(BlockInterfaceType type, int index); int drive_get_max_bus(BlockInterfaceType type); int drive_get_max_devs(BlockInterfaceType type); =20 -QemuOpts *drive_def(const char *optstr); QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file, const char *optstr); DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type, diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index 2ac4aedfff..bfb3c043a0 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -101,7 +101,7 @@ void hmp_drive_add(Monitor *mon, const QDict *qdict) return; } =20 - opts =3D drive_def(optstr); + opts =3D qemu_opts_parse_noisily(qemu_find_opts("drive"), optstr, fals= e); if (!opts) return; =20 diff --git a/blockdev.c b/blockdev.c index b5ff9b854e..25b3b202e7 100644 --- a/blockdev.c +++ b/blockdev.c @@ -197,17 +197,12 @@ static int drive_index_to_unit_id(BlockInterfaceType = type, int index) return max_devs ? index % max_devs : index; } =20 -QemuOpts *drive_def(const char *optstr) -{ - return qemu_opts_parse_noisily(qemu_find_opts("drive"), optstr, false); -} - QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file, const char *optstr) { QemuOpts *opts; =20 - opts =3D drive_def(optstr); + opts =3D qemu_opts_parse_noisily(qemu_find_opts("drive"), optstr, fals= e); if (!opts) { return NULL; } diff --git a/softmmu/vl.c b/softmmu/vl.c index a8cad43691..207a9eb8be 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2887,7 +2887,9 @@ void qemu_init(int argc, char **argv, char **envp) break; } case QEMU_OPTION_drive: - if (drive_def(optarg) =3D=3D NULL) { + opts =3D qemu_opts_parse_noisily(qemu_find_opts("drive"), + optarg, false); + if (opts =3D=3D NULL) { exit(1); } break; --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642168527; cv=none; d=zohomail.com; s=zohoarc; b=PFozn58lWSIpgW8QIj554H4Ct9PulY8oJm7exoMnPck6ZkBOGB70mr+isWtQtEHvikGUNGj6Q6yZr+1SujWkf+2cSlA5exEurhcVuJLvtU1WT7JxFc/oz0hPXJWVxW+8Eq2V7kf5EpsJmRndUdEj4A9K+mAo5nBD6FT4eEivj4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642168527; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cgFY6FYWAmea9btfG53zrB8BGsroNsMyvdy9HMacuzY=; b=EXIVndKNGkOkCR4QXctYbI1jAgBNbmwDvpmqKOc1PelaAbUtps3rYrUQjjdYZLSdeAyxEGXlcz1WPOla4jAf7scDqcUs7AI9aNK0jsqcJf5EQnhCkRkJMFHO6CXKW+Vnn6/jvE2/1IPRf3wReCIPBSmiOGYz2+x5twpgv4VqweU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164216852770393.27655599543698; Fri, 14 Jan 2022 05:55:27 -0800 (PST) Received: from localhost ([::1]:51064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8N38-0006Uq-GL for importer@patchew.org; Fri, 14 Jan 2022 08:55:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0T-0002zJ-2q for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0R-0000JD-Ii for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:40 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-362-ACfSdj9nMk6M0PAqw0E8hg-1; Fri, 14 Jan 2022 08:52:35 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 929CD1023F53; Fri, 14 Jan 2022 13:52:34 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 906FD105B213; Fri, 14 Jan 2022 13:52:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168358; 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=cgFY6FYWAmea9btfG53zrB8BGsroNsMyvdy9HMacuzY=; b=hOWdl3R68oWgU1o12OOIrGXNmG2eZVwt/6egp0x53IiFDZprbDc6RNGQ1RC8YFTgkDr1Bk b8puRH6To+wUmYjx3Rq9+nDyQo3K5rsLupNfgx2apWP6COwxWOD1Nm5wW1DlnouYuZ/wck xg2bm8IvGUTfuXvCdx+OdISGdLYPSRg= X-MC-Unique: ACfSdj9nMk6M0PAqw0E8hg-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 03/16] include/sysemu/blockdev.h: remove drive_get_max_devs Date: Fri, 14 Jan 2022 14:52:13 +0100 Message-Id: <20220114135226.185407-4-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-Type: text/plain; charset="utf-8" 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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642168529240100001 From: Emanuele Giuseppe Esposito Remove drive_get_max_devs, as it is not used by anyone. Last use was removed in commit 8f2d75e81d5 ("hw: Drop superfluous special checks for orphaned -drive"). Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi Message-Id: <20211215121140.456939-4-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- include/sysemu/blockdev.h | 1 - blockdev.c | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index ea35c42f5c..f9fb54d437 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@ -48,7 +48,6 @@ DriveInfo *drive_get(BlockInterfaceType type, int bus, in= t unit); void drive_check_orphaned(void); DriveInfo *drive_get_by_index(BlockInterfaceType type, int index); int drive_get_max_bus(BlockInterfaceType type); -int drive_get_max_devs(BlockInterfaceType type); =20 QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file, const char *optstr); diff --git a/blockdev.c b/blockdev.c index 25b3b202e7..8197165bb5 100644 --- a/blockdev.c +++ b/blockdev.c @@ -168,23 +168,6 @@ void blockdev_auto_del(BlockBackend *blk) } } =20 -/** - * Returns the current mapping of how many units per bus - * a particular interface can support. - * - * A positive integer indicates n units per bus. - * 0 implies the mapping has not been established. - * -1 indicates an invalid BlockInterfaceType was given. - */ -int drive_get_max_devs(BlockInterfaceType type) -{ - if (type >=3D IF_IDE && type < IF_COUNT) { - return if_max_devs[type]; - } - - return -1; -} - static int drive_index_to_bus_id(BlockInterfaceType type, int index) { int max_devs =3D if_max_devs[type]; --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642168760; cv=none; d=zohomail.com; s=zohoarc; b=UiyT4BifgCsaifmDr4l5e2ROi4jMvIDv6EPiW4R7RmEOragBLyzkmTnBVgZ9JGqj+aMo4z2nMhXs8sIm9DlJs3CFfgoaXHg58AwdSDKI0/NyqFtuB3b1Q08VUOjjh7j7s0Mfyolr2jzu0zZ5GT6gcGKcunQ16I4bOA905wZ1gJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642168760; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hzZXTLmmLA7YlJEboW2drBQ+s+ZG+F2OELE7QTNMOwU=; b=YfQ7ZL5Q+mQOquvtBlREEXK9NrYP60tsEIKhvbERw4ahkV36f12jd+c1F1jEy3ERa/cYk/G4B3QN5UoXa8nZTtoqpsR1+CaX8laoZqZSahDFv+2XW33WJNeaH+Q1n/0vDbpSkY8F5V3RZYCybY0cgRpYcIchh6fy0sbCjX5aJ88= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642168760498289.2998834878979; Fri, 14 Jan 2022 05:59:20 -0800 (PST) Received: from localhost ([::1]:60104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8N6s-0004DN-Ue for importer@patchew.org; Fri, 14 Jan 2022 08:59:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0U-000307-Ew for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31675) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0S-0000Jx-L8 for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:42 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-594-DnaFf6FgOz2iYbgFn8-_PQ-1; Fri, 14 Jan 2022 08:52:37 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0065F83DD21; Fri, 14 Jan 2022 13:52:36 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF41D105B20E; Fri, 14 Jan 2022 13:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168360; 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=hzZXTLmmLA7YlJEboW2drBQ+s+ZG+F2OELE7QTNMOwU=; b=i7n3lfZbNX+/Ixq5cv2ImW6+CXKnaabLK99+bz0M0CtusPhvKKjDiu9kDKGLLl0+hAe5/H EAL5KrHGwysRpZ6MZkX2r/XroX0Rw+hZvqeVhX9fT+N4iOYgvTf/oaoVzvhhGcZPZSvu7h el17alkJ5lDEKdIyDF5UkMd03w6zAks= X-MC-Unique: DnaFf6FgOz2iYbgFn8-_PQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 04/16] softmmu: fix device deletion events with -device JSON syntax Date: Fri, 14 Jan 2022 14:52:14 +0100 Message-Id: <20220114135226.185407-5-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-Type: text/plain; charset="utf-8" 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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642168761566100001 From: Daniel P. Berrang=C3=A9 The -device JSON syntax impl leaks a reference on the created DeviceState instance. As a result when you hot-unplug the device, the device_finalize method won't be called and thus it will fail to emit the required DEVICE_DELETED event. A 'json-cli' feature was previously added against the 'device_add' QMP command QAPI schema to indicated to mgmt apps that -device supported JSON syntax. Given the hotplug bug that feature flag is not usable for its purpose, so we add a new 'json-cli-hotplug' feature to indicate the -device supports JSON without breaking hotplug. Fixes: 5dacda5167560b3af8eadbce5814f60ba44b467e Resolves: https://gitlab.com/qemu-project/qemu/-/issues/802 Signed-off-by: Daniel P. Berrang=C3=A9 Message-Id: <20220105123847.4047954-2-berrange@redhat.com> Reviewed-by: Laurent Vivier Tested-by: J=C3=A1n Tomko Reviewed-by: Thomas Huth Signed-off-by: Kevin Wolf --- qapi/qdev.json | 5 ++++- softmmu/vl.c | 4 +++- tests/qtest/device-plug-test.c | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/qapi/qdev.json b/qapi/qdev.json index 69656b14df..26cd10106b 100644 --- a/qapi/qdev.json +++ b/qapi/qdev.json @@ -44,6 +44,9 @@ # @json-cli: If present, the "-device" command line option supports JSON # syntax with a structure identical to the arguments of this # command. +# @json-cli-hotplug: If present, the "-device" command line option support= s JSON +# syntax without the reference counting leak that broke +# hot-unplug # # Notes: # @@ -74,7 +77,7 @@ { 'command': 'device_add', 'data': {'driver': 'str', '*bus': 'str', '*id': 'str'}, 'gen': false, # so we can get the additional arguments - 'features': ['json-cli'] } + 'features': ['json-cli', 'json-cli-hotplug'] } =20 ## # @device_del: diff --git a/softmmu/vl.c b/softmmu/vl.c index 207a9eb8be..5e1b35ba48 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2684,6 +2684,7 @@ static void qemu_create_cli_devices(void) qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, &error_fatal); QTAILQ_FOREACH(opt, &device_opts, next) { + DeviceState *dev; loc_push_restore(&opt->loc); /* * TODO Eventually we should call qmp_device_add() here to make su= re it @@ -2692,7 +2693,8 @@ static void qemu_create_cli_devices(void) * from the start, so call qdev_device_add_from_qdict() directly f= or * now. */ - qdev_device_add_from_qdict(opt->opts, true, &error_fatal); + dev =3D qdev_device_add_from_qdict(opt->opts, true, &error_fatal); + object_unref(OBJECT(dev)); loc_pop(&opt->loc); } rom_reset_order_override(); diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c index 559d47727a..ad79bd4c14 100644 --- a/tests/qtest/device-plug-test.c +++ b/tests/qtest/device-plug-test.c @@ -77,6 +77,23 @@ static void test_pci_unplug_request(void) qtest_quit(qtest); } =20 +static void test_pci_unplug_json_request(void) +{ + QTestState *qtest =3D qtest_initf( + "-device '{\"driver\": \"virtio-mouse-pci\", \"id\": \"dev0\"}'"); + + /* + * Request device removal. As the guest is not running, the request wo= n't + * be processed. However during system reset, the removal will be + * handled, removing the device. + */ + device_del(qtest, "dev0"); + system_reset(qtest); + wait_device_deleted_event(qtest, "dev0"); + + qtest_quit(qtest); +} + static void test_ccw_unplug(void) { QTestState *qtest =3D qtest_initf("-device virtio-balloon-ccw,id=3Ddev= 0"); @@ -145,6 +162,8 @@ int main(int argc, char **argv) */ qtest_add_func("/device-plug/pci-unplug-request", test_pci_unplug_request); + qtest_add_func("/device-plug/pci-unplug-json-request", + test_pci_unplug_json_request); =20 if (!strcmp(arch, "s390x")) { qtest_add_func("/device-plug/ccw-unplug", --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642168521; cv=none; d=zohomail.com; s=zohoarc; b=AcgEV6MZywvrVGPp3VTfS8XDe+bjUTz8Z/i0KR7JL8QtxXHrlQkng94LfhPPpe/T+lOwyrTsUfqGkfcnHjvM4Is27ZtFH1YyE2N29NHEeeNaGW12jah2dhvsRs7NdUF+rPNaT14LsbYA//l3pDLttiyl58LvFCOXHFcfGOjgx1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642168521; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=E9h1zxhQ3qJZcXdlgkol0HUHu71QzW/pKx4ap24WsX0=; b=CsNQ35zLPxIdwtVe/umipG7U3ocD5VYuKBCEU8weTPwZBTmdH3r/h/s5TAxGiFcxMPDn3Uc2qrET4MRbWCrkXSyPXwB/lYeWF2KwAzNzc2PCdsWWTFEGDsHIfZcAWR/TjRIy/TVVUL8YBM3DeSS+1CMdgOrux3aen7U39iTcXG8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164216852117936.098042613824305; Fri, 14 Jan 2022 05:55:21 -0800 (PST) Received: from localhost ([::1]:50618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8N32-0006CG-1r for importer@patchew.org; Fri, 14 Jan 2022 08:55:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0V-00030B-AJ for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50969) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0T-0000KJ-Tn for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:43 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-298-DVlhpARaOwyNAkPqvchr0A-1; Fri, 14 Jan 2022 08:52:38 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 693EC760C1; Fri, 14 Jan 2022 13:52:37 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CAC4105B20E; Fri, 14 Jan 2022 13:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168361; 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=E9h1zxhQ3qJZcXdlgkol0HUHu71QzW/pKx4ap24WsX0=; b=DDvfsgQqEkL4zkH/LE6/ysgMfV+lMI+isgb8hLVa6lXZDgDtU/OmEIQ4HDftS4x1kfs6aZ ZelALmg5ICC3Ry7yGf5al5bBRmxCwqtUbjc8U3BZyFFvwA0AcRmf2TKO4VW/mEE1zR1AXv tlwuQ2VytbuZcV5ZVZs2zn6C0UVDfgE= X-MC-Unique: DVlhpARaOwyNAkPqvchr0A-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 05/16] docs: Correct 'vhost-user-blk' spelling Date: Fri, 14 Jan 2022 14:52:15 +0100 Message-Id: <20220114135226.185407-6-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-Type: text/plain; charset="utf-8" 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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642168522532100001 From: Philippe Mathieu-Daud=C3=A9 Reported-by: Eric Blake Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20220107105420.395011-2-f4bug@amsat.org> Signed-off-by: Kevin Wolf --- docs/tools/qemu-storage-daemon.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tools/qemu-storage-daemon.rst b/docs/tools/qemu-storage-d= aemon.rst index 3e5a9dc032..9b0eaba6e5 100644 --- a/docs/tools/qemu-storage-daemon.rst +++ b/docs/tools/qemu-storage-daemon.rst @@ -201,7 +201,7 @@ Export raw image file ``disk.img`` over NBD UNIX domain= socket ``nbd.sock``:: --nbd-server addr.type=3Dunix,addr.path=3Dnbd.sock \ --export type=3Dnbd,id=3Dexport,node-name=3Ddisk,writable=3Don =20 -Export a qcow2 image file ``disk.qcow2`` as a vhosts-user-blk device over = UNIX +Export a qcow2 image file ``disk.qcow2`` as a vhost-user-blk device over U= NIX domain socket ``vhost-user-blk.sock``:: =20 $ qemu-storage-daemon \ --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642169238; cv=none; d=zohomail.com; s=zohoarc; b=YJ3Rh0mPX4Dlf7FIEY16qChpLik+RIT7J2SY3TrrS2xzmFxG5QuIRI60eDngLAbbAOy/BRWOgjngeKKMUfPgLGsYGvyaQy7gEDuV5PC4iz73kWDfLMjTujzCLA/U9GPL/NbelOlIic5obaUQthU4oTT2KhU6kYrp1Wl2JmnjWck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642169238; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PJAeIDTzFB0lyVcDFZdcUvZc+kB3SleGw6HOFB3RExs=; b=OXcBB3OVZSVrUPl6WV3AAlNsbf+2Mj+PCA6Sh48Pgz+i7wAAUOoDK5peKrAFotkvNO8lesBf1lAsV3Xq7SpPjiy2FmvP/KwE7pyFlGTatvP9SExiufkhBdOl9GRV+7JmGsDTeBVLcwYuppG/60ICcv+hBu7edy9kyESaPwZDw1U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642169238811421.00287805807216; Fri, 14 Jan 2022 06:07:18 -0800 (PST) Received: from localhost ([::1]:40358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8NEb-0002iJ-Sn for importer@patchew.org; Fri, 14 Jan 2022 09:07:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0U-000309-Ro for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53471) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0T-0000K7-90 for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:42 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-187-jcDR5ID1PtC7v07t4gii1w-1; Fri, 14 Jan 2022 08:52:39 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B60311853020; Fri, 14 Jan 2022 13:52:38 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id B50C5105B20E; Fri, 14 Jan 2022 13:52:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168360; 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=PJAeIDTzFB0lyVcDFZdcUvZc+kB3SleGw6HOFB3RExs=; b=SiWfrrUGN6SxFV5+/IM7rev1OPKTzt87mfxxX8+T98ej8Z/Cv1QguUeaFZxdU13rKi9pDv FhMbOnMhehVfx/oe9i+A5T5Ti+e65NcJkP9P186f5ZVD7k4ClletaLdkwhoX6kjvWQPN3+ 9xebdXkJ9FOuRpO+bzs6kd/L8Xq8FUo= X-MC-Unique: jcDR5ID1PtC7v07t4gii1w-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 06/16] qemu-storage-daemon: Add vhost-user-blk help Date: Fri, 14 Jan 2022 14:52:16 +0100 Message-Id: <20220114135226.185407-7-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-Type: text/plain; charset="utf-8" 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.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642169240247100001 From: Philippe Mathieu-Daud=C3=A9 Add missing vhost-user-blk help: $ qemu-storage-daemon -h ... --export [type=3D]vhost-user-blk,id=3D,node-name=3D, addr.type=3Dunix,addr.path=3D[,writable=3Don|off] [,logical-block-size=3D][,num-queues=3D] export the specified block node as a vhosts-user-blk device over UNIX domain socket --export [type=3D]vhost-user-blk,id=3D,node-name=3D, fd,addr.str=3D[,writable=3Don|off] [,logical-block-size=3D][,num-queues=3D] export the specified block node as a vhosts-user-blk device over file descriptor ... Fixes: 90fc91d50b7 ("convert vhost-user-blk server to block export API") Reported-by: Qing Wang Reviewed-by: Eric Blake Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20220107105420.395011-3-f4bug@amsat.org> Signed-off-by: Kevin Wolf --- storage-daemon/qemu-storage-daemon.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-sto= rage-daemon.c index 52cf17e8ac..9d76d1114d 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -104,6 +104,19 @@ static void help(void) " export the specified block node over FUSE\n" "\n" #endif /* CONFIG_FUSE */ +#ifdef CONFIG_VHOST_USER_BLK_SERVER +" --export [type=3D]vhost-user-blk,id=3D,node-name=3D,\n" +" addr.type=3Dunix,addr.path=3D[,writable=3Don|off]= \n" +" [,logical-block-size=3D][,num-queues=3D]\n" +" export the specified block node as a\n" +" vhost-user-blk device over UNIX domain socket\n" +" --export [type=3D]vhost-user-blk,id=3D,node-name=3D,\n" +" fd,addr.str=3D[,writable=3Don|off]\n" +" [,logical-block-size=3D][,num-queues=3D]\n" +" export the specified block node as a\n" +" vhost-user-blk device over file descriptor\n" +"\n" +#endif /* CONFIG_VHOST_USER_BLK_SERVER */ " --monitor [chardev=3D]name[,mode=3Dcontrol][,pretty[=3Don|off]]\n" " configure a QMP monitor\n" "\n" --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642169006; cv=none; d=zohomail.com; s=zohoarc; b=j83rfs8UPdBvJlH58CJSHIk+D1mEko3RGFVa5qAkWd7soR95f+h332z6Hkrp5Xc0fjm9NugPtOUEowZZhx9EI2xEMYk6Zg3C8KjcgxQg4hSEAdVsCiso9Fh98ACca0Ftkc0Lm7r+aO0LACpVosuM2o2RUBn5Oo35qXbMpXttjWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642169006; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Hg4GavXcIyyKHZ3LcdHXTMWCD+n4iUVopHqlBHCdcO0=; b=BP743PyZA0SNiE8EKI2ORJcofSrRmThuhgPYyxJGs8Y5uKE4W+HN6ybS5hqVH2uaCsPySHEomPpFZ6IAJEFUJCVH56W+/gmlHMiic2093sFwl2gOZtk+Z29zULtVKPJ3k109Ty2nhZWgWpjj2rzVyIEWawLd/FpjzktoWmlPLyw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642169006543225.17718588696448; Fri, 14 Jan 2022 06:03:26 -0800 (PST) Received: from localhost ([::1]:36350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8NAr-0007jc-8v for importer@patchew.org; Fri, 14 Jan 2022 09:03:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0Y-00031N-Cu for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41531) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0W-0000L1-SG for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:46 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-203-YGwMZhbAOEO3zLur3Kxjgw-1; Fri, 14 Jan 2022 08:52:41 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27AF481EE62; Fri, 14 Jan 2022 13:52:40 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FC75105B20E; Fri, 14 Jan 2022 13:52:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168364; 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=Hg4GavXcIyyKHZ3LcdHXTMWCD+n4iUVopHqlBHCdcO0=; b=NVUvJMrOcqdEd/Tr2/MxL1dP/TIPZBu0PrVznyRkvj/jJEfQWDAL0pEyoPzGh6pEmWtRYd yE2dSbVj6lV7h92kojoTk8lQsu6rwg1voMLJ9dpveUOdhh9yW7+80ncNwSW6vXHZapxAEc AwwO3f0AVHlbH1BScaUV16lYvTJCrys= X-MC-Unique: YGwMZhbAOEO3zLur3Kxjgw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 07/16] qapi/block: Restrict vhost-user-blk to CONFIG_VHOST_USER_BLK_SERVER Date: Fri, 14 Jan 2022 14:52:17 +0100 Message-Id: <20220114135226.185407-8-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-Type: text/plain; charset="utf-8" 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.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642169008817100001 From: Philippe Mathieu-Daud=C3=A9 When building QEMU with --disable-vhost-user and using introspection, query-qmp-schema lists vhost-user-blk even though it's not actually available: { "execute": "query-qmp-schema" } { "return": [ ... { "name": "312", "members": [ { "name": "nbd" }, { "name": "vhost-user-blk" } ], "meta-type": "enum", "values": [ "nbd", "vhost-user-blk" ] }, Restrict vhost-user-blk in BlockExportType when CONFIG_VHOST_USER_BLK_SERVER is disabled, so it doesn't end listed by query-qmp-schema. Fixes: 90fc91d50b7 ("convert vhost-user-blk server to block export API") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20220107105420.395011-4-f4bug@amsat.org> Signed-off-by: Kevin Wolf --- qapi/block-export.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qapi/block-export.json b/qapi/block-export.json index c1b92ce1c1..f9ce79a974 100644 --- a/qapi/block-export.json +++ b/qapi/block-export.json @@ -277,7 +277,8 @@ # Since: 4.2 ## { 'enum': 'BlockExportType', - 'data': [ 'nbd', 'vhost-user-blk', + 'data': [ 'nbd', + { 'name': 'vhost-user-blk', 'if': 'CONFIG_VHOST_USER_BLK_SERVE= R' }, { 'name': 'fuse', 'if': 'CONFIG_FUSE' } ] } =20 ## @@ -319,7 +320,8 @@ 'discriminator': 'type', 'data': { 'nbd': 'BlockExportOptionsNbd', - 'vhost-user-blk': 'BlockExportOptionsVhostUserBlk', + 'vhost-user-blk': { 'type': 'BlockExportOptionsVhostUserBlk', + 'if': 'CONFIG_VHOST_USER_BLK_SERVER' }, 'fuse': { 'type': 'BlockExportOptionsFuse', 'if': 'CONFIG_FUSE' } } } --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642168776; cv=none; d=zohomail.com; s=zohoarc; b=TrP9IX61FdqWmZZXTSwj1YWDNTeDsJxO1GDOj8HiEL8fgtRVE2YlwoHUIV8zHJwzOtvtaJeCIcoG3m+TJdrDtW/x5bL6xgpW0aBclusHQkhrp2JRLktKdvy9VJg7r8q6LnsRwaIApU2c7UIEFCaFme31E+y61ShWRfelKywdlKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642168776; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nPqtEYLJDSXGqqV0nFG9igLA9sxKeXDQBMx/9g1Q1OM=; b=NqRCtZmQXRD8bnX2F/UQg/kMECvxM9avhieDXOk4oi3g8f4Nsn3e26cnUT7An2vVJMp/h/g+efoLFK21S0UHUGwX56QRO3zTDyrQ0M5S2Tn0pV9frPdMDJtpBbe6P2iozdFGlm3u2K1YIHKixhb6voZE4Q7AgWZWmbfW2E0aodE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642168776794592.3578115628252; Fri, 14 Jan 2022 05:59:36 -0800 (PST) Received: from localhost ([::1]:32944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8N79-00058y-O4 for importer@patchew.org; Fri, 14 Jan 2022 08:59:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0Z-00037O-WB for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58779) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0Y-0000LN-6N for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:47 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-ki7off1XMTioqKCluD5P-w-1; Fri, 14 Jan 2022 08:52:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 76EFD760C0; Fri, 14 Jan 2022 13:52:41 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 745EE105B20E; Fri, 14 Jan 2022 13:52:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168365; 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=nPqtEYLJDSXGqqV0nFG9igLA9sxKeXDQBMx/9g1Q1OM=; b=EDaNnZo19Rdx/wMy3vXwxWVY1q0IdAVQbEszRNv/zXrMXx5qs8dvXUTo0Qmh1SWhFnD/WJ /elGGe+D8G/jgQlVLb0NI4xGzBBUjn0XNr79w4HXIpsx07O258lq0jDbqD+8qBccmuvk/A bo8EXOJrXNt4NjNAXfjwPajl+HDrKws= X-MC-Unique: ki7off1XMTioqKCluD5P-w-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 08/16] block-backend: prevent dangling BDS pointers across aio_poll() Date: Fri, 14 Jan 2022 14:52:18 +0100 Message-Id: <20220114135226.185407-9-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642168778608100001 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi The BlockBackend root child can change when aio_poll() is invoked. This happens when a temporary filter node is removed upon blockjob completion, for example. Functions in block/block-backend.c must be aware of this when using a blk_bs() pointer across aio_poll() because the BlockDriverState refcnt may reach 0, resulting in a stale pointer. One example is scsi_device_purge_requests(), which calls blk_drain() to wait for in-flight requests to cancel. If the backup blockjob is active, then the BlockBackend root child is a temporary filter BDS owned by the blockjob. The blockjob can complete during bdrv_drained_begin() and the last reference to the BDS is released when the temporary filter node is removed. This results in a use-after-free when blk_drain() calls bdrv_drained_end(bs) on the dangling pointer. Explicitly hold a reference to bs across block APIs that invoke aio_poll(). Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D2021778 Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D2036178 Signed-off-by: Stefan Hajnoczi Message-Id: <20220111153613.25453-2-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- block/block-backend.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 12ef80ea17..23e727199b 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -822,16 +822,22 @@ BlockBackend *blk_by_public(BlockBackendPublic *publi= c) void blk_remove_bs(BlockBackend *blk) { ThrottleGroupMember *tgm =3D &blk->public.throttle_group_member; - BlockDriverState *bs; BdrvChild *root; =20 notifier_list_notify(&blk->remove_bs_notifiers, blk); if (tgm->throttle_state) { - bs =3D blk_bs(blk); + BlockDriverState *bs =3D blk_bs(blk); + + /* + * Take a ref in case blk_bs() changes across bdrv_drained_begin()= , for + * example, if a temporary filter node is removed by a blockjob. + */ + bdrv_ref(bs); bdrv_drained_begin(bs); throttle_group_detach_aio_context(tgm); throttle_group_attach_aio_context(tgm, qemu_get_aio_context()); bdrv_drained_end(bs); + bdrv_unref(bs); } =20 blk_update_root_state(blk); @@ -1705,6 +1711,7 @@ void blk_drain(BlockBackend *blk) BlockDriverState *bs =3D blk_bs(blk); =20 if (bs) { + bdrv_ref(bs); bdrv_drained_begin(bs); } =20 @@ -1714,6 +1721,7 @@ void blk_drain(BlockBackend *blk) =20 if (bs) { bdrv_drained_end(bs); + bdrv_unref(bs); } } =20 @@ -2044,10 +2052,13 @@ static int blk_do_set_aio_context(BlockBackend *blk= , AioContext *new_context, int ret; =20 if (bs) { + bdrv_ref(bs); + if (update_root_node) { ret =3D bdrv_child_try_set_aio_context(bs, new_context, blk->r= oot, errp); if (ret < 0) { + bdrv_unref(bs); return ret; } } @@ -2057,6 +2068,8 @@ static int blk_do_set_aio_context(BlockBackend *blk, = AioContext *new_context, throttle_group_attach_aio_context(tgm, new_context); bdrv_drained_end(bs); } + + bdrv_unref(bs); } =20 blk->ctx =3D new_context; @@ -2326,11 +2339,13 @@ void blk_io_limits_disable(BlockBackend *blk) ThrottleGroupMember *tgm =3D &blk->public.throttle_group_member; assert(tgm->throttle_state); if (bs) { + bdrv_ref(bs); bdrv_drained_begin(bs); } throttle_group_unregister_tgm(tgm); if (bs) { bdrv_drained_end(bs); + bdrv_unref(bs); } } =20 --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642169251; cv=none; d=zohomail.com; s=zohoarc; b=Dny/ctYQ6jyWOUGGYj0YhOmRAfraTwAEfeLPl7pjdff8f+ha+/YuDzZFLm3ubUQf/FLsafmvJ+pqw+FHBSx4L+WaVb3HGLiJ+MhIk92hB6voSzsNXRdbK7k6tCd1s3b4rJdL3vbKckywXqqIvFIlMWfLtXXRcplIE1PBVjI6rm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642169251; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gpT2w30WSUo7d2SOMBmCERq8noAYchtmHueolHdpuD8=; b=TfEhb9V+O2qg22PciZhuHwNu/tSCgm5M3Le8b60s032u3h1296Lx5i87I+D+nu7mvRyYrj7Hk5Aji9B+6WcjEySTg/4AsoXeB3/F+BqOYXF1lpvtMlNBEckddHvhwCRqMt4sW+daiFmBCPSjLR0CzHvX6SbHkDWBGFdbqz/e5yI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642169251532775.582269820372; Fri, 14 Jan 2022 06:07:31 -0800 (PST) Received: from localhost ([::1]:41398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8NEo-0003R9-Gc for importer@patchew.org; Fri, 14 Jan 2022 09:07:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0a-0003B8-Ug for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35449) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0Y-0000M4-Nu for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:48 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-333-A1CCwysFOhOCTwXChcCDsQ-1; Fri, 14 Jan 2022 08:52:43 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C860D1853030; Fri, 14 Jan 2022 13:52:42 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3F05105B213; Fri, 14 Jan 2022 13:52:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168366; 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=gpT2w30WSUo7d2SOMBmCERq8noAYchtmHueolHdpuD8=; b=aN3tBLHGtCUQjLMU+j5ovtwax9JH+tJRExEy0nYP7cnFqK7uiwDJ/c6PvP5G3zanTy9+h8 zKwBjcYuim4Bq8SfsDd5suCwvKNHwvQMgBhycQpro4f4U7sANw3U9GP643moVNgCOG9xkT CMWI+OuxhDrjtsP7PxmVK7iISmZqnu4= X-MC-Unique: A1CCwysFOhOCTwXChcCDsQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 09/16] iotests/stream-error-on-reset: New test Date: Fri, 14 Jan 2022 14:52:19 +0100 Message-Id: <20220114135226.185407-10-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642169253427100001 Content-Type: text/plain; charset="utf-8" From: Hanna Reitz Test the following scenario: - Simple stream block in two-layer backing chain (base and top) - The job is drained via blk_drain(), then an error occurs while the job settles the ongoing request - And so the job completes while in blk_drain() This was reported as a segfault, but is fixed by "block-backend: prevent dangling BDS pointers across aio_poll()". Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D2036178 Signed-off-by: Hanna Reitz Signed-off-by: Stefan Hajnoczi Message-Id: <20220111153613.25453-3-stefanha@redhat.com> Signed-off-by: Kevin Wolf --- .../qemu-iotests/tests/stream-error-on-reset | 140 ++++++++++++++++++ .../tests/stream-error-on-reset.out | 5 + 2 files changed, 145 insertions(+) create mode 100755 tests/qemu-iotests/tests/stream-error-on-reset create mode 100644 tests/qemu-iotests/tests/stream-error-on-reset.out diff --git a/tests/qemu-iotests/tests/stream-error-on-reset b/tests/qemu-io= tests/tests/stream-error-on-reset new file mode 100755 index 0000000000..7eaedb24d7 --- /dev/null +++ b/tests/qemu-iotests/tests/stream-error-on-reset @@ -0,0 +1,140 @@ +#!/usr/bin/env python3 +# group: rw quick +# +# Test what happens when a stream job completes in a blk_drain(). +# +# Copyright (C) 2022 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import os +import iotests +from iotests import imgfmt, qemu_img_create, qemu_io_silent, QMPTestCase + + +image_size =3D 1 * 1024 * 1024 +data_size =3D 64 * 1024 +base =3D os.path.join(iotests.test_dir, 'base.img') +top =3D os.path.join(iotests.test_dir, 'top.img') + + +# We want to test completing a stream job in a blk_drain(). +# +# The blk_drain() we are going to use is a virtio-scsi device resetting, +# which we can trigger by resetting the system. +# +# In order to have the block job complete on drain, we (1) throttle its +# base image so we can start the drain after it has begun, but before it +# completes, and (2) make it encounter an I/O error on the ensuing write. +# (If it completes regularly, the completion happens after the drain for +# some reason.) + +class TestStreamErrorOnReset(QMPTestCase): + def setUp(self) -> None: + """ + Create two images: + - base image {base} with {data_size} bytes allocated + - top image {top} without any data allocated + + And the following VM configuration: + - base image throttled to {data_size} + - top image with a blkdebug configuration so the first write access + to it will result in an error + - top image is attached to a virtio-scsi device + """ + assert qemu_img_create('-f', imgfmt, base, str(image_size)) =3D=3D= 0 + assert qemu_io_silent('-c', f'write 0 {data_size}', base) =3D=3D 0 + assert qemu_img_create('-f', imgfmt, top, str(image_size)) =3D=3D 0 + + self.vm =3D iotests.VM() + self.vm.add_args('-accel', 'tcg') # Make throttling work properly + self.vm.add_object(self.vm.qmp_to_opts({ + 'qom-type': 'throttle-group', + 'id': 'thrgr', + 'x-bps-total': str(data_size) + })) + self.vm.add_blockdev(self.vm.qmp_to_opts({ + 'driver': imgfmt, + 'node-name': 'base', + 'file': { + 'driver': 'throttle', + 'throttle-group': 'thrgr', + 'file': { + 'driver': 'file', + 'filename': base + } + } + })) + self.vm.add_blockdev(self.vm.qmp_to_opts({ + 'driver': imgfmt, + 'node-name': 'top', + 'file': { + 'driver': 'blkdebug', + 'node-name': 'top-blkdebug', + 'inject-error': [{ + 'event': 'pwritev', + 'immediately': 'true', + 'once': 'true' + }], + 'image': { + 'driver': 'file', + 'filename': top + } + }, + 'backing': 'base' + })) + self.vm.add_device(self.vm.qmp_to_opts({ + 'driver': 'virtio-scsi', + 'id': 'vscsi' + })) + self.vm.add_device(self.vm.qmp_to_opts({ + 'driver': 'scsi-hd', + 'bus': 'vscsi.0', + 'drive': 'top' + })) + self.vm.launch() + + def tearDown(self) -> None: + self.vm.shutdown() + os.remove(top) + os.remove(base) + + def test_stream_error_on_reset(self) -> None: + # Launch a stream job, which will take at least a second to + # complete, because the base image is throttled (so we can + # get in between it having started and it having completed) + res =3D self.vm.qmp('block-stream', job_id=3D'stream', device=3D't= op') + self.assert_qmp(res, 'return', {}) + + while True: + ev =3D self.vm.event_wait('JOB_STATUS_CHANGE') + if ev['data']['status'] =3D=3D 'running': + # Once the stream job is running, reset the system, which + # forces the virtio-scsi device to be reset, thus draining + # the stream job, and making it complete. Completing + # inside of that drain should not result in a segfault. + res =3D self.vm.qmp('system_reset') + self.assert_qmp(res, 'return', {}) + elif ev['data']['status'] =3D=3D 'null': + # The test is done once the job is gone + break + + +if __name__ =3D=3D '__main__': + # Passes with any format with backing file support, but qed and + # qcow1 do not seem to exercise the used-to-be problematic code + # path, so there is no point in having them in this list + iotests.main(supported_fmts=3D['qcow2', 'vmdk'], + supported_protocols=3D['file']) diff --git a/tests/qemu-iotests/tests/stream-error-on-reset.out b/tests/qem= u-iotests/tests/stream-error-on-reset.out new file mode 100644 index 0000000000..ae1213e6f8 --- /dev/null +++ b/tests/qemu-iotests/tests/stream-error-on-reset.out @@ -0,0 +1,5 @@ +. +---------------------------------------------------------------------- +Ran 1 tests + +OK --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642169392; cv=none; d=zohomail.com; s=zohoarc; b=FvVRQemXEP3v5TtIIbls0je9K1SlkjNkmB6ln8HlvQbuySCPr1byrp7qscYinLK8W6E4N7xf32w3YttizQBCDcFpx+wQhF4yjBY6jpbV6MzeL7q2w9e4F0KalQIdGa38t6MNJbiejN4/8er4a0BplzIQ4a6GoBygue3vqe2Ub/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642169392; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XqlX6m2FKBI9Fml4ap/jhMvbWxTyaWroJQcKYgH6OvQ=; b=lt/s+rLjQ2XiMk4E0LrfJhqcOhqh+a2KstEA0XgLDHwGTan1tDQ0whPHfg79OIR32itWg5yhLPBtankMisW4mYav9IreRAPx7c3oNNrJN0YHeRjSso9Esuqz6NN3Tut7vbRAcq3Ik3L5H2Op1yPyoxIhv3t1tPnIFuvbl/ouiZk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642169391823515.9801066507912; Fri, 14 Jan 2022 06:09:51 -0800 (PST) Received: from localhost ([::1]:48732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8NH4-0000BS-DX for importer@patchew.org; Fri, 14 Jan 2022 09:09:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0d-0003Dh-6s for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28105) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0a-0000MY-TK for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:50 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-576-0HDb0DNGP_m_ffYQJVyYPw-1; Fri, 14 Jan 2022 08:52:45 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22D161023F4D; Fri, 14 Jan 2022 13:52:44 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2180A105B20E; Fri, 14 Jan 2022 13:52:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168368; 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=XqlX6m2FKBI9Fml4ap/jhMvbWxTyaWroJQcKYgH6OvQ=; b=EBh3t/ffPQlg0PbHecWrzIJolwzCs/jclVLpoTa/ELLKhXsm+bvJ/ny4RzPWVbtq3Iwnsv Almu7tV/j79168mI+Oo8xZgOdlTcDi/Zb+L6zu6yBXrO3swts3yqwjugMtYQpwhD1ASbNl LeaVMEPOs4vpEmqVMG6iW27f8xruElc= X-MC-Unique: 0HDb0DNGP_m_ffYQJVyYPw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 10/16] iotests/308: Fix for CAP_DAC_OVERRIDE Date: Fri, 14 Jan 2022 14:52:20 +0100 Message-Id: <20220114135226.185407-11-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642169393143100001 Content-Type: text/plain; charset="utf-8" From: Hanna Reitz With CAP_DAC_OVERRIDE (which e.g. root generally has), permission checks will be bypassed when opening files. 308 in one instance tries to open a read-only file (FUSE export) with qemu-io as read/write, and expects this to fail. However, when running it as root, opening will succeed (thanks to CAP_DAC_OVERRIDE) and only the actual write operation will fail. Note this as "Case not run", but have the test pass in either case. Reported-by: Vladimir Sementsov-Ogievskiy Fixes: 2c7dd057aa7bd7a875e9b1a53975c220d6380bc4 ("export/fuse: Pass default_permissions for mount") Signed-off-by: Hanna Reitz Message-Id: <20220103120014.13061-1-hreitz@redhat.com> Signed-off-by: Kevin Wolf --- tests/qemu-iotests/308 | 25 +++++++++++++++++++++++-- tests/qemu-iotests/308.out | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/308 b/tests/qemu-iotests/308 index 2e3f8f4282..bde4aac2fa 100755 --- a/tests/qemu-iotests/308 +++ b/tests/qemu-iotests/308 @@ -230,8 +230,29 @@ echo '=3D=3D=3D Writable export =3D=3D=3D' fuse_export_add 'export-mp' "'mountpoint': '$EXT_MP', 'writable': true" =20 # Check that writing to the read-only export fails -$QEMU_IO -f raw -c 'write -P 42 1M 64k' "$TEST_IMG" 2>&1 \ - | _filter_qemu_io | _filter_testdir | _filter_imgfmt +output=3D$($QEMU_IO -f raw -c 'write -P 42 1M 64k' "$TEST_IMG" 2>&1 \ + | _filter_qemu_io | _filter_testdir | _filter_imgfmt) + +# Expected reference output: Opening the file fails because it has no +# write permission +reference=3D"Could not open 'TEST_DIR/t.IMGFMT': Permission denied" + +if echo "$output" | grep -q "$reference"; then + echo "Writing to read-only export failed: OK" +elif echo "$output" | grep -q "write failed: Permission denied"; then + # With CAP_DAC_OVERRIDE (e.g. when running this test as root), the exp= ort + # can be opened regardless of its file permissions, but writing will t= hen + # fail. This is not the result for which we want to test, so count th= is as + # a SKIP. + _casenotrun "Opening RO export as R/W succeeded, perhaps because of" \ + "CAP_DAC_OVERRIDE" + + # Still, write this to the reference output to make the test pass + echo "Writing to read-only export failed: OK" +else + echo "Writing to read-only export failed: ERROR" + echo "$output" +fi =20 # But here it should work $QEMU_IO -f raw -c 'write -P 42 1M 64k' "$EXT_MP" | _filter_qemu_io diff --git a/tests/qemu-iotests/308.out b/tests/qemu-iotests/308.out index fc47bb11a2..e4467a10cf 100644 --- a/tests/qemu-iotests/308.out +++ b/tests/qemu-iotests/308.out @@ -95,7 +95,7 @@ virtual size: 0 B (0 bytes) 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse', 'writable': true } } {"return": {}} -qemu-io: can't open device TEST_DIR/t.IMGFMT: Could not open 'TEST_DIR/t.I= MGFMT': Permission denied +Writing to read-only export failed: OK wrote 65536/65536 bytes at offset 1048576 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 65536/65536 bytes at offset 1048576 --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642169645; cv=none; d=zohomail.com; s=zohoarc; b=SQ+fmSoRtWCJQULdSw46xEBUojojZZ/lPhCyeB0QjLqN8zRVmy749n9TbxxUab/SDawJyupysJdvRAwvU2zElGuzL8KGeAziOO5pjEfLFErKHkIiSErnA75wFSfambmnKJSXs8Gg3fDXA5oTCxkNAo8JGXpPFOawqTkfYy/R8DI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642169645; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=C3tJhglUcJz48pyYktcgRGFCerCkrIo+T9WluYYSZ1c=; b=mcBxEKmEaQCsH+0iZjYNMuR39y0weKsWP5Zr1OZV4ulWudaw3u52MW6Q5pXf1XexMIsuIyan0IHZ/n6Di6FkvbGnRJW6eL0654fWcJLJ5RyHJiOPkOmTOCo/aTrGgQNW7/hMdwLg5Di6XMTsTm6Ke2aCNI7rzWZZzWwmuCwBpBM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642169645402393.58339640036047; Fri, 14 Jan 2022 06:14:05 -0800 (PST) Received: from localhost ([::1]:57390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8NLA-0006QY-Dg for importer@patchew.org; Fri, 14 Jan 2022 09:14:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0c-0003D6-48 for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0a-0000MQ-Lc for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:49 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-152-t73sNy0iPsC3WVzg4YrFfQ-1; Fri, 14 Jan 2022 08:52:46 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77DC91023F51; Fri, 14 Jan 2022 13:52:45 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7008A105B20E; Fri, 14 Jan 2022 13:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168368; 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=C3tJhglUcJz48pyYktcgRGFCerCkrIo+T9WluYYSZ1c=; b=UjQuw6OisPP25S6jO5efjWmvP6HiZsqRZBiRfHt8tRmC9bQIW2xIcMTI2E1/6yOHAQLOnE ru/0v5I3zZh8HzjXM36uQuM2McHfQmVpWoEo5wJiRmohj62aEAl994xMJGUEdtDd+Ij6xk INgsPfYAVuTI4Pr5ZLDQXqqhVaHOax4= X-MC-Unique: t73sNy0iPsC3WVzg4YrFfQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 11/16] vvfat: Fix size of temporary qcow file Date: Fri, 14 Jan 2022 14:52:21 +0100 Message-Id: <20220114135226.185407-12-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642169647392100001 Content-Type: text/plain; charset="utf-8" The size of the qcow size was calculated so that only the FAT partition would fit on it, but not the whole disk. However, offsets relative to the whole disk are used to access it, so increase its size to be large enough for that. Signed-off-by: Kevin Wolf Message-Id: <20211209151815.23495-1-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- block/vvfat.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 5dacc6cfac..36e73d4c64 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1230,6 +1230,7 @@ static int vvfat_open(BlockDriverState *bs, QDict *op= tions, int flags, dirname, cyls, heads, secs)); =20 s->sector_count =3D cyls * heads * secs - s->offset_to_bootsector; + bs->total_sectors =3D cyls * heads * secs; =20 if (qemu_opt_get_bool(opts, "rw", false)) { if (!bdrv_is_read_only(bs)) { @@ -1250,8 +1251,6 @@ static int vvfat_open(BlockDriverState *bs, QDict *op= tions, int flags, } } =20 - bs->total_sectors =3D cyls * heads * secs; - if (init_directories(s, dirname, heads, secs, errp)) { ret =3D -EIO; goto fail; @@ -3147,8 +3146,8 @@ static int enable_write_target(BlockDriverState *bs, = Error **errp) } =20 opts =3D qemu_opts_create(bdrv_qcow->create_opts, NULL, 0, &error_abor= t); - qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s->sector_count * 512, - &error_abort); + qemu_opt_set_number(opts, BLOCK_OPT_SIZE, + bs->total_sectors * BDRV_SECTOR_SIZE, &error_abort= ); qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, "fat:", &error_abort); =20 ret =3D bdrv_create(bdrv_qcow, s->qcow_filename, opts, errp); --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642170104; cv=none; d=zohomail.com; s=zohoarc; b=KlBaqv61b4dBnxewkj7p3rLauSyK9ZjA06lMnnJrysmkEBaknQOCQzK8fdTkDZ0UZCYZlcxJyNOo0qID39YFYP3C1jFYFttWJoHRFLKqvLP4Rai3EMKimIIGfb6Jou9nQq4UbZYERDI2WFkm/YoZ8K08dHVeuINrA0vaaS2DgYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642170104; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h+Cxm0dWgNF1FatP7v9EAri02bBoOs4vzaitqar3HcM=; b=ZDlmyEy5Za5lad1ok2Mmv1+NL0k94+vYlnbVKsWIFyJWrB1bKYQh2wTTYtGRcQ3ApNfApWfQawbX4Lpe6et3v40xhB8sxcfEcsZ+C98lk5i21Lc909FDaS2vAJR73NFWEg3jm6EhLjJsmezWZTfsLb/bjAOX26ZpCHi6rg8skFc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642170104139639.3046260781654; Fri, 14 Jan 2022 06:21:44 -0800 (PST) Received: from localhost ([::1]:46290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8NSZ-0001Bc-4k for importer@patchew.org; Fri, 14 Jan 2022 09:21:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0f-0003IW-4k for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0d-0000Ng-IH for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:52 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-643-GRg2k5J6P-uF1YeiIuhCFw-1; Fri, 14 Jan 2022 08:52:48 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EAEFA760C1; Fri, 14 Jan 2022 13:52:46 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4177105B20E; Fri, 14 Jan 2022 13:52:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168371; 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=h+Cxm0dWgNF1FatP7v9EAri02bBoOs4vzaitqar3HcM=; b=F5Q9c4ImAO2PfQauWmMtJ8UEtVRSel4eJtq4UY4x8invZJ1BpkF5ZAK5JZv+xVm5oEdQLW p+0E3RnDX9eX8LWgMljPZKyYgAH5zpfY6/IeGMF0JxgW9oBtnL1phUtH48VQfnPADbD/b7 J2ZQpE4KKxNrvkW3VJ/e0E2tFN0MhIw= X-MC-Unique: GRg2k5J6P-uF1YeiIuhCFw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 12/16] vvfat: Fix vvfat_write() for writes before the root directory Date: Fri, 14 Jan 2022 14:52:22 +0100 Message-Id: <20220114135226.185407-13-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642170104961100001 Content-Type: text/plain; charset="utf-8" The calculation in sector2cluster() is done relative to the offset of the root directory. Any writes to blocks before the start of the root directory (in particular, writes to the FAT) result in negative values, which are not handled correctly in vvfat_write(). This changes sector2cluster() to return a signed value, and makes sure that vvfat_write() doesn't try to find mappings for negative cluster number. It clarifies the code in vvfat_write() to make it more obvious that the cluster numbers can be negative. Signed-off-by: Kevin Wolf Message-Id: <20211209152231.23756-1-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- block/vvfat.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 36e73d4c64..b2b58d93b8 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -882,7 +882,7 @@ static int read_directory(BDRVVVFATState* s, int mappin= g_index) return 0; } =20 -static inline uint32_t sector2cluster(BDRVVVFATState* s,off_t sector_num) +static inline int32_t sector2cluster(BDRVVVFATState* s,off_t sector_num) { return (sector_num - s->offset_to_root_dir) / s->sectors_per_cluster; } @@ -2981,6 +2981,7 @@ static int vvfat_write(BlockDriverState *bs, int64_t = sector_num, { BDRVVVFATState *s =3D bs->opaque; int i, ret; + int first_cluster, last_cluster; =20 DLOG(checkpoint()); =20 @@ -2999,9 +3000,20 @@ DLOG(checkpoint()); if (sector_num < s->offset_to_fat) return -1; =20 - for (i =3D sector2cluster(s, sector_num); - i <=3D sector2cluster(s, sector_num + nb_sectors - 1);) { - mapping_t* mapping =3D find_mapping_for_cluster(s, i); + /* + * Values will be negative for writes to the FAT, which is located bef= ore + * the root directory. + */ + first_cluster =3D sector2cluster(s, sector_num); + last_cluster =3D sector2cluster(s, sector_num + nb_sectors - 1); + + for (i =3D first_cluster; i <=3D last_cluster;) { + mapping_t *mapping =3D NULL; + + if (i >=3D 0) { + mapping =3D find_mapping_for_cluster(s, i); + } + if (mapping) { if (mapping->read_only) { fprintf(stderr, "Tried to write to write-protected file %s= \n", @@ -3041,8 +3053,9 @@ DLOG(checkpoint()); } } i =3D mapping->end; - } else + } else { i++; + } } =20 /* @@ -3056,10 +3069,11 @@ DLOG(fprintf(stderr, "Write to qcow backend: %d + %= d\n", (int)sector_num, nb_sec return ret; } =20 - for (i =3D sector2cluster(s, sector_num); - i <=3D sector2cluster(s, sector_num + nb_sectors - 1); i++) - if (i >=3D 0) + for (i =3D first_cluster; i <=3D last_cluster; i++) { + if (i >=3D 0) { s->used_clusters[i] |=3D USED_ALLOCATED; + } + } =20 DLOG(checkpoint()); /* TODO: add timeout */ --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642169925; cv=none; d=zohomail.com; s=zohoarc; b=ADI9icimh6dcrEBMKXclE32X6d9WuTyRZvE9aYa+zh0hi13nlGtFtOrfmFNBN2528IaAcl9aQK3xbmEytcbFvic5KGZWxXB6aDJdYKj/iCLsER9W2WIaRP2xIpX/cfBlTO7Jy33aEninPEbRW+SoJyt1jg4mgIpGyZja+EeQVV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642169925; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=I4aq1SO/dnyF/nSA0Mkl9gIarZVffuIuzcCCoM6+wKE=; b=Zu0yhvvqjU9Vv6hi5MUlVh+SzpH1uXXbLaPHy9wx73L/l4Ldu7QtgFIJ7QDzRzdJS2KDAM5/a7WAaO53b8bhcA0ch/Y7zhYEa7eW2E00OCKNJOoUzKipO3kovPcT3a3vDk/aoyXvtDmjROdV3IvKi9JMgQU9zkDDclDKj7cSBHs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642169925603941.9297700812572; Fri, 14 Jan 2022 06:18:45 -0800 (PST) Received: from localhost ([::1]:39140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8NPg-0004oM-7P for importer@patchew.org; Fri, 14 Jan 2022 09:18:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0e-0003H2-Iv for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27405) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0c-0000NL-Tw for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:52 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-422-fQLYUzfuNPmfx0a1WR0rkw-1; Fri, 14 Jan 2022 08:52:49 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1C4881023F4E; Fri, 14 Jan 2022 13:52:48 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BB38105B20E; Fri, 14 Jan 2022 13:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168370; 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=I4aq1SO/dnyF/nSA0Mkl9gIarZVffuIuzcCCoM6+wKE=; b=CwkMjYIpw/2+XaMAD/Gbyzg7DhF12K+Re59rx8VJBvIHRe7ecoeegrrff7uvDti8ZN+Ecd /sEpL1NZ49RDtkDGXjneSdBtA86hT3qAJS9/7ul36wIS1AWz3YpMxeTbK+CX7QUTDehKb0 p7UrEU5gOa8WhX6yCX5zOLxP89U0loA= X-MC-Unique: fQLYUzfuNPmfx0a1WR0rkw-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 13/16] iotests: Test qemu-img convert of zeroed data cluster Date: Fri, 14 Jan 2022 14:52:23 +0100 Message-Id: <20220114135226.185407-14-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642169927349100001 Content-Type: text/plain; charset="utf-8" This demonstrates what happens when the block status changes in sub-min_sparse granularity, but all of the parts are zeroed out. The alignment logic in is_allocated_sectors() prevents that the target image remains fully sparse as expected, but turns it into a data cluster of explicit zeros. Signed-off-by: Kevin Wolf Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20211217164654.1184218-2-vsementsov@virtuozzo.com> Tested-by: Peter Lieven Signed-off-by: Kevin Wolf --- tests/qemu-iotests/122 | 1 + tests/qemu-iotests/122.out | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/122 b/tests/qemu-iotests/122 index efb260d822..be0f6b79e5 100755 --- a/tests/qemu-iotests/122 +++ b/tests/qemu-iotests/122 @@ -251,6 +251,7 @@ $QEMU_IO -c "write -P 0 0 64k" "$TEST_IMG" 2>&1 | _filt= er_qemu_io | _filter_test $QEMU_IO -c "write 0 1k" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_test= dir $QEMU_IO -c "write 8k 1k" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_tes= tdir $QEMU_IO -c "write 17k 1k" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_te= stdir +$QEMU_IO -c "write -P 0 65k 1k" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filt= er_testdir =20 for min_sparse in 4k 8k; do echo diff --git a/tests/qemu-iotests/122.out b/tests/qemu-iotests/122.out index 8fbdac2b39..69b8e8b803 100644 --- a/tests/qemu-iotests/122.out +++ b/tests/qemu-iotests/122.out @@ -192,6 +192,8 @@ wrote 1024/1024 bytes at offset 8192 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 1024/1024 bytes at offset 17408 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1024/1024 bytes at offset 66560 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 convert -S 4k [{ "start": 0, "length": 4096, "depth": 0, "present": true, "zero": false,= "data": true, "offset": OFFSET}, @@ -199,7 +201,9 @@ convert -S 4k { "start": 8192, "length": 4096, "depth": 0, "present": true, "zero": fals= e, "data": true, "offset": OFFSET}, { "start": 12288, "length": 4096, "depth": 0, "present": false, "zero": tr= ue, "data": false}, { "start": 16384, "length": 4096, "depth": 0, "present": true, "zero": fal= se, "data": true, "offset": OFFSET}, -{ "start": 20480, "length": 67088384, "depth": 0, "present": false, "zero"= : true, "data": false}] +{ "start": 20480, "length": 46080, "depth": 0, "present": false, "zero": t= rue, "data": false}, +{ "start": 66560, "length": 1024, "depth": 0, "present": true, "zero": fal= se, "data": true, "offset": OFFSET}, +{ "start": 67584, "length": 67041280, "depth": 0, "present": false, "zero"= : true, "data": false}] =20 convert -c -S 4k [{ "start": 0, "length": 1024, "depth": 0, "present": true, "zero": false,= "data": true}, @@ -211,7 +215,9 @@ convert -c -S 4k =20 convert -S 8k [{ "start": 0, "length": 24576, "depth": 0, "present": true, "zero": false= , "data": true, "offset": OFFSET}, -{ "start": 24576, "length": 67084288, "depth": 0, "present": false, "zero"= : true, "data": false}] +{ "start": 24576, "length": 41984, "depth": 0, "present": false, "zero": t= rue, "data": false}, +{ "start": 66560, "length": 1024, "depth": 0, "present": true, "zero": fal= se, "data": true, "offset": OFFSET}, +{ "start": 67584, "length": 67041280, "depth": 0, "present": false, "zero"= : true, "data": false}] =20 convert -c -S 8k [{ "start": 0, "length": 1024, "depth": 0, "present": true, "zero": false,= "data": true}, --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642169632; cv=none; d=zohomail.com; s=zohoarc; b=U6gp2tashUw1SNgPeH4ohoax/Hw7k3fkCNxuoB5jvh0SaiK+nVv0mqKjk/1HUQBI85P4aRHvh5PeBGXpprNW0WjomrixRHAjNq9v3Hugj7efDa04dzUEhKO5lFZGbjB9Mxzp1SRyAwGBriTpNxMUfgnFXggx5Ccd9YUNFelQHe0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642169632; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yBeDq1TQZkaS+a6CTH6lheHgQ07lW02DNpjs6pu+mhc=; b=MgQCE//Vj2cESvH6C4zUo9dbSh60U5qtli8guAPtzWbi2cpuUuijJ+i+gBGNbqkNvio30TNMzh1XiIhn8pwVj10WHf8ECg3f4cHB4hTWFn91iJN/eTvp97ZNN4HFD+XDm6M6ZO0Ed6YBZ4/M3FhLY6rcRsvQWAO/51vh7ie/a2k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642169632357370.57741276939066; Fri, 14 Jan 2022 06:13:52 -0800 (PST) Received: from localhost ([::1]:56172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8NKx-0005dP-5Z for importer@patchew.org; Fri, 14 Jan 2022 09:13:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0i-0003JX-8W for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:53:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0g-0000OJ-Fy for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:52:55 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-500-BuSpUOGqPvilPo0t3swPVQ-1; Fri, 14 Jan 2022 08:52:50 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72A3D760C0; Fri, 14 Jan 2022 13:52:49 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B3C2105B20E; Fri, 14 Jan 2022 13:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168374; 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=yBeDq1TQZkaS+a6CTH6lheHgQ07lW02DNpjs6pu+mhc=; b=cCbjwRKqYJ4i8/PUNguc9S/OTKfR3D2+d4TzVuoFa5HPNuaGMrv2xuneZLSPYRceZDcbJI ajBXGayNwUbWCKTfh++c5xvc9V4gO5eyI/GikP2gYs5/M85hJrWukCx7wGH5r8vJkblVtn 9pf1gaOaljjuXnAXibdeH0q3ly/Q1Ho= X-MC-Unique: BuSpUOGqPvilPo0t3swPVQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 14/16] qemu-img: make is_allocated_sectors() more efficient Date: Fri, 14 Jan 2022 14:52:24 +0100 Message-Id: <20220114135226.185407-15-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642169632836100001 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Consider the case when the whole buffer is zero and end is unaligned. If i <=3D tail, we return 1 and do one unaligned WRITE, RMW happens. If i > tail, we do on aligned WRITE_ZERO (or skip if target is zeroed) and again one unaligned WRITE, RMW happens. Let's do better: don't fragment the whole-zero buffer and report it as ZERO: in case of zeroed target we just do nothing and avoid RMW. If target is not zeroes, one unaligned WRITE_ZERO should not be much worse than one unaligned WRITE. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20211217164654.1184218-3-vsementsov@virtuozzo.com> Tested-by: Peter Lieven Signed-off-by: Kevin Wolf --- qemu-img.c | 23 +++++++++++++++++++---- tests/qemu-iotests/122.out | 8 ++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 21ba1e6800..6fe2466032 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1171,19 +1171,34 @@ static int is_allocated_sectors(const uint8_t *buf,= int n, int *pnum, } } =20 + if (i =3D=3D n) { + /* + * The whole buf is the same. + * No reason to split it into chunks, so return now. + */ + *pnum =3D i; + return !is_zero; + } + tail =3D (sector_num + i) & (alignment - 1); if (tail) { if (is_zero && i <=3D tail) { - /* treat unallocated areas which only consist - * of a small tail as allocated. */ + /* + * For sure next sector after i is data, and it will rewrite t= his + * tail anyway due to RMW. So, let's just write data now. + */ is_zero =3D false; } if (!is_zero) { - /* align up end offset of allocated areas. */ + /* If possible, align up end offset of allocated areas. */ i +=3D alignment - tail; i =3D MIN(i, n); } else { - /* align down end offset of zero areas. */ + /* + * For sure next sector after i is data, and it will rewrite t= his + * tail anyway due to RMW. Better is avoid RMW and write zeroe= s up + * to aligned bound. + */ i -=3D tail; } } diff --git a/tests/qemu-iotests/122.out b/tests/qemu-iotests/122.out index 69b8e8b803..e18766e167 100644 --- a/tests/qemu-iotests/122.out +++ b/tests/qemu-iotests/122.out @@ -201,9 +201,7 @@ convert -S 4k { "start": 8192, "length": 4096, "depth": 0, "present": true, "zero": fals= e, "data": true, "offset": OFFSET}, { "start": 12288, "length": 4096, "depth": 0, "present": false, "zero": tr= ue, "data": false}, { "start": 16384, "length": 4096, "depth": 0, "present": true, "zero": fal= se, "data": true, "offset": OFFSET}, -{ "start": 20480, "length": 46080, "depth": 0, "present": false, "zero": t= rue, "data": false}, -{ "start": 66560, "length": 1024, "depth": 0, "present": true, "zero": fal= se, "data": true, "offset": OFFSET}, -{ "start": 67584, "length": 67041280, "depth": 0, "present": false, "zero"= : true, "data": false}] +{ "start": 20480, "length": 67088384, "depth": 0, "present": false, "zero"= : true, "data": false}] =20 convert -c -S 4k [{ "start": 0, "length": 1024, "depth": 0, "present": true, "zero": false,= "data": true}, @@ -215,9 +213,7 @@ convert -c -S 4k =20 convert -S 8k [{ "start": 0, "length": 24576, "depth": 0, "present": true, "zero": false= , "data": true, "offset": OFFSET}, -{ "start": 24576, "length": 41984, "depth": 0, "present": false, "zero": t= rue, "data": false}, -{ "start": 66560, "length": 1024, "depth": 0, "present": true, "zero": fal= se, "data": true, "offset": OFFSET}, -{ "start": 67584, "length": 67041280, "depth": 0, "present": false, "zero"= : true, "data": false}] +{ "start": 24576, "length": 67084288, "depth": 0, "present": false, "zero"= : true, "data": false}] =20 convert -c -S 8k [{ "start": 0, "length": 1024, "depth": 0, "present": true, "zero": false,= "data": true}, --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642169665; cv=none; d=zohomail.com; s=zohoarc; b=C04Ph2CB0qNI0dGyqBdTClDH9qMR04wpMIHCtq7Q5p9g881NnwbKc3NDnBzH29HCkQfuBEW9C7CDEX9iqFfeAt0H9jcdKkxMeqx3f+pmmJVcRw5dnHcHdPbcoisVpwme5Sd64FBEvEiFdM4PRpt1lZRY/aQHElVRhNP6w5sqaiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642169665; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HCxiaL2NAHJjXkUXBL66Fb6bAUA/Ps7WjTBLifcbmvY=; b=H8WyOalkepZJynU6Y+2xi44leCvslZKH+gJneN4G6/bC1B7Q31hcqBg5oySD4XQ56ZlkI3wpc6SHXKDDM07/UKD2kwWO9oTMDf0FZKXPbkC+4mNp/dXlziRXr3nADMjHN1z89rcA9fsAYmeR321D0tHSCWwfqMJ0ush5uT2E+Mk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642169665991775.9729374856486; Fri, 14 Jan 2022 06:14:25 -0800 (PST) Received: from localhost ([::1]:59110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8NLU-0007ZF-Tu for importer@patchew.org; Fri, 14 Jan 2022 09:14:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0m-0003K9-JA for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:53:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0k-0000Ow-PX for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:53:00 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-401-2nKMrE7GPkaQmKh1dQqKvQ-1; Fri, 14 Jan 2022 08:52:51 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC5A71853020; Fri, 14 Jan 2022 13:52:50 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9F43105B20E; Fri, 14 Jan 2022 13:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168377; 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=HCxiaL2NAHJjXkUXBL66Fb6bAUA/Ps7WjTBLifcbmvY=; b=BWIP+sQs11uJ4n56IUoq2WdYegyicz8oGASquk8CIDm2dWml3dAuQEMdDI2oZfzMzxCdAn AdYkhALLU0fcnxWLffryvZhH3b/S7UrdIat9YjQrd78fa93cgLSHPdIRODr8eGmgYGCST6 //FvavsfwFv1Nq+nGivt9bJ1Ql9obEQ= X-MC-Unique: 2nKMrE7GPkaQmKh1dQqKvQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 15/16] block: drop BLK_PERM_GRAPH_MOD Date: Fri, 14 Jan 2022 14:52:25 +0100 Message-Id: <20220114135226.185407-16-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642169666945100001 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy First, this permission never protected a node from being changed, as generic child-replacing functions don't check it. Second, it's a strange thing: it presents a permission of parent node to change its child. But generally, children are replaced by different mechanisms, like jobs or qmp commands, not by nodes. Graph-mod permission is hard to understand. All other permissions describe operations which done by parent node on its child: read, write, resize. Graph modification operations are something completely different. The only place where BLK_PERM_GRAPH_MOD is used as "perm" (not shared perm) is mirror_start_job, for s->target. Still modern code should use bdrv_freeze_backing_chain() to protect from graph modification, if we don't do it somewhere it may be considered as a bug. So, it's a bit risky to drop GRAPH_MOD, and analyzing of possible loss of protection is hard. But one day we should do it, let's do it now. One more bit of information is that locking the corresponding byte in file-posix doesn't make sense at all. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20210902093754.2352-1-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf --- qapi/block-core.json | 7 ++----- include/block/block.h | 9 +++++---- block.c | 7 +------ block/commit.c | 1 - block/mirror.c | 15 +++------------ hw/block/block.c | 3 +-- scripts/render_block_graph.py | 1 - tests/qemu-iotests/273.out | 4 ---- 8 files changed, 12 insertions(+), 35 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index bd0b285245..9a5a3641d0 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1878,14 +1878,11 @@ # # @resize: This permission is required to change the size of a block node. # -# @graph-mod: This permission is required to change the node that this -# BdrvChild points to. -# # Since: 4.0 ## { 'enum': 'BlockPermission', - 'data': [ 'consistent-read', 'write', 'write-unchanged', 'resize', - 'graph-mod' ] } + 'data': [ 'consistent-read', 'write', 'write-unchanged', 'resize' ] } + ## # @XDbgBlockGraphEdge: # diff --git a/include/block/block.h b/include/block/block.h index e5dd22b034..9d4050220b 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -269,12 +269,13 @@ enum { BLK_PERM_RESIZE =3D 0x08, =20 /** - * This permission is required to change the node that this BdrvChild - * points to. + * There was a now-removed bit BLK_PERM_GRAPH_MOD, with value of 0x10.= QEMU + * 6.1 and earlier may still lock the corresponding byte in block/file= -posix + * locking. So, implementing some new permission should be very caref= ul to + * not interfere with this old unused thing. */ - BLK_PERM_GRAPH_MOD =3D 0x10, =20 - BLK_PERM_ALL =3D 0x1f, + BLK_PERM_ALL =3D 0x0f, =20 DEFAULT_PERM_PASSTHROUGH =3D BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE diff --git a/block.c b/block.c index 10346b5011..7b3ce415d8 100644 --- a/block.c +++ b/block.c @@ -2485,7 +2485,6 @@ char *bdrv_perm_names(uint64_t perm) { BLK_PERM_WRITE, "write" }, { BLK_PERM_WRITE_UNCHANGED, "write unchanged" }, { BLK_PERM_RESIZE, "resize" }, - { BLK_PERM_GRAPH_MOD, "change children" }, { 0, NULL } }; =20 @@ -2601,8 +2600,7 @@ static void bdrv_default_perms_for_cow(BlockDriverSta= te *bs, BdrvChild *c, shared =3D 0; } =20 - shared |=3D BLK_PERM_CONSISTENT_READ | BLK_PERM_GRAPH_MOD | - BLK_PERM_WRITE_UNCHANGED; + shared |=3D BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED; =20 if (bs->open_flags & BDRV_O_INACTIVE) { shared |=3D BLK_PERM_WRITE | BLK_PERM_RESIZE; @@ -2720,7 +2718,6 @@ uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission q= api_perm) [BLOCK_PERMISSION_WRITE] =3D BLK_PERM_WRITE, [BLOCK_PERMISSION_WRITE_UNCHANGED] =3D BLK_PERM_WRITE_UNCHANGED, [BLOCK_PERMISSION_RESIZE] =3D BLK_PERM_RESIZE, - [BLOCK_PERMISSION_GRAPH_MOD] =3D BLK_PERM_GRAPH_MOD, }; =20 QEMU_BUILD_BUG_ON(ARRAY_SIZE(permissions) !=3D BLOCK_PERMISSION__MAX); @@ -5546,8 +5543,6 @@ int bdrv_drop_intermediate(BlockDriverState *top, Blo= ckDriverState *base, update_inherits_from =3D bdrv_inherits_from_recursive(base, explicit_t= op); =20 /* success - we can delete the intermediate states, and link top->base= */ - /* TODO Check graph modification op blockers (BLK_PERM_GRAPH_MOD) once - * we've figured out how they should work. */ if (!backing_file_str) { bdrv_refresh_filename(base); backing_file_str =3D base->filename; diff --git a/block/commit.c b/block/commit.c index 10cc5ff451..b1fc7b908b 100644 --- a/block/commit.c +++ b/block/commit.c @@ -370,7 +370,6 @@ void commit_start(const char *job_id, BlockDriverState = *bs, s->base =3D blk_new(s->common.job.aio_context, base_perms, BLK_PERM_CONSISTENT_READ - | BLK_PERM_GRAPH_MOD | BLK_PERM_WRITE_UNCHANGED); ret =3D blk_insert_bs(s->base, base, errp); if (ret < 0) { diff --git a/block/mirror.c b/block/mirror.c index 959e3dfbd6..69b2c1c697 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1139,10 +1139,7 @@ static void mirror_complete(Job *job, Error **errp) replace_aio_context =3D bdrv_get_aio_context(s->to_replace); aio_context_acquire(replace_aio_context); =20 - /* TODO Translate this into permission system. Current definition = of - * GRAPH_MOD would require to request it for the parents; they mig= ht - * not even be BlockDriverStates, however, so a BdrvChild can't ad= dress - * them. May need redefinition of GRAPH_MOD. */ + /* TODO Translate this into child freeze system. */ error_setg(&s->replace_blocker, "block device is in use by block-job-complete"); bdrv_op_block_all(s->to_replace, s->replace_blocker); @@ -1666,7 +1663,7 @@ static BlockJob *mirror_start_job( s =3D block_job_create(job_id, driver, NULL, mirror_top_bs, BLK_PERM_CONSISTENT_READ, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANG= ED | - BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD, speed, + BLK_PERM_WRITE, speed, creation_flags, cb, opaque, errp); if (!s) { goto fail; @@ -1710,9 +1707,7 @@ static BlockJob *mirror_start_job( target_perms |=3D BLK_PERM_RESIZE; } =20 - target_shared_perms |=3D BLK_PERM_CONSISTENT_READ - | BLK_PERM_WRITE - | BLK_PERM_GRAPH_MOD; + target_shared_perms |=3D BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE; } else if (bdrv_chain_contains(bs, bdrv_skip_filters(target))) { /* * We may want to allow this in the future, but it would @@ -1723,10 +1718,6 @@ static BlockJob *mirror_start_job( goto fail; } =20 - if (backing_mode !=3D MIRROR_LEAVE_BACKING_CHAIN) { - target_perms |=3D BLK_PERM_GRAPH_MOD; - } - s->target =3D blk_new(s->common.job.aio_context, target_perms, target_shared_perms); ret =3D blk_insert_bs(s->target, target, errp); diff --git a/hw/block/block.c b/hw/block/block.c index d47ebf005a..25f45df723 100644 --- a/hw/block/block.c +++ b/hw/block/block.c @@ -171,8 +171,7 @@ bool blkconf_apply_backend_options(BlockConf *conf, boo= l readonly, perm |=3D BLK_PERM_WRITE; } =20 - shared_perm =3D BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED | - BLK_PERM_GRAPH_MOD; + shared_perm =3D BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED; if (resizable) { shared_perm |=3D BLK_PERM_RESIZE; } diff --git a/scripts/render_block_graph.py b/scripts/render_block_graph.py index da6acf050d..42288a3cfb 100755 --- a/scripts/render_block_graph.py +++ b/scripts/render_block_graph.py @@ -35,7 +35,6 @@ def perm(arr): s =3D 'w' if 'write' in arr else '_' s +=3D 'r' if 'consistent-read' in arr else '_' s +=3D 'u' if 'write-unchanged' in arr else '_' - s +=3D 'g' if 'graph-mod' in arr else '_' s +=3D 's' if 'resize' in arr else '_' return s =20 diff --git a/tests/qemu-iotests/273.out b/tests/qemu-iotests/273.out index 4e840b6730..6a74a8138b 100644 --- a/tests/qemu-iotests/273.out +++ b/tests/qemu-iotests/273.out @@ -204,7 +204,6 @@ Testing: -blockdev file,node-name=3Dbase,filename=3DTES= T_DIR/t.IMGFMT.base -blockdev "name": "file", "parent": 5, "shared-perm": [ - "graph-mod", "write-unchanged", "consistent-read" ], @@ -219,7 +218,6 @@ Testing: -blockdev file,node-name=3Dbase,filename=3DTES= T_DIR/t.IMGFMT.base -blockdev "name": "backing", "parent": 5, "shared-perm": [ - "graph-mod", "resize", "write-unchanged", "write", @@ -233,7 +231,6 @@ Testing: -blockdev file,node-name=3Dbase,filename=3DTES= T_DIR/t.IMGFMT.base -blockdev "name": "file", "parent": 3, "shared-perm": [ - "graph-mod", "write-unchanged", "consistent-read" ], @@ -246,7 +243,6 @@ Testing: -blockdev file,node-name=3Dbase,filename=3DTES= T_DIR/t.IMGFMT.base -blockdev "name": "backing", "parent": 3, "shared-perm": [ - "graph-mod", "resize", "write-unchanged", "write", --=20 2.31.1 From nobody Thu Mar 28 10:47:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642169358; cv=none; d=zohomail.com; s=zohoarc; b=HvEPb5Xxxz02OgQyQV90unxZbGe0w8HiP2wPN6MUYy4zYEDZYyAjuSXyipKTAxq4zIuKeOoEj8XSpY17m4URa3TJtok/2TsmG78kjvG4PPlLVI39YvDnUukWGz0m3UltJZ5Mw+ihVZmuMo/02iK2LRLjtfqA3TAavAHOAGnCL/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642169358; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KMlqghHYUP4YhwTi8hsyxob4KH0JvCtGp488RsCVU9g=; b=kcohkR5uHXNniCgYOCWBtRq4wLxD1ZbCnB6lkvRJmF3yxQTFHDuolG8TjlDWN/rB4rRduG3J3udGdUSMGq6ZcGpw68dbAGkNZ3TjQQBRVhP3JYns+T50hLngSbbcmqnfkTL+6gFkB/FkLHystfKpNeMRzewC4FpiyyZJaZsF4/Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642169358636652.5582313576923; Fri, 14 Jan 2022 06:09:18 -0800 (PST) Received: from localhost ([::1]:47160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8NGX-0007Vs-Jc for importer@patchew.org; Fri, 14 Jan 2022 09:09:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0m-0003K8-DM for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:53:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59070) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8N0k-0000Op-Pl for qemu-devel@nongnu.org; Fri, 14 Jan 2022 08:53:00 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-14-sde32uDmNbSukS20dVrfaQ-1; Fri, 14 Jan 2022 08:52:53 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19C961054F90; Fri, 14 Jan 2022 13:52:52 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A3E5105B20E; Fri, 14 Jan 2022 13:52:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642168376; 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=KMlqghHYUP4YhwTi8hsyxob4KH0JvCtGp488RsCVU9g=; b=S127vJ+CfuLmkKzmK9RVxOgxQGi2ADOCi49HanWuuXsqVIceAiJxzUkeMI011feHiuNdcl hkTW4UGAjl41TejZW8IC4nYhm7gUq6kekGAdZmyiEeiG3QzyRvobNSVGypeMWQ2vyv/7+W 1CQWLhgBhDdI4hnuL3l9LXY/NbkvakA= X-MC-Unique: sde32uDmNbSukS20dVrfaQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 16/16] iotests/testrunner.py: refactor test_field_width Date: Fri, 14 Jan 2022 14:52:26 +0100 Message-Id: <20220114135226.185407-17-kwolf@redhat.com> In-Reply-To: <20220114135226.185407-1-kwolf@redhat.com> References: <20220114135226.185407-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.595, 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_H3=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642169360214100003 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy A lot of Optional[] types doesn't make code beautiful. test_field_width defaults to 8, but that is never used in the code. More over, if we want some default behavior for single call of test_run(), it should just print the whole test name, not limiting or expanding its width, so 8 is bad default. So, just drop the default as unused for now. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20211210201450.101576-1-vsementsov@virtuozzo.com> Reviewed-by: John Snow Signed-off-by: Kevin Wolf --- tests/qemu-iotests/testrunner.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunn= er.py index 0feaa396d0..15788f919e 100644 --- a/tests/qemu-iotests/testrunner.py +++ b/tests/qemu-iotests/testrunner.py @@ -174,19 +174,17 @@ def __enter__(self) -> 'TestRunner': def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> N= one: self._stack.close() =20 - def test_print_one_line(self, test: str, starttime: str, + def test_print_one_line(self, test: str, + test_field_width: int, + starttime: str, endtime: Optional[str] =3D None, status: str = =3D '...', lasttime: Optional[float] =3D None, thistime: Optional[float] =3D None, description: str =3D '', - test_field_width: Optional[int] =3D None, end: str =3D '\n') -> None: """ Print short test info before/after test run """ test =3D os.path.basename(test) =20 - if test_field_width is None: - test_field_width =3D 8 - if self.makecheck and status !=3D '...': if status and status !=3D 'pass': status =3D f' [{status}]' @@ -328,7 +326,7 @@ def do_run_test(self, test: str, mp: bool) -> TestResul= t: casenotrun=3Dcasenotrun) =20 def run_test(self, test: str, - test_field_width: Optional[int] =3D None, + test_field_width: int, mp: bool =3D False) -> TestResult: """ Run one test and print short status @@ -347,20 +345,21 @@ def run_test(self, test: str, =20 if not self.makecheck: self.test_print_one_line(test=3Dtest, + test_field_width=3Dtest_field_width, status =3D 'started' if mp else '...', starttime=3Dstart, lasttime=3Dlast_el, - end =3D '\n' if mp else '\r', - test_field_width=3Dtest_field_width) + end =3D '\n' if mp else '\r') =20 res =3D self.do_run_test(test, mp) =20 end =3D datetime.datetime.now().strftime('%H:%M:%S') - self.test_print_one_line(test=3Dtest, status=3Dres.status, + self.test_print_one_line(test=3Dtest, + test_field_width=3Dtest_field_width, + status=3Dres.status, starttime=3Dstart, endtime=3Dend, lasttime=3Dlast_el, thistime=3Dres.elapse= d, - description=3Dres.description, - test_field_width=3Dtest_field_width) + description=3Dres.description) =20 if res.casenotrun: print(res.casenotrun) --=20 2.31.1