block.c (3cb99f4124faeca3235bd76ba2879ad091b43a50) block.c (9ad08c44566bf4466c6263c71d43e9f7a354d4ba)
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

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

3196{
3197 int ret = -1;
3198 Error *local_err = NULL;
3199 BlockDriver *drv;
3200 QemuOpts *opts;
3201 QDict *orig_reopen_opts;
3202 char *discard = NULL;
3203 bool read_only;
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

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

3196{
3197 int ret = -1;
3198 Error *local_err = NULL;
3199 BlockDriver *drv;
3200 QemuOpts *opts;
3201 QDict *orig_reopen_opts;
3202 char *discard = NULL;
3203 bool read_only;
3204 bool drv_prepared = false;
3204
3205 assert(reopen_state != NULL);
3206 assert(reopen_state->bs->drv != NULL);
3207 drv = reopen_state->bs->drv;
3208
3209 /* This function and each driver's bdrv_reopen_prepare() remove
3210 * entries from reopen_state->options as they are processed, so
3211 * we need to make a copy of the original QDict. */

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

3280 * handler for each supported drv. */
3281 error_setg(errp, "Block format '%s' used by node '%s' "
3282 "does not support reopening files", drv->format_name,
3283 bdrv_get_device_or_node_name(reopen_state->bs));
3284 ret = -1;
3285 goto error;
3286 }
3287
3205
3206 assert(reopen_state != NULL);
3207 assert(reopen_state->bs->drv != NULL);
3208 drv = reopen_state->bs->drv;
3209
3210 /* This function and each driver's bdrv_reopen_prepare() remove
3211 * entries from reopen_state->options as they are processed, so
3212 * we need to make a copy of the original QDict. */

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

3281 * handler for each supported drv. */
3282 error_setg(errp, "Block format '%s' used by node '%s' "
3283 "does not support reopening files", drv->format_name,
3284 bdrv_get_device_or_node_name(reopen_state->bs));
3285 ret = -1;
3286 goto error;
3287 }
3288
3289 drv_prepared = true;
3290
3288 /* Options that are not handled are only okay if they are unchanged
3289 * compared to the old state. It is expected that some options are only
3290 * used for the initial open, but not reopen (e.g. filename) */
3291 if (qdict_size(reopen_state->options)) {
3292 const QDictEntry *entry = qdict_first(reopen_state->options);
3293
3294 do {
3295 QObject *new = entry->value;

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

3345
3346 ret = 0;
3347
3348 /* Restore the original reopen_state->options QDict */
3349 qobject_unref(reopen_state->options);
3350 reopen_state->options = qobject_ref(orig_reopen_opts);
3351
3352error:
3291 /* Options that are not handled are only okay if they are unchanged
3292 * compared to the old state. It is expected that some options are only
3293 * used for the initial open, but not reopen (e.g. filename) */
3294 if (qdict_size(reopen_state->options)) {
3295 const QDictEntry *entry = qdict_first(reopen_state->options);
3296
3297 do {
3298 QObject *new = entry->value;

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

3348
3349 ret = 0;
3350
3351 /* Restore the original reopen_state->options QDict */
3352 qobject_unref(reopen_state->options);
3353 reopen_state->options = qobject_ref(orig_reopen_opts);
3354
3355error:
3356 if (ret < 0 && drv_prepared) {
3357 /* drv->bdrv_reopen_prepare() has succeeded, so we need to
3358 * call drv->bdrv_reopen_abort() before signaling an error
3359 * (bdrv_reopen_multiple() will not call bdrv_reopen_abort()
3360 * when the respective bdrv_reopen_prepare() has failed) */
3361 if (drv->bdrv_reopen_abort) {
3362 drv->bdrv_reopen_abort(reopen_state);
3363 }
3364 }
3353 qemu_opts_del(opts);
3354 qobject_unref(orig_reopen_opts);
3355 g_free(discard);
3356 return ret;
3357}
3358
3359/*
3360 * Takes the staged changes for the reopen from bdrv_reopen_prepare(), and

--- 2066 unchanged lines hidden ---
3365 qemu_opts_del(opts);
3366 qobject_unref(orig_reopen_opts);
3367 g_free(discard);
3368 return ret;
3369}
3370
3371/*
3372 * Takes the staged changes for the reopen from bdrv_reopen_prepare(), and

--- 2066 unchanged lines hidden ---