]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
update submodule and patches to 7.1.0
[pve-qemu.git] / debian / patches / pve / 0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
CommitLineData
46598e97
AD
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Alexandre Derumier <aderumier@odiso.com>
83faa3fe 3Date: Mon, 6 Apr 2020 12:16:42 +0200
d7f4e01a 4Subject: [PATCH] PVE: [Up] qemu-img dd: add -n skip_create
46598e97 5
b855dce7 6Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
107132be
FE
7[FE: fix getopt-string + add documentation]
8Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
46598e97 9---
107132be
FE
10 docs/tools/qemu-img.rst | 11 ++++++++++-
11 qemu-img-cmds.hx | 4 ++--
12 qemu-img.c | 23 ++++++++++++++---------
13 3 files changed, 26 insertions(+), 12 deletions(-)
46598e97 14
107132be 15diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
5b15e2ec 16index 85a6e05b35..699229eef6 100644
107132be
FE
17--- a/docs/tools/qemu-img.rst
18+++ b/docs/tools/qemu-img.rst
19@@ -208,6 +208,10 @@ Parameters to convert subcommand:
20
21 Parameters to dd subcommand:
22
23+.. option:: -n
24+
25+ Skip the creation of the target volume
26+
27 .. program:: qemu-img-dd
28
29 .. option:: bs=BLOCK_SIZE
30@@ -488,7 +492,7 @@ Command description:
31 it doesn't need to be specified separately in this case.
32
33
34-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT
35+.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [-n] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] if=INPUT of=OUTPUT
36
37 dd copies from *INPUT* file to *OUTPUT* file converting it from
38 *FMT* format to *OUTPUT_FMT* format.
39@@ -499,6 +503,11 @@ Command description:
40
41 The size syntax is similar to :manpage:`dd(1)`'s size syntax.
42
43+ If the ``-n`` option is specified, the target volume creation will be
44+ skipped. This is useful for formats such as ``rbd`` if the target
45+ volume has already been created with site specific options that cannot
46+ be supplied through ``qemu-img``.
47+
48 .. option:: info [--object OBJECTDEF] [--image-opts] [-f FMT] [--output=OFMT] [--backing-chain] [-U] FILENAME
49
50 Give information about the disk image *FILENAME*. Use it in
51diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
dc9827a6 52index d1616c045a..b5b0bb4467 100644
107132be
FE
53--- a/qemu-img-cmds.hx
54+++ b/qemu-img-cmds.hx
55@@ -58,9 +58,9 @@ SRST
56 ERST
57
58 DEF("dd", img_dd,
59- "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output")
60+ "dd [--image-opts] [-U] [-f fmt] [-O output_fmt] [-n] [bs=block_size] [count=blocks] [skip=blocks] [osize=output_size] if=input of=output")
61 SRST
62-.. option:: dd [--image-opts] [-U] [-f FMT] [-O OUTPUT_FMT] [bs=BLOCK_SIZE] [count=BLOCKS] [skip=BLOCKS] [osize=OUTPUT_SIZE] if=INPUT of=OUTPUT
63+.. 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
64 ERST
65
66 DEF("info", img_info,
46598e97 67diff --git a/qemu-img.c b/qemu-img.c
5b15e2ec 68index 14594d44b6..c6b4a5567d 100644
46598e97
AD
69--- a/qemu-img.c
70+++ b/qemu-img.c
5b15e2ec 71@@ -4951,7 +4951,7 @@ static int img_dd(int argc, char **argv)
46598e97
AD
72 const char *fmt = NULL;
73 int64_t size = 0, readsize = 0;
74 int64_t block_count = 0, out_pos, in_pos;
75- bool force_share = false;
76+ bool force_share = false, skip_create = false;
77 struct DdInfo dd = {
78 .flags = 0,
79 .count = 0,
5b15e2ec 80@@ -4989,7 +4989,7 @@ static int img_dd(int argc, char **argv)
46598e97
AD
81 { 0, 0, 0, 0 }
82 };
83
84- while ((c = getopt_long(argc, argv, ":hf:O:U", long_options, NULL))) {
107132be 85+ while ((c = getopt_long(argc, argv, ":hf:O:Un", long_options, NULL))) {
46598e97
AD
86 if (c == EOF) {
87 break;
88 }
5b15e2ec 89@@ -5009,6 +5009,9 @@ static int img_dd(int argc, char **argv)
46598e97
AD
90 case 'h':
91 help();
92 break;
93+ case 'n':
94+ skip_create = true;
95+ break;
96 case 'U':
97 force_share = true;
98 break;
5b15e2ec 99@@ -5139,13 +5142,15 @@ static int img_dd(int argc, char **argv)
46598e97
AD
100 size - in.bsz * in.offset, &error_abort);
101 }
102
103- ret = bdrv_create(drv, out.filename, opts, &local_err);
104- if (ret < 0) {
105- error_reportf_err(local_err,
106- "%s: error while creating output image: ",
107- out.filename);
108- ret = -1;
109- goto out;
110+ if (!skip_create) {
111+ ret = bdrv_create(drv, out.filename, opts, &local_err);
112+ if (ret < 0) {
113+ error_reportf_err(local_err,
114+ "%s: error while creating output image: ",
115+ out.filename);
116+ ret = -1;
117+ goto out;
118+ }
119 }
120
121 /* TODO, we can't honour --image-opts for the target,