Change requested in launchpad bug #1288352
[packages/centos6/qemu.git] / 0167-Don-t-require-encryption-password-for-qemu-img-info-.patch
1 From 4812a358ff2d7442c33a517a6c80d7d3c301ec56 Mon Sep 17 00:00:00 2001
2 From: "Daniel P. Berrange" <berrange@redhat.com>
3 Date: Mon, 10 Sep 2012 12:11:31 +0100
4 Subject: [PATCH] Don't require encryption password for 'qemu-img info'
5  command
6
7 The encryption password is only required if I/O is going to be
8 performed on a disk image. The 'qemu-img info' command merely
9 reports metadata, so it should not ask for a decryption password
10
11 Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 (cherry picked from commit f0536bb848ad6eb2709a7dc675f261bd160c751b)
14
15 Conflicts:
16
17         qemu-img.c
18
19 Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
20 ---
21  qemu-img.c | 21 +++++++++++----------
22  1 file changed, 11 insertions(+), 10 deletions(-)
23
24 diff --git a/qemu-img.c b/qemu-img.c
25 index b41e670..0d208e8 100644
26 --- a/qemu-img.c
27 +++ b/qemu-img.c
28 @@ -221,7 +221,8 @@ static int print_block_option_help(const char *filename, const char *fmt)
29  
30  static BlockDriverState *bdrv_new_open(const char *filename,
31                                         const char *fmt,
32 -                                       int flags)
33 +                                       int flags,
34 +                                       bool require_io)
35  {
36      BlockDriverState *bs;
37      BlockDriver *drv;
38 @@ -246,7 +247,7 @@ static BlockDriverState *bdrv_new_open(const char *filename,
39          goto fail;
40      }
41  
42 -    if (bdrv_is_encrypted(bs)) {
43 +    if (bdrv_is_encrypted(bs) && require_io) {
44          printf("Disk image '%s' is encrypted.\n", filename);
45          if (read_password(password, sizeof(password)) < 0) {
46              error_report("No password given");
47 @@ -413,7 +414,7 @@ static int img_check(int argc, char **argv)
48      }
49      filename = argv[optind++];
50  
51 -    bs = bdrv_new_open(filename, fmt, flags);
52 +    bs = bdrv_new_open(filename, fmt, flags, true);
53      if (!bs) {
54          return 1;
55      }
56 @@ -520,7 +521,7 @@ static int img_commit(int argc, char **argv)
57          return -1;
58      }
59  
60 -    bs = bdrv_new_open(filename, fmt, flags);
61 +    bs = bdrv_new_open(filename, fmt, flags, true);
62      if (!bs) {
63          return 1;
64      }
65 @@ -762,7 +763,7 @@ static int img_convert(int argc, char **argv)
66  
67      total_sectors = 0;
68      for (bs_i = 0; bs_i < bs_n; bs_i++) {
69 -        bs[bs_i] = bdrv_new_open(argv[optind + bs_i], fmt, BDRV_O_FLAGS);
70 +        bs[bs_i] = bdrv_new_open(argv[optind + bs_i], fmt, BDRV_O_FLAGS, true);
71          if (!bs[bs_i]) {
72              error_report("Could not open '%s'", argv[optind + bs_i]);
73              ret = -1;
74 @@ -881,7 +882,7 @@ static int img_convert(int argc, char **argv)
75          return -1;
76      }
77  
78 -    out_bs = bdrv_new_open(out_filename, out_fmt, flags);
79 +    out_bs = bdrv_new_open(out_filename, out_fmt, flags, true);
80      if (!out_bs) {
81          ret = -1;
82          goto out;
83 @@ -1135,7 +1136,7 @@ static int img_info(int argc, char **argv)
84      }
85      filename = argv[optind++];
86  
87 -    bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_NO_BACKING);
88 +    bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_NO_BACKING, false);
89      if (!bs) {
90          return 1;
91      }
92 @@ -1248,7 +1249,7 @@ static int img_snapshot(int argc, char **argv)
93      filename = argv[optind++];
94  
95      /* Open the image */
96 -    bs = bdrv_new_open(filename, NULL, bdrv_oflags);
97 +    bs = bdrv_new_open(filename, NULL, bdrv_oflags, true);
98      if (!bs) {
99          return 1;
100      }
101 @@ -1366,7 +1367,7 @@ static int img_rebase(int argc, char **argv)
102       * Ignore the old backing file for unsafe rebase in case we want to correct
103       * the reference to a renamed or moved backing file.
104       */
105 -    bs = bdrv_new_open(filename, fmt, flags);
106 +    bs = bdrv_new_open(filename, fmt, flags, true);
107      if (!bs) {
108          return 1;
109      }
110 @@ -1639,7 +1640,7 @@ static int img_resize(int argc, char **argv)
111      n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0);
112      qemu_opts_del(param);
113  
114 -    bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR);
115 +    bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR, true);
116      if (!bs) {
117          ret = -1;
118          goto out;
119 -- 
120 1.7.12.1
121