From nobody Mon Feb 9 12:09:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=git.sr.ht ARC-Seal: i=1; a=rsa-sha256; t=1689608711; cv=none; d=zohomail.com; s=zohoarc; b=aBf/MWDv+tcck9IbPTg3S4aSUYlvoDrMANIC3KlDlvPkeUrz01in7JkoOT4Bc2aGPiLeHmw+R4g6rIbefmMKs67GF+tF7Bph5A0998dQsqyz17MkwAWtip84EEeRayUNjvYjghKB0K5Tzfu8HrIAnqbGly6TgWIZTUX5IZGY/68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689608711; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=uKVtdnkAgFIy2wc6QI5v2JahNNi9acEX19A0+pz0CGE=; b=Ci5aEFCNQKPjoV0iOM8Ve9BwgtWNgGxnNAp1pEfBJfGCS5MqBD2X41c5Uw2jTKyWmepewcWIj2lMjfG4HBAiGvsiI5kKUHOC+G5UklNIm7USZuw+AW6NvIT7ln64cocWUGqvF9FnqnKWCEw1r+zuWwO0+bbl3R3ao0ty6s6dS1o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1689608711484739.9008507381353; Mon, 17 Jul 2023 08:45:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-269-DezWzSWVOKCFPn6l1DDnbA-1; Mon, 17 Jul 2023 11:45:08 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5C337185A7B0; Mon, 17 Jul 2023 15:45:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42B081454142; Mon, 17 Jul 2023 15:45:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E128819465B5; Mon, 17 Jul 2023 15:44:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B236F1946588 for ; Mon, 17 Jul 2023 15:35:07 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 92D2C4CD0C8; Mon, 17 Jul 2023 15:35:07 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 89DF04CD0F1 for ; Mon, 17 Jul 2023 15:35:07 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 68A0F104458B for ; Mon, 17 Jul 2023 15:35:07 +0000 (UTC) Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-sUiiN4q7Plq1P72-4WxLSQ-1; Mon, 17 Jul 2023 11:35:01 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id C9C9611EFFA for ; Mon, 17 Jul 2023 15:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689608710; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=uKVtdnkAgFIy2wc6QI5v2JahNNi9acEX19A0+pz0CGE=; b=S5opaVy+KUMXp4qB13HG2AxmyVoIGInoP/fj4G1femfFmOccExum8rcEusMNzA/mS9okiT F7R5LqO9AJx9e/1MpkDPmr0+ASqhCnt3iSwxhrw0hQk6bRstE0zF4vw2HKPNOLfkhtx27e AzxeWWWrji977vx5zb98r6oFB6wVDpY= X-MC-Unique: DezWzSWVOKCFPn6l1DDnbA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: sUiiN4q7Plq1P72-4WxLSQ-1 From: ~hyman Date: Sun, 16 Jul 2023 22:36:21 +0800 Subject: [PATCH Libvirt 2/3] conf: Add 'virtio_discard' and 'virtio_write_zeroes' attributes MIME-Version: 1.0 Message-ID: <168960750325.27968.6928307240119276003-2@git.sr.ht> In-Reply-To: <168960750325.27968.6928307240119276003-0@git.sr.ht> To: libvir-list@redhat.com X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mailman-Approved-At: Mon, 17 Jul 2023 15:44:38 +0000 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ~hyman Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: git.sr.ht Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1689608713173100002 From: Hyman Huang(=E9=BB=84=E5=8B=87) Add 'virtio_discard' and 'virtio_write_zeroes' attribute to control whether discard and write-zeroes requests are handled by the virtio-blk device. To distinguish the attributes in block drive layer, use the 'virtio' prefix to indicate that these attributes are specific for virtio-blk. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- docs/formatdomain.rst | 8 ++++++++ src/conf/domain_conf.c | 16 ++++++++++++++++ src/conf/domain_conf.h | 2 ++ src/conf/schemas/domaincommon.rng | 10 ++++++++++ 4 files changed, 36 insertions(+) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 4af0b82569..7be12ff08e 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -3259,6 +3259,14 @@ paravirtualized driver is specified via the ``disk``= element. value can be either "unmap" (allow the discard request to be passed)= or "ignore" (ignore the discard request). :since:`Since 1.0.6 (QEMU and= KVM only)` + - The optional ``virtio_discard`` and ``virtio_write_zeroes`` are attr= ibutes + that control whether discard and write-zeroes requests are handled b= y the + virtio-blk device. The feature is based on DISCARD and WRITE_ZEROES + commands introduced in virtio-blk protocol to improve performance wh= en + using SSD backend. The value can be either 'on' or 'off'. Note that + ``discard`` and ``write_zeroes`` implementations in the block drive = layer + are parts of the feature logically and should be turned on when enab= ling + the feature. :since:`Since 9.6.0 (QEMU and KVM only)` - The optional ``detect_zeroes`` attribute controls whether to detect = zero write requests. The value can be "off", "on" or "unmap". First two v= alues turn the detection off and on, respectively. The third value ("unmap= ") diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5ac5c0b771..0f82b489f4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7813,6 +7813,14 @@ virDomainDiskDefDriverParseXML(virDomainDiskDef *def, VIR_XML_PROP_NONZERO, &def->discard) < 0) return -1; =20 + if (virXMLPropTristateSwitch(cur, "virtio_discard", VIR_XML_PROP_NONE, + &def->virtio_discard) < 0) + return -1; + + if (virXMLPropTristateSwitch(cur, "virtio_write_zeroes", VIR_XML_PROP_= NONE, + &def->virtio_write_zeroes) < 0) + return -1; + if (virXMLPropUInt(cur, "iothread", 10, VIR_XML_PROP_NONZERO, &def->io= thread) < 0) return -1; =20 @@ -22514,6 +22522,14 @@ virDomainDiskDefFormatDriver(virBuffer *buf, virBufferAsprintf(&attrBuf, " discard=3D'%s'", virDomainDiskDiscardTypeToString(disk->discard)); =20 + if (disk->virtio_discard) + virBufferAsprintf(&attrBuf, " virtio_discard=3D'%s'", + virTristateSwitchTypeToString(disk->virtio_disca= rd)); + + if (disk->virtio_write_zeroes) + virBufferAsprintf(&attrBuf, " virtio_write_zeroes=3D'%s'", + virTristateSwitchTypeToString(disk->virtio_write= _zeroes)); + if (disk->iothread) virBufferAsprintf(&attrBuf, " iothread=3D'%u'", disk->iothread); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c857ba556f..b73b1241ad 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -604,6 +604,8 @@ struct _virDomainDiskDef { virTristateBool rawio; virDomainDeviceSGIO sgio; virDomainDiskDiscard discard; + virTristateSwitch virtio_discard; + virTristateSwitch virtio_write_zeroes; unsigned int iothread; /* unused =3D 0, > 0 specific thread # */ virDomainDiskDetectZeroes detect_zeroes; virTristateSwitch discard_no_unref; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index c2f56b0490..c3a59aeb15 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -2510,6 +2510,16 @@ + + + + + + + + + + --=20 2.38.5