blockdev.c (2024c1df43eae0d2e35663da0c6e8c51290a386e) blockdev.c (4f6fd3491cf0f768b135ed2e242bd1d1d2a2efec)
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 *

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

207static void bdrv_format_print(void *opaque, const char *name)
208{
209 error_printf(" %s", name);
210}
211
212static void drive_uninit(DriveInfo *dinfo)
213{
214 qemu_opts_del(dinfo->opts);
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 *

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

207static void bdrv_format_print(void *opaque, const char *name)
208{
209 error_printf(" %s", name);
210}
211
212static void drive_uninit(DriveInfo *dinfo)
213{
214 qemu_opts_del(dinfo->opts);
215 bdrv_delete(dinfo->bdrv);
215 bdrv_unref(dinfo->bdrv);
216 g_free(dinfo->id);
217 QTAILQ_REMOVE(&drives, dinfo, next);
218 g_free(dinfo->serial);
219 g_free(dinfo);
220}
221
222void drive_put_ref(DriveInfo *dinfo)
223{

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

730 QDECREF(bs_opts);
731 qemu_opts_del(opts);
732
733 return dinfo;
734
735err:
736 qemu_opts_del(opts);
737 QDECREF(bs_opts);
216 g_free(dinfo->id);
217 QTAILQ_REMOVE(&drives, dinfo, next);
218 g_free(dinfo->serial);
219 g_free(dinfo);
220}
221
222void drive_put_ref(DriveInfo *dinfo)
223{

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

730 QDECREF(bs_opts);
731 qemu_opts_del(opts);
732
733 return dinfo;
734
735err:
736 qemu_opts_del(opts);
737 QDECREF(bs_opts);
738 bdrv_delete(dinfo->bdrv);
738 bdrv_unref(dinfo->bdrv);
739 g_free(dinfo->id);
740 QTAILQ_REMOVE(&drives, dinfo, next);
741 g_free(dinfo);
742 return NULL;
743}
744
745static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to)
746{

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

991 NULL);
992}
993
994static void external_snapshot_abort(BlkTransactionState *common)
995{
996 ExternalSnapshotState *state =
997 DO_UPCAST(ExternalSnapshotState, common, common);
998 if (state->new_bs) {
739 g_free(dinfo->id);
740 QTAILQ_REMOVE(&drives, dinfo, next);
741 g_free(dinfo);
742 return NULL;
743}
744
745static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to)
746{

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

991 NULL);
992}
993
994static void external_snapshot_abort(BlkTransactionState *common)
995{
996 ExternalSnapshotState *state =
997 DO_UPCAST(ExternalSnapshotState, common, common);
998 if (state->new_bs) {
999 bdrv_delete(state->new_bs);
999 bdrv_unref(state->new_bs);
1000 }
1001}
1002
1003typedef struct DriveBackupState {
1004 BlkTransactionState common;
1005 BlockDriverState *bs;
1006 BlockJob *job;
1007} DriveBackupState;

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

1633 if (error_is_set(&local_err)) {
1634 error_propagate(errp, local_err);
1635 return;
1636 }
1637
1638 target_bs = bdrv_new("");
1639 ret = bdrv_open(target_bs, target, NULL, flags, drv);
1640 if (ret < 0) {
1000 }
1001}
1002
1003typedef struct DriveBackupState {
1004 BlkTransactionState common;
1005 BlockDriverState *bs;
1006 BlockJob *job;
1007} DriveBackupState;

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

1633 if (error_is_set(&local_err)) {
1634 error_propagate(errp, local_err);
1635 return;
1636 }
1637
1638 target_bs = bdrv_new("");
1639 ret = bdrv_open(target_bs, target, NULL, flags, drv);
1640 if (ret < 0) {
1641 bdrv_delete(target_bs);
1641 bdrv_unref(target_bs);
1642 error_setg_file_open(errp, -ret, target);
1643 return;
1644 }
1645
1646 backup_start(bs, target_bs, speed, sync, on_source_error, on_target_error,
1647 block_job_cb, bs, &local_err);
1648 if (local_err != NULL) {
1642 error_setg_file_open(errp, -ret, target);
1643 return;
1644 }
1645
1646 backup_start(bs, target_bs, speed, sync, on_source_error, on_target_error,
1647 block_job_cb, bs, &local_err);
1648 if (local_err != NULL) {
1649 bdrv_delete(target_bs);
1649 bdrv_unref(target_bs);
1650 error_propagate(errp, local_err);
1651 return;
1652 }
1653
1654 /* Grab a reference so hotplug does not delete the BlockDriverState from
1655 * underneath us.
1656 */
1657 drive_get_ref(drive_get_by_blockdev(bs));

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

1773 }
1774
1775 /* Mirroring takes care of copy-on-write using the source's backing
1776 * file.
1777 */
1778 target_bs = bdrv_new("");
1779 ret = bdrv_open(target_bs, target, NULL, flags | BDRV_O_NO_BACKING, drv);
1780 if (ret < 0) {
1650 error_propagate(errp, local_err);
1651 return;
1652 }
1653
1654 /* Grab a reference so hotplug does not delete the BlockDriverState from
1655 * underneath us.
1656 */
1657 drive_get_ref(drive_get_by_blockdev(bs));

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

1773 }
1774
1775 /* Mirroring takes care of copy-on-write using the source's backing
1776 * file.
1777 */
1778 target_bs = bdrv_new("");
1779 ret = bdrv_open(target_bs, target, NULL, flags | BDRV_O_NO_BACKING, drv);
1780 if (ret < 0) {
1781 bdrv_delete(target_bs);
1781 bdrv_unref(target_bs);
1782 error_setg_file_open(errp, -ret, target);
1783 return;
1784 }
1785
1786 mirror_start(bs, target_bs, speed, granularity, buf_size, sync,
1787 on_source_error, on_target_error,
1788 block_job_cb, bs, &local_err);
1789 if (local_err != NULL) {
1782 error_setg_file_open(errp, -ret, target);
1783 return;
1784 }
1785
1786 mirror_start(bs, target_bs, speed, granularity, buf_size, sync,
1787 on_source_error, on_target_error,
1788 block_job_cb, bs, &local_err);
1789 if (local_err != NULL) {
1790 bdrv_delete(target_bs);
1790 bdrv_unref(target_bs);
1791 error_propagate(errp, local_err);
1792 return;
1793 }
1794
1795 /* Grab a reference so hotplug does not delete the BlockDriverState from
1796 * underneath us.
1797 */
1798 drive_get_ref(drive_get_by_blockdev(bs));

--- 276 unchanged lines hidden ---
1791 error_propagate(errp, local_err);
1792 return;
1793 }
1794
1795 /* Grab a reference so hotplug does not delete the BlockDriverState from
1796 * underneath us.
1797 */
1798 drive_get_ref(drive_get_by_blockdev(bs));

--- 276 unchanged lines hidden ---