block.c (3ca1f3225727419ba573673b744edac10904276f) | block.c (228ca37e12f97788e05bd0c92f89b3e5e4019607) |
---|---|
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 --- 2686 unchanged lines hidden (view full) --- 2695 * 2696 * The caller must hold the AioContext lock @child_bs, but not that of @ctx 2697 * (unless @child_bs is already in @ctx). 2698 */ 2699BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, 2700 const char *child_name, 2701 const BdrvChildClass *child_class, 2702 BdrvChildRole child_role, | 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 --- 2686 unchanged lines hidden (view full) --- 2695 * 2696 * The caller must hold the AioContext lock @child_bs, but not that of @ctx 2697 * (unless @child_bs is already in @ctx). 2698 */ 2699BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, 2700 const char *child_name, 2701 const BdrvChildClass *child_class, 2702 BdrvChildRole child_role, |
2703 AioContext *ctx, | |
2704 uint64_t perm, uint64_t shared_perm, 2705 void *opaque, Error **errp) 2706{ 2707 BdrvChild *child; 2708 Error *local_err = NULL; 2709 int ret; | 2703 uint64_t perm, uint64_t shared_perm, 2704 void *opaque, Error **errp) 2705{ 2706 BdrvChild *child; 2707 Error *local_err = NULL; 2708 int ret; |
2709 AioContext *ctx; |
|
2710 2711 ret = bdrv_check_update_perm(child_bs, NULL, perm, shared_perm, NULL, errp); 2712 if (ret < 0) { 2713 bdrv_abort_perm_update(child_bs); 2714 bdrv_unref(child_bs); 2715 return NULL; 2716 } 2717 2718 child = g_new(BdrvChild, 1); 2719 *child = (BdrvChild) { 2720 .bs = NULL, 2721 .name = g_strdup(child_name), 2722 .klass = child_class, 2723 .role = child_role, 2724 .perm = perm, 2725 .shared_perm = shared_perm, 2726 .opaque = opaque, 2727 }; 2728 | 2710 2711 ret = bdrv_check_update_perm(child_bs, NULL, perm, shared_perm, NULL, errp); 2712 if (ret < 0) { 2713 bdrv_abort_perm_update(child_bs); 2714 bdrv_unref(child_bs); 2715 return NULL; 2716 } 2717 2718 child = g_new(BdrvChild, 1); 2719 *child = (BdrvChild) { 2720 .bs = NULL, 2721 .name = g_strdup(child_name), 2722 .klass = child_class, 2723 .role = child_role, 2724 .perm = perm, 2725 .shared_perm = shared_perm, 2726 .opaque = opaque, 2727 }; 2728 |
2729 ctx = bdrv_child_get_parent_aio_context(child); 2730 |
|
2729 /* If the AioContexts don't match, first try to move the subtree of 2730 * child_bs into the AioContext of the new parent. If this doesn't work, 2731 * try moving the parent into the AioContext of child_bs instead. */ 2732 if (bdrv_get_aio_context(child_bs) != ctx) { 2733 ret = bdrv_try_set_aio_context(child_bs, ctx, &local_err); 2734 if (ret < 0 && child_class->can_set_aio_ctx) { 2735 GSList *ignore = g_slist_prepend(NULL, child); 2736 ctx = bdrv_get_aio_context(child_bs); --- 44 unchanged lines hidden (view full) --- 2781 2782 bdrv_get_cumulative_perm(parent_bs, &perm, &shared_perm); 2783 2784 assert(parent_bs->drv); 2785 bdrv_child_perm(parent_bs, child_bs, NULL, child_role, NULL, 2786 perm, shared_perm, &perm, &shared_perm); 2787 2788 child = bdrv_root_attach_child(child_bs, child_name, child_class, | 2731 /* If the AioContexts don't match, first try to move the subtree of 2732 * child_bs into the AioContext of the new parent. If this doesn't work, 2733 * try moving the parent into the AioContext of child_bs instead. */ 2734 if (bdrv_get_aio_context(child_bs) != ctx) { 2735 ret = bdrv_try_set_aio_context(child_bs, ctx, &local_err); 2736 if (ret < 0 && child_class->can_set_aio_ctx) { 2737 GSList *ignore = g_slist_prepend(NULL, child); 2738 ctx = bdrv_get_aio_context(child_bs); --- 44 unchanged lines hidden (view full) --- 2783 2784 bdrv_get_cumulative_perm(parent_bs, &perm, &shared_perm); 2785 2786 assert(parent_bs->drv); 2787 bdrv_child_perm(parent_bs, child_bs, NULL, child_role, NULL, 2788 perm, shared_perm, &perm, &shared_perm); 2789 2790 child = bdrv_root_attach_child(child_bs, child_name, child_class, |
2789 child_role, bdrv_get_aio_context(parent_bs), 2790 perm, shared_perm, parent_bs, errp); | 2791 child_role, perm, shared_perm, parent_bs, 2792 errp); |
2791 if (child == NULL) { 2792 return NULL; 2793 } 2794 2795 QLIST_INSERT_HEAD(&parent_bs->children, child, next); 2796 return child; 2797} 2798 --- 4512 unchanged lines hidden --- | 2793 if (child == NULL) { 2794 return NULL; 2795 } 2796 2797 QLIST_INSERT_HEAD(&parent_bs->children, child, next); 2798 return child; 2799} 2800 --- 4512 unchanged lines hidden --- |