From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id BB2CD60741 for ; Wed, 16 Feb 2022 14:17:53 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AF6D64C35 for ; Wed, 16 Feb 2022 14:17:53 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id EB9F94C2B for ; Wed, 16 Feb 2022 14:17:52 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id BD8EB46D63 for ; Wed, 16 Feb 2022 14:17:52 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Wed, 16 Feb 2022 14:17:48 +0100 Message-Id: <20220216131748.87052-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.134 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [RFC qemu] vma: create: support 64KiB-unaligned input images X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Feb 2022 13:17:53 -0000 which fixes backing up templates with such disks in PVE, for example efitype=4m EFI disks on a file-based storage (size = 540672). If there is not enough left to read, blk_co_preadv will return -EIO, so limit the size in the last iteration. For writing, an unaligned end is already handled correctly. The call to memset is not strictly necessary, because writing also checks that it doesn't write data beyond the end of the image. But there are two reasons to do it: 1. It's cleaner that way. 2. It allows detecting when the final piece is all zeroes, which might not happen if the buffer still contains data from the previous iteration. Signed-off-by: Fabian Ebner --- RFC, because I'm no vma expert :) ...VE-Backup-add-vma-backup-format-code.patch | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/debian/patches/pve/0025-PVE-Backup-add-vma-backup-format-code.patch b/debian/patches/pve/0025-PVE-Backup-add-vma-backup-format-code.patch index c4ed5bb..a875253 100644 --- a/debian/patches/pve/0025-PVE-Backup-add-vma-backup-format-code.patch +++ b/debian/patches/pve/0025-PVE-Backup-add-vma-backup-format-code.patch @@ -4,16 +4,17 @@ Date: Mon, 6 Apr 2020 12:16:57 +0200 Subject: [PATCH] PVE-Backup: add vma backup format code Signed-off-by: Thomas Lamprecht -[FE: create: register all streams before entering coroutines] +[FE: create: register all streams before entering coroutines + fix reading 64KiB-unalinged images] Signed-off-by: Fabian Ebner --- block/meson.build | 2 + meson.build | 5 + vma-reader.c | 857 ++++++++++++++++++++++++++++++++++++++++++++++ vma-writer.c | 790 ++++++++++++++++++++++++++++++++++++++++++ - vma.c | 851 +++++++++++++++++++++++++++++++++++++++++++++ + vma.c | 857 ++++++++++++++++++++++++++++++++++++++++++++++ vma.h | 150 ++++++++ - 6 files changed, 2655 insertions(+) + 6 files changed, 2661 insertions(+) create mode 100644 vma-reader.c create mode 100644 vma-writer.c create mode 100644 vma.c @@ -1716,10 +1717,10 @@ index 0000000000..11d8321ffd +} diff --git a/vma.c b/vma.c new file mode 100644 -index 0000000000..df542b7732 +index 0000000000..abfcc534b8 --- /dev/null +++ b/vma.c -@@ -0,0 +1,851 @@ +@@ -0,0 +1,857 @@ +/* + * VMA: Virtual Machine Archive + * @@ -2251,7 +2252,7 @@ index 0000000000..df542b7732 + struct iovec iov; + QEMUIOVector qiov; + -+ int64_t start, end; ++ int64_t start, end, readlen; + int ret = 0; + + unsigned char *buf = blk_blockalign(job->target, VMA_CLUSTER_SIZE); @@ -2265,8 +2266,14 @@ index 0000000000..df542b7732 + iov.iov_len = VMA_CLUSTER_SIZE; + qemu_iovec_init_external(&qiov, &iov, 1); + ++ if (start + 1 == end) { ++ memset(buf, 0, VMA_CLUSTER_SIZE); ++ readlen = job->len - start * VMA_CLUSTER_SIZE; ++ } else { ++ readlen = VMA_CLUSTER_SIZE; ++ } + ret = blk_co_preadv(job->target, start * VMA_CLUSTER_SIZE, -+ VMA_CLUSTER_SIZE, &qiov, 0); ++ readlen, &qiov, 0); + if (ret < 0) { + vma_writer_set_error(job->vmaw, "read error", -1); + goto out; -- 2.30.2