qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/4] Introduce VM state


From: Blue Swirl
Subject: [Qemu-devel] [PATCH 2/4] Introduce VM state
Date: Sun, 27 Mar 2011 00:26:49 +0200

Move all state related to current VM and migration to vm-state.h.

Signed-off-by: Blue Swirl <address@hidden>
---
 arch_init.c          |    1 +
 audio/audio.c        |    2 +-
 blockdev.c           |    2 +-
 cpus.c               |    1 +
 gdbstub.c            |    2 +-
 hw/fw_cfg.c          |    1 +
 hw/ide/cmd646.c      |    2 +-
 hw/ide/core.c        |    1 +
 hw/ide/piix.c        |    2 +-
 hw/ide/via.c         |    2 +-
 hw/scsi-disk.c       |    1 +
 hw/smbios.c          |    1 +
 hw/sun4m.c           |    1 +
 hw/usb-msd.c         |    1 +
 hw/virtio.h          |    1 +
 hw/watchdog.c        |    1 +
 hw/xen_domainbuild.c |    2 +-
 hw/xenfb.c           |    2 +-
 kvm-all.c            |    1 +
 migration.c          |    2 +-
 monitor.c            |    1 +
 qemu-timer.c         |    1 +
 savevm.c             |    1 +
 sysemu.h             |   49 -----------------------------------------
 target-i386/kvm.c    |    1 +
 ui/sdl.c             |    1 +
 vl.c                 |    1 +
 vm-state.h           |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 28 files changed, 85 insertions(+), 58 deletions(-)
 create mode 100644 vm-state.h

diff --git a/arch_init.c b/arch_init.c
index 0c09f91..2dac75c 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -41,6 +41,7 @@
 #include "net.h"
 #include "gdbstub.h"
 #include "hw/smbios.h"
+#include "vm-state.h"

 #ifdef TARGET_SPARC
 int graphic_width = 1024;
diff --git a/audio/audio.c b/audio/audio.c
index 50d2b64..c9fcbba 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -25,7 +25,7 @@
 #include "audio.h"
 #include "monitor.h"
 #include "qemu-timer.h"
-#include "sysemu.h"
+#include "vm-state.h"

 #define AUDIO_CAP "audio"
 #include "audio_int.h"
diff --git a/blockdev.c b/blockdev.c
index ecf2252..8a38c6b 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -13,9 +13,9 @@
 #include "qerror.h"
 #include "qemu-option.h"
 #include "qemu-config.h"
-#include "sysemu.h"
 #include "hw/qdev.h"
 #include "block_int.h"
+#include "vm-state.h"

 static QTAILQ_HEAD(drivelist, DriveInfo) drives =
QTAILQ_HEAD_INITIALIZER(drives);

diff --git a/cpus.c b/cpus.c
index 41bec7c..0dce227 100644
--- a/cpus.c
+++ b/cpus.c
@@ -35,6 +35,7 @@
 #include "qemu-thread.h"
 #include "cpus.h"
 #include "compatfd.h"
+#include "vm-state.h"

 #ifdef SIGRTMIN
 #define SIG_IPI (SIGRTMIN+4)
diff --git a/gdbstub.c b/gdbstub.c
index 1e9f931..c1745a9 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -31,8 +31,8 @@
 #else
 #include "monitor.h"
 #include "qemu-char.h"
-#include "sysemu.h"
 #include "gdbstub.h"
+#include "vm-state.h"
 #endif

 #define MAX_PACKET_LENGTH 4096
diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c
index 3c191d0..0eb862f 100644
--- a/hw/fw_cfg.c
+++ b/hw/fw_cfg.c
@@ -27,6 +27,7 @@
 #include "fw_cfg.h"
 #include "sysbus.h"
 #include "host-state.h"
+#include "vm-state.h"

 /* debug firmware config */
 //#define DEBUG_FW_CFG
diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index 5d5464a..91f5082 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -28,8 +28,8 @@
 #include <hw/isa.h>
 #include "block.h"
 #include "block_int.h"
-#include "sysemu.h"
 #include "dma.h"
+#include "vm-state.h"

 #include <hw/ide/pci.h>

diff --git a/hw/ide/core.c b/hw/ide/core.c
index 007a4ee..342feb1 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -33,6 +33,7 @@
 #include "blockdev.h"

 #include <hw/ide/internal.h>
