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 1B56A6215E for ; Fri, 11 Feb 2022 10:25:11 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1870F263C7 for ; Fri, 11 Feb 2022 10:24:41 +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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 2FBB5263BD for ; Fri, 11 Feb 2022 10:24:40 +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 0A51D46DEC for ; Fri, 11 Feb 2022 10:24:40 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Fri, 11 Feb 2022 10:24:35 +0100 Message-Id: <20220211092435.84731-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220211092435.84731-1-f.ebner@proxmox.com> References: <20220211092435.84731-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.135 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] [PATCH v2 qemu 3/3] add patch for loading a snapshot with qemu-img dd 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: Fri, 11 Feb 2022 09:25:11 -0000 Will be used when cloning from a qcow2 efidisk. Signed-off-by: Fabian Ebner --- New in v2. ...-add-l-option-for-loading-a-snapshot.patch | 129 ++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 130 insertions(+) create mode 100644 debian/patches/pve/0049-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch diff --git a/debian/patches/pve/0049-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch b/debian/patches/pve/0049-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch new file mode 100644 index 0000000..f239cd4 --- /dev/null +++ b/debian/patches/pve/0049-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch @@ -0,0 +1,129 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Fabian Ebner +Date: Mon, 7 Feb 2022 14:21:01 +0100 +Subject: [PATCH] qemu-img: dd: add -l option for loading a snapshot + +Signed-off-by: Fabian Ebner +--- + docs/tools/qemu-img.rst | 6 +++--- + qemu-img-cmds.hx | 4 ++-- + qemu-img.c | 33 +++++++++++++++++++++++++++++++-- + 3 files changed, 36 insertions(+), 7 deletions(-) + +diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst +index a49badb158..1039aec01c 100644 +--- a/docs/tools/qemu-img.rst ++++ b/docs/tools/qemu-img.rst +@@ -492,10 +492,10 @@ Command description: + it doesn't need to be specified separately in this case. + + +-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT ++.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [-l SNAPSHOT_PARAM] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT + +- dd copies from *INPUT* file to *OUTPUT* file converting it from +- *FMT* format to *OUTPUT_FMT* format. ++ dd copies from *INPUT* file or snapshot *SNAPSHOT_PARAM* to *OUTPUT* file ++ converting it from *FMT* format to *OUTPUT_FMT* format. + + The data is by default read and written using blocks of 512 bytes but can be + modified by specifying *BLOCK_SIZE*. If count=\ *BLOCKS* is specified +diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx +index f3b2b1b4de..e77ed9347f 100644 +--- a/qemu-img-cmds.hx ++++ b/qemu-img-cmds.hx +@@ -58,9 +58,9 @@ SRST + ERST + + DEF("dd", img_dd, +- "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [-n] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output") ++ "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [-n] [-l snapshot_param] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output") + SRST +-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] [osize=OUTPUT_SIZE] if=INPUT of=OUTPUT ++.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [-l SNAPSHOT_PARAM] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] [osize=OUTPUT_SIZE] if=INPUT of=OUTPUT + ERST + + DEF("info", img_info, +diff --git a/qemu-img.c b/qemu-img.c +index 015d6d2ce4..7031195e32 100644 +--- a/qemu-img.c ++++ b/qemu-img.c +@@ -4922,6 +4922,7 @@ static int img_dd(int argc, char **argv) + BlockDriver *drv = NULL, *proto_drv = NULL; + BlockBackend *blk1 = NULL, *blk2 = NULL; + QemuOpts *opts = NULL; ++ QemuOpts *sn_opts = NULL; + QemuOptsList *create_opts = NULL; + Error *local_err = NULL; + bool image_opts = false; +@@ -4931,6 +4932,7 @@ static int img_dd(int argc, char **argv) + int64_t size = 0, readsize = 0; + int64_t block_count = 0, out_pos, in_pos; + bool force_share = false, skip_create = false; ++ const char *snapshot_name = NULL; + struct DdInfo dd = { + .flags = 0, + .count = 0, +@@ -4968,7 +4970,7 @@ static int img_dd(int argc, char **argv) + { 0, 0, 0, 0 } + }; + +- while ((c = getopt_long(argc, argv, ":hf:O:Un", long_options, NULL))) { ++ while ((c = getopt_long(argc, argv, ":hf:O:l:Un", long_options, NULL))) { + if (c == EOF) { + break; + } +@@ -4991,6 +4993,19 @@ static int img_dd(int argc, char **argv) + case 'n': + skip_create = true; + break; ++ case 'l': ++ if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) { ++ sn_opts = qemu_opts_parse_noisily(&internal_snapshot_opts, ++ optarg, false); ++ if (!sn_opts) { ++ error_report("Failed in parsing snapshot param '%s'", ++ optarg); ++ goto out; ++ } ++ } else { ++ snapshot_name = optarg; ++ } ++ break; + case 'U': + force_share = true; + break; +@@ -5050,11 +5065,24 @@ static int img_dd(int argc, char **argv) + if (dd.flags & C_IF) { + blk1 = img_open(image_opts, in.filename, fmt, 0, false, false, + force_share); +- + if (!blk1) { + ret = -1; + goto out; + } ++ if (sn_opts) { ++ bdrv_snapshot_load_tmp(blk_bs(blk1), ++ qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID), ++ qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME), ++ &local_err); ++ } else if (snapshot_name != NULL) { ++ bdrv_snapshot_load_tmp_by_id_or_name(blk_bs(blk1), snapshot_name, ++ &local_err); ++ } ++ if (local_err) { ++ error_reportf_err(local_err, "Failed to load snapshot: "); ++ ret = -1; ++ goto out; ++ } + } + + if (dd.flags & C_OSIZE) { +@@ -5203,6 +5231,7 @@ static int img_dd(int argc, char **argv) + out: + g_free(arg); + qemu_opts_del(opts); ++ qemu_opts_del(sn_opts); + qemu_opts_free(create_opts); + blk_unref(blk1); + blk_unref(blk2); diff --git a/debian/patches/series b/debian/patches/series index daaff7c..a02a2d7 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -61,3 +61,4 @@ pve/0045-block-io-accept-NULL-qiov-in-bdrv_pad_request.patch pve/0046-block-add-alloc-track-driver.patch pve/0047-PVE-whitelist-invalid-QAPI-names-for-backwards-compa.patch pve/0048-PVE-savevm-async-register-yank-before-migration_inco.patch +pve/0049-qemu-img-dd-add-l-option-for-loading-a-snapshot.patch -- 2.30.2