Commit 61fce45f12964d8775313e3c7f56318bac913902
1 parent
396f9297
qemu-img: set encrypted disk image password (Laurent Vivier)
This patch modify qemu-img to ask and set a password when an encrypted disk image is created. Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net> Signed-off-by: Anthony Liguori <anthony@codemonkey.ws> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4977 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
4 additions
and
1 deletions
qemu-img.c
| ... | ... | @@ -208,6 +208,7 @@ static int img_create(int argc, char **argv) |
| 208 | 208 | uint64_t size; |
| 209 | 209 | const char *p; |
| 210 | 210 | BlockDriver *drv; |
| 211 | + BlockDriverState *bs; | |
| 211 | 212 | |
| 212 | 213 | flags = 0; |
| 213 | 214 | for(;;) { |
| ... | ... | @@ -237,7 +238,6 @@ static int img_create(int argc, char **argv) |
| 237 | 238 | filename = argv[optind++]; |
| 238 | 239 | size = 0; |
| 239 | 240 | if (base_filename) { |
| 240 | - BlockDriverState *bs; | |
| 241 | 241 | bs = bdrv_new_open(base_filename, NULL); |
| 242 | 242 | bdrv_get_geometry(bs, &size); |
| 243 | 243 | size *= 512; |
| ... | ... | @@ -279,6 +279,9 @@ static int img_create(int argc, char **argv) |
| 279 | 279 | error("Error while formatting"); |
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | + /* to set password */ | |
| 283 | + bs = bdrv_new_open(filename, NULL); | |
| 284 | + bdrv_delete(bs); | |
| 282 | 285 | return 0; |
| 283 | 286 | } |
| 284 | 287 | ... | ... |