+#include "vm-state.h"

 /* These values were based on a Seagate ST3500418AS but have been modified
    to make more sense in QEMU */
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index c349644..7594bca 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -28,8 +28,8 @@
 #include <hw/isa.h>
 #include "block.h"
 #include "block_int.h"
-#include "sysemu.h"
 #include "dma.h"
+#include "vm-state.h"

 #include <hw/ide/pci.h>

diff --git a/hw/ide/via.c b/hw/ide/via.c
index 04f3290..e260bc5 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -29,8 +29,8 @@
 #include <hw/isa.h>
 #include "block.h"
 #include "block_int.h"
-#include "sysemu.h"
 #include "dma.h"
+#include "vm-state.h"

 #include <hw/ide/pci.h>

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index b05e654..c3f60e0 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -37,6 +37,7 @@ do { fprintf(stderr, "scsi-disk: " fmt , ##
__VA_ARGS__); } while (0)
 #include "scsi-defs.h"
 #include "sysemu.h"
 #include "blockdev.h"
+#include "vm-state.h"

 #define SCSI_DMA_BUF_SIZE    131072
 #define SCSI_MAX_INQUIRY_LEN 256
diff --git a/hw/smbios.c b/hw/smbios.c
index a3ae1de..95f9935 100644
--- a/hw/smbios.c
+++ b/hw/smbios.c
@@ -14,6 +14,7 @@
 #include "sysemu.h"
 #include "smbios.h"
 #include "loader.h"
+#include "vm-state.h"

 /*
  * Structures shared with the BIOS
diff --git a/hw/sun4m.c b/hw/sun4m.c
index df3aa32..6719bdf 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -42,6 +42,7 @@
 #include "elf.h"
 #include "blockdev.h"
 #include "trace.h"
+#include "host-state.h"

 /*
  * Sun4m architecture was used in the following machines:
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index 76f5b02..edd3f3b 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -17,6 +17,7 @@
 #include "monitor.h"
 #include "sysemu.h"
 #include "blockdev.h"
+#include "vm-state.h"

 //#define DEBUG_MSD

diff --git a/hw/virtio.h b/hw/virtio.h
index d0920a8..8cff445 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -20,6 +20,7 @@
 #include "sysemu.h"
 #include "block_int.h"
 #include "event_notifier.h"
+#include "vm-state.h"
 #ifdef CONFIG_LINUX
 #include "9p.h"
 #endif
diff --git a/hw/watchdog.c b/hw/watchdog.c
index 1c900a1..30dd91b 100644
--- a/hw/watchdog.c
+++ b/hw/watchdog.c
@@ -27,6 +27,7 @@
 #include "monitor.h"
 #include "sysemu.h"
 #include "hw/watchdog.h"
+#include "vm-state.h"

 /* Possible values for action parameter. */
 #define WDT_RESET        1     /* Hard reset. */
diff --git a/hw/xen_domainbuild.c b/hw/xen_domainbuild.c
index 9440864..adad8c3 100644
--- a/hw/xen_domainbuild.c
+++ b/hw/xen_domainbuild.c
@@ -1,10 +1,10 @@
 #include <signal.h>
 #include "xen_backend.h"
 #include "xen_domainbuild.h"
-#include "sysemu.h"
 #include "qemu-timer.h"
 #include "qemu-log.h"
 #include "host-state.h"
+#include "vm-state.h"

 #include <xenguest.h>

diff --git a/hw/xenfb.c b/hw/xenfb.c
index da5297b..2229de3 100644
--- a/hw/xenfb.c
+++ b/hw/xenfb.c
@@ -44,10 +44,10 @@
 #include <xen/io/protocols.h>

 #include "hw.h"
-#include "sysemu.h"
 #include "console.h"
 #include "qemu-char.h"
 #include "xen_backend.h"
+#include "vm-state.h"

 #ifndef BTN_LEFT
 #define BTN_LEFT 0x110 /* from <linux/input.h> */
diff --git a/kvm-all.c b/kvm-all.c
index 1d7e8ea..79c7327 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -27,6 +27,7 @@
 #include "gdbstub.h"
 #include "kvm.h"
 #include "bswap.h"
+#include "vm-state.h"

 /* This check must be after config-host.h is included */
 #ifdef CONFIG_EVENTFD
diff --git a/migration.c b/migration.c
index af3a1f2..4612473 100644
--- a/migration.c
+++ b/migration.c
@@ -15,11 +15,11 @@
 #include "migration.h"
 #include "monitor.h"
 #include "buffered_file.h"
