aboutsummaryrefslogtreecommitdiff
path: root/savevm.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-07-22 16:42:57 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-07-27 14:08:23 -0500
commit751c6a17042b5d011013d6963c0505d671cf708e (patch)
tree61a769ed1a1c16ebdfc1397ce9d775222dfa8e57 /savevm.c
parent8a14daa5a1ae22fcfc317f4727a88d6c15c39aae (diff)
kill drives_table
First step cleaning up the drives handling. This one does nothing but removing drives_table[], still it became seriously big. drive_get_index() is gone and is replaced by drives_get() which hands out DriveInfo pointers instead of a table index. This needs adaption in *tons* of places all over. The drives are now maintained as linked list. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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));