blockdev.c (82a402e99f3f8c6177528ad6d561bf07ff6ee606) blockdev.c (465bee1da82e43f18d10c43cc7566d0284ad13a9)
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 *

--- 329 unchanged lines hidden (view full) ---

338 ThrottleConfig cfg;
339 int snapshot = 0;
340 bool copy_on_read;
341 int ret;
342 Error *error = NULL;
343 QemuOpts *opts;
344 const char *id;
345 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 *

--- 329 unchanged lines hidden (view full) ---

338 ThrottleConfig cfg;
339 int snapshot = 0;
340 bool copy_on_read;
341 int ret;
342 Error *error = NULL;
343 QemuOpts *opts;
344 const char *id;
345 bool has_driver_specific_opts;
346 BlockdevDetectZeroesOptions detect_zeroes;
346 BlockDriver *drv = NULL;
347
348 /* Check common options by copying from bs_opts to opts, all other options
349 * stay in bs_opts for processing by bdrv_open(). */
350 id = qdict_get_try_str(bs_opts, "id");
351 opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error);
352 if (error) {
353 error_propagate(errp, error);

--- 112 unchanged lines hidden (view full) ---

466 if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
467 on_read_error = parse_block_error_action(buf, 1, &error);
468 if (error) {
469 error_propagate(errp, error);
470 goto early_err;
471 }
472 }
473
347 BlockDriver *drv = NULL;
348
349 /* Check common options by copying from bs_opts to opts, all other options
350 * stay in bs_opts for processing by bdrv_open(). */
351 id = qdict_get_try_str(bs_opts, "id");
352 opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error);
353 if (error) {
354 error_propagate(errp, error);

--- 112 unchanged lines hidden (view full) ---

467 if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
468 on_read_error = parse_block_error_action(buf, 1, &error);
469 if (error) {
470 error_propagate(errp, error);
471 goto early_err;
472 }
473 }
474
475 detect_zeroes =
476 parse_enum_option(BlockdevDetectZeroesOptions_lookup,
477 qemu_opt_get(opts, "detect-zeroes"),
478 BLOCKDEV_DETECT_ZEROES_OPTIONS_MAX,
479 BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF,
480 &error);
481 if (error) {
482 error_propagate(errp, error);
483 goto early_err;
484 }
485
486 if (detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP &&
487 !(bdrv_flags & BDRV_O_UNMAP)) {
488 error_setg(errp, "setting detect-zeroes to unmap is not allowed "
489 "without setting discard operation to unmap");
490 goto early_err;
491 }
492
474 /* init */
475 dinfo = g_malloc0(sizeof(*dinfo));
476 dinfo->id = g_strdup(qemu_opts_id(opts));
477 dinfo->bdrv = bdrv_new(dinfo->id, &error);
478 if (error) {
479 error_propagate(errp, error);
480 goto bdrv_new_err;
481 }
482 dinfo->bdrv->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0;
483 dinfo->bdrv->read_only = ro;
493 /* init */
494 dinfo = g_malloc0(sizeof(*dinfo));
495 dinfo->id = g_strdup(qemu_opts_id(opts));
496 dinfo->bdrv = bdrv_new(dinfo->id, &error);
497 if (error) {
498 error_propagate(errp, error);
499 goto bdrv_new_err;
500 }
501 dinfo->bdrv->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0;
502 dinfo->bdrv->read_only = ro;
503 dinfo->bdrv->detect_zeroes = detect_zeroes;
484 dinfo->refcount = 1;
485 if (serial != NULL) {
486 dinfo->serial = g_strdup(serial);
487 }
488 QTAILQ_INSERT_TAIL(&drives, dinfo, next);
489
490 bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error);
491

--- 1977 unchanged lines hidden (view full) ---

2469 },{
2470 .name = "throttling.iops-size",
2471 .type = QEMU_OPT_NUMBER,
2472 .help = "when limiting by iops max size of an I/O in bytes",
2473 },{
2474 .name = "copy-on-read",
2475 .type = QEMU_OPT_BOOL,
2476 .help = "copy read data from backing file into image file",
504 dinfo->refcount = 1;
505 if (serial != NULL) {
506 dinfo->serial = g_strdup(serial);
507 }
508 QTAILQ_INSERT_TAIL(&drives, dinfo, next);
509
510 bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error);
511

--- 1977 unchanged lines hidden (view full) ---

2489 },{
2490 .name = "throttling.iops-size",
2491 .type = QEMU_OPT_NUMBER,
2492 .help = "when limiting by iops max size of an I/O in bytes",
2493 },{
2494 .name = "copy-on-read",
2495 .type = QEMU_OPT_BOOL,
2496 .help = "copy read data from backing file into image file",
2497 },{
2498 .name = "detect-zeroes",
2499 .type = QEMU_OPT_STRING,
2500 .help = "try to optimize zero writes (off, on, unmap)",
2477 },
2478 { /* end of list */ }
2479 },
2480};
2481
2482QemuOptsList qemu_drive_opts = {
2483 .name = "drive",
2484 .head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head),
2485 .desc = {
2486 /*
2487 * no elements => accept any params
2488 * validation will happen later
2489 */
2490 { /* end of list */ }
2491 },
2492};
2501 },
2502 { /* end of list */ }
2503 },
2504};
2505
2506QemuOptsList qemu_drive_opts = {
2507 .name = "drive",
2508 .head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head),
2509 .desc = {
2510 /*
2511 * no elements => accept any params
2512 * validation will happen later
2513 */
2514 { /* end of list */ }
2515 },
2516};