-#include "sysemu.h"
 #include "block.h"
 #include "qemu_socket.h"
 #include "block-migration.h"
 #include "qemu-objects.h"
+#include "vm-state.h"

 //#define DEBUG_MIGRATION

diff --git a/monitor.c b/monitor.c
index d8cf21d..fa02d57 100644
--- a/monitor.c
+++ b/monitor.c
@@ -62,6 +62,7 @@
 #endif
 #include "ui/qemu-spice.h"
 #include "host-state.h"
+#include "vm-state.h"

 //#define DEBUG
 //#define DEBUG_COMPLETION
diff --git a/qemu-timer.c b/qemu-timer.c
index 50f1943..f7338c6 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -53,6 +53,7 @@
 #include <mmsystem.h>
 #endif

+#include "vm-state.h"
 #include "qemu-timer.h"

 /* Conversion factor from emulated instructions to virtual clock ticks.  */
diff --git a/savevm.c b/savevm.c
index 03fce62..418fb97 100644
--- a/savevm.c
+++ b/savevm.c
@@ -82,6 +82,7 @@
 #include "migration.h"
 #include "qemu_socket.h"
 #include "qemu-queue.h"
+#include "vm-state.h"

 #define SELF_ANNOUNCE_ROUNDS 5

diff --git a/sysemu.h b/sysemu.h
index 8e54a01..6dbec35 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -24,35 +24,6 @@ extern const char *bios_name;
 #define QEMU_FILE_TYPE_KEYMAP 1
 char *qemu_find_file(int type, const char *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);
-
-uint64_t ram_bytes_remaining(void);
-uint64_t ram_bytes_transferred(void);
-uint64_t ram_bytes_total(void);
-
 int64_t cpu_get_ticks(void);
 void cpu_enable_ticks(void);
 void cpu_disable_ticks(void);
@@ -61,7 +32,6 @@ 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);
@@ -70,35 +40,16 @@ 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 cpu_synchronize_all_states(void);
 void cpu_synchronize_all_post_reset(void);
 void cpu_synchronize_all_post_init(void);

-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);
-
 /* OS specific functions */
 void os_setup_early_signal_handling(void);
 char *os_find_datadir(const char *argv0);
 void os_parse_cmd_args(int index, const char *optarg);
 void os_pidfile_error(void);

-extern int autostart;
-extern int incoming_expected;
 extern int bios_size;

 typedef enum {
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index a13599d..75ff202 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -28,6 +28,7 @@
 #include "hw/pc.h"
 #include "hw/apic.h"
 #include "ioport.h"
+#include "vm-state.h"

 #ifdef CONFIG_KVM_PARA
 #include <linux/kvm_para.h>
diff --git a/ui/sdl.c b/ui/sdl.c
index 6a96ea1..0545915 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -38,6 +38,7 @@
 #include "x_keymap.h"
 #include "sdl_zoom.h"
 #include "host-state.h"
+#include "vm-state.h"

 static DisplayChangeListener *dcl;
 static SDL_Surface *real_screen;
diff --git a/vl.c b/vl.c
index 4354674..71a7616 100644
--- a/vl.c
+++ b/vl.c
@@ -161,6 +161,7 @@ int main(int argc, char **argv)
 #include "cpus.h"
 #include "arch_init.h"
 #include "host-state.h"
+#include "vm-state.h"

 #include "ui/qemu-spice.h"

diff --git a/vm-state.h b/vm-state.h
new file mode 100644
index 0000000..8e09e4b
--- /dev/null
+++ b/vm-state.h
@@ -0,0 +1,59 @@
+#ifndef QEMU_VM_STATE_H
+#define QEMU_VM_STATE_H
+/*
+ * VM state: All state related to current VM, migration. Usually not
+ * guest visible except for PV.
+ */
+
+#include "qdict.h"
+
+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);
+
+uint64_t ram_bytes_remaining(void);
+uint64_t ram_bytes_transferred(void);
+uint64_t ram_bytes_total(void);
+
+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);
+
+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);
+void qemu_announce_self(void);
+
+extern int autostart;
+extern int incoming_expected;
+
+void main_loop_wait(int nonblocking);
+
+#endif
-- 
1.6.2.4

Attachment: 0002-Introduce-VM-state.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]