blockdev.c (56105bd5c0b6d7ac62b34c8b8f496df8f7bd9d92) | blockdev.c (6db5f5d68e2ffc430ba0511e23fc36c7363510f1) |
---|---|
1/* 2 * QEMU host block devices 3 * 4 * Copyright (c) 2003-2008 Fabrice Bellard 5 * 6 * This work is licensed under the terms of the GNU GPL, version 2 or 7 * later. See the COPYING file in the top-level directory. 8 * --- 326 unchanged lines hidden (view full) --- 335 int snapshot = 0; 336 bool copy_on_read; 337 int ret; 338 Error *error = NULL; 339 QemuOpts *opts; 340 QDict *bs_opts; 341 const char *id; 342 bool has_driver_specific_opts; | 1/* 2 * QEMU host block devices 3 * 4 * Copyright (c) 2003-2008 Fabrice Bellard 5 * 6 * This work is licensed under the terms of the GNU GPL, version 2 or 7 * later. See the COPYING file in the top-level directory. 8 * --- 326 unchanged lines hidden (view full) --- 335 int snapshot = 0; 336 bool copy_on_read; 337 int ret; 338 Error *error = NULL; 339 QemuOpts *opts; 340 QDict *bs_opts; 341 const char *id; 342 bool has_driver_specific_opts; |
343 BlockDriver *drv = NULL; |
|
343 344 translation = BIOS_ATA_TRANSLATION_AUTO; 345 media = MEDIA_DISK; 346 347 /* Check common options by copying from all_opts to opts, all other options 348 * are stored in bs_opts. */ 349 id = qemu_opts_id(all_opts); 350 opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error); --- 129 unchanged lines hidden (view full) --- 480 if ((buf = qemu_opt_get(opts, "format")) != NULL) { 481 if (is_help_option(buf)) { 482 error_printf("Supported formats:"); 483 bdrv_iterate_format(bdrv_format_print, NULL); 484 error_printf("\n"); 485 return NULL; 486 } 487 | 344 345 translation = BIOS_ATA_TRANSLATION_AUTO; 346 media = MEDIA_DISK; 347 348 /* Check common options by copying from all_opts to opts, all other options 349 * are stored in bs_opts. */ 350 id = qemu_opts_id(all_opts); 351 opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error); --- 129 unchanged lines hidden (view full) --- 481 if ((buf = qemu_opt_get(opts, "format")) != NULL) { 482 if (is_help_option(buf)) { 483 error_printf("Supported formats:"); 484 bdrv_iterate_format(bdrv_format_print, NULL); 485 error_printf("\n"); 486 return NULL; 487 } 488 |
488 qdict_put(bs_opts, "driver", qstring_from_str(buf)); | 489 drv = bdrv_find_whitelisted_format(buf, ro); 490 if (!drv) { 491 error_report("'%s' invalid format", buf); 492 return NULL; 493 } |
489 } 490 491 /* disk I/O throttling */ 492 io_limits.bps[BLOCK_IO_LIMIT_TOTAL] = 493 qemu_opt_get_number(opts, "throttling.bps-total", 0); 494 io_limits.bps[BLOCK_IO_LIMIT_READ] = 495 qemu_opt_get_number(opts, "throttling.bps-read", 0); 496 io_limits.bps[BLOCK_IO_LIMIT_WRITE] = --- 198 unchanged lines hidden (view full) --- 695 696 bdrv_flags |= ro ? 0 : BDRV_O_RDWR; 697 698 if (ro && copy_on_read) { 699 error_report("warning: disabling copy_on_read on read-only drive"); 700 } 701 702 QINCREF(bs_opts); | 494 } 495 496 /* disk I/O throttling */ 497 io_limits.bps[BLOCK_IO_LIMIT_TOTAL] = 498 qemu_opt_get_number(opts, "throttling.bps-total", 0); 499 io_limits.bps[BLOCK_IO_LIMIT_READ] = 500 qemu_opt_get_number(opts, "throttling.bps-read", 0); 501 io_limits.bps[BLOCK_IO_LIMIT_WRITE] = --- 198 unchanged lines hidden (view full) --- 700 701 bdrv_flags |= ro ? 0 : BDRV_O_RDWR; 702 703 if (ro && copy_on_read) { 704 error_report("warning: disabling copy_on_read on read-only drive"); 705 } 706 707 QINCREF(bs_opts); |
703 ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, NULL); | 708 ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, drv); |
704 705 if (ret < 0) { 706 if (ret == -EMEDIUMTYPE) { 707 error_report("could not open disk image %s: not in %s format", | 709 710 if (ret < 0) { 711 if (ret == -EMEDIUMTYPE) { 712 error_report("could not open disk image %s: not in %s format", |
708 file ?: dinfo->id, qdict_get_str(bs_opts, "driver")); | 713 file ?: dinfo->id, drv ? drv->format_name : 714 qdict_get_str(bs_opts, "driver")); |
709 } else { 710 error_report("could not open disk image %s: %s", 711 file ?: dinfo->id, strerror(-ret)); 712 } 713 goto err; 714 } 715 716 if (bdrv_key_required(dinfo->bdrv)) --- 1411 unchanged lines hidden --- | 715 } else { 716 error_report("could not open disk image %s: %s", 717 file ?: dinfo->id, strerror(-ret)); 718 } 719 goto err; 720 } 721 722 if (bdrv_key_required(dinfo->bdrv)) --- 1411 unchanged lines hidden --- |