From nobody Fri May 3 11:09:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=oracle.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523297700169760.0419537729109; Mon, 9 Apr 2018 11:15:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4580C85A05; Mon, 9 Apr 2018 18:14:58 +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 1A3E85C88F; Mon, 9 Apr 2018 18:14:58 +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 CFDA91800C9F; Mon, 9 Apr 2018 18:14:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w39IEuWX000922 for ; Mon, 9 Apr 2018 14:14:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id AB6AE18760; Mon, 9 Apr 2018 18:14:56 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A28855F717; Mon, 9 Apr 2018 18:14:52 +0000 (UTC) Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7189B804E4; Mon, 9 Apr 2018 18:14:51 +0000 (UTC) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w39IBSnm031050; Mon, 9 Apr 2018 18:14:50 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2h6pn4ehp0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Apr 2018 18:14:50 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w39IEnR7015106 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Apr 2018 18:14:49 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w39IEnnS008842; Mon, 9 Apr 2018 18:14:49 GMT Received: from nina.dynamic.ziggo.nl (/10.175.1.96) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Apr 2018 11:14:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=pN++F+BXYenP+TBzFN85rimmJAia0tL8MCWOkR3RcVU=; b=XFd25lqHmDslYwUUGhxn4/g5yMOo8QozRdpL4r99TZZXiHhiUvSSOqkIDHzaNdZ0AI6g 9hv8/6uc15Mz17kgRHcKooYXjGK1CGxcyy1Swj+ZMhdxQ2IC0pRAwWZIxMm90C+eItEc ws6GmMYcckZ/POJUYE2NIzI1g90DB4UJwNaDCLmkq2STQ6yWzYTlfjPIDZbEnYHYryfJ oU0BRC5UqfGdR9FMlQNl6ud6rtt9xCiRGeUfVs2bR6C2mAsRoI4kMexcol9MNauof7Gk ngST35Zdvs1yniF/Af41LDak2HtEq5ahYRh9dhlpBeBljgt/n4tRO0RTKc2yNMtFBe7A Kw== From: Wim Ten Have To: Libvirt Development List Date: Mon, 9 Apr 2018 20:14:35 +0200 Message-Id: <20180409181435.30540-2-wim.ten.have@oracle.com> In-Reply-To: <20180409181435.30540-1-wim.ten.have@oracle.com> References: <20180409181435.30540-1-wim.ten.have@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8858 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804090185 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 09 Apr 2018 18:14:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 09 Apr 2018 18:14:51 +0000 (UTC) for IP:'156.151.31.85' DOMAIN:'userp2120.oracle.com' HELO:'userp2120.oracle.com' FROM:'wim.ten.have@oracle.com' RCPT:'' X-RedHat-Spam-Score: -100.131 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIMWL_WL_HIGH, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY, USER_IN_WHITELIST) 156.151.31.85 userp2120.oracle.com 156.151.31.85 userp2120.oracle.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , Wim ten Have Subject: [libvirt] [PATCH v2 1/1] storage: extend preallocation flags support for qemu-img 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 09 Apr 2018 18:14:58 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Wim ten Have This patch adds support to qcow2 formatted filesystem object storage by instructing qemu-img to build them with preallocation=3Dfalloc whenever the XML described storage matches its . For all other cases the filesystem stored objects are built with preallocation=3Dmetadata. Signed-off-by: Wim ten Have --- src/conf/storage_conf.c | 3 +++ src/storage/storage_util.c | 10 ++++++= ++-- .../qcow2-nocapacity-convert-prealloc.argv | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 5036ab9ef..2bd077237 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1184,6 +1184,9 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, ret->target.allocation =3D ret->target.capacity; } =20 + if (ret->target.allocation < ret->target.capacity) + ret->target.sparse =3D true; + ret->target.path =3D virXPathString("string(./target/path)", ctxt); if (options->formatFromString) { char *format =3D virXPathString("string(./target/format/@type)", c= txt); diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index b4aed0f70..c4f311ded 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -856,6 +856,7 @@ struct _virStorageBackendQemuImgInfo { const char *compat; virBitmapPtr features; bool nocow; + bool sparse; =20 const char *backingPath; int backingFormat; @@ -884,8 +885,12 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionIn= foDefPtr enc, virStorageFileFormatTypeToString(info.backin= gFormat)); if (info.encryption) virBufferAddLit(&buf, "encryption=3Don,"); - if (info.preallocate) - virBufferAddLit(&buf, "preallocation=3Dmetadata,"); + if (info.preallocate) { + if (info.sparse) + virBufferAddLit(&buf, "preallocation=3Dmetadata,"); + else + virBufferAddLit(&buf, "preallocation=3Dfalloc,"); + } } =20 if (info.nocow) @@ -1187,6 +1192,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, .compat =3D vol->target.compat, .features =3D vol->target.features, .nocow =3D vol->target.nocow, + .sparse =3D vol->target.sparse, .secretPath =3D secretPath, .secretAlias =3D NULL, }; diff --git a/tests/storagevolxml2argvdata/qcow2-nocapacity-convert-prealloc= .argv b/tests/storagevolxml2argvdata/qcow2-nocapacity-convert-prealloc.argv index 9073b1b16..b151b9401 100644 --- a/tests/storagevolxml2argvdata/qcow2-nocapacity-convert-prealloc.argv +++ b/tests/storagevolxml2argvdata/qcow2-nocapacity-convert-prealloc.argv @@ -1,4 +1,4 @@ qemu-img convert -f raw -O qcow2 \ --o encryption=3Don,preallocation=3Dmetadata \ +-o encryption=3Don,preallocation=3Dfalloc \ /var/lib/libvirt/images/sparse.img \ /var/lib/libvirt/images/OtherDemo.img --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list