blockdev.c (7fa24b8d61be040ba58bed6fc1c16fd5fb7b6af0) blockdev.c (142e6907120d12de1e7ac402e556597ebbab86e8)
1/*
2 * QEMU host block devices
3 *
4 * Copyright (c) 2003-2008 Fabrice Bellard
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or
7 * later. See the COPYING file in the top-level directory.
8 *

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

1625 * the main AioContext. As we're still going to be using it, return
1626 * it to the AioContext it was before.
1627 */
1628 tmp_context = bdrv_get_aio_context(state->old_bs);
1629 if (aio_context != tmp_context) {
1630 aio_context_release(aio_context);
1631 aio_context_acquire(tmp_context);
1632
1/*
2 * QEMU host block devices
3 *
4 * Copyright (c) 2003-2008 Fabrice Bellard
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or
7 * later. See the COPYING file in the top-level directory.
8 *

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

1625 * the main AioContext. As we're still going to be using it, return
1626 * it to the AioContext it was before.
1627 */
1628 tmp_context = bdrv_get_aio_context(state->old_bs);
1629 if (aio_context != tmp_context) {
1630 aio_context_release(aio_context);
1631 aio_context_acquire(tmp_context);
1632
1633 ret = bdrv_try_set_aio_context(state->old_bs,
1634 aio_context, NULL);
1633 ret = bdrv_try_change_aio_context(state->old_bs,
1634 aio_context, NULL, NULL);
1635 assert(ret == 0);
1636
1637 aio_context_release(tmp_context);
1638 aio_context_acquire(aio_context);
1639 }
1640
1641 bdrv_replace_node(state->new_bs, state->old_bs, &error_abort);
1642 bdrv_unref(state->old_bs); /* bdrv_replace_node() ref'ed old_bs */

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

1787 qdict_put_str(options, "driver", backup->format);
1788 }
1789
1790 target_bs = bdrv_open(backup->target, NULL, options, flags, errp);
1791 if (!target_bs) {
1792 goto out;
1793 }
1794
1635 assert(ret == 0);
1636
1637 aio_context_release(tmp_context);
1638 aio_context_acquire(aio_context);
1639 }
1640
1641 bdrv_replace_node(state->new_bs, state->old_bs, &error_abort);
1642 bdrv_unref(state->old_bs); /* bdrv_replace_node() ref'ed old_bs */

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

1787 qdict_put_str(options, "driver", backup->format);
1788 }
1789
1790 target_bs = bdrv_open(backup->target, NULL, options, flags, errp);
1791 if (!target_bs) {
1792 goto out;
1793 }
1794
1795 /* Honor bdrv_try_set_aio_context() context acquisition requirements. */
1795 /* Honor bdrv_try_change_aio_context() context acquisition requirements. */
1796 old_context = bdrv_get_aio_context(target_bs);
1797 aio_context_release(aio_context);
1798 aio_context_acquire(old_context);
1799
1796 old_context = bdrv_get_aio_context(target_bs);
1797 aio_context_release(aio_context);
1798 aio_context_acquire(old_context);
1799
1800 ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
1800 ret = bdrv_try_change_aio_context(target_bs, aio_context, NULL, errp);
1801 if (ret < 0) {
1802 bdrv_unref(target_bs);
1803 aio_context_release(old_context);
1804 return;
1805 }
1806
1807 aio_context_release(old_context);
1808 aio_context_acquire(aio_context);

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

1887 return;
1888 }
1889
1890 target_bs = bdrv_lookup_bs(backup->target, backup->target, errp);
1891 if (!target_bs) {
1892 return;
1893 }
1894
1801 if (ret < 0) {
1802 bdrv_unref(target_bs);
1803 aio_context_release(old_context);
1804 return;
1805 }
1806
1807 aio_context_release(old_context);
1808 aio_context_acquire(aio_context);

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

1887 return;
1888 }
1889
1890 target_bs = bdrv_lookup_bs(backup->target, backup->target, errp);
1891 if (!target_bs) {
1892 return;
1893 }
1894
1895 /* Honor bdrv_try_set_aio_context() context acquisition requirements. */
1895 /* Honor bdrv_try_change_aio_context() context acquisition requirements. */
1896 aio_context = bdrv_get_aio_context(bs);
1897 old_context = bdrv_get_aio_context(target_bs);
1898 aio_context_acquire(old_context);
1899
1896 aio_context = bdrv_get_aio_context(bs);
1897 old_context = bdrv_get_aio_context(target_bs);
1898 aio_context_acquire(old_context);
1899
1900 ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
1900 ret = bdrv_try_change_aio_context(target_bs, aio_context, NULL, errp);
1901 if (ret < 0) {
1902 aio_context_release(old_context);
1903 return;
1904 }
1905
1906 aio_context_release(old_context);
1907 aio_context_acquire(aio_context);
1908 state->bs = bs;

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

