From nobody Mon Feb 9 00:20:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1592294130; cv=none; d=zohomail.com; s=zohoarc; b=j63d+dkUPlg++S1yG49cPdb2CjvpWpAZK6KRdtzG/4u74F+CppnThIhsFP9UeYdM5y/SmVRag60CWrEXTK4+OP7eDi2seyJ9KyVLZ7d0xIxQ0Li2ZYjhuo56CSNdLc9jWVPOv50cStR0USf0+HciSRqKLX5/J4y44OBQJmMZyWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592294130; 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=STzzNqN6HYCA0arYVAMi69NXvxaelyOhS/2R3Be4BSE=; b=AWCqVrG6WMbL3TZRmrzE3LhYwQrXy+a3f609DIfCqoojum/HWbUuYNjYmFjng8h8R1FAPcLel8N0HQJl9Lq75PXa3wRO66ivPV3mUbllcxXJ0wDrfRU/NBMYEiQZ8pKtV34dbbkpQn8PptQ8DvEBYy5daJH18qL3QxphF5Sgqsg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1592294130671941.8445767825349; Tue, 16 Jun 2020 00:55:30 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-338-7bTCTVbwNqWJV6LYBJg8gA-1; Tue, 16 Jun 2020 03:55:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 752BAE915; Tue, 16 Jun 2020 07:55:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4DF616EDBE; Tue, 16 Jun 2020 07:55:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F12651809554; Tue, 16 Jun 2020 07:55:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05G7tJmb005037 for ; Tue, 16 Jun 2020 03:55:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 46A462028CD2; Tue, 16 Jun 2020 07:55:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3D7742014E15 for ; Tue, 16 Jun 2020 07:55:16 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4703C18A6668 for ; Tue, 16 Jun 2020 07:55:16 +0000 (UTC) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80049.outbound.protection.outlook.com [40.107.8.49]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-282-rYPz53EVNNip_xjGYNMe8A-3; Tue, 16 Jun 2020 03:55:13 -0400 Received: from AM6PR04MB5782.eurprd04.prod.outlook.com (2603:10a6:20b:aa::17) by AM6PR04MB5765.eurprd04.prod.outlook.com (2603:10a6:20b:ae::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Tue, 16 Jun 2020 07:55:12 +0000 Received: from AM6PR04MB5782.eurprd04.prod.outlook.com ([fe80::d848:9dea:7742:a55]) by AM6PR04MB5782.eurprd04.prod.outlook.com ([fe80::d848:9dea:7742:a55%4]) with mapi id 15.20.3088.029; Tue, 16 Jun 2020 07:55:12 +0000 Received: from t440p.gns.novell.com (114.255.249.163) by SN4PR0201CA0062.namprd02.prod.outlook.com (2603:10b6:803:20::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19 via Frontend Transport; Tue, 16 Jun 2020 07:55:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592294129; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=STzzNqN6HYCA0arYVAMi69NXvxaelyOhS/2R3Be4BSE=; b=KyIQi/N595ziR9rB2WI6dBWd6ZtOsz6I7pGqAyl1Ln1RZHr9tTCU82qJPLMs/ai5fYR04T 1stzdck+/NcB/kKvqP3bxwdNWOI/GuvABRLCUB0bpvun7qYj/odUN587xVjoh2QAG5VJfq b1+uNfBMDP8OCa7l+ZxaQm5p00oicSY= X-MC-Unique: 7bTCTVbwNqWJV6LYBJg8gA-1 X-MC-Unique: rYPz53EVNNip_xjGYNMe8A-3 From: Lin Ma To: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/5] qemu: Add Support for discard granularity Date: Tue, 16 Jun 2020 15:54:35 +0800 Message-ID: <20200616075438.5726-3-lma@suse.com> In-Reply-To: <20200616075438.5726-1-lma@suse.com> References: <20200616075438.5726-1-lma@suse.com> X-ClientProxiedBy: SN4PR0201CA0062.namprd02.prod.outlook.com (2603:10b6:803:20::24) To AM6PR04MB5782.eurprd04.prod.outlook.com (2603:10a6:20b:aa::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Originating-IP: [114.255.249.163] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b88dfdfa-0677-4fb7-4fab-08d811ca98e8 X-MS-TrafficTypeDiagnostic: AM6PR04MB5765: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-Forefront-PRVS: 04362AC73B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mJdS45p5ra98FnotLFNawCP76wN4x9n/iHILNeZ11iMzhnyyU9cFOImmbrdIiiWgEGZSttKMXHGRIlxbi53tI+M7DYo3q2xAIbwXsoDvSDt6pG+CaSRVdACZK3Q8XIUH3NpWYfHkw1u3LrftlGdyA+L80bH0WxOdvmRdt3LsqNb6eYKH3mXIWU2wuS0F4u+Z3E0xgncmJQGPbSGbVzJrUKKNDtoho62cU3zJTUc9X0fdtAzgwnhVuETJXpvO8rC3iNvGwRNDz54OgzeNSXBR2yQsXTEaEajrqz1TEEHvlT7iry+EnC/ZHlbv3rlrnu/buStUcHlIXpoKJ7K0jmm50w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5782.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(346002)(39860400002)(136003)(366004)(396003)(376002)(2906002)(508600001)(6486002)(6512007)(316002)(1076003)(6506007)(83380400001)(52116002)(186003)(16526019)(8676002)(8936002)(26005)(2616005)(956004)(86362001)(66556008)(66476007)(66946007)(6666004)(5660300002)(6916009)(4326008)(36756003)(107886003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: +9+knAJg6OhtZTGvrdAl6fRYuY46JxLAYEfrvAgp1O5CxYk8eP5F6DJXGWAvcG2kUqGJtAJbAjFzj+GiU/9V9OF0z4o9AoWG3jkhTNp4/G+ZgU6Y2fPjgmxXTErBt/khT4EU3s3XRSUtWxddtrnpGSJZPx1YlQe8fgAxHR/DkRI/+g3+V4+lLuARucVSnglL3DiP6gn+ZMOGr/MNrFB7cv2JuTEfe4KCziDYNHqQZKCP5nqKtpjGKpvb1xTTjnpyNsUfOnuCELPOqhCdL/swGlfo7nN3trD+7oWP/FfRkv3Rb+CMZZPHBM7MF4sc4UDvDh1JsqihRG1hw+a8ytyKjbM+PkqyO+SKG4sQnYMXvi/TpKGmzxLGheBpQyqvIdbP5qds93d7snibpd2oT24ymQsbJNkXAkWR39F4gAuip6SF3Yliy+bJ3ngnxWs1yWAkOOOn5PQI8G6YLVhXL3am2eqaJgroGEwQryirPpRbyCA= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: b88dfdfa-0677-4fb7-4fab-08d811ca98e8 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2020 07:55:12.4609 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3NlrpYLTnzK0SAYsB4lT6Q9bUGiENkAEDKpbMFzo+1PkGTG6jkRcqLrsX65rcfAQ X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5765 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 05G7tJmb005037 X-loop: libvir-list@redhat.com Cc: Lin Ma X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The default discard granularity is set to the logical block size or 4k by qemu, whichever is largest. The Optimal Unmap Granularity field in the block limits VPD page is impacted by it: Optimal Unmap Granularity =3D discard granularity / logical block size Signed-off-by: Lin Ma --- src/qemu/qemu_command.c | 3 +++ tests/qemuxml2argvdata/disk-blockio.args | 2 +- tests/qemuxml2argvdata/disk-blockio.xml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f27246b4c6..43f3a4c2a3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1849,6 +1849,9 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, if (disk->blockio.physical_block_size > 0) virBufferAsprintf(&opt, ",physical_block_size=3D%u", disk->blockio.physical_block_size); + if (disk->blockio.discard_granularity > 0) + virBufferAsprintf(&opt, ",discard_granularity=3D%u", + disk->blockio.discard_granularity); } =20 if (disk->wwn) { diff --git a/tests/qemuxml2argvdata/disk-blockio.args b/tests/qemuxml2argvd= ata/disk-blockio.args index 72aa592fef..b02f833692 100644 --- a/tests/qemuxml2argvdata/disk-blockio.args +++ b/tests/qemuxml2argvdata/disk-blockio.args @@ -30,5 +30,5 @@ readonly=3Don \ -device ide-cd,bus=3Dide.0,unit=3D1,drive=3Ddrive-ide0-0-1,id=3Dide0-0-1 \ -drive file=3D/tmp/idedisk.img,format=3Draw,if=3Dnone,id=3Ddrive-ide0-0-2 \ -device ide-hd,bus=3Dide.0,unit=3D2,drive=3Ddrive-ide0-0-2,id=3Dide0-0-2,b= ootindex=3D1,\ -logical_block_size=3D512,physical_block_size=3D512 \ +logical_block_size=3D512,physical_block_size=3D512,discard_granularity=3D4= 096 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/disk-blockio.xml b/tests/qemuxml2argvda= ta/disk-blockio.xml index 1f78b38cb6..8ae53cdeb5 100644 --- a/tests/qemuxml2argvdata/disk-blockio.xml +++ b/tests/qemuxml2argvdata/disk-blockio.xml @@ -23,7 +23,7 @@
- + --=20 2.26.0