Commit 91a073a975b220447eb64263690f49a5494347cb

Authored by Kevin Wolf
Committed by Anthony Liguori
1 parent a980c98c

Drop bdrv_create2

This patch converts the remaining users of bdrv_create2 to bdrv_create and
removes the now unused function.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing 2 changed files with 24 additions and 42 deletions
@@ -184,42 +184,6 @@ BlockDriver *bdrv_find_format(const char *format_name) @@ -184,42 +184,6 @@ BlockDriver *bdrv_find_format(const char *format_name)
184 return NULL; 184 return NULL;
185 } 185 }
186 186
187 -int bdrv_create2(BlockDriver *drv,  
188 - const char *filename, int64_t size_in_sectors,  
189 - const char *backing_file, const char *backing_format,  
190 - int flags)  
191 -{  
192 - QEMUOptionParameter *options;  
193 -  
194 - options = parse_option_parameters("", drv->create_options, NULL);  
195 -  
196 - // Process flags  
197 - if (flags & ~(BLOCK_FLAG_ENCRYPT | BLOCK_FLAG_COMPAT6 | BLOCK_FLAG_COMPRESS)) {  
198 - return -ENOTSUP;  
199 - }  
200 -  
201 - if (flags & BLOCK_FLAG_ENCRYPT) {  
202 - set_option_parameter_int(options, BLOCK_OPT_ENCRYPT, 1);  
203 - }  
204 - if (flags & BLOCK_FLAG_COMPAT6) {  
205 - set_option_parameter_int(options, BLOCK_OPT_COMPAT6, 1);  
206 - }  
207 -  
208 - // Add size to options  
209 - set_option_parameter_int(options, BLOCK_OPT_SIZE, size_in_sectors * 512);  
210 -  
211 - // Backing files  
212 - if ((backing_file != NULL && set_option_parameter(options,  
213 - BLOCK_OPT_BACKING_FILE, backing_file))  
214 - || (backing_format != NULL && set_option_parameter(options,  
215 - BLOCK_OPT_BACKING_FMT, backing_format)))  
216 - {  
217 - return -ENOTSUP;  
218 - }  
219 -  
220 - return bdrv_create(drv, filename, options);  
221 -}  
222 -  
223 int bdrv_create(BlockDriver *drv, const char* filename, 187 int bdrv_create(BlockDriver *drv, const char* filename,
224 QEMUOptionParameter *options) 188 QEMUOptionParameter *options)
225 { 189 {
@@ -392,6 +356,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, @@ -392,6 +356,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
392 BlockDriverState *bs1; 356 BlockDriverState *bs1;
393 int64_t total_size; 357 int64_t total_size;
394 int is_protocol = 0; 358 int is_protocol = 0;
  359 + BlockDriver *bdrv_qcow2;
  360 + QEMUOptionParameter *options;
395 361
396 /* if snapshot, we create a temporary backing file and open it 362 /* if snapshot, we create a temporary backing file and open it
397 instead of opening 'filename' directly */ 363 instead of opening 'filename' directly */
@@ -419,14 +385,23 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, @@ -419,14 +385,23 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
419 else 385 else
420 realpath(filename, backing_filename); 386 realpath(filename, backing_filename);
421 387
422 - ret = bdrv_create2(bdrv_find_format("qcow2"), tmp_filename,  
423 - total_size, backing_filename,  
424 - (drv ? drv->format_name : NULL), 0); 388 + bdrv_qcow2 = bdrv_find_format("qcow2");
  389 + options = parse_option_parameters("", bdrv_qcow2->create_options, NULL);
  390 +
  391 + set_option_parameter_int(options, BLOCK_OPT_SIZE, total_size * 512);
  392 + set_option_parameter(options, BLOCK_OPT_BACKING_FILE, backing_filename);
  393 + if (drv) {
  394 + set_option_parameter(options, BLOCK_OPT_BACKING_FMT,
  395 + drv->format_name);
  396 + }
  397 +
  398 + ret = bdrv_create(bdrv_qcow2, tmp_filename, options);
425 if (ret < 0) { 399 if (ret < 0) {
426 return ret; 400 return ret;
427 } 401 }
  402 +
428 filename = tmp_filename; 403 filename = tmp_filename;
429 - drv = bdrv_find_format("qcow2"); 404 + drv = bdrv_qcow2;
430 bs->is_temporary = 1; 405 bs->is_temporary = 1;
431 } 406 }
432 407
block/vvfat.c
@@ -2770,6 +2770,8 @@ static BlockDriver vvfat_write_target = { @@ -2770,6 +2770,8 @@ static BlockDriver vvfat_write_target = {
2770 2770
2771 static int enable_write_target(BDRVVVFATState *s) 2771 static int enable_write_target(BDRVVVFATState *s)
2772 { 2772 {
  2773 + BlockDriver *bdrv_qcow;
  2774 + QEMUOptionParameter *options;
2773 int size = sector2cluster(s, s->sector_count); 2775 int size = sector2cluster(s, s->sector_count);
2774 s->used_clusters = calloc(size, 1); 2776 s->used_clusters = calloc(size, 1);
2775 2777
@@ -2777,8 +2779,13 @@ static int enable_write_target(BDRVVVFATState *s) @@ -2777,8 +2779,13 @@ static int enable_write_target(BDRVVVFATState *s)
2777 2779
2778 s->qcow_filename = qemu_malloc(1024); 2780 s->qcow_filename = qemu_malloc(1024);
2779 get_tmp_filename(s->qcow_filename, 1024); 2781 get_tmp_filename(s->qcow_filename, 1024);
2780 - if (bdrv_create2(bdrv_find_format("qcow"),  
2781 - s->qcow_filename, s->sector_count, "fat:", NULL, 0) < 0) 2782 +
  2783 + bdrv_qcow = bdrv_find_format("qcow");
  2784 + options = parse_option_parameters("", bdrv_qcow->create_options, NULL);
  2785 + set_option_parameter_int(options, BLOCK_OPT_SIZE, s->sector_count * 512);
  2786 + set_option_parameter(options, BLOCK_OPT_BACKING_FILE, "fat:");
  2787 +
  2788 + if (bdrv_create(bdrv_qcow, s->qcow_filename, options) < 0)
2782 return -1; 2789 return -1;
2783 s->qcow = bdrv_new(""); 2790 s->qcow = bdrv_new("");
2784 if (s->qcow == NULL || bdrv_open(s->qcow, s->qcow_filename, 0) < 0) 2791 if (s->qcow == NULL || bdrv_open(s->qcow, s->qcow_filename, 0) < 0)