block.c (a2aabf88958119ec7d3022287eff6bcc924c90a8) | block.c (72373e40fbc7e4218061a8211384db362d3e7348) |
---|---|
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 --- 81 unchanged lines hidden (view full) --- 90 const BdrvChildClass *child_class, 91 BdrvChildRole child_role, 92 BdrvChild **child, 93 Transaction *tran, 94 Error **errp); 95static void bdrv_remove_filter_or_cow_child(BlockDriverState *bs, 96 Transaction *tran); 97 | 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 --- 81 unchanged lines hidden (view full) --- 90 const BdrvChildClass *child_class, 91 BdrvChildRole child_role, 92 BdrvChild **child, 93 Transaction *tran, 94 Error **errp); 95static void bdrv_remove_filter_or_cow_child(BlockDriverState *bs, 96 Transaction *tran); 97 |
98static int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue 99 *queue, Error **errp); | 98static int bdrv_reopen_prepare(BDRVReopenState *reopen_state, 99 BlockReopenQueue *queue, 100 Transaction *set_backings_tran, Error **errp); |
100static void bdrv_reopen_commit(BDRVReopenState *reopen_state); 101static void bdrv_reopen_abort(BDRVReopenState *reopen_state); 102 103/* If non-zero, use only whitelisted block drivers */ 104static int use_bdrv_whitelist; 105 106#ifdef _WIN32 107static int is_windows_drive_prefix(const char *filename) --- 2355 unchanged lines hidden (view full) --- 2463 2464static void bdrv_list_abort_perm_update(GSList *list) 2465{ 2466 for ( ; list; list = list->next) { 2467 bdrv_node_abort_perm_update((BlockDriverState *)list->data); 2468 } 2469} 2470 | 101static void bdrv_reopen_commit(BDRVReopenState *reopen_state); 102static void bdrv_reopen_abort(BDRVReopenState *reopen_state); 103 104/* If non-zero, use only whitelisted block drivers */ 105static int use_bdrv_whitelist; 106 107#ifdef _WIN32 108static int is_windows_drive_prefix(const char *filename) --- 2355 unchanged lines hidden (view full) --- 2464 2465static void bdrv_list_abort_perm_update(GSList *list) 2466{ 2467 for ( ; list; list = list->next) { 2468 bdrv_node_abort_perm_update((BlockDriverState *)list->data); 2469 } 2470} 2471 |
2472__attribute__((unused)) |
|
2471static void bdrv_abort_perm_update(BlockDriverState *bs) 2472{ 2473 g_autoptr(GSList) list = bdrv_topological_dfs(NULL, NULL, bs); 2474 return bdrv_list_abort_perm_update(list); 2475} 2476 2477static void bdrv_node_set_perm(BlockDriverState *bs) 2478{ --- 79 unchanged lines hidden (view full) --- 2558/* 2559 * Checks whether a new reference to @bs can be added if the new user requires 2560 * @new_used_perm/@new_shared_perm as its permissions. If @ignore_children is 2561 * set, the BdrvChild objects in this list are ignored in the calculations; 2562 * this allows checking permission updates for an existing reference. 2563 * 2564 * Needs to be followed by a call to either bdrv_set_perm() or 2565 * bdrv_abort_perm_update(). */ | 2473static void bdrv_abort_perm_update(BlockDriverState *bs) 2474{ 2475 g_autoptr(GSList) list = bdrv_topological_dfs(NULL, NULL, bs); 2476 return bdrv_list_abort_perm_update(list); 2477} 2478 2479static void bdrv_node_set_perm(BlockDriverState *bs) 2480{ --- 79 unchanged lines hidden (view full) --- 2560/* 2561 * Checks whether a new reference to @bs can be added if the new user requires 2562 * @new_used_perm/@new_shared_perm as its permissions. If @ignore_children is 2563 * set, the BdrvChild objects in this list are ignored in the calculations; 2564 * this allows checking permission updates for an existing reference. 2565 * 2566 * Needs to be followed by a call to either bdrv_set_perm() or 2567 * bdrv_abort_perm_update(). */ |
2568__attribute__((unused)) |
|
2566static int bdrv_check_update_perm(BlockDriverState *bs, BlockReopenQueue *q, 2567 uint64_t new_used_perm, 2568 uint64_t new_shared_perm, 2569 Error **errp) 2570{ 2571 BdrvChild *c; 2572 uint64_t cumulative_perms = new_used_perm; 2573 uint64_t cumulative_shared_perms = new_shared_perm; --- 1604 unchanged lines hidden (view full) --- 4178 qobject_unref(bs_entry->state.explicit_options); 4179 } 4180 4181 bs_entry->state.bs = bs; 4182 bs_entry->state.options = options; 4183 bs_entry->state.explicit_options = explicit_options; 4184 bs_entry->state.flags = flags; 4185 | 2569static int bdrv_check_update_perm(BlockDriverState *bs, BlockReopenQueue *q, 2570 uint64_t new_used_perm, 2571 uint64_t new_shared_perm, 2572 Error **errp) 2573{ 2574 BdrvChild *c; 2575 uint64_t cumulative_perms = new_used_perm; 2576 uint64_t cumulative_shared_perms = new_shared_perm; --- 1604 unchanged lines hidden (view full) --- 4181 qobject_unref(bs_entry->state.explicit_options); 4182 } 4183 4184 bs_entry->state.bs = bs; 4185 bs_entry->state.options = options; 4186 bs_entry->state.explicit_options = explicit_options; 4187 bs_entry->state.flags = flags; 4188 |
4186 /* This needs to be overwritten in bdrv_reopen_prepare() */ 4187 bs_entry->state.perm = UINT64_MAX; 4188 bs_entry->state.shared_perm = 0; 4189 | |
4190 /* 4191 * If keep_old_opts is false then it means that unspecified 4192 * options must be reset to their original value. We don't allow 4193 * resetting 'backing' but we need to know if the option is 4194 * missing in order to decide if we have to return an error. 4195 */ 4196 if (!keep_old_opts) { 4197 bs_entry->state.backing_missing = --- 68 unchanged lines hidden (view full) --- 4266 * 4267 * All affected nodes must be drained between bdrv_reopen_queue() and 4268 * bdrv_reopen_multiple(). 4269 */ 4270int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp) 4271{ 4272 int ret = -1; 4273 BlockReopenQueueEntry *bs_entry, *next; | 4189 /* 4190 * If keep_old_opts is false then it means that unspecified 4191 * options must be reset to their original value. We don't allow 4192 * resetting 'backing' but we need to know if the option is 4193 * missing in order to decide if we have to return an error. 4194 */ 4195 if (!keep_old_opts) { 4196 bs_entry->state.backing_missing = --- 68 unchanged lines hidden (view full) --- 4265 * 4266 * All affected nodes must be drained between bdrv_reopen_queue() and 4267 * bdrv_reopen_multiple(). 4268 */ 4269int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp) 4270{ 4271 int ret = -1; 4272 BlockReopenQueueEntry *bs_entry, *next; |
4273 Transaction *tran = tran_new(); 4274 g_autoptr(GHashTable) found = NULL; 4275 g_autoptr(GSList) refresh_list = NULL; |
|
4274 4275 assert(bs_queue != NULL); 4276 4277 QTAILQ_FOREACH(bs_entry, bs_queue, entry) { 4278 ret = bdrv_flush(bs_entry->state.bs); 4279 if (ret < 0) { 4280 error_setg_errno(errp, -ret, "Error flushing drive"); 4281 goto cleanup; 4282 } 4283 } 4284 4285 QTAILQ_FOREACH(bs_entry, bs_queue, entry) { 4286 assert(bs_entry->state.bs->quiesce_counter > 0); | 4276 4277 assert(bs_queue != NULL); 4278 4279 QTAILQ_FOREACH(bs_entry, bs_queue, entry) { 4280 ret = bdrv_flush(bs_entry->state.bs); 4281 if (ret < 0) { 4282 error_setg_errno(errp, -ret, "Error flushing drive"); 4283 goto cleanup; 4284 } 4285 } 4286 4287 QTAILQ_FOREACH(bs_entry, bs_queue, entry) { 4288 assert(bs_entry->state.bs->quiesce_counter > 0); |
4287 if (bdrv_reopen_prepare(&bs_entry->state, bs_queue, errp)) { 4288 goto cleanup; | 4289 ret = bdrv_reopen_prepare(&bs_entry->state, bs_queue, tran, errp); 4290 if (ret < 0) { 4291 goto abort; |
4289 } 4290 bs_entry->prepared = true; 4291 } 4292 | 4292 } 4293 bs_entry->prepared = true; 4294 } 4295 |
4296 found = g_hash_table_new(NULL, NULL); |
|
4293 QTAILQ_FOREACH(bs_entry, bs_queue, entry) { 4294 BDRVReopenState *state = &bs_entry->state; | 4297 QTAILQ_FOREACH(bs_entry, bs_queue, entry) { 4298 BDRVReopenState *state = &bs_entry->state; |
4295 ret = bdrv_check_perm(state->bs, bs_queue, state->perm, 4296 state->shared_perm, errp); 4297 if (ret < 0) { 4298 goto cleanup_perm; | 4299 4300 refresh_list = bdrv_topological_dfs(refresh_list, found, state->bs); 4301 if (state->old_backing_bs) { 4302 refresh_list = bdrv_topological_dfs(refresh_list, found, 4303 state->old_backing_bs); |
4299 } | 4304 } |
4300 /* Check if new_backing_bs would accept the new permissions */ 4301 if (state->replace_backing_bs && state->new_backing_bs) { 4302 uint64_t nperm, nshared; 4303 bdrv_child_perm(state->bs, state->new_backing_bs, 4304 NULL, bdrv_backing_role(state->bs), 4305 bs_queue, state->perm, state->shared_perm, 4306 &nperm, &nshared); 4307 ret = bdrv_check_update_perm(state->new_backing_bs, NULL, 4308 nperm, nshared, errp); 4309 if (ret < 0) { 4310 goto cleanup_perm; 4311 } 4312 } 4313 bs_entry->perms_checked = true; | |
4314 } 4315 4316 /* | 4305 } 4306 4307 /* |
4308 * Note that file-posix driver rely on permission update done during reopen 4309 * (even if no permission changed), because it wants "new" permissions for 4310 * reconfiguring the fd and that's why it does it in raw_check_perm(), not 4311 * in raw_reopen_prepare() which is called with "old" permissions. 4312 */ 4313 ret = bdrv_list_refresh_perms(refresh_list, bs_queue, tran, errp); 4314 if (ret < 0) { 4315 goto abort; 4316 } 4317 4318 /* |
|
4317 * If we reach this point, we have success and just need to apply the 4318 * changes. 4319 * 4320 * Reverse order is used to comfort qcow2 driver: on commit it need to write 4321 * IN_USE flag to the image, to mark bitmaps in the image as invalid. But 4322 * children are usually goes after parents in reopen-queue, so go from last 4323 * to first element. 4324 */ 4325 QTAILQ_FOREACH_REVERSE(bs_entry, bs_queue, entry) { 4326 bdrv_reopen_commit(&bs_entry->state); 4327 } 4328 | 4319 * If we reach this point, we have success and just need to apply the 4320 * changes. 4321 * 4322 * Reverse order is used to comfort qcow2 driver: on commit it need to write 4323 * IN_USE flag to the image, to mark bitmaps in the image as invalid. But 4324 * children are usually goes after parents in reopen-queue, so go from last 4325 * to first element. 4326 */ 4327 QTAILQ_FOREACH_REVERSE(bs_entry, bs_queue, entry) { 4328 bdrv_reopen_commit(&bs_entry->state); 4329 } 4330 |
4329 ret = 0; 4330cleanup_perm: 4331 QTAILQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) { 4332 BDRVReopenState *state = &bs_entry->state; | 4331 tran_commit(tran); |
4333 | 4332 |
4334 if (!bs_entry->perms_checked) { 4335 continue; 4336 } | 4333 QTAILQ_FOREACH_REVERSE(bs_entry, bs_queue, entry) { 4334 BlockDriverState *bs = bs_entry->state.bs; |
4337 | 4335 |
4338 if (ret == 0) { 4339 uint64_t perm, shared; 4340 4341 bdrv_get_cumulative_perm(state->bs, &perm, &shared); 4342 assert(perm == state->perm); 4343 assert(shared == state->shared_perm); 4344 4345 bdrv_set_perm(state->bs); 4346 } else { 4347 bdrv_abort_perm_update(state->bs); 4348 if (state->replace_backing_bs && state->new_backing_bs) { 4349 bdrv_abort_perm_update(state->new_backing_bs); 4350 } | 4336 if (bs->drv->bdrv_reopen_commit_post) { 4337 bs->drv->bdrv_reopen_commit_post(&bs_entry->state); |
4351 } 4352 } 4353 | 4338 } 4339 } 4340 |
4354 if (ret == 0) { 4355 QTAILQ_FOREACH_REVERSE(bs_entry, bs_queue, entry) { 4356 BlockDriverState *bs = bs_entry->state.bs; | 4341 ret = 0; 4342 goto cleanup; |
4357 | 4343 |
4358 if (bs->drv->bdrv_reopen_commit_post) 4359 bs->drv->bdrv_reopen_commit_post(&bs_entry->state); | 4344abort: 4345 tran_abort(tran); 4346 QTAILQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) { 4347 if (bs_entry->prepared) { 4348 bdrv_reopen_abort(&bs_entry->state); |
4360 } | 4349 } |
4350 qobject_unref(bs_entry->state.explicit_options); 4351 qobject_unref(bs_entry->state.options); |
|
4361 } | 4352 } |
4353 |
|
4362cleanup: 4363 QTAILQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) { | 4354cleanup: 4355 QTAILQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) { |
4364 if (ret) { 4365 if (bs_entry->prepared) { 4366 bdrv_reopen_abort(&bs_entry->state); 4367 } 4368 qobject_unref(bs_entry->state.explicit_options); 4369 qobject_unref(bs_entry->state.options); 4370 } 4371 if (bs_entry->state.new_backing_bs) { 4372 bdrv_unref(bs_entry->state.new_backing_bs); 4373 } | |
4374 g_free(bs_entry); 4375 } 4376 g_free(bs_queue); 4377 4378 return ret; 4379} 4380 4381int bdrv_reopen_set_read_only(BlockDriverState *bs, bool read_only, --- 8 unchanged lines hidden (view full) --- 4390 bdrv_subtree_drained_begin(bs); 4391 queue = bdrv_reopen_queue(NULL, bs, opts, true); 4392 ret = bdrv_reopen_multiple(queue, errp); 4393 bdrv_subtree_drained_end(bs); 4394 4395 return ret; 4396} 4397 | 4356 g_free(bs_entry); 4357 } 4358 g_free(bs_queue); 4359 4360 return ret; 4361} 4362 4363int bdrv_reopen_set_read_only(BlockDriverState *bs, bool read_only, --- 8 unchanged lines hidden (view full) --- 4372 bdrv_subtree_drained_begin(bs); 4373 queue = bdrv_reopen_queue(NULL, bs, opts, true); 4374 ret = bdrv_reopen_multiple(queue, errp); 4375 bdrv_subtree_drained_end(bs); 4376 4377 return ret; 4378} 4379 |
4398static BlockReopenQueueEntry *find_parent_in_reopen_queue(BlockReopenQueue *q, 4399 BdrvChild *c) 4400{ 4401 BlockReopenQueueEntry *entry; 4402 4403 QTAILQ_FOREACH(entry, q, entry) { 4404 BlockDriverState *bs = entry->state.bs; 4405 BdrvChild *child; 4406 4407 QLIST_FOREACH(child, &bs->children, next) { 4408 if (child == c) { 4409 return entry; 4410 } 4411 } 4412 } 4413 4414 return NULL; 4415} 4416 4417static void bdrv_reopen_perm(BlockReopenQueue *q, BlockDriverState *bs, 4418 uint64_t *perm, uint64_t *shared) 4419{ 4420 BdrvChild *c; 4421 BlockReopenQueueEntry *parent; 4422 uint64_t cumulative_perms = 0; 4423 uint64_t cumulative_shared_perms = BLK_PERM_ALL; 4424 4425 QLIST_FOREACH(c, &bs->parents, next_parent) { 4426 parent = find_parent_in_reopen_queue(q, c); 4427 if (!parent) { 4428 cumulative_perms |= c->perm; 4429 cumulative_shared_perms &= c->shared_perm; 4430 } else { 4431 uint64_t nperm, nshared; 4432 4433 bdrv_child_perm(parent->state.bs, bs, c, c->role, q, 4434 parent->state.perm, parent->state.shared_perm, 4435 &nperm, &nshared); 4436 4437 cumulative_perms |= nperm; 4438 cumulative_shared_perms &= nshared; 4439 } 4440 } 4441 *perm = cumulative_perms; 4442 *shared = cumulative_shared_perms; 4443} 4444 | |
4445static bool bdrv_reopen_can_attach(BlockDriverState *parent, 4446 BdrvChild *child, 4447 BlockDriverState *new_child, 4448 Error **errp) 4449{ 4450 AioContext *parent_ctx = bdrv_get_aio_context(parent); 4451 AioContext *child_ctx = bdrv_get_aio_context(new_child); 4452 GSList *ignore; --- 25 unchanged lines hidden (view full) --- 4478 * whether the current backing file can be replaced with the new one. 4479 * If that's the case then reopen_state->replace_backing_bs is set to 4480 * true and reopen_state->new_backing_bs contains a pointer to the new 4481 * backing BlockDriverState (or NULL). 4482 * 4483 * Return 0 on success, otherwise return < 0 and set @errp. 4484 */ 4485static int bdrv_reopen_parse_backing(BDRVReopenState *reopen_state, | 4380static bool bdrv_reopen_can_attach(BlockDriverState *parent, 4381 BdrvChild *child, 4382 BlockDriverState *new_child, 4383 Error **errp) 4384{ 4385 AioContext *parent_ctx = bdrv_get_aio_context(parent); 4386 AioContext *child_ctx = bdrv_get_aio_context(new_child); 4387 GSList *ignore; --- 25 unchanged lines hidden (view full) --- 4413 * whether the current backing file can be replaced with the new one. 4414 * If that's the case then reopen_state->replace_backing_bs is set to 4415 * true and reopen_state->new_backing_bs contains a pointer to the new 4416 * backing BlockDriverState (or NULL). 4417 * 4418 * Return 0 on success, otherwise return < 0 and set @errp. 4419 */ 4420static int bdrv_reopen_parse_backing(BDRVReopenState *reopen_state, |
4421 Transaction *set_backings_tran, |
|
4486 Error **errp) 4487{ 4488 BlockDriverState *bs = reopen_state->bs; 4489 BlockDriverState *overlay_bs, *below_bs, *new_backing_bs; 4490 QObject *value; 4491 const char *str; 4492 4493 value = qdict_get(reopen_state->options, "backing"); --- 60 unchanged lines hidden (view full) --- 4554 below_bs && below_bs->implicit; 4555 below_bs = bdrv_filter_or_cow_bs(overlay_bs)) 4556 { 4557 overlay_bs = below_bs; 4558 } 4559 4560 /* If we want to replace the backing file we need some extra checks */ 4561 if (new_backing_bs != bdrv_filter_or_cow_bs(overlay_bs)) { | 4422 Error **errp) 4423{ 4424 BlockDriverState *bs = reopen_state->bs; 4425 BlockDriverState *overlay_bs, *below_bs, *new_backing_bs; 4426 QObject *value; 4427 const char *str; 4428 4429 value = qdict_get(reopen_state->options, "backing"); --- 60 unchanged lines hidden (view full) --- 4490 below_bs && below_bs->implicit; 4491 below_bs = bdrv_filter_or_cow_bs(overlay_bs)) 4492 { 4493 overlay_bs = below_bs; 4494 } 4495 4496 /* If we want to replace the backing file we need some extra checks */ 4497 if (new_backing_bs != bdrv_filter_or_cow_bs(overlay_bs)) { |
4498 int ret; 4499 |
|
4562 /* Check for implicit nodes between bs and its backing file */ 4563 if (bs != overlay_bs) { 4564 error_setg(errp, "Cannot change backing link if '%s' has " 4565 "an implicit backing file", bs->node_name); 4566 return -EPERM; 4567 } 4568 /* 4569 * Check if the backing link that we want to replace is frozen. --- 4 unchanged lines hidden (view full) --- 4574 * with bs->drv->supports_backing == true. 4575 */ 4576 if (bdrv_is_backing_chain_frozen(overlay_bs, 4577 child_bs(overlay_bs->backing), errp)) 4578 { 4579 return -EPERM; 4580 } 4581 reopen_state->replace_backing_bs = true; | 4500 /* Check for implicit nodes between bs and its backing file */ 4501 if (bs != overlay_bs) { 4502 error_setg(errp, "Cannot change backing link if '%s' has " 4503 "an implicit backing file", bs->node_name); 4504 return -EPERM; 4505 } 4506 /* 4507 * Check if the backing link that we want to replace is frozen. --- 4 unchanged lines hidden (view full) --- 4512 * with bs->drv->supports_backing == true. 4513 */ 4514 if (bdrv_is_backing_chain_frozen(overlay_bs, 4515 child_bs(overlay_bs->backing), errp)) 4516 { 4517 return -EPERM; 4518 } 4519 reopen_state->replace_backing_bs = true; |
4582 if (new_backing_bs) { 4583 bdrv_ref(new_backing_bs); 4584 reopen_state->new_backing_bs = new_backing_bs; | 4520 reopen_state->old_backing_bs = bs->backing ? bs->backing->bs : NULL; 4521 ret = bdrv_set_backing_noperm(bs, new_backing_bs, set_backings_tran, 4522 errp); 4523 if (ret < 0) { 4524 return ret; |
4585 } 4586 } 4587 4588 return 0; 4589} 4590 4591/* 4592 * Prepares a BlockDriverState for reopen. All changes are staged in the --- 8 unchanged lines hidden (view full) --- 4601 * as well. 4602 * 4603 * On failure, bdrv_reopen_abort() will be called to clean up any data. 4604 * It is the responsibility of the caller to then call the abort() or 4605 * commit() for any other BDS that have been left in a prepare() state 4606 * 4607 */ 4608static int bdrv_reopen_prepare(BDRVReopenState *reopen_state, | 4525 } 4526 } 4527 4528 return 0; 4529} 4530 4531/* 4532 * Prepares a BlockDriverState for reopen. All changes are staged in the --- 8 unchanged lines hidden (view full) --- 4541 * as well. 4542 * 4543 * On failure, bdrv_reopen_abort() will be called to clean up any data. 4544 * It is the responsibility of the caller to then call the abort() or 4545 * commit() for any other BDS that have been left in a prepare() state 4546 * 4547 */ 4548static int bdrv_reopen_prepare(BDRVReopenState *reopen_state, |
4609 BlockReopenQueue *queue, Error **errp) | 4549 BlockReopenQueue *queue, 4550 Transaction *set_backings_tran, Error **errp) |
4610{ 4611 int ret = -1; 4612 int old_flags; 4613 Error *local_err = NULL; 4614 BlockDriver *drv; 4615 QemuOpts *opts; 4616 QDict *orig_reopen_opts; 4617 char *discard = NULL; --- 50 unchanged lines hidden (view full) --- 4668 * not set, or if the BDS still has copy_on_read enabled */ 4669 read_only = !(reopen_state->flags & BDRV_O_RDWR); 4670 ret = bdrv_can_set_read_only(reopen_state->bs, read_only, true, &local_err); 4671 if (local_err) { 4672 error_propagate(errp, local_err); 4673 goto error; 4674 } 4675 | 4551{ 4552 int ret = -1; 4553 int old_flags; 4554 Error *local_err = NULL; 4555 BlockDriver *drv; 4556 QemuOpts *opts; 4557 QDict *orig_reopen_opts; 4558 char *discard = NULL; --- 50 unchanged lines hidden (view full) --- 4609 * not set, or if the BDS still has copy_on_read enabled */ 4610 read_only = !(reopen_state->flags & BDRV_O_RDWR); 4611 ret = bdrv_can_set_read_only(reopen_state->bs, read_only, true, &local_err); 4612 if (local_err) { 4613 error_propagate(errp, local_err); 4614 goto error; 4615 } 4616 |
4676 /* Calculate required permissions after reopening */ 4677 bdrv_reopen_perm(queue, reopen_state->bs, 4678 &reopen_state->perm, &reopen_state->shared_perm); 4679 | |
4680 if (drv->bdrv_reopen_prepare) { 4681 /* 4682 * If a driver-specific option is missing, it means that we 4683 * should reset it to its default value. 4684 * But not all options allow that, so we need to check it first. 4685 */ 4686 ret = bdrv_reset_options_allowed(reopen_state->bs, 4687 reopen_state->options, errp); --- 37 unchanged lines hidden (view full) --- 4725 goto error; 4726 } 4727 4728 /* 4729 * Allow changing the 'backing' option. The new value can be 4730 * either a reference to an existing node (using its node name) 4731 * or NULL to simply detach the current backing file. 4732 */ | 4617 if (drv->bdrv_reopen_prepare) { 4618 /* 4619 * If a driver-specific option is missing, it means that we 4620 * should reset it to its default value. 4621 * But not all options allow that, so we need to check it first. 4622 */ 4623 ret = bdrv_reset_options_allowed(reopen_state->bs, 4624 reopen_state->options, errp); --- 37 unchanged lines hidden (view full) --- 4662 goto error; 4663 } 4664 4665 /* 4666 * Allow changing the 'backing' option. The new value can be 4667 * either a reference to an existing node (using its node name) 4668 * or NULL to simply detach the current backing file. 4669 */ |
4733 ret = bdrv_reopen_parse_backing(reopen_state, errp); | 4670 ret = bdrv_reopen_parse_backing(reopen_state, set_backings_tran, errp); |
4734 if (ret < 0) { 4735 goto error; 4736 } 4737 qdict_del(reopen_state->options, "backing"); 4738 4739 /* Options that are not handled are only okay if they are unchanged 4740 * compared to the old state. It is expected that some options are only 4741 * used for the initial open, but not reopen (e.g. filename) */ --- 105 unchanged lines hidden (view full) --- 4847 } 4848 4849 /* Remove child references from bs->options and bs->explicit_options. 4850 * Child options were already removed in bdrv_reopen_queue_child() */ 4851 QLIST_FOREACH(child, &bs->children, next) { 4852 qdict_del(bs->explicit_options, child->name); 4853 qdict_del(bs->options, child->name); 4854 } | 4671 if (ret < 0) { 4672 goto error; 4673 } 4674 qdict_del(reopen_state->options, "backing"); 4675 4676 /* Options that are not handled are only okay if they are unchanged 4677 * compared to the old state. It is expected that some options are only 4678 * used for the initial open, but not reopen (e.g. filename) */ --- 105 unchanged lines hidden (view full) --- 4784 } 4785 4786 /* Remove child references from bs->options and bs->explicit_options. 4787 * Child options were already removed in bdrv_reopen_queue_child() */ 4788 QLIST_FOREACH(child, &bs->children, next) { 4789 qdict_del(bs->explicit_options, child->name); 4790 qdict_del(bs->options, child->name); 4791 } |
4855 4856 /* 4857 * Change the backing file if a new one was specified. We do this 4858 * after updating bs->options, so bdrv_refresh_filename() (called 4859 * from bdrv_set_backing_hd()) has the new values. 4860 */ 4861 if (reopen_state->replace_backing_bs) { 4862 BlockDriverState *old_backing_bs = child_bs(bs->backing); 4863 assert(!old_backing_bs || !old_backing_bs->implicit); 4864 /* Abort the permission update on the backing bs we're detaching */ 4865 if (old_backing_bs) { 4866 bdrv_abort_perm_update(old_backing_bs); 4867 } 4868 bdrv_set_backing_hd(bs, reopen_state->new_backing_bs, &error_abort); 4869 } 4870 | |
4871 bdrv_refresh_limits(bs, NULL, NULL); 4872} 4873 4874/* 4875 * Abort the reopen, and delete and free the staged changes in 4876 * reopen_state 4877 */ 4878static void bdrv_reopen_abort(BDRVReopenState *reopen_state) --- 3007 unchanged lines hidden --- | 4792 bdrv_refresh_limits(bs, NULL, NULL); 4793} 4794 4795/* 4796 * Abort the reopen, and delete and free the staged changes in 4797 * reopen_state 4798 */ 4799static void bdrv_reopen_abort(BDRVReopenState *reopen_state) --- 3007 unchanged lines hidden --- |