From patchwork Thu Aug 22 10:52:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhipeng Lu X-Patchwork-Id: 13773205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 97DFFC3DA4A for ; Thu, 22 Aug 2024 10:55:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sh5SU-0003ex-69; Thu, 22 Aug 2024 06:54:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sh5SR-0003eS-Je for qemu-devel@nongnu.org; Thu, 22 Aug 2024 06:54:23 -0400 Received: from [1.203.97.240] (helo=smtp.cecloud.com) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sh5SO-0002mz-VK for qemu-devel@nongnu.org; Thu, 22 Aug 2024 06:54:23 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.cecloud.com (Postfix) with ESMTP id 04F74900113; Thu, 22 Aug 2024 18:54:09 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-SKE-CHECKED: 1 X-ANTISPAM-LEVEL: 2 Received: from localhost.localdomain (unknown [111.48.58.10]) by smtp.cecloud.com (postfix) whith ESMTP id P1340312T281473046933872S1724324047027053_; Thu, 22 Aug 2024 18:54:08 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: luzhipeng@cestc.cn X-SENDER: luzhipeng@cestc.cn X-LOGIN-NAME: luzhipeng@cestc.cn X-FST-TO: qemu-devel@nongnu.org X-RCPT-COUNT: 6 X-LOCAL-RCPT-COUNT: 1 X-MUTI-DOMAIN-COUNT: 0 X-SENDER-IP: 111.48.58.10 X-ATTACHMENT-NUM: 0 X-UNIQUE-TAG: <87d4f5d528284d5139c9d68a5d078646> X-System-Flag: 0 From: luzhipeng To: qemu-devel Cc: Fam Zheng , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org, luzhipeng Subject: [PATCH] vmdk:truncate more one sector in init extent Date: Thu, 22 Aug 2024 18:52:37 +0800 Message-Id: <20240822105237.777-1-luzhipeng@cestc.cn> X-Mailer: git-send-email 2.34.0.windows.1 MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 1.203.97.240 (failed) Received-SPF: pass client-ip=1.203.97.240; envelope-from=luzhipeng@cestc.cn; helo=smtp.cecloud.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org issue:https://gitlab.com/qemu-project/qemu/-/issues/1357 empty vmdk only contains metadata, ovftool failed. So it allocates more one sector for empty disk. the ovftool command line: ovftool input.ovf output.ova Signed-off-by: luzhipeng --- block/vmdk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 2.39.3 diff --git a/block/vmdk.c b/block/vmdk.c index 78f6433607..283dee9b49 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2286,7 +2286,7 @@ vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool compress, goto exit; } - ret = blk_co_truncate(blk, le64_to_cpu(header.grain_offset) << 9, false, + ret = blk_co_truncate(blk, (le64_to_cpu(header.grain_offset) << 9) + BDRV_SECTOR_SIZE, + false, PREALLOC_MODE_OFF, 0, errp); if (ret < 0) { goto exit; --