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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3C49AB73A for ; Wed, 9 Aug 2023 16:01:14 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1FDB61635D for ; Wed, 9 Aug 2023 16:01:14 +0200 (CEST) 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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 9 Aug 2023 16:01:13 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C990F43C5F for ; Wed, 9 Aug 2023 16:01:12 +0200 (CEST) From: Filip Schauer To: pve-devel@lists.proxmox.com Date: Wed, 9 Aug 2023 16:01:05 +0200 Message-Id: <20230809140105.97858-1-f.schauer@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.001 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 Subject: [pve-devel] [PATCH v3 qemu] fix #1534: vma: Add extract filter for disk 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, 09 Aug 2023 14:01:14 -0000 Add a filter to the "vma extract" command. A comma seperated list of disk images that should be extracted can be passed with the "-d" option. Example to extract an IDE drive and an SCSI drive from vzdump.vma: vma extract vzdump.vma -d "drive-ide0,drive-scsi0" extractdir Signed-off-by: Filip Schauer --- Changes since v2: * Rename filter to drive-list * Rename the "-f" option to "-d" * Match exact drive names only instead of prefixes * Fix disk images not being renamed when no filter is given ...VE-Backup-add-vma-backup-format-code.patch | 47 +++++++++++++++---- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch index 8471a6f..5f67435 100644 --- a/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch +++ b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch @@ -1738,7 +1738,7 @@ new file mode 100644 index 0000000000..304f02bc84 --- /dev/null +++ b/vma.c -@@ -0,0 +1,878 @@ +@@ -0,0 +1,909 @@ +/* + * VMA: Virtual Machine Archive + * @@ -1772,7 +1772,7 @@ index 0000000000..304f02bc84 + "vma list \n" + "vma config [-c config]\n" + "vma create [-c config] pathname ...\n" -+ "vma extract [-r ] \n" ++ "vma extract [-d ] [-r ] \n" + "vma verify [-v]\n" + ; + @@ -1917,9 +1917,10 @@ index 0000000000..304f02bc84 + const char *filename; + const char *dirname; + const char *readmap = NULL; ++ const char *drive_list = NULL; + + for (;;) { -+ c = getopt(argc, argv, "hvr:"); ++ c = getopt(argc, argv, "hvd:r:"); + if (c == -1) { + break; + } @@ -1928,6 +1929,9 @@ index 0000000000..304f02bc84 + case 'h': + help(); + break; ++ case 'f': ++ drive_list = optarg; ++ break; + case 'r': + readmap = optarg; + break; @@ -2064,12 +2068,12 @@ index 0000000000..304f02bc84 + + int i; + int vmstate_fd = -1; -+ guint8 vmstate_stream = 0; ++ bool drive_rename_bitmap[255]; ++ memset(drive_rename_bitmap, 0, sizeof(drive_rename_bitmap)); + + for (i = 1; i < 255; i++) { + VmaDeviceInfo *di = vma_reader_get_device_info(vmar, i); + if (di && (strcmp(di->devname, "vmstate") == 0)) { -+ vmstate_stream = i; + char *statefn = g_strdup_printf("%s/vmstate.bin", dirname); + vmstate_fd = open(statefn, O_WRONLY|O_CREAT|O_EXCL, 0644); + if (vmstate_fd < 0) { @@ -2089,7 +2093,34 @@ index 0000000000..304f02bc84 + + BlockBackend *blk = NULL; + -+ if (readmap) { ++ if (drive_list) { ++ skip = true; ++ size_t devname_len = strlen(di->devname); ++ const char *token = drive_list; ++ while (*token) { ++ const char *comma = strchr(token, ','); ++ if (comma == NULL) { ++ comma = token + strlen(token); ++ } ++ ++ size_t token_len = comma - token; ++ if (token_len == devname_len && strncmp(token, di->devname, token_len) == 0) { ++ skip = false; ++ drive_rename_bitmap[i] = true; ++ break; ++ } ++ ++ if (*comma == '\0') { ++ break; ++ } ++ ++ token = comma + 1; ++ } ++ } else { ++ drive_rename_bitmap[i] = true; ++ } ++ ++ if (!skip && readmap) { + RestoreMap *map; + map = (RestoreMap *)g_hash_table_lookup(devmap, di->devname); + if (map == NULL) { @@ -2102,7 +2133,7 @@ index 0000000000..304f02bc84 + cache = map->cache; + write_zero = map->write_zero; + skip = map->skip; -+ } else { ++ } else if (!skip) { + devfn = g_strdup_printf("%s/tmp-disk-%s.raw", + dirname, di->devname); + printf("DEVINFO %s %zd\n", devfn, di->size); @@ -2190,7 +2221,7 @@ index 0000000000..304f02bc84 + if (!readmap) { + for (i = 1; i < 255; i++) { + VmaDeviceInfo *di = vma_reader_get_device_info(vmar, i); -+ if (di && (i != vmstate_stream)) { ++ if (di && drive_rename_bitmap[i]) { + char *tmpfn = g_strdup_printf("%s/tmp-disk-%s.raw", + dirname, di->devname); + char *fn = g_strdup_printf("%s/disk-%s.raw", -- 2.39.2