block.c (077e8e2018bce66aa1d1a87fa42beb24992c490f) | block.c (8546632e610f9b906ff9d34ecba167915fc8157c) |
---|---|
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 --- 3093 unchanged lines hidden (view full) --- 3102 bs_entry->state.options = options; 3103 bs_entry->state.explicit_options = explicit_options; 3104 bs_entry->state.flags = flags; 3105 3106 /* This needs to be overwritten in bdrv_reopen_prepare() */ 3107 bs_entry->state.perm = UINT64_MAX; 3108 bs_entry->state.shared_perm = 0; 3109 | 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 --- 3093 unchanged lines hidden (view full) --- 3102 bs_entry->state.options = options; 3103 bs_entry->state.explicit_options = explicit_options; 3104 bs_entry->state.flags = flags; 3105 3106 /* This needs to be overwritten in bdrv_reopen_prepare() */ 3107 bs_entry->state.perm = UINT64_MAX; 3108 bs_entry->state.shared_perm = 0; 3109 |
3110 /* 3111 * If keep_old_opts is false then it means that unspecified 3112 * options must be reset to their original value. We don't allow 3113 * resetting 'backing' but we need to know if the option is 3114 * missing in order to decide if we have to return an error. 3115 */ 3116 if (!keep_old_opts) { 3117 bs_entry->state.backing_missing = 3118 !qdict_haskey(options, "backing") && 3119 !qdict_haskey(options, "backing.driver"); 3120 } 3121 |
|
3110 QLIST_FOREACH(child, &bs->children, next) { | 3122 QLIST_FOREACH(child, &bs->children, next) { |
3111 QDict *new_child_options; 3112 char *child_key_dot; | 3123 QDict *new_child_options = NULL; 3124 bool child_keep_old = keep_old_opts; |
3113 3114 /* reopen can only change the options of block devices that were 3115 * implicitly created and inherited options. For other (referenced) 3116 * block devices, a syntax like "backing.foo" results in an error. */ 3117 if (child->bs->inherits_from != bs) { 3118 continue; 3119 } 3120 | 3125 3126 /* reopen can only change the options of block devices that were 3127 * implicitly created and inherited options. For other (referenced) 3128 * block devices, a syntax like "backing.foo" results in an error. */ 3129 if (child->bs->inherits_from != bs) { 3130 continue; 3131 } 3132 |
3121 child_key_dot = g_strdup_printf("%s.", child->name); 3122 qdict_extract_subqdict(explicit_options, NULL, child_key_dot); 3123 qdict_extract_subqdict(options, &new_child_options, child_key_dot); 3124 g_free(child_key_dot); | 3133 /* Check if the options contain a child reference */ 3134 if (qdict_haskey(options, child->name)) { 3135 const char *childref = qdict_get_try_str(options, child->name); 3136 /* 3137 * The current child must not be reopened if the child 3138 * reference is null or points to a different node. 3139 */ 3140 if (g_strcmp0(childref, child->bs->node_name)) { 3141 continue; 3142 } 3143 /* 3144 * If the child reference points to the current child then 3145 * reopen it with its existing set of options (note that 3146 * it can still inherit new options from the parent). 3147 */ 3148 child_keep_old = true; 3149 } else { 3150 /* Extract child options ("child-name.*") */ 3151 char *child_key_dot = g_strdup_printf("%s.", child->name); 3152 qdict_extract_subqdict(explicit_options, NULL, child_key_dot); 3153 qdict_extract_subqdict(options, &new_child_options, child_key_dot); 3154 g_free(child_key_dot); 3155 } |
3125 3126 bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, | 3156 3157 bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, |
3127 child->role, options, flags, keep_old_opts); | 3158 child->role, options, flags, child_keep_old); |
3128 } 3129 3130 return bs_queue; 3131} 3132 3133BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, 3134 BlockDriverState *bs, 3135 QDict *options, bool keep_old_opts) --- 262 unchanged lines hidden (view full) --- 3398 "does not support reopening files", drv->format_name, 3399 bdrv_get_device_or_node_name(reopen_state->bs)); 3400 ret = -1; 3401 goto error; 3402 } 3403 3404 drv_prepared = true; 3405 | 3159 } 3160 3161 return bs_queue; 3162} 3163 3164BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, 3165 BlockDriverState *bs, 3166 QDict *options, bool keep_old_opts) --- 262 unchanged lines hidden (view full) --- 3429 "does not support reopening files", drv->format_name, 3430 bdrv_get_device_or_node_name(reopen_state->bs)); 3431 ret = -1; 3432 goto error; 3433 } 3434 3435 drv_prepared = true; 3436 |
3437 if (drv->supports_backing && reopen_state->backing_missing) { 3438 error_setg(errp, "backing is missing for '%s'", 3439 reopen_state->bs->node_name); 3440 ret = -EINVAL; 3441 goto error; 3442 } 3443 |
|
3406 /* Options that are not handled are only okay if they are unchanged 3407 * compared to the old state. It is expected that some options are only 3408 * used for the initial open, but not reopen (e.g. filename) */ 3409 if (qdict_size(reopen_state->options)) { 3410 const QDictEntry *entry = qdict_first(reopen_state->options); 3411 3412 do { 3413 QObject *new = entry->value; --- 2551 unchanged lines hidden --- | 3444 /* Options that are not handled are only okay if they are unchanged 3445 * compared to the old state. It is expected that some options are only 3446 * used for the initial open, but not reopen (e.g. filename) */ 3447 if (qdict_size(reopen_state->options)) { 3448 const QDictEntry *entry = qdict_first(reopen_state->options); 3449 3450 do { 3451 QObject *new = entry->value; --- 2551 unchanged lines hidden --- |