aboutsummaryrefslogtreecommitdiff
path: root/savevm.c
diff options
context:
space:
mode:
Diffstat (limited to 'savevm.c')
-rw-r--r--savevm.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/savevm.c b/savevm.c
index 181c088494..0c0b49f1d0 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1011,12 +1011,12 @@ static int bdrv_has_snapshot(BlockDriverState *bs)
static BlockDriverState *get_bs_snapshots(void)
{
BlockDriverState *bs;
- int i;
+ DriveInfo *dinfo;
if (bs_snapshots)
return bs_snapshots;
- for(i = 0; i <= nb_drives; i++) {
- bs = drives_table[i].bdrv;
+ TAILQ_FOREACH(dinfo, &drives, next) {
+ bs = dinfo->bdrv;
if (bdrv_can_snapshot(bs))
goto ok;
}
@@ -1050,9 +1050,10 @@ static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
void do_savevm(Monitor *mon, const char *name)
{
+ DriveInfo *dinfo;
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
- int must_delete, ret, i;
+ int must_delete, ret;
QEMUFile *f;
int saved_vm_running;
uint32_t vm_state_size;
@@ -1118,8 +1119,8 @@ void do_savevm(Monitor *mon, const char *name)
/* create the snapshots */
- for(i = 0; i < nb_drives; i++) {
- bs1 = drives_table[i].bdrv;
+ TAILQ_FOREACH(dinfo, &drives, next) {
+ bs1 = dinfo->bdrv;
if (bdrv_has_snapshot(bs1)) {
if (must_delete) {
ret = bdrv_snapshot_delete(bs1, old_sn->id_str);
@@ -1146,10 +1147,11 @@ void do_savevm(Monitor *mon, const char *name)
void do_loadvm(Monitor *mon, const char *name)
{
+ DriveInfo *dinfo;
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo sn;
QEMUFile *f;
- int i, ret;
+ int ret;
int saved_vm_running;
bs = get_bs_snapshots();
@@ -1164,8 +1166,8 @@ void do_loadvm(Monitor *mon, const char *name)
saved_vm_running = vm_running;
vm_stop(0);
- for(i = 0; i <= nb_drives; i++) {
- bs1 = drives_table[i].bdrv;
+ TAILQ_FOREACH(dinfo, &drives, next) {
+ bs1 = dinfo->bdrv;
if (bdrv_has_snapshot(bs1)) {
ret = bdrv_snapshot_goto(bs1, name);
if (ret < 0) {
@@ -1217,8 +1219,9 @@ void do_loadvm(Monitor *mon, const char *name)
void do_delvm(Monitor *mon, const char *name)
{
+ DriveInfo *dinfo;
BlockDriverState *bs, *bs1;
- int i, ret;
+ int ret;
bs = get_bs_snapshots();
if (!bs) {
@@ -1226,8 +1229,8 @@ void do_delvm(Monitor *mon, const char *name)
return;
}
- for(i = 0; i <= nb_drives; i++) {
- bs1 = drives_table[i].bdrv;
+ TAILQ_FOREACH(dinfo, &drives, next) {
+ bs1 = dinfo->bdrv;
if (bdrv_has_snapshot(bs1)) {
ret = bdrv_snapshot_delete(bs1, name);
if (ret < 0) {
@@ -1245,6 +1248,7 @@ void do_delvm(Monitor *mon, const char *name)
void do_info_snapshots(Monitor *mon)
{
+ DriveInfo *dinfo;
BlockDriverState *bs, *bs1;
QEMUSnapshotInfo *sn_tab, *sn;
int nb_sns, i;
@@ -1256,8 +1260,8 @@ void do_info_snapshots(Monitor *mon)
return;
}
monitor_printf(mon, "Snapshot devices:");
- for(i = 0; i <= nb_drives; i++) {
- bs1 = drives_table[i].bdrv;
+ TAILQ_FOREACH(dinfo, &drives, next) {
+ bs1 = dinfo->bdrv;
if (bdrv_has_snapshot(bs1)) {
if (bs == bs1)
monitor_printf(mon, " %s", bdrv_get_device_name(bs1));