blockdev.c (d29d3d1f80b3947fb26e7139645c83de66d146a9) blockdev.c (30dd65f307b647eef8156c4a33bd007823ef85cb)
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 *

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

1465 /* Reference to the new image (for 'blockdev-snapshot') */
1466 const char *snapshot_ref;
1467 /* File name of the new image (for 'blockdev-snapshot-sync') */
1468 const char *new_image_file;
1469 ExternalSnapshotState *state =
1470 DO_UPCAST(ExternalSnapshotState, common, common);
1471 TransactionAction *action = common->action;
1472 AioContext *aio_context;
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 *

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

1465 /* Reference to the new image (for 'blockdev-snapshot') */
1466 const char *snapshot_ref;
1467 /* File name of the new image (for 'blockdev-snapshot-sync') */
1468 const char *new_image_file;
1469 ExternalSnapshotState *state =
1470 DO_UPCAST(ExternalSnapshotState, common, common);
1471 TransactionAction *action = common->action;
1472 AioContext *aio_context;
1473 AioContext *old_context;
1474 uint64_t perm, shared;
1473 uint64_t perm, shared;
1475 int ret;
1476
1477 /* 'blockdev-snapshot' and 'blockdev-snapshot-sync' have similar
1478 * purpose but a different set of parameters */
1479 switch (action->type) {
1480 case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT:
1481 {
1482 BlockdevSnapshot *s = action->u.blockdev_snapshot.data;
1483 device = s->node;

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

1603 goto out;
1604 }
1605
1606 if (!state->new_bs->drv->supports_backing) {
1607 error_setg(errp, "The overlay does not support backing images");
1608 goto out;
1609 }
1610
1474
1475 /* 'blockdev-snapshot' and 'blockdev-snapshot-sync' have similar
1476 * purpose but a different set of parameters */
1477 switch (action->type) {
1478 case TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT:
1479 {
1480 BlockdevSnapshot *s = action->u.blockdev_snapshot.data;
1481 device = s->node;

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

1601 goto out;
1602 }
1603
1604 if (!state->new_bs->drv->supports_backing) {
1605 error_setg(errp, "The overlay does not support backing images");
1606 goto out;
1607 }
1608
1611 /* Honor bdrv_try_set_aio_context() context acquisition requirements. */
1612 old_context = bdrv_get_aio_context(state->new_bs);
1613 aio_context_release(aio_context);
1614 aio_context_acquire(old_context);
1615
1616 ret = bdrv_try_set_aio_context(state->new_bs, aio_context, errp);
1617
1618 aio_context_release(old_context);
1619 aio_context_acquire(aio_context);
1620
1621 if (ret < 0) {
1622 goto out;
1623 }
1624
1625 /* This removes our old bs and adds the new bs. This is an operation that
1626 * can fail, so we need to do it in .prepare; undoing it for abort is
1627 * always possible. */
1628 bdrv_ref(state->new_bs);
1629 bdrv_append(state->new_bs, state->old_bs, &local_err);
1630 if (local_err) {
1631 error_propagate(errp, local_err);
1632 goto out;

--- 2417 unchanged lines hidden ---
1609 /* This removes our old bs and adds the new bs. This is an operation that
1610 * can fail, so we need to do it in .prepare; undoing it for abort is
1611 * always possible. */
1612 bdrv_ref(state->new_bs);
1613 bdrv_append(state->new_bs, state->old_bs, &local_err);
1614 if (local_err) {
1615 error_propagate(errp, local_err);
1616 goto out;

--- 2417 unchanged lines hidden ---