block.c (be64bbb0149748f3999c49b13976aafb8330ea86) block.c (562bda8bb41879eeda0bd484dd3d55134579b28e)
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

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

4882/*
4883 * A function to remove backing or file child of @bs.
4884 * Function doesn't update permissions, caller is responsible for this.
4885 */
4886static void bdrv_remove_file_or_backing_child(BlockDriverState *bs,
4887 BdrvChild *child,
4888 Transaction *tran)
4889{
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

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

4882/*
4883 * A function to remove backing or file child of @bs.
4884 * Function doesn't update permissions, caller is responsible for this.
4885 */
4886static void bdrv_remove_file_or_backing_child(BlockDriverState *bs,
4887 BdrvChild *child,
4888 Transaction *tran)
4889{
4890 BdrvChild **childp;
4890 BdrvRemoveFilterOrCowChild *s;
4891
4891 BdrvRemoveFilterOrCowChild *s;
4892
4892 assert(child == bs->backing || child == bs->file);
4893
4894 if (!child) {
4895 return;
4896 }
4897
4893 if (!child) {
4894 return;
4895 }
4896
4897 if (child == bs->backing) {
4898 childp = &bs->backing;
4899 } else if (child == bs->file) {
4900 childp = &bs->file;
4901 } else {
4902 g_assert_not_reached();
4903 }
4904
4898 if (child->bs) {
4905 if (child->bs) {
4899 bdrv_replace_child_tran(child, NULL, tran);
4906 bdrv_replace_child_tran(*childp, NULL, tran);
4900 }
4901
4902 s = g_new(BdrvRemoveFilterOrCowChild, 1);
4903 *s = (BdrvRemoveFilterOrCowChild) {
4904 .child = child,
4907 }
4908
4909 s = g_new(BdrvRemoveFilterOrCowChild, 1);
4910 *s = (BdrvRemoveFilterOrCowChild) {
4911 .child = child,
4905 .is_backing = (child == bs->backing),
4912 .is_backing = (childp == &bs->backing),
4906 };
4907 tran_add(tran, &bdrv_remove_filter_or_cow_child_drv, s);
4908
4913 };
4914 tran_add(tran, &bdrv_remove_filter_or_cow_child_drv, s);
4915
4909 if (s->is_backing) {
4910 bs->backing = NULL;
4911 } else {
4912 bs->file = NULL;
4913 }
4916 *childp = NULL;
4914}
4915
4916/*
4917 * A function to remove backing-chain child of @bs if exists: cow child for
4918 * format nodes (always .backing) and filter child for filters (may be .file or
4919 * .backing)
4920 */
4921static void bdrv_remove_filter_or_cow_child(BlockDriverState *bs,

--- 2911 unchanged lines hidden ---
4917}
4918
4919/*
4920 * A function to remove backing-chain child of @bs if exists: cow child for
4921 * format nodes (always .backing) and filter child for filters (may be .file or
4922 * .backing)
4923 */
4924static void bdrv_remove_filter_or_cow_child(BlockDriverState *bs,

--- 2911 unchanged lines hidden ---