3189 goto out;
3190 }
3191
3192 zero_target = (arg->sync == MIRROR_SYNC_MODE_FULL &&
3193 (arg->mode == NEW_IMAGE_MODE_EXISTING ||
3194 !bdrv_has_zero_init(target_bs)));
3195
3196
1901 if (ret < 0) {
1902 aio_context_release(old_context);
1903 return;
1904 }
1905
1906 aio_context_release(old_context);
1907 aio_context_acquire(aio_context);
1908 state->bs = bs;

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

3189 goto out;
3190 }
3191
3192 zero_target = (arg->sync == MIRROR_SYNC_MODE_FULL &&
3193 (arg->mode == NEW_IMAGE_MODE_EXISTING ||
3194 !bdrv_has_zero_init(target_bs)));
3195
3196
3197 /* Honor bdrv_try_set_aio_context() context acquisition requirements. */
3197 /* Honor bdrv_try_change_aio_context() context acquisition requirements. */
3198 old_context = bdrv_get_aio_context(target_bs);
3199 aio_context_release(aio_context);
3200 aio_context_acquire(old_context);
3201
3198 old_context = bdrv_get_aio_context(target_bs);
3199 aio_context_release(aio_context);
3200 aio_context_acquire(old_context);
3201
3202 ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
3202 ret = bdrv_try_change_aio_context(target_bs, aio_context, NULL, errp);
3203 if (ret < 0) {
3204 bdrv_unref(target_bs);
3205 aio_context_release(old_context);
3206 return;
3207 }
3208
3209 aio_context_release(old_context);
3210 aio_context_acquire(aio_context);

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

3261
3262 target_bs = bdrv_lookup_bs(target, target, errp);
3263 if (!target_bs) {
3264 return;
3265 }
3266
3267 zero_target = (sync == MIRROR_SYNC_MODE_FULL);
3268
3203 if (ret < 0) {
3204 bdrv_unref(target_bs);
3205 aio_context_release(old_context);
3206 return;
3207 }
3208
3209 aio_context_release(old_context);
3210 aio_context_acquire(aio_context);

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

3261
3262 target_bs = bdrv_lookup_bs(target, target, errp);
3263 if (!target_bs) {
3264 return;
3265 }
3266
3267 zero_target = (sync == MIRROR_SYNC_MODE_FULL);
3268
3269 /* Honor bdrv_try_set_aio_context() context acquisition requirements. */
3269 /* Honor bdrv_try_change_aio_context() context acquisition requirements. */
3270 old_context = bdrv_get_aio_context(target_bs);
3271 aio_context = bdrv_get_aio_context(bs);
3272 aio_context_acquire(old_context);
3273
3270 old_context = bdrv_get_aio_context(target_bs);
3271 aio_context = bdrv_get_aio_context(bs);
3272 aio_context_acquire(old_context);
3273
3274 ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
3274 ret = bdrv_try_change_aio_context(target_bs, aio_context, NULL, errp);
3275
3276 aio_context_release(old_context);
3277 aio_context_acquire(aio_context);
3278
3279 if (ret < 0) {
3280 goto out;
3281 }
3282

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

3762 new_context = iothread_get_aio_context(obj);
3763 } else {
3764 new_context = qemu_get_aio_context();
3765 }
3766
3767 old_context = bdrv_get_aio_context(bs);
3768 aio_context_acquire(old_context);
3769
3275
3276 aio_context_release(old_context);
3277 aio_context_acquire(aio_context);
3278
3279 if (ret < 0) {
3280 goto out;
3281 }
3282

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

3762 new_context = iothread_get_aio_context(obj);
3763 } else {
3764 new_context = qemu_get_aio_context();
3765 }
3766
3767 old_context = bdrv_get_aio_context(bs);
3768 aio_context_acquire(old_context);
3769
3770 bdrv_try_set_aio_context(bs, new_context, errp);
3770 bdrv_try_change_aio_context(bs, new_context, NULL, errp);
3771
3772 aio_context_release(old_context);
3773}
3774
3775QemuOptsList qemu_common_drive_opts = {
3776 .name = "drive",
3777 .head = QTAILQ_HEAD_INITIALIZER(qemu_common_drive_opts.head),
3778 .desc = {

--- 70 unchanged lines hidden ---
3771
3772 aio_context_release(old_context);
3773}
3774
3775QemuOptsList qemu_common_drive_opts = {
3776 .name = "drive",
3777 .head = QTAILQ_HEAD_INITIALIZER(qemu_common_drive_opts.head),
3778 .desc = {

--- 70 unchanged lines hidden ---