Revision f9092b10 block.c
b/block.c | ||
---|---|---|
63 | 63 |
static QLIST_HEAD(, BlockDriver) bdrv_drivers = |
64 | 64 |
QLIST_HEAD_INITIALIZER(bdrv_drivers); |
65 | 65 |
|
66 |
/* The device to use for VM snapshots */ |
|
67 |
static BlockDriverState *bs_snapshots; |
|
68 |
|
|
66 | 69 |
/* If non-zero, use only whitelisted block drivers */ |
67 | 70 |
static int use_bdrv_whitelist; |
68 | 71 |
|
... | ... | |
629 | 632 |
void bdrv_close(BlockDriverState *bs) |
630 | 633 |
{ |
631 | 634 |
if (bs->drv) { |
635 |
if (bs == bs_snapshots) { |
|
636 |
bs_snapshots = NULL; |
|
637 |
} |
|
632 | 638 |
if (bs->backing_hd) { |
633 | 639 |
bdrv_delete(bs->backing_hd); |
634 | 640 |
bs->backing_hd = NULL; |
... | ... | |
677 | 683 |
bdrv_delete(bs->file); |
678 | 684 |
} |
679 | 685 |
|
686 |
assert(bs != bs_snapshots); |
|
680 | 687 |
qemu_free(bs); |
681 | 688 |
} |
682 | 689 |
|
... | ... | |
1778 | 1785 |
return 1; |
1779 | 1786 |
} |
1780 | 1787 |
|
1788 |
BlockDriverState *bdrv_snapshots(void) |
|
1789 |
{ |
|
1790 |
BlockDriverState *bs; |
|
1791 |
|
|
1792 |
if (bs_snapshots) |
|
1793 |
return bs_snapshots; |
|
1794 |
|
|
1795 |
bs = NULL; |
|
1796 |
while ((bs = bdrv_next(bs))) { |
|
1797 |
if (bdrv_can_snapshot(bs)) { |
|
1798 |
goto ok; |
|
1799 |
} |
|
1800 |
} |
|
1801 |
return NULL; |
|
1802 |
ok: |
|
1803 |
bs_snapshots = bs; |
|
1804 |
return bs; |
|
1805 |
} |
|
1806 |
|
|
1781 | 1807 |
int bdrv_snapshot_create(BlockDriverState *bs, |
1782 | 1808 |
QEMUSnapshotInfo *sn_info) |
1783 | 1809 |
{ |
Also available in: Unified diff