Revision dbc13590

b/savevm.c
1578 1578
static BlockDriverState *get_bs_snapshots(void)
1579 1579
{
1580 1580
    BlockDriverState *bs;
1581
    DriveInfo *dinfo;
1582 1581

  
1583 1582
    if (bs_snapshots)
1584 1583
        return bs_snapshots;
1585
    QTAILQ_FOREACH(dinfo, &drives, next) {
1586
        bs = dinfo->bdrv;
1584
    /* FIXME what if bs_snapshots gets hot-unplugged? */
1585

  
1586
    bs = NULL;
1587
    while ((bs = bdrv_next(bs))) {
1587 1588
        if (bdrv_can_snapshot(bs)) {
1588 1589
            goto ok;
1589 1590
        }
......
1622 1623
static int del_existing_snapshots(Monitor *mon, const char *name)
1623 1624
{
1624 1625
    BlockDriverState *bs;
1625
    DriveInfo *dinfo;
1626 1626
    QEMUSnapshotInfo sn1, *snapshot = &sn1;
1627 1627
    int ret;
1628 1628

  
1629
    QTAILQ_FOREACH(dinfo, &drives, next) {
1630
        bs = dinfo->bdrv;
1629
    bs = NULL;
1630
    while ((bs = bdrv_next(bs))) {
1631 1631
        if (bdrv_can_snapshot(bs) &&
1632 1632
            bdrv_snapshot_find(bs, snapshot, name) >= 0)
1633 1633
        {
......
1646 1646

  
1647 1647
void do_savevm(Monitor *mon, const QDict *qdict)
1648 1648
{
1649
    DriveInfo *dinfo;
1650 1649
    BlockDriverState *bs, *bs1;
1651 1650
    QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
1652 1651
    int ret;
......
1661 1660
    const char *name = qdict_get_try_str(qdict, "name");
1662 1661

  
1663 1662
    /* Verify if there is a device that doesn't support snapshots and is writable */
1664
    QTAILQ_FOREACH(dinfo, &drives, next) {
1665
        bs = dinfo->bdrv;
1663
    bs = NULL;
1664
    while ((bs = bdrv_next(bs))) {
1666 1665

  
1667 1666
        if (bdrv_is_removable(bs) || bdrv_is_read_only(bs)) {
1668 1667
            continue;
......
1730 1729

  
1731 1730
    /* create the snapshots */
1732 1731

  
1733
    QTAILQ_FOREACH(dinfo, &drives, next) {
1734
        bs1 = dinfo->bdrv;
1732
    bs1 = NULL;
1733
    while ((bs1 = bdrv_next(bs1))) {
1735 1734
        if (bdrv_can_snapshot(bs1)) {
1736 1735
            /* Write VM state size only to the image that contains the state */
1737 1736
            sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);
......
1750 1749

  
1751 1750
int load_vmstate(const char *name)
1752 1751
{
1753
    DriveInfo *dinfo;
1754 1752
    BlockDriverState *bs, *bs1;
1755 1753
    QEMUSnapshotInfo sn;
1756 1754
    QEMUFile *f;
1757 1755
    int ret;
1758 1756

  
1759 1757
    /* Verify if there is a device that doesn't support snapshots and is writable */
1760
    QTAILQ_FOREACH(dinfo, &drives, next) {
1761
        bs = dinfo->bdrv;
1758
    bs = NULL;
1759
    while ((bs = bdrv_next(bs))) {
1762 1760

  
1763 1761
        if (bdrv_is_removable(bs) || bdrv_is_read_only(bs)) {
1764 1762
            continue;
......
1780 1778
    /* Flush all IO requests so they don't interfere with the new state.  */
1781 1779
    qemu_aio_flush();
1782 1780

  
1783
    QTAILQ_FOREACH(dinfo, &drives, next) {
1784
        bs1 = dinfo->bdrv;
1781
    bs1 = NULL;
1782
    while ((bs1 = bdrv_next(bs1))) {
1785 1783
        if (bdrv_can_snapshot(bs1)) {
1786 1784
            ret = bdrv_snapshot_goto(bs1, name);
1787 1785
            if (ret < 0) {
......
1831 1829

  
1832 1830
void do_delvm(Monitor *mon, const QDict *qdict)
1833 1831
{
1834
    DriveInfo *dinfo;
1835 1832
    BlockDriverState *bs, *bs1;
1836 1833
    int ret;
1837 1834
    const char *name = qdict_get_str(qdict, "name");
......
1842 1839
        return;
1843 1840
    }
1844 1841

  
1845
    QTAILQ_FOREACH(dinfo, &drives, next) {
1846
        bs1 = dinfo->bdrv;
1842
    bs1 = NULL;
1843
    while ((bs1 = bdrv_next(bs1))) {
1847 1844
        if (bdrv_can_snapshot(bs1)) {
1848 1845
            ret = bdrv_snapshot_delete(bs1, name);
1849 1846
            if (ret < 0) {
......
1861 1858

  
1862 1859
void do_info_snapshots(Monitor *mon)
1863 1860
{
1864
    DriveInfo *dinfo;
1865 1861
    BlockDriverState *bs, *bs1;
1866 1862
    QEMUSnapshotInfo *sn_tab, *sn;
1867 1863
    int nb_sns, i;
......
1873 1869
        return;
1874 1870
    }
1875 1871
    monitor_printf(mon, "Snapshot devices:");
1876
    QTAILQ_FOREACH(dinfo, &drives, next) {
1877
        bs1 = dinfo->bdrv;
1872
    bs1 = NULL;
1873
    while ((bs1 = bdrv_next(bs1))) {
1878 1874
        if (bdrv_can_snapshot(bs1)) {
1879 1875
            if (bs == bs1)
1880 1876
                monitor_printf(mon, " %s", bdrv_get_device_name(bs1));

Also available in: Unified diff