savevm.c: Getting closer to upstream.
This patch refactors savevm.c considerably to get much closer
to upstream. The main benefit is the introduction of savevm_register()
and savevm_unregister() functions, which allow the client to provide
a description of the state through a VMStateDescription structure.
The 'legacy' register_savevm() and unregister_savevm() are still
provided (just like upstream does). Future patches will 'upgrade'
our virtual devices to the new interface.
NOTE: Since DeviceState is not implemented properly yet, qdev_get_path()
is stubbed to always return NULL.
Change-Id: I7bfa201da40a0e470fafde6ccc002a4216ecd9c1
diff --git a/hw/android/android_mips.c b/hw/android/android_mips.c
index ed9f42f..1d0f34f 100644
--- a/hw/android/android_mips.c
+++ b/hw/android/android_mips.c
@@ -167,7 +167,13 @@
env = cpu_init(cpu_model);
- register_savevm( "cpu", 0, MIPS_CPU_SAVE_VERSION, cpu_save, cpu_load, env );
+ register_savevm(NULL,
+ "cpu",
+ 0,
+ MIPS_CPU_SAVE_VERSION,
+ cpu_save,
+ cpu_load,
+ env);
if (ram_size > GOLDFISH_IO_SPACE)
ram_size = GOLDFISH_IO_SPACE; /* avoid overlap of ram and IO regs */
diff --git a/hw/android/goldfish/audio.c b/hw/android/goldfish/audio.c
index 228a7ca..9259a75 100644
--- a/hw/android/goldfish/audio.c
+++ b/hw/android/goldfish/audio.c
@@ -665,7 +665,12 @@
goldfish_device_add(&s->dev, goldfish_audio_readfn, goldfish_audio_writefn, s);
- register_savevm( "audio_state", 0, AUDIO_STATE_SAVE_VERSION,
- audio_state_save, audio_state_load, s );
+ register_savevm(NULL,
+ "audio_state",
+ 0,
+ AUDIO_STATE_SAVE_VERSION,
+ audio_state_save,
+ audio_state_load,
+ s);
}
diff --git a/hw/android/goldfish/battery.c b/hw/android/goldfish/battery.c
index 4797bbb..6624176 100644
--- a/hw/android/goldfish/battery.c
+++ b/hw/android/goldfish/battery.c
@@ -178,8 +178,13 @@
goldfish_device_add(&s->dev, goldfish_battery_readfn, goldfish_battery_writefn, s);
- register_savevm( "battery_state", 0, BATTERY_STATE_SAVE_VERSION,
- goldfish_battery_save, goldfish_battery_load, s);
+ register_savevm(NULL,
+ "battery_state",
+ 0,
+ BATTERY_STATE_SAVE_VERSION,
+ goldfish_battery_save,
+ goldfish_battery_load,
+ s);
}
void goldfish_battery_set_prop(int ac, int property, int value)
diff --git a/hw/android/goldfish/events_device.c b/hw/android/goldfish/events_device.c
index f11e7ab..6672678 100644
--- a/hw/android/goldfish/events_device.c
+++ b/hw/android/goldfish/events_device.c
@@ -537,6 +537,11 @@
*/
user_event_register_generic(s, events_put_generic);
- register_savevm( "events_state", 0, EVENTS_STATE_SAVE_VERSION,
- events_state_save, events_state_load, s );
+ register_savevm(NULL,
+ "events_state",
+ 0,
+ EVENTS_STATE_SAVE_VERSION,
+ events_state_save,
+ events_state_load,
+ s);
}
diff --git a/hw/android/goldfish/fb.c b/hw/android/goldfish/fb.c
index da7376f..8738321 100644
--- a/hw/android/goldfish/fb.c
+++ b/hw/android/goldfish/fb.c
@@ -672,6 +672,11 @@
goldfish_device_add(&s->dev, goldfish_fb_readfn, goldfish_fb_writefn, s);
- register_savevm( "goldfish_fb", 0, GOLDFISH_FB_SAVE_VERSION,
- goldfish_fb_save, goldfish_fb_load, s);
+ register_savevm(NULL,
+ "goldfish_fb",
+ 0,
+ GOLDFISH_FB_SAVE_VERSION,
+ goldfish_fb_save,
+ goldfish_fb_load,
+ s);
}
diff --git a/hw/android/goldfish/interrupt.c b/hw/android/goldfish/interrupt.c
index b7738e6..6b6abb0 100644
--- a/hw/android/goldfish/interrupt.c
+++ b/hw/android/goldfish/interrupt.c
@@ -181,8 +181,13 @@
return NULL;
}
- register_savevm( "goldfish_int", 0, GOLDFISH_INT_SAVE_VERSION,
- goldfish_int_save, goldfish_int_load, s);
+ register_savevm(NULL,
+ "goldfish_int",
+ 0,
+ GOLDFISH_INT_SAVE_VERSION,
+ goldfish_int_save,
+ goldfish_int_load,
+ s);
return qi;
}
diff --git a/hw/android/goldfish/mmc.c b/hw/android/goldfish/mmc.c
index a4e1177..cfd483a 100644
--- a/hw/android/goldfish/mmc.c
+++ b/hw/android/goldfish/mmc.c
@@ -533,7 +533,12 @@
goldfish_device_add(&s->dev, goldfish_mmc_readfn, goldfish_mmc_writefn, s);
- register_savevm( "goldfish_mmc", 0, GOLDFISH_MMC_SAVE_VERSION,
- goldfish_mmc_save, goldfish_mmc_load, s);
+ register_savevm(NULL,
+ "goldfish_mmc",
+ 0,
+ GOLDFISH_MMC_SAVE_VERSION,
+ goldfish_mmc_save,
+ goldfish_mmc_load,
+ s);
}
diff --git a/hw/android/goldfish/nand.c b/hw/android/goldfish/nand.c
index d52b377..b3c7e6f 100644
--- a/hw/android/goldfish/nand.c
+++ b/hw/android/goldfish/nand.c
@@ -681,8 +681,13 @@
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
s->base = base;
- register_savevm( "nand_dev", instance_id++, NAND_DEV_STATE_SAVE_VERSION,
- nand_dev_controller_state_save, nand_dev_controller_state_load, s);
+ register_savevm(NULL,
+ "nand_dev",
+ instance_id++,
+ NAND_DEV_STATE_SAVE_VERSION,
+ nand_dev_controller_state_save,
+ nand_dev_controller_state_load,
+ s);
}
static int arg_match(const char *a, const char *b, size_t b_len)
diff --git a/hw/android/goldfish/pipe.c b/hw/android/goldfish/pipe.c
index 719dce7..95b29e6 100644
--- a/hw/android/goldfish/pipe.c
+++ b/hw/android/goldfish/pipe.c
@@ -1327,8 +1327,13 @@
goldfish_device_add(&s->dev, pipe_dev_readfn, pipe_dev_writefn, s);
- register_savevm( "goldfish_pipe", 0, GOLDFISH_PIPE_SAVE_VERSION,
- goldfish_pipe_save, goldfish_pipe_load, s);
+ register_savevm(NULL,
+ "goldfish_pipe",
+ 0,
+ GOLDFISH_PIPE_SAVE_VERSION,
+ goldfish_pipe_save,
+ goldfish_pipe_load,
+ s);
#if DEBUG_ZERO_PIPE
goldfish_pipe_add_type("zero", NULL, &zeroPipe_funcs);
diff --git a/hw/android/goldfish/switch.c b/hw/android/goldfish/switch.c
index 5f5eaae..4208545 100644
--- a/hw/android/goldfish/switch.c
+++ b/hw/android/goldfish/switch.c
@@ -164,8 +164,13 @@
return NULL;
}
- register_savevm( "goldfish_switch", 0, GOLDFISH_SWITCH_SAVE_VERSION,
- goldfish_switch_save, goldfish_switch_load, s);
+ register_savevm(NULL,
+ "goldfish_switch",
+ 0,
+ GOLDFISH_SWITCH_SAVE_VERSION,
+ goldfish_switch_save,
+ goldfish_switch_load,
+ s);
return s;
}
diff --git a/hw/android/goldfish/timer.c b/hw/android/goldfish/timer.c
index 3d46db0..b8921e5 100644
--- a/hw/android/goldfish/timer.c
+++ b/hw/android/goldfish/timer.c
@@ -238,11 +238,21 @@
timer_state.dev.irq = timerirq;
timer_state.timer = timer_new(QEMU_CLOCK_VIRTUAL, SCALE_NS, goldfish_timer_tick, &timer_state);
goldfish_device_add(&timer_state.dev, goldfish_timer_readfn, goldfish_timer_writefn, &timer_state);
- register_savevm( "goldfish_timer", 0, GOLDFISH_TIMER_SAVE_VERSION,
- goldfish_timer_save, goldfish_timer_load, &timer_state);
+ register_savevm(NULL,
+ "goldfish_timer",
+ 0,
+ GOLDFISH_TIMER_SAVE_VERSION,
+ goldfish_timer_save,
+ goldfish_timer_load,
+ &timer_state);
goldfish_device_add(&rtc_state.dev, goldfish_rtc_readfn, goldfish_rtc_writefn, &rtc_state);
- register_savevm( "goldfish_rtc", 0, GOLDFISH_RTC_SAVE_VERSION,
- goldfish_rtc_save, goldfish_rtc_load, &rtc_state);
+ register_savevm(NULL,
+ "goldfish_rtc",
+ 0,
+ GOLDFISH_RTC_SAVE_VERSION,
+ goldfish_rtc_save,
+ goldfish_rtc_load,
+ &rtc_state);
}
diff --git a/hw/android/goldfish/tty.c b/hw/android/goldfish/tty.c
index cd8db89..066448b 100644
--- a/hw/android/goldfish/tty.c
+++ b/hw/android/goldfish/tty.c
@@ -229,8 +229,13 @@
if(ret) {
g_free(s);
} else {
- register_savevm( "goldfish_tty", instance_id++, GOLDFISH_TTY_SAVE_VERSION,
- goldfish_tty_save, goldfish_tty_load, s);
+ register_savevm(NULL,
+ "goldfish_tty",
+ instance_id++,
+ GOLDFISH_TTY_SAVE_VERSION,
+ goldfish_tty_save,
+ goldfish_tty_load,
+ s);
}
return ret;
}