Revision f9092b10
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 |
{ |
b/block.h | ||
---|---|---|
193 | 193 |
void bdrv_get_backing_filename(BlockDriverState *bs, |
194 | 194 |
char *filename, int filename_size); |
195 | 195 |
int bdrv_can_snapshot(BlockDriverState *bs); |
196 |
BlockDriverState *bdrv_snapshots(void); |
|
196 | 197 |
int bdrv_snapshot_create(BlockDriverState *bs, |
197 | 198 |
QEMUSnapshotInfo *sn_info); |
198 | 199 |
int bdrv_snapshot_goto(BlockDriverState *bs, |
b/savevm.c | ||
---|---|---|
83 | 83 |
#include "qemu_socket.h" |
84 | 84 |
#include "qemu-queue.h" |
85 | 85 |
|
86 |
/* point to the block driver where the snapshots are managed */ |
|
87 |
static BlockDriverState *bs_snapshots; |
|
88 |
|
|
89 | 86 |
#define SELF_ANNOUNCE_ROUNDS 5 |
90 | 87 |
|
91 | 88 |
#ifndef ETH_P_RARP |
... | ... | |
1575 | 1572 |
return ret; |
1576 | 1573 |
} |
1577 | 1574 |
|
1578 |
static BlockDriverState *get_bs_snapshots(void) |
|
1579 |
{ |
|
1580 |
BlockDriverState *bs; |
|
1581 |
|
|
1582 |
if (bs_snapshots) |
|
1583 |
return bs_snapshots; |
|
1584 |
/* FIXME what if bs_snapshots gets hot-unplugged? */ |
|
1585 |
|
|
1586 |
bs = NULL; |
|
1587 |
while ((bs = bdrv_next(bs))) { |
|
1588 |
if (bdrv_can_snapshot(bs)) { |
|
1589 |
goto ok; |
|
1590 |
} |
|
1591 |
} |
|
1592 |
return NULL; |
|
1593 |
ok: |
|
1594 |
bs_snapshots = bs; |
|
1595 |
return bs; |
|
1596 |
} |
|
1597 |
|
|
1598 | 1575 |
static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, |
1599 | 1576 |
const char *name) |
1600 | 1577 |
{ |
... | ... | |
1674 | 1651 |
} |
1675 | 1652 |
} |
1676 | 1653 |
|
1677 |
bs = get_bs_snapshots();
|
|
1654 |
bs = bdrv_snapshots();
|
|
1678 | 1655 |
if (!bs) { |
1679 | 1656 |
monitor_printf(mon, "No block device can accept snapshots\n"); |
1680 | 1657 |
return; |
... | ... | |
1769 | 1746 |
} |
1770 | 1747 |
} |
1771 | 1748 |
|
1772 |
bs = get_bs_snapshots();
|
|
1749 |
bs = bdrv_snapshots();
|
|
1773 | 1750 |
if (!bs) { |
1774 | 1751 |
error_report("No block device supports snapshots"); |
1775 | 1752 |
return -EINVAL; |
... | ... | |
1833 | 1810 |
int ret; |
1834 | 1811 |
const char *name = qdict_get_str(qdict, "name"); |
1835 | 1812 |
|
1836 |
bs = get_bs_snapshots();
|
|
1813 |
bs = bdrv_snapshots();
|
|
1837 | 1814 |
if (!bs) { |
1838 | 1815 |
monitor_printf(mon, "No block device supports snapshots\n"); |
1839 | 1816 |
return; |
... | ... | |
1863 | 1840 |
int nb_sns, i; |
1864 | 1841 |
char buf[256]; |
1865 | 1842 |
|
1866 |
bs = get_bs_snapshots();
|
|
1843 |
bs = bdrv_snapshots();
|
|
1867 | 1844 |
if (!bs) { |
1868 | 1845 |
monitor_printf(mon, "No available block device supports snapshots\n"); |
1869 | 1846 |
return; |
Also available in: Unified diff