From 1417eb555b3590b72750e934b47628f59d40c296 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Blue Swirl Date: Sat, 26 Mar 2011 15:59:37 +0000 Subject: [PATCH 09/11] Introduce emulator state v2 Move all state related to current VM to emulator-state.h. Move a few migration related function declarations to migration.h. Signed-off-by: Blue Swirl --- emulator-state.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ sysemu.h | 42 +----------------------------------------- 2 files changed, 53 insertions(+), 41 deletions(-) create mode 100644 emulator-state.h diff --git a/emulator-state.h b/emulator-state.h new file mode 100644 index 0000000..4609382 --- /dev/null +++ b/emulator-state.h @@ -0,0 +1,52 @@ +#ifndef QEMU_EMULATOR_STATE_H +#define QEMU_EMULATOR_STATE_H +/* + * Emulator state: All state related to current VM. Usually not guest + * visible except for PV. + */ + +#include "qdict.h" + +extern int vm_running; + +typedef struct vm_change_state_entry VMChangeStateEntry; +typedef void VMChangeStateHandler(void *opaque, int running, int reason); + +VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, + void *opaque); +void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); + +#define VMSTOP_USER 0 +#define VMSTOP_DEBUG 1 +#define VMSTOP_SHUTDOWN 2 +#define VMSTOP_DISKFULL 3 +#define VMSTOP_WATCHDOG 4 +#define VMSTOP_PANIC 5 +#define VMSTOP_SAVEVM 6 +#define VMSTOP_LOADVM 7 +#define VMSTOP_MIGRATE 8 + +void vm_start(void); +void vm_stop(int reason); + +void qemu_system_vmstop_request(int reason); + +void do_savevm(Monitor *mon, const QDict *qdict); +int load_vmstate(const char *name); +void do_delvm(Monitor *mon, const QDict *qdict); +void do_info_snapshots(Monitor *mon); + +void qemu_announce_self(void); + +void main_loop_wait(int nonblocking); + +bool qemu_savevm_state_blocked(Monitor *mon); +int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable, + int shared); +int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f); +int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f); +void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f); +int qemu_loadvm_state(QEMUFile *f); + +extern int autostart; +#endif diff --git a/sysemu.h b/sysemu.h index 4bd1543..2d7a476 100644 --- a/sysemu.h +++ b/sysemu.h @@ -8,40 +8,18 @@ #include "qemu-timer.h" #include "notify.h" #include "host-state.h" +#include "emulator-state.h" /* vl.c */ extern const char *bios_name; - -extern int vm_running; extern uint8_t qemu_uuid[]; int qemu_uuid_parse(const char *str, uint8_t *uuid); #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" -typedef struct vm_change_state_entry VMChangeStateEntry; -typedef void VMChangeStateHandler(void *opaque, int running, int reason); - -VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, - void *opaque); -void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); - -#define VMSTOP_USER 0 -#define VMSTOP_DEBUG 1 -#define VMSTOP_SHUTDOWN 2 -#define VMSTOP_DISKFULL 3 -#define VMSTOP_WATCHDOG 4 -#define VMSTOP_PANIC 5 -#define VMSTOP_SAVEVM 6 -#define VMSTOP_LOADVM 7 -#define VMSTOP_MIGRATE 8 - -void vm_start(void); -void vm_stop(int reason); - void qemu_system_reset_request(void); void qemu_system_shutdown_request(void); void qemu_system_powerdown_request(void); void qemu_system_debug_request(void); -void qemu_system_vmstop_request(int reason); int qemu_shutdown_requested(void); int qemu_reset_requested(void); int qemu_powerdown_requested(void); @@ -50,24 +28,6 @@ void qemu_system_reset(void); void qemu_add_machine_init_done_notifier(Notifier *notify); -void do_savevm(Monitor *mon, const QDict *qdict); -int load_vmstate(const char *name); -void do_delvm(Monitor *mon, const QDict *qdict); -void do_info_snapshots(Monitor *mon); - -void qemu_announce_self(void); - -void main_loop_wait(int nonblocking); - -bool qemu_savevm_state_blocked(Monitor *mon); -int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable, - int shared); -int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f); -int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f); -void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f); -int qemu_loadvm_state(QEMUFile *f); - -extern int autostart; extern int bios_size; typedef enum { -- 1.7.2.5