]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/pve/0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
update submodule and patches to 7.2.0
[pve-qemu.git] / debian / patches / pve / 0012-PVE-Up-qemu-img-dd-add-n-skip_create.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Alexandre Derumier <aderumier@odiso.com>
3 Date: Mon, 6 Apr 2020 12:16:42 +0200
4 Subject: [PATCH] PVE: [Up] qemu-img dd: add -n skip_create
5
6 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
7 [FE: fix getopt-string + add documentation]
8 Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
9 ---
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(-)
14
15 diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
16 index 15aeddc6d8..5e713e231d 100644
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
51 diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
52 index d1616c045a..b5b0bb4467 100644
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,
67 diff --git a/qemu-img.c b/qemu-img.c
68 index c1306385a8..59c403373b 100644
69 --- a/qemu-img.c
70 +++ b/qemu-img.c
71 @@ -4954,7 +4954,7 @@ static int img_dd(int argc, char **argv)
72 const char *fmt = NULL;
73 int64_t size = 0, readsize = 0;
74 int64_t 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,
80 @@ -4992,7 +4992,7 @@ static int img_dd(int argc, char **argv)
81 { 0, 0, 0, 0 }
82 };
83
84 - while ((c = getopt_long(argc, argv, ":hf:O:U", long_options, NULL))) {
85 + while ((c = getopt_long(argc, argv, ":hf:O:Un", long_options, NULL))) {
86 if (c == EOF) {
87 break;
88 }
89 @@ -5012,6 +5012,9 @@ static int img_dd(int argc, char **argv)
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;
99 @@ -5142,13 +5145,15 @@ static int img_dd(int argc, char **argv)
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,