block.c (0f0b1e29d35e0a7da6271b3fa0fefa63380204e7) | block.c (a2c37a30422328fe2391bd1ff342f8941c7681bc) |
---|---|
1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * Copyright (c) 2020 Virtuozzo International GmbH. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal --- 5041 unchanged lines hidden (view full) --- 5050/* 5051 * A function to remove backing or file child of @bs. 5052 * Function doesn't update permissions, caller is responsible for this. 5053 */ 5054static void bdrv_remove_file_or_backing_child(BlockDriverState *bs, 5055 BdrvChild *child, 5056 Transaction *tran) 5057{ | 1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * Copyright (c) 2020 Virtuozzo International GmbH. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal --- 5041 unchanged lines hidden (view full) --- 5050/* 5051 * A function to remove backing or file child of @bs. 5052 * Function doesn't update permissions, caller is responsible for this. 5053 */ 5054static void bdrv_remove_file_or_backing_child(BlockDriverState *bs, 5055 BdrvChild *child, 5056 Transaction *tran) 5057{ |
5058 BdrvChild **childp; | |
5059 BdrvRemoveFilterOrCowChild *s; 5060 | 5058 BdrvRemoveFilterOrCowChild *s; 5059 |
5060 assert(child == bs->backing || child == bs->file); 5061 |
|
5061 if (!child) { 5062 return; 5063 } 5064 | 5062 if (!child) { 5063 return; 5064 } 5065 |
5065 if (child == bs->backing) { 5066 childp = &bs->backing; 5067 } else if (child == bs->file) { 5068 childp = &bs->file; 5069 } else { 5070 g_assert_not_reached(); 5071 } 5072 | |
5073 if (child->bs) { | 5066 if (child->bs) { |
5074 bdrv_replace_child_tran(*childp, NULL, tran); | 5067 bdrv_replace_child_tran(child, NULL, tran); |
5075 } 5076 5077 s = g_new(BdrvRemoveFilterOrCowChild, 1); 5078 *s = (BdrvRemoveFilterOrCowChild) { 5079 .child = child, | 5068 } 5069 5070 s = g_new(BdrvRemoveFilterOrCowChild, 1); 5071 *s = (BdrvRemoveFilterOrCowChild) { 5072 .child = child, |
5080 .is_backing = (childp == &bs->backing), | 5073 .is_backing = (child == bs->backing), |
5081 }; 5082 tran_add(tran, &bdrv_remove_filter_or_cow_child_drv, s); 5083 | 5074 }; 5075 tran_add(tran, &bdrv_remove_filter_or_cow_child_drv, s); 5076 |
5084 *childp = NULL; | 5077 if (s->is_backing) { 5078 bs->backing = NULL; 5079 } else { 5080 bs->file = NULL; 5081 } |
5085} 5086 5087/* 5088 * A function to remove backing-chain child of @bs if exists: cow child for 5089 * format nodes (always .backing) and filter child for filters (may be .file or 5090 * .backing) 5091 */ 5092static void bdrv_remove_filter_or_cow_child(BlockDriverState *bs, --- 3061 unchanged lines hidden --- | 5082} 5083 5084/* 5085 * A function to remove backing-chain child of @bs if exists: cow child for 5086 * format nodes (always .backing) and filter child for filters (may be .file or 5087 * .backing) 5088 */ 5089static void bdrv_remove_filter_or_cow_child(BlockDriverState *bs, --- 3061 unchanged lines hidden --- |