Patchwork [3/4] Introduce machine state

login
register
mail settings
Submitter Blue Swirl
Date March 26, 2011, 10:28 p.m.
Message ID <AANLkTikkPbsov3it21-j=Fs12jz21-b0C=iG09WMwx7V@mail.gmail.com>
Download mbox | patch
Permalink /patch/88483/
State New
Headers show

Comments

Blue Swirl - March 26, 2011, 10:28 p.m.
Move generic machine state to machine-state.h, adjust
users.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 cpus.c                   |    1 +
 hw/acpi_piix4.c          |    2 +-
 hw/apb_pci.c             |    2 +-
 hw/arm_boot.c            |    2 +-
 hw/arm_sysctl.c          |    2 +-
 hw/bonito.c              |    2 +-
 hw/cbus.c                |    2 +-
 hw/cuda.c                |    2 +-
 hw/e1000.c               |    2 +-
 hw/eepro100.c            |    2 +-
 hw/etraxfs_dma.c         |    2 +-
 hw/etraxfs_timer.c       |    2 +-
 hw/fdc.c                 |    2 +-
 hw/fw_cfg.c              |    2 +-
 hw/ide/core.c            |    2 +-
 hw/ide/qdev.c            |    2 +-
 hw/leon3.c               |    2 +-
 hw/lm32_sys.c            |    2 +-
 hw/loader.c              |    2 +-
 hw/m48t59.c              |    2 +-
 hw/mac_nvram.c           |    2 +-
 hw/mc146818rtc.c         |    2 +-
 hw/mcf5206.c             |    2 +-
 hw/mcf5208.c             |    2 +-
 hw/mips_fulong2e.c       |    2 +-
 hw/mips_jazz.c           |    2 +-
 hw/mips_malta.c          |    2 +-
 hw/mips_mipssim.c        |    2 +-
 hw/mips_r4k.c            |    2 +-
 hw/multiboot.c           |    2 +-
 hw/musicpal.c            |    2 +-
 hw/ne2000.c              |    2 +-
 hw/nseries.c             |    2 +-
 hw/omap1.c               |    2 +-
 hw/omap2.c               |    2 +-
 hw/palm.c                |    2 +-
 hw/parallel.c            |    2 +-
 hw/pc.c                  |    1 +
 hw/pc_piix.c             |    2 +-
 hw/pci-hotplug.c         |    1 +
 hw/pci-stub.c            |    1 +
 hw/pci.c                 |    2 +-
 hw/pcie_aer.c            |    2 +-
 hw/pckbd.c               |    2 +-
 hw/pcnet.c               |    2 +-
 hw/petalogix_ml605_mmu.c |    2 +-
 hw/ppc.c                 |    2 +-
 hw/ppc405_boards.c       |    2 +-
 hw/ppc405_uc.c           |    2 +-
 hw/ppc440.c              |    2 +-
 hw/ppc_newworld.c        |    2 +-
 hw/ppc_oldworld.c        |    2 +-
 hw/ppc_prep.c            |    2 +-
 hw/ppce500_mpc8544ds.c   |    2 +-
 hw/pxa2xx.c              |    2 +-
 hw/pxa2xx_lcd.c          |    4 +-
 hw/pxa2xx_timer.c        |    2 +-
 hw/qdev.c                |    2 +-
 hw/r2d.c                 |    2 +-
 hw/realview.c            |    2 +-
 hw/rtl8139.c             |    2 +-
 hw/scsi-disk.c           |    2 +-
 hw/serial.c              |    2 +-
 hw/sh7750.c              |    2 +-
 hw/shix.c                |    2 +-
 hw/slavio_misc.c         |    2 +-
 hw/smbios.c              |    4 +-
 hw/spitz.c               |    3 +-
 hw/sun4m.c               |    2 +-
 hw/sun4u.c               |    2 +-
 hw/usb-msd.c             |    2 +-
 hw/usb-net.c             |    2 +-
 hw/versatilepb.c         |    2 +-
 hw/virtex_ml507.c        |    2 +-
 hw/virtio-blk.c          |    1 +
 hw/virtio-net.c          |    1 +
 hw/vt82c686.c            |    2 +-
 hw/watchdog.c            |    1 +
 hw/xen_console.c         |    2 +-
 hw/xen_domainbuild.c     |    1 +
 hw/xen_machine_pv.c      |    2 +-
 input.c                  |    2 +-
 kvm-all.c                |    2 +-
 machine-state.h          |  100 ++++++++++++++++++++++++++++++++++++++++++++++
 monitor.c                |    1 +
 qemu-common.h            |    5 ++
 qemu-timer.c             |    1 +
 sysemu.h                 |   92 ------------------------------------------
 target-i386/helper.c     |    2 +-
 target-i386/kvm.c        |    2 +-
 target-sparc/op_helper.c |    2 +-
 ui/sdl.c                 |    1 +
 vl.c                     |    1 +
 93 files changed, 199 insertions(+), 171 deletions(-)
 create mode 100644 machine-state.h
Paolo Bonzini - March 28, 2011, 7:25 a.m.
On 03/26/2011 11:28 PM, Blue Swirl wrote:
> Move generic machine state to machine-state.h, adjust
> users.

What's the distinction between vm state and machine state?

Perhaps your vm state is more appropriately called "emulator state" 
(i.e. sits between host and vm), and machine state is actually "vm state"?

BTW, uuid should be in machine state rather than (your definition of) vm 
state.

Paolo
Blue Swirl - March 28, 2011, 5:21 p.m.
On Mon, Mar 28, 2011 at 10:25 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> On 03/26/2011 11:28 PM, Blue Swirl wrote:
>>
>> Move generic machine state to machine-state.h, adjust
>> users.
>
> What's the distinction between vm state and machine state?

Machine state or configuration is visible to guest, for example number
of CPUs. Machine level actions are also guest visible, for example
hotplugging.

VM state should be invisible (except for PV devices).

> Perhaps your vm state is more appropriately called "emulator state" (i.e.
> sits between host and vm), and machine state is actually "vm state"?

I agree that the names are not so great. But 'emulator' is a bit
generic. About 'machine', I was thinking about -M switch to specify
the emulated machine type.

> BTW, uuid should be in machine state rather than (your definition of) vm
> state.

Right.

About patch sequencing, it should be possible to avoid most of the
changes until the last patch set, by adding for example
#include "vm-state.h"
to sysemu.h when vm-state.h is introduced. The last patch, which
removes sysemu.h, would adjust all sysemu.h users at once.

If the general view is that this patch set goes to the right
direction, the next step after machine/vm state would be to introduce
generic VCPU state, probably based on cpus.[ch].
Paolo Bonzini - March 29, 2011, 8:14 a.m.
On 03/28/2011 07:21 PM, Blue Swirl wrote:
>> >
>> >  What's the distinction between vm state and machine state?
>
> VM state should be invisible (except for PV devices).

Got it.  That's why I called it "emulator state" (a bit generic, but 
more precise than vm state: vm_clock for example is guest-visible).

> About 'machine', I was thinking about -M switch to specify
> the emulated machine type.

Yes, makes sense.  I actually like the name machine state, as long as 
you rename what you called "virtual machine state".

Paolo
Blue Swirl - March 29, 2011, 5:50 p.m.
On Tue, Mar 29, 2011 at 11:14 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> On 03/28/2011 07:21 PM, Blue Swirl wrote:
>>>
>>> >
>>> >  What's the distinction between vm state and machine state?
>>
>> VM state should be invisible (except for PV devices).
>
> Got it.  That's why I called it "emulator state" (a bit generic, but more
> precise than vm state: vm_clock for example is guest-visible).
>
>> About 'machine', I was thinking about -M switch to specify
>> the emulated machine type.
>
> Yes, makes sense.  I actually like the name machine state, as long as you
> rename what you called "virtual machine state".

OK, I'll change 'vm' to 'emulator'. Thanks for the review.

Patch

From 66f07911d44650f17375192d85cc32d3d50f14c5 Mon Sep 17 00:00:00 2001
Message-Id: <66f07911d44650f17375192d85cc32d3d50f14c5.1301178270.git.blauwirbel@gmail.com>
In-Reply-To: <1ae00000c153f56f45a62e9520a773bbfa3d185c.1301178269.git.blauwirbel@gmail.com>
References: <1ae00000c153f56f45a62e9520a773bbfa3d185c.1301178269.git.blauwirbel@gmail.com>
From: Blue Swirl <blauwirbel@gmail.com>
Date: Sat, 26 Mar 2011 18:41:36 +0000
Subject: [PATCH 3/4] Introduce machine state

Move generic machine state to machine-state.h, adjust
users.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 cpus.c                   |    1 +
 hw/acpi_piix4.c          |    2 +-
 hw/apb_pci.c             |    2 +-
 hw/arm_boot.c            |    2 +-
 hw/arm_sysctl.c          |    2 +-
 hw/bonito.c              |    2 +-
 hw/cbus.c                |    2 +-
 hw/cuda.c                |    2 +-
 hw/e1000.c               |    2 +-
 hw/eepro100.c            |    2 +-
 hw/etraxfs_dma.c         |    2 +-
 hw/etraxfs_timer.c       |    2 +-
 hw/fdc.c                 |    2 +-
 hw/fw_cfg.c              |    2 +-
 hw/ide/core.c            |    2 +-
 hw/ide/qdev.c            |    2 +-
 hw/leon3.c               |    2 +-
 hw/lm32_sys.c            |    2 +-
 hw/loader.c              |    2 +-
 hw/m48t59.c              |    2 +-
 hw/mac_nvram.c           |    2 +-
 hw/mc146818rtc.c         |    2 +-
 hw/mcf5206.c             |    2 +-
 hw/mcf5208.c             |    2 +-
 hw/mips_fulong2e.c       |    2 +-
 hw/mips_jazz.c           |    2 +-
 hw/mips_malta.c          |    2 +-
 hw/mips_mipssim.c        |    2 +-
 hw/mips_r4k.c            |    2 +-
 hw/multiboot.c           |    2 +-
 hw/musicpal.c            |    2 +-
 hw/ne2000.c              |    2 +-
 hw/nseries.c             |    2 +-
 hw/omap1.c               |    2 +-
 hw/omap2.c               |    2 +-
 hw/palm.c                |    2 +-
 hw/parallel.c            |    2 +-
 hw/pc.c                  |    1 +
 hw/pc_piix.c             |    2 +-
 hw/pci-hotplug.c         |    1 +
 hw/pci-stub.c            |    1 +
 hw/pci.c                 |    2 +-
 hw/pcie_aer.c            |    2 +-
 hw/pckbd.c               |    2 +-
 hw/pcnet.c               |    2 +-
 hw/petalogix_ml605_mmu.c |    2 +-
 hw/ppc.c                 |    2 +-
 hw/ppc405_boards.c       |    2 +-
 hw/ppc405_uc.c           |    2 +-
 hw/ppc440.c              |    2 +-
 hw/ppc_newworld.c        |    2 +-
 hw/ppc_oldworld.c        |    2 +-
 hw/ppc_prep.c            |    2 +-
 hw/ppce500_mpc8544ds.c   |    2 +-
 hw/pxa2xx.c              |    2 +-
 hw/pxa2xx_lcd.c          |    4 +-
 hw/pxa2xx_timer.c        |    2 +-
 hw/qdev.c                |    2 +-
 hw/r2d.c                 |    2 +-
 hw/realview.c            |    2 +-
 hw/rtl8139.c             |    2 +-
 hw/scsi-disk.c           |    2 +-
 hw/serial.c              |    2 +-
 hw/sh7750.c              |    2 +-
 hw/shix.c                |    2 +-
 hw/slavio_misc.c         |    2 +-
 hw/smbios.c              |    4 +-
 hw/spitz.c               |    3 +-
 hw/sun4m.c               |    2 +-
 hw/sun4u.c               |    2 +-
 hw/usb-msd.c             |    2 +-
 hw/usb-net.c             |    2 +-
 hw/versatilepb.c         |    2 +-
 hw/virtex_ml507.c        |    2 +-
 hw/virtio-blk.c          |    1 +
 hw/virtio-net.c          |    1 +
 hw/vt82c686.c            |    2 +-
 hw/watchdog.c            |    1 +
 hw/xen_console.c         |    2 +-
 hw/xen_domainbuild.c     |    1 +
 hw/xen_machine_pv.c      |    2 +-
 input.c                  |    2 +-
 kvm-all.c                |    2 +-
 machine-state.h          |  100 ++++++++++++++++++++++++++++++++++++++++++++++
 monitor.c                |    1 +
 qemu-common.h            |    5 ++
 qemu-timer.c             |    1 +
 sysemu.h                 |   92 ------------------------------------------
 target-i386/helper.c     |    2 +-
 target-i386/kvm.c        |    2 +-
 target-sparc/op_helper.c |    2 +-
 ui/sdl.c                 |    1 +
 vl.c                     |    1 +
 93 files changed, 199 insertions(+), 171 deletions(-)
 create mode 100644 machine-state.h

diff --git a/cpus.c b/cpus.c
index 0dce227..997a60d 100644
--- a/cpus.c
+++ b/cpus.c
@@ -36,6 +36,7 @@ 
 #include "cpus.h"
 #include "compatfd.h"
 #include "vm-state.h"
+#include "machine-state.h"
 
 #ifdef SIGRTMIN
 #define SIG_IPI (SIGRTMIN+4)
diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 0b2bc97..54adbc4 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -21,8 +21,8 @@ 
 #include "pm_smbus.h"
 #include "pci.h"
 #include "acpi.h"
-#include "sysemu.h"
 #include "range.h"
+#include "machine-state.h"
 
 //#define DEBUG
 
diff --git a/hw/apb_pci.c b/hw/apb_pci.c
index 84e9af7..332e745 100644
--- a/hw/apb_pci.c
+++ b/hw/apb_pci.c
@@ -33,7 +33,7 @@ 
 #include "pci_internals.h"
 #include "rwhandler.h"
 #include "apb_pci.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 /* debug APB */
 //#define DEBUG_APB
diff --git a/hw/arm_boot.c b/hw/arm_boot.c
index 41e99d1..a78e61c 100644
--- a/hw/arm_boot.c
+++ b/hw/arm_boot.c
@@ -9,9 +9,9 @@ 
 
 #include "hw.h"
 #include "arm-misc.h"
-#include "sysemu.h"
 #include "loader.h"
 #include "elf.h"
+#include "machine-state.h"
 
 #define KERNEL_ARGS_ADDR 0x100
 #define KERNEL_LOAD_ADDR 0x00010000
diff --git a/hw/arm_sysctl.c b/hw/arm_sysctl.c
index 9225b58..a4810ce 100644
--- a/hw/arm_sysctl.c
+++ b/hw/arm_sysctl.c
@@ -11,7 +11,7 @@ 
 #include "qemu-timer.h"
 #include "sysbus.h"
 #include "primecell.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 #define LOCK_VALUE 0xa05f
 
diff --git a/hw/bonito.c b/hw/bonito.c
index 65a4a63..ec1b34a 100644
--- a/hw/bonito.c
+++ b/hw/bonito.c
@@ -41,7 +41,7 @@ 
 #include "pc.h"
 #include "mips.h"
 #include "pci_host.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 //#define DEBUG_BONITO
 
diff --git a/hw/cbus.c b/hw/cbus.c
index 8ae24e0..08cbf81 100644
--- a/hw/cbus.c
+++ b/hw/cbus.c
@@ -23,7 +23,7 @@ 
 #include "qemu-common.h"
 #include "irq.h"
 #include "devices.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 //#define DEBUG
 
diff --git a/hw/cuda.c b/hw/cuda.c
index 37aa3f4..5b28fab 100644
--- a/hw/cuda.c
+++ b/hw/cuda.c
@@ -25,7 +25,7 @@ 
 #include "hw.h"
 #include "ppc_mac.h"
 #include "qemu-timer.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 /* XXX: implement all timer modes */
 
diff --git a/hw/e1000.c b/hw/e1000.c
index 2a4d5c7..a99f226 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -30,7 +30,7 @@ 
 #include "net.h"
 #include "net/checksum.h"
 #include "loader.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 #include "e1000_hw.h"
 
diff --git a/hw/eepro100.c b/hw/eepro100.c
index edf48f6..fe779e6 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -46,7 +46,7 @@ 
 #include "pci.h"
 #include "net.h"
 #include "eeprom93xx.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 #define KiB 1024
 
diff --git a/hw/etraxfs_dma.c b/hw/etraxfs_dma.c
index c205ec1..d6eb324 100644
--- a/hw/etraxfs_dma.c
+++ b/hw/etraxfs_dma.c
@@ -25,7 +25,7 @@ 
 #include <sys/time.h>
 #include "hw.h"
 #include "qemu-common.h"
-#include "sysemu.h"
+#include "vm-state.h"
 
 #include "etraxfs_dma.h"
 
diff --git a/hw/etraxfs_timer.c b/hw/etraxfs_timer.c
index b08e574..8ce90f5 100644
--- a/hw/etraxfs_timer.c
+++ b/hw/etraxfs_timer.c
@@ -22,8 +22,8 @@ 
  * THE SOFTWARE.
  */
 #include "sysbus.h"
-#include "sysemu.h"
 #include "qemu-timer.h"
+#include "machine-state.h"
 
 #define D(x)
 
diff --git a/hw/fdc.c b/hw/fdc.c
index 9fdbc75..d368018 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -35,7 +35,7 @@ 
 #include "sysbus.h"
 #include "qdev-addr.h"
 #include "blockdev.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 /********************************************************/
 /* debug Floppy devices */
diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c
index 0eb862f..a83129d 100644
--- a/hw/fw_cfg.c
+++ b/hw/fw_cfg.c
@@ -22,12 +22,12 @@ 
  * THE SOFTWARE.
  */
 #include "hw.h"
-#include "sysemu.h"
 #include "isa.h"
 #include "fw_cfg.h"
 #include "sysbus.h"
 #include "host-state.h"
 #include "vm-state.h"
+#include "machine-state.h"
 
 /* debug firmware config */
 //#define DEBUG_FW_CFG
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 342feb1..12eeaf3 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -28,12 +28,12 @@ 
 #include <hw/scsi.h>
 #include "qemu-error.h"
 #include "qemu-timer.h"
-#include "sysemu.h"
 #include "dma.h"
 #include "blockdev.h"
 
 #include <hw/ide/internal.h>
 #include "vm-state.h"
+#include "machine-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/qdev.c b/hw/ide/qdev.c
index 2bb5c27..b135153 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -21,7 +21,7 @@ 
 #include "qemu-error.h"
 #include <hw/ide/internal.h>
 #include "blockdev.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 /* --------------------------------- */
 
diff --git a/hw/leon3.c b/hw/leon3.c
index 919f49f..3a48694 100644
--- a/hw/leon3.c
+++ b/hw/leon3.c
@@ -24,11 +24,11 @@ 
 #include "hw.h"
 #include "qemu-timer.h"
 #include "qemu-char.h"
-#include "sysemu.h"
 #include "boards.h"
 #include "loader.h"
 #include "elf.h"
 #include "trace.h"
+#include "machine-state.h"
 
 #include "grlib.h"
 
diff --git a/hw/lm32_sys.c b/hw/lm32_sys.c
index 427b05f..0539265 100644
--- a/hw/lm32_sys.c
+++ b/hw/lm32_sys.c
@@ -33,8 +33,8 @@ 
 #include "trace.h"
 #include "qemu-log.h"
 #include "qemu-error.h"
-#include "sysemu.h"
 #include "qemu-log.h"
+#include "machine-state.h"
 
 enum {
     R_CTRL = 0,
diff --git a/hw/loader.c b/hw/loader.c
index 35d792e..843a23e 100644
--- a/hw/loader.c
+++ b/hw/loader.c
@@ -45,10 +45,10 @@ 
 #include "hw.h"
 #include "disas.h"
 #include "monitor.h"
-#include "sysemu.h"
 #include "uboot_image.h"
 #include "loader.h"
 #include "fw_cfg.h"
+#include "machine-state.h"
 
 #include <zlib.h>
 
diff --git a/hw/m48t59.c b/hw/m48t59.c
index 9f39d6b..a8c68b0 100644
--- a/hw/m48t59.c
+++ b/hw/m48t59.c
@@ -24,9 +24,9 @@ 
 #include "hw.h"
 #include "nvram.h"
 #include "qemu-timer.h"
-#include "sysemu.h"
 #include "sysbus.h"
 #include "isa.h"
+#include "machine-state.h"
 
 //#define DEBUG_NVRAM
 
diff --git a/hw/mac_nvram.c b/hw/mac_nvram.c
index c2a2fc2..37d3a09 100644
--- a/hw/mac_nvram.c
+++ b/hw/mac_nvram.c
@@ -24,8 +24,8 @@ 
  */
 #include "hw.h"
 #include "firmware_abi.h"
-#include "sysemu.h"
 #include "ppc_mac.h"
+#include "machine-state.h"
 
 /* debug NVR */
 //#define DEBUG_NVR
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index 1c9a706..8f66d44 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -23,11 +23,11 @@ 
  */
 #include "hw.h"
 #include "qemu-timer.h"
-#include "sysemu.h"
 #include "pc.h"
 #include "apic.h"
 #include "isa.h"
 #include "mc146818rtc.h"
+#include "machine-state.h"
 
 //#define DEBUG_CMOS
 //#define DEBUG_COALESCED
diff --git a/hw/mcf5206.c b/hw/mcf5206.c
index 2a618d4..e9a809a 100644
--- a/hw/mcf5206.c
+++ b/hw/mcf5206.c
@@ -8,7 +8,7 @@ 
 #include "hw.h"
 #include "mcf.h"
 #include "qemu-timer.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 /* General purpose timer module.  */
 typedef struct {
diff --git a/hw/mcf5208.c b/hw/mcf5208.c
index 17a692d..239ba18 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -8,11 +8,11 @@ 
 #include "hw.h"
 #include "mcf.h"
 #include "qemu-timer.h"
-#include "sysemu.h"
 #include "net.h"
 #include "boards.h"
 #include "loader.h"
 #include "elf.h"
+#include "machine-state.h"
 
 #define SYS_FREQ 66000000
 
diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index f5ae639..76c8743 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -28,7 +28,6 @@ 
 #include "pci.h"
 #include "usb-uhci.h"
 #include "qemu-char.h"
-#include "sysemu.h"
 #include "audio/audio.h"
 #include "qemu-log.h"
 #include "loader.h"
@@ -38,6 +37,7 @@ 
 #include "vt82c686.h"
 #include "mc146818rtc.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 #define DEBUG_FULONG2E_INIT
 
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index a100394..60a3a5f 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -28,7 +28,6 @@ 
 #include "pc.h"
 #include "isa.h"
 #include "fdc.h"
-#include "sysemu.h"
 #include "arch_init.h"
 #include "boards.h"
 #include "net.h"
@@ -37,6 +36,7 @@ 
 #include "loader.h"
 #include "mc146818rtc.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 enum jazz_model_e
 {
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index d8baa6d..06e78d6 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -36,7 +36,6 @@ 
 #include "usb-uhci.h"
 #include "vmware_vga.h"
 #include "qemu-char.h"
-#include "sysemu.h"
 #include "arch_init.h"
 #include "boards.h"
 #include "qemu-log.h"
@@ -46,6 +45,7 @@ 
 #include "elf.h"
 #include "mc146818rtc.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 //#define DEBUG_BOARD_INIT
 
diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c
index 380a7eb..c884987 100644
--- a/hw/mips_mipssim.c
+++ b/hw/mips_mipssim.c
@@ -30,11 +30,11 @@ 
 #include "pc.h"
 #include "isa.h"
 #include "net.h"
-#include "sysemu.h"
 #include "boards.h"
 #include "mips-bios.h"
 #include "loader.h"
 #include "elf.h"
+#include "machine-state.h"
 
 static struct _loaderparams {
     int ram_size;
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index 8feb461..86c47ed 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -13,7 +13,6 @@ 
 #include "pc.h"
 #include "isa.h"
 #include "net.h"
-#include "sysemu.h"
 #include "boards.h"
 #include "flash.h"
 #include "qemu-log.h"
@@ -23,6 +22,7 @@ 
 #include "elf.h"
 #include "mc146818rtc.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 #define MAX_IDE_BUS 2
 
diff --git a/hw/multiboot.c b/hw/multiboot.c
index 0d2bfb4..bd1e800 100644
--- a/hw/multiboot.c
+++ b/hw/multiboot.c
@@ -27,7 +27,7 @@ 
 #include "multiboot.h"
 #include "loader.h"
 #include "elf.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 /* Show multiboot debug output */
 //#define DEBUG_MULTIBOOT
diff --git a/hw/musicpal.c b/hw/musicpal.c
index d98aa8d..3dea602 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -10,7 +10,6 @@ 
 #include "arm-misc.h"
 #include "devices.h"
 #include "net.h"
-#include "sysemu.h"
 #include "boards.h"
 #include "pc.h"
 #include "qemu-timer.h"
@@ -19,6 +18,7 @@ 
 #include "console.h"
 #include "i2c.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 #define MP_MISC_BASE            0x80002000
 #define MP_MISC_SIZE            0x00001000
diff --git a/hw/ne2000.c b/hw/ne2000.c
index 5966359..949ef93 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -26,7 +26,7 @@ 
 #include "net.h"
 #include "ne2000.h"
 #include "loader.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 /* debug NE2000 card */
 //#define DEBUG_NE2000
diff --git a/hw/nseries.c b/hw/nseries.c
index 2f6f473..86d265d 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -19,7 +19,6 @@ 
  */
 
 #include "qemu-common.h"
-#include "sysemu.h"
 #include "omap.h"
 #include "arm-misc.h"
 #include "irq.h"
@@ -31,6 +30,7 @@ 
 #include "hw.h"
 #include "bt.h"
 #include "loader.h"
+#include "machine-state.h"
 
 /* Nokia N8x0 support */
 struct n800_s {
diff --git a/hw/omap1.c b/hw/omap1.c
index 364c26f..f0d1475 100644
--- a/hw/omap1.c
+++ b/hw/omap1.c
@@ -19,7 +19,6 @@ 
 #include "hw.h"
 #include "arm-misc.h"
 #include "omap.h"
-#include "sysemu.h"
 #include "qemu-timer.h"
 #include "qemu-char.h"
 #include "soc_dma.h"
@@ -27,6 +26,7 @@ 
 #include "pc.h"
 #include "blockdev.h"
 #include "range.h"
+#include "machine-state.h"
 
 /* Should signal the TCMI/GPMC */
 uint32_t omap_badwidth_read8(void *opaque, target_phys_addr_t addr)
diff --git a/hw/omap2.c b/hw/omap2.c
index 0f13272..10de752 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -22,12 +22,12 @@ 
 #include "hw.h"
 #include "arm-misc.h"
 #include "omap.h"
-#include "sysemu.h"
 #include "qemu-timer.h"
 #include "qemu-char.h"
 #include "flash.h"
 #include "soc_dma.h"
 #include "audio/audio.h"
+#include "machine-state.h"
 
 /* Enhanced Audio Controller (CODEC only) */
 struct omap_eac_s {
diff --git a/hw/palm.c b/hw/palm.c
index f22d777..97ea131 100644
--- a/hw/palm.c
+++ b/hw/palm.c
@@ -18,13 +18,13 @@ 
  */
 #include "hw.h"
 #include "audio/audio.h"
-#include "sysemu.h"
 #include "console.h"
 #include "omap.h"
 #include "boards.h"
 #include "arm-misc.h"
 #include "devices.h"
 #include "loader.h"
+#include "machine-state.h"
 
 static uint32_t static_readb(void *opaque, target_phys_addr_t offset)
 {
diff --git a/hw/parallel.c b/hw/parallel.c
index cc853a5..d48df5d 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -26,7 +26,7 @@ 
 #include "qemu-char.h"
 #include "isa.h"
 #include "pc.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 //#define DEBUG_PARALLEL
 
diff --git a/hw/pc.c b/hw/pc.c
index 6939c04..68076c6 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -41,6 +41,7 @@ 
 #include "sysemu.h"
 #include "blockdev.h"
 #include "ui/qemu-spice.h"
+#include "machine-state.h"
 
 /* output Bochs bios info messages */
 //#define DEBUG_BIOS
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index b3ede89..daf82b2 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -33,10 +33,10 @@ 
 #include "ide.h"
 #include "kvm.h"
 #include "kvmclock.h"
-#include "sysemu.h"
 #include "sysbus.h"
 #include "arch_init.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 #define MAX_IDE_BUS 2
 
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index 478fe9b..053a171 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -32,6 +32,7 @@ 
 #include "virtio-blk.h"
 #include "qemu-config.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 #if defined(TARGET_I386)
 static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
diff --git a/hw/pci-stub.c b/hw/pci-stub.c
index c5a0aa8..820992b 100644
--- a/hw/pci-stub.c
+++ b/hw/pci-stub.c
@@ -21,6 +21,7 @@ 
 #include "sysemu.h"
 #include "monitor.h"
 #include "pci.h"
+#include "machine-state.h"
 
 static void pci_error_message(Monitor *mon)
 {
diff --git a/hw/pci.c b/hw/pci.c
index 8b76cea..8866dbd 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -27,10 +27,10 @@ 
 #include "pci_internals.h"
 #include "monitor.h"
 #include "net.h"
-#include "sysemu.h"
 #include "loader.h"
 #include "qemu-objects.h"
 #include "range.h"
+#include "machine-state.h"
 
 //#define DEBUG_PCI
 #ifdef DEBUG_PCI
diff --git a/hw/pcie_aer.c b/hw/pcie_aer.c
index 0c4e8a5..8497e4b 100644
--- a/hw/pcie_aer.c
+++ b/hw/pcie_aer.c
@@ -18,7 +18,6 @@ 
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "sysemu.h"
 #include "qemu-objects.h"
 #include "monitor.h"
 #include "pci_bridge.h"
@@ -27,6 +26,7 @@ 
 #include "msi.h"
 #include "pci_internals.h"
 #include "pcie_regs.h"
+#include "machine-state.h"
 
 //#define DEBUG_PCIE
 #ifdef DEBUG_PCIE
diff --git a/hw/pckbd.c b/hw/pckbd.c
index ae65c04..5bca9f9 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -25,7 +25,7 @@ 
 #include "isa.h"
 #include "pc.h"
 #include "ps2.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 /* debug PC keyboard */
 //#define DEBUG_KBD
diff --git a/hw/pcnet.c b/hw/pcnet.c
index 82ccbbd..7e33877 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -39,7 +39,7 @@ 
 #include "net.h"
 #include "qemu-timer.h"
 #include "qemu_socket.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 #include "pcnet.h"
 
diff --git a/hw/petalogix_ml605_mmu.c b/hw/petalogix_ml605_mmu.c
index 8213902..a5f35a9 100644
--- a/hw/petalogix_ml605_mmu.c
+++ b/hw/petalogix_ml605_mmu.c
@@ -29,7 +29,6 @@ 
 #include "hw.h"
 #include "net.h"
 #include "flash.h"
-#include "sysemu.h"
 #include "devices.h"
 #include "boards.h"
 #include "device_tree.h"
@@ -38,6 +37,7 @@ 
 #include "elf.h"
 #include "blockdev.h"
 #include "pc.h"
+#include "machine-state.h"
 
 #include "xilinx_axidma.h"
 
diff --git a/hw/ppc.c b/hw/ppc.c
index b55a848..865f0b2 100644
--- a/hw/ppc.c
+++ b/hw/ppc.c
@@ -24,12 +24,12 @@ 
 #include "hw.h"
 #include "ppc.h"
 #include "qemu-timer.h"
-#include "sysemu.h"
 #include "nvram.h"
 #include "qemu-log.h"
 #include "loader.h"
 #include "kvm.h"
 #include "kvm_ppc.h"
+#include "machine-state.h"
 
 //#define PPC_DEBUG_IRQ
 //#define PPC_DEBUG_TB
diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c
index ad27181..013a919 100644
--- a/hw/ppc405_boards.c
+++ b/hw/ppc405_boards.c
@@ -26,12 +26,12 @@ 
 #include "ppc405.h"
 #include "nvram.h"
 #include "flash.h"
-#include "sysemu.h"
 #include "block.h"
 #include "boards.h"
 #include "qemu-log.h"
 #include "loader.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 #define BIOS_FILENAME "ppc405_rom.bin"
 #define BIOS_SIZE (2048 * 1024)
diff --git a/hw/ppc405_uc.c b/hw/ppc405_uc.c
index 2ce79ee..d6d2ef7 100644
--- a/hw/ppc405_uc.c
+++ b/hw/ppc405_uc.c
@@ -26,8 +26,8 @@ 
 #include "ppc405.h"
 #include "pc.h"
 #include "qemu-timer.h"
-#include "sysemu.h"
 #include "qemu-log.h"
+#include "machine-state.h"
 
 #define DEBUG_OPBA
 #define DEBUG_SDRAM
diff --git a/hw/ppc440.c b/hw/ppc440.c
index 1ed001a..a5a4fe6 100644
--- a/hw/ppc440.c
+++ b/hw/ppc440.c
@@ -18,8 +18,8 @@ 
 #include "ppc4xx.h"
 #include "ppc440.h"
 #include "ppc405.h"
-#include "sysemu.h"
 #include "kvm.h"
+#include "machine-state.h"
 
 #define PPC440EP_PCI_CONFIG     0xeec00000
 #define PPC440EP_PCI_INTACK     0xeed00000
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index b9245f0..0470db9 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -55,7 +55,6 @@ 
 #include "pci.h"
 #include "usb-ohci.h"
 #include "net.h"
-#include "sysemu.h"
 #include "boards.h"
 #include "fw_cfg.h"
 #include "escc.h"
@@ -67,6 +66,7 @@ 
 #include "kvm_ppc.h"
 #include "hw/usb.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 #define MAX_IDE_BUS 2
 #define CFG_ADDR 0xf0000510
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index 8a4e088..638387b 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -29,7 +29,6 @@ 
 #include "mac_dbdma.h"
 #include "nvram.h"
 #include "pc.h"
-#include "sysemu.h"
 #include "net.h"
 #include "isa.h"
 #include "pci.h"
@@ -43,6 +42,7 @@ 
 #include "kvm.h"
 #include "kvm_ppc.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 #define MAX_IDE_BUS 2
 #define CFG_ADDR 0xf0000510
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 5615ef9..6e9edca 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -26,7 +26,6 @@ 
 #include "pc.h"
 #include "fdc.h"
 #include "net.h"
-#include "sysemu.h"
 #include "isa.h"
 #include "pci.h"
 #include "prep_pci.h"
@@ -38,6 +37,7 @@ 
 #include "loader.h"
 #include "mc146818rtc.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 //#define HARD_DEBUG_PPC_IO
 //#define DEBUG_PPC_IO
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index b7670ae..2cf5a7e 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -23,7 +23,6 @@ 
 #include "pc.h"
 #include "pci.h"
 #include "boards.h"
-#include "sysemu.h"
 #include "kvm.h"
 #include "kvm_ppc.h"
 #include "device_tree.h"
@@ -31,6 +30,7 @@ 
 #include "ppce500.h"
 #include "loader.h"
 #include "elf.h"
+#include "machine-state.h"
 
 #define BINARY_DEVICE_TREE_FILE    "mpc8544ds.dtb"
 #define UIMAGE_LOAD_BASE           0
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index 9b95e2c..9ce5c5f 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -9,12 +9,12 @@ 
 
 #include "sysbus.h"
 #include "pxa.h"
-#include "sysemu.h"
 #include "pc.h"
 #include "i2c.h"
 #include "ssi.h"
 #include "qemu-char.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 static struct {
     target_phys_addr_t io_base;
diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c
index 5b2b07e..a1879bc 100644
--- a/hw/pxa2xx_lcd.c
+++ b/hw/pxa2xx_lcd.c
@@ -11,9 +11,9 @@ 
 #include "console.h"
 #include "pxa.h"
 #include "pixel_ops.h"
-/* FIXME: For graphic_rotate. Should probably be done in common code.  */
-#include "sysemu.h"
 #include "framebuffer.h"
+/* FIXME: For graphic_rotate. Should probably be done in common code.  */
+#include "machine-state.h"
 
 struct PXA2xxLCDState {
     qemu_irq irq;
diff --git a/hw/pxa2xx_timer.c b/hw/pxa2xx_timer.c
index f777a21..0ef8da2 100644
--- a/hw/pxa2xx_timer.c
+++ b/hw/pxa2xx_timer.c
@@ -9,9 +9,9 @@ 
 
 #include "hw.h"
 #include "qemu-timer.h"
-#include "sysemu.h"
 #include "pxa.h"
 #include "sysbus.h"
+#include "machine-state.h"
 
 #define OSMR0	0x00
 #define OSMR1	0x04
diff --git a/hw/qdev.c b/hw/qdev.c
index 1aa1ea0..e69b3fe 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -27,8 +27,8 @@ 
 
 #include "net.h"
 #include "qdev.h"
-#include "sysemu.h"
 #include "monitor.h"
+#include "machine-state.h"
 
 static int qdev_hotplug = 0;
 static bool qdev_hot_added = false;
diff --git a/hw/r2d.c b/hw/r2d.c
index a0f8c1f..efb0c0b 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -27,7 +27,6 @@ 
 #include "hw.h"
 #include "sh.h"
 #include "devices.h"
-#include "sysemu.h"
 #include "boards.h"
 #include "pci.h"
 #include "net.h"
@@ -37,6 +36,7 @@ 
 #include "usb.h"
 #include "flash.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 #define FLASH_BASE 0x00000000
 #define FLASH_SIZE 0x02000000
diff --git a/hw/realview.c b/hw/realview.c
index a67861e..53c4f2f 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -14,11 +14,11 @@ 
 #include "pci.h"
 #include "usb-ohci.h"
 #include "net.h"
-#include "sysemu.h"
 #include "boards.h"
 #include "bitbang_i2c.h"
 #include "sysbus.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 #define SMP_BOOT_ADDR 0xe0000000
 
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index d545933..9d0bc7d 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -56,8 +56,8 @@ 
 #include "qemu-timer.h"
 #include "net.h"
 #include "loader.h"
-#include "sysemu.h"
 #include "iov.h"
+#include "machine-state.h"
 
 /* debug RTL8139 card */
 //#define DEBUG_RTL8139 1
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index c3f60e0..27561de 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -35,9 +35,9 @@  do { fprintf(stderr, "scsi-disk: " fmt , ## __VA_ARGS__); } while (0)
 #include "qemu-error.h"
 #include "scsi.h"
 #include "scsi-defs.h"
-#include "sysemu.h"
 #include "blockdev.h"
 #include "vm-state.h"
+#include "machine-state.h"
 
 #define SCSI_DMA_BUF_SIZE    131072
 #define SCSI_MAX_INQUIRY_LEN 256
diff --git a/hw/serial.c b/hw/serial.c
index 0ee61dd..930fd5c 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -27,7 +27,7 @@ 
 #include "isa.h"
 #include "pc.h"
 #include "qemu-timer.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 //#define DEBUG_SERIAL
 
diff --git a/hw/sh7750.c b/hw/sh7750.c
index 19d5bf8..40890bf 100644
--- a/hw/sh7750.c
+++ b/hw/sh7750.c
@@ -25,12 +25,12 @@ 
 #include <stdio.h>
 #include "hw.h"
 #include "sh.h"
-#include "sysemu.h"
 #include "sh7750_regs.h"
 #include "sh7750_regnames.h"
 #include "sh_intc.h"
 #include "exec-all.h"
 #include "cpu.h"
+#include "machine-state.h"
 
 #define NB_DEVICES 4
 
diff --git a/hw/shix.c b/hw/shix.c
index 638bf16..fc51e70 100644
--- a/hw/shix.c
+++ b/hw/shix.c
@@ -30,9 +30,9 @@ 
 #include "hw.h"
 #include "pc.h"
 #include "sh.h"
-#include "sysemu.h"
 #include "boards.h"
 #include "loader.h"
+#include "machine-state.h"
 
 #define BIOS_FILENAME "shix_bios.bin"
 #define BIOS_ADDRESS 0xA0000000
diff --git a/hw/slavio_misc.c b/hw/slavio_misc.c
index 198360d..4c25597 100644
--- a/hw/slavio_misc.c
+++ b/hw/slavio_misc.c
@@ -22,9 +22,9 @@ 
  * THE SOFTWARE.
  */
 
-#include "sysemu.h"
 #include "sysbus.h"
 #include "trace.h"
+#include "machine-state.h"
 
 /*
  * This is the auxio port, chip control and system control part of
diff --git a/hw/smbios.c b/hw/smbios.c
index 95f9935..fb9a6e7 100644
--- a/hw/smbios.c
+++ b/hw/smbios.c
@@ -11,10 +11,12 @@ 
  *
  */
 
-#include "sysemu.h"
+#include "qemu-common.h"
+#include "qemu-option.h"
 #include "smbios.h"
 #include "loader.h"
 #include "vm-state.h"
+#include "machine-state.h"
 
 /*
  * Structures shared with the BIOS
diff --git a/hw/spitz.c b/hw/spitz.c
index 006f7a9..9f20c83 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -10,7 +10,6 @@ 
 #include "hw.h"
 #include "pxa.h"
 #include "arm-misc.h"
-#include "sysemu.h"
 #include "pcmcia.h"
 #include "i2c.h"
 #include "ssi.h"
@@ -24,6 +23,8 @@ 
 #include "boards.h"
 #include "blockdev.h"
 #include "sysbus.h"
+/* FIXME: For graphic_rotate. Should probably be done in common code.  */
+#include "machine-state.h"
 
 #undef REG_FMT
 #define REG_FMT			"0x%02lx"
diff --git a/hw/sun4m.c b/hw/sun4m.c
index 6719bdf..4c9a00b 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -27,7 +27,6 @@ 
 #include "nvram.h"
 #include "sparc32_dma.h"
 #include "fdc.h"
-#include "sysemu.h"
 #include "net.h"
 #include "boards.h"
 #include "firmware_abi.h"
@@ -43,6 +42,7 @@ 
 #include "blockdev.h"
 #include "trace.h"
 #include "host-state.h"
+#include "machine-state.h"
 
 /*
  * Sun4m architecture was used in the following machines:
diff --git a/hw/sun4u.c b/hw/sun4u.c
index dbb5a15..9f4e734 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -29,7 +29,6 @@ 
 #include "fdc.h"
 #include "net.h"
 #include "qemu-timer.h"
-#include "sysemu.h"
 #include "boards.h"
 #include "firmware_abi.h"
 #include "fw_cfg.h"
@@ -38,6 +37,7 @@ 
 #include "loader.h"
 #include "elf.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 //#define DEBUG_IRQ
 //#define DEBUG_EBUS
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index edd3f3b..c31018b 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -15,9 +15,9 @@ 
 #include "scsi.h"
 #include "console.h"
 #include "monitor.h"
-#include "sysemu.h"
 #include "blockdev.h"
 #include "vm-state.h"
+#include "machine-state.h"
 
 //#define DEBUG_MSD
 
diff --git a/hw/usb-net.c b/hw/usb-net.c
index bf51bb3..c4d097d 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -28,7 +28,7 @@ 
 #include "usb-desc.h"
 #include "net.h"
 #include "qemu-queue.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 /*#define TRAFFIC_DEBUG*/
 /* Thanks to NetChip Technologies for donating this product ID.
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 9f1bfcf..54ffe18 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -12,11 +12,11 @@ 
 #include "primecell.h"
 #include "devices.h"
 #include "net.h"
-#include "sysemu.h"
 #include "pci.h"
 #include "usb-ohci.h"
 #include "boards.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 /* Primary interrupt controller.  */
 
diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c
index fa60515..911e014 100644
--- a/hw/virtex_ml507.c
+++ b/hw/virtex_ml507.c
@@ -27,13 +27,13 @@ 
 #include "pc.h"
 #include "net.h"
 #include "flash.h"
-#include "sysemu.h"
 #include "devices.h"
 #include "boards.h"
 #include "device_tree.h"
 #include "loader.h"
 #include "elf.h"
 #include "qemu-log.h"
+#include "machine-state.h"
 
 #include "ppc.h"
 #include "ppc4xx.h"
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index b14fb99..71a951d 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -16,6 +16,7 @@ 
 #include "trace.h"
 #include "blockdev.h"
 #include "virtio-blk.h"
+#include "machine-state.h"
 #ifdef __linux__
 # include <scsi/sg.h>
 #endif
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 6997e02..50d9ae6 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -20,6 +20,7 @@ 
 #include "qemu-timer.h"
 #include "virtio-net.h"
 #include "vhost_net.h"
+#include "machine-state.h"
 
 #define VIRTIO_NET_VM_VERSION    11
 
diff --git a/hw/vt82c686.c b/hw/vt82c686.c
index 818460d..d602475 100644
--- a/hw/vt82c686.c
+++ b/hw/vt82c686.c
@@ -19,8 +19,8 @@ 
 #include "apm.h"
 #include "acpi.h"
 #include "pm_smbus.h"
-#include "sysemu.h"
 #include "qemu-timer.h"
+#include "machine-state.h"
 
 typedef uint32_t pci_addr_t;
 #include "pci_host.h"
diff --git a/hw/watchdog.c b/hw/watchdog.c
index 30dd91b..c1dde67 100644
--- a/hw/watchdog.c
+++ b/hw/watchdog.c
@@ -28,6 +28,7 @@ 
 #include "sysemu.h"
 #include "hw/watchdog.h"
 #include "vm-state.h"
+#include "machine-state.h"
 
 /* Possible values for action parameter. */
 #define WDT_RESET        1	/* Hard reset. */
diff --git a/hw/xen_console.c b/hw/xen_console.c
index d2261f4..0dac2ca 100644
--- a/hw/xen_console.c
+++ b/hw/xen_console.c
@@ -33,9 +33,9 @@ 
 #include <xenctrl.h>
 
 #include "hw.h"
-#include "sysemu.h"
 #include "qemu-char.h"
 #include "xen_backend.h"
+#include "machine-state.h"
 
 struct buffer {
     uint8_t *data;
diff --git a/hw/xen_domainbuild.c b/hw/xen_domainbuild.c
index adad8c3..74ccf10 100644
--- a/hw/xen_domainbuild.c
+++ b/hw/xen_domainbuild.c
@@ -5,6 +5,7 @@ 
 #include "qemu-log.h"
 #include "host-state.h"
 #include "vm-state.h"
+#include "machine-state.h"
 
 #include <xenguest.h>
 
diff --git a/hw/xen_machine_pv.c b/hw/xen_machine_pv.c
index 77a34bf..f00d899 100644
--- a/hw/xen_machine_pv.c
+++ b/hw/xen_machine_pv.c
@@ -24,11 +24,11 @@ 
 
 #include "hw.h"
 #include "pc.h"
-#include "sysemu.h"
 #include "boards.h"
 #include "xen_backend.h"
 #include "xen_domainbuild.h"
 #include "blockdev.h"
+#include "machine-state.h"
 
 static void xen_init_pv(ram_addr_t ram_size,
 			const char *boot_device,
diff --git a/input.c b/input.c
index ec05548..2a20318 100644
--- a/input.c
+++ b/input.c
@@ -22,11 +22,11 @@ 
  * THE SOFTWARE.
  */
 
-#include "sysemu.h"
 #include "net.h"
 #include "monitor.h"
 #include "console.h"
 #include "qjson.h"
+#include "machine-state.h"
 
 static QEMUPutKBDEvent *qemu_put_kbd_event;
 static void *qemu_put_kbd_event_opaque;
diff --git a/kvm-all.c b/kvm-all.c
index 79c7327..85781cf 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -22,12 +22,12 @@ 
 
 #include "qemu-common.h"
 #include "qemu-barrier.h"
-#include "sysemu.h"
 #include "hw/hw.h"
 #include "gdbstub.h"
 #include "kvm.h"
 #include "bswap.h"
 #include "vm-state.h"
+#include "machine-state.h"
 
 /* This check must be after config-host.h is included */
 #ifdef CONFIG_EVENTFD
diff --git a/machine-state.h b/machine-state.h
new file mode 100644
index 0000000..4b88509
--- /dev/null
+++ b/machine-state.h
@@ -0,0 +1,100 @@ 
+#ifndef QEMU_MACHINE_STATE_H
+#define QEMU_MACHINE_STATE_H
+/*
+ * Machine state: All generic machine state.
+ */
+
+#include "notify.h"
+#include "qemu-timer.h"
+#include "qdict.h"
+
+extern const char *bios_name;
+
+void qemu_system_reset_request(void);
+void qemu_system_shutdown_request(void);
+void qemu_system_powerdown_request(void);
+void qemu_system_debug_request(void);
+int qemu_shutdown_requested(void);
+int qemu_reset_requested(void);
+int qemu_powerdown_requested(void);
+extern qemu_irq qemu_system_powerdown;
+void qemu_system_reset(void);
+
+void qemu_add_machine_init_done_notifier(Notifier *notify);
+
+extern int bios_size;
+
+typedef enum {
+    VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL,
+} VGAInterfaceType;
+
+extern int vga_interface_type;
+#define cirrus_vga_enabled (vga_interface_type == VGA_CIRRUS)
+#define std_vga_enabled (vga_interface_type == VGA_STD)
+#define xenfb_enabled (vga_interface_type == VGA_XENFB)
+#define vmsvga_enabled (vga_interface_type == VGA_VMWARE)
+#define qxl_enabled (vga_interface_type == VGA_QXL)
+
+extern int graphic_width;
+extern int graphic_height;
+extern int graphic_depth;
+extern uint8_t irq0override;
+extern int win2k_install_hack;
+extern int rtc_td_hack;
+extern int usb_enabled;
+extern int smp_cpus;
+extern int max_cpus;
+extern int graphic_rotate;
+extern int semihosting_enabled;
+extern int old_param;
+extern int boot_menu;
+
+extern QEMUClock *rtc_clock;
+
+#define MAX_NODES 64
+extern int nb_numa_nodes;
+extern uint64_t node_mem[MAX_NODES];
+extern uint64_t node_cpumask[MAX_NODES];
+
+#define MAX_OPTION_ROMS 16
+typedef struct QEMUOptionRom {
+    const char *name;
+    int32_t bootindex;
+} QEMUOptionRom;
+extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
+extern int nb_option_roms;
+
+#define MAX_PROM_ENVS 128
+extern const char *prom_envs[MAX_PROM_ENVS];
+extern unsigned int nb_prom_envs;
+
+/* pci-hotplug */
+void pci_device_hot_add(Monitor *mon, const QDict *qdict);
+void drive_hot_add(Monitor *mon, const QDict *qdict);
+void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
+
+/* pcie aer error injection */
+void pcie_aer_inject_error_print(Monitor *mon, const QObject *data);
+int do_pcie_aer_inejct_error(Monitor *mon,
+                             const QDict *qdict, QObject **ret_data);
+
+/* serial ports */
+
+#define MAX_SERIAL_PORTS 4
+
+extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
+
+/* parallel ports */
+
+#define MAX_PARALLEL_PORTS 3
+
+extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
+
+void rtc_change_mon_event(struct tm *tm);
+
+void register_devices(void);
+
+void add_boot_device_path(int32_t bootindex, DeviceState *dev,
+                          const char *suffix);
+char *get_boot_devices_list(uint32_t *size);
+#endif
diff --git a/monitor.c b/monitor.c
index fa02d57..cda8733 100644
--- a/monitor.c
+++ b/monitor.c
@@ -63,6 +63,7 @@ 
 #include "ui/qemu-spice.h"
 #include "host-state.h"
 #include "vm-state.h"
+#include "machine-state.h"
 
 //#define DEBUG
 //#define DEBUG_COMPLETION
diff --git a/qemu-common.h b/qemu-common.h
index 8a52f14..2c70044 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -331,6 +331,11 @@  void qemu_iovec_memset(QEMUIOVector *qiov, int c, size_t count);
 void qemu_iovec_memset_skip(QEMUIOVector *qiov, int c, size_t count,
                             size_t skip);
 
+#define QEMU_FILE_TYPE_BIOS   0
+#define QEMU_FILE_TYPE_KEYMAP 1
+char *qemu_find_file(int type, const char *name);
+
+
 /* Convert a byte between binary and BCD.  */
 static inline uint8_t to_bcd(uint8_t val)
 {
diff --git a/qemu-timer.c b/qemu-timer.c
index f7338c6..b1cc013 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -54,6 +54,7 @@ 
 #endif
 
 #include "vm-state.h"
+#include "machine-state.h"
 #include "qemu-timer.h"
 
 /* Conversion factor from emulated instructions to virtual clock ticks.  */
diff --git a/sysemu.h b/sysemu.h
index 6dbec35..a27da92 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -18,28 +18,10 @@ 
 #endif
 
 /* vl.c */
-extern const char *bios_name;
-
-#define QEMU_FILE_TYPE_BIOS   0
-#define QEMU_FILE_TYPE_KEYMAP 1
-char *qemu_find_file(int type, const char *name);
-
 int64_t cpu_get_ticks(void);
 void cpu_enable_ticks(void);
 void cpu_disable_ticks(void);
 
-void qemu_system_reset_request(void);
-void qemu_system_shutdown_request(void);
-void qemu_system_powerdown_request(void);
-void qemu_system_debug_request(void);
-int qemu_shutdown_requested(void);
-int qemu_reset_requested(void);
-int qemu_powerdown_requested(void);
-extern qemu_irq qemu_system_powerdown;
-void qemu_system_reset(void);
-
-void qemu_add_machine_init_done_notifier(Notifier *notify);
-
 void cpu_synchronize_all_states(void);
 void cpu_synchronize_all_post_reset(void);
 void cpu_synchronize_all_post_init(void);
@@ -50,78 +32,4 @@  char *os_find_datadir(const char *argv0);
 void os_parse_cmd_args(int index, const char *optarg);
 void os_pidfile_error(void);
 
-extern int bios_size;
-
-typedef enum {
-    VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL,
-} VGAInterfaceType;
-
-extern int vga_interface_type;
-#define cirrus_vga_enabled (vga_interface_type == VGA_CIRRUS)
-#define std_vga_enabled (vga_interface_type == VGA_STD)
-#define xenfb_enabled (vga_interface_type == VGA_XENFB)
-#define vmsvga_enabled (vga_interface_type == VGA_VMWARE)
-#define qxl_enabled (vga_interface_type == VGA_QXL)
-
-extern int graphic_width;
-extern int graphic_height;
-extern int graphic_depth;
-extern uint8_t irq0override;
-extern int win2k_install_hack;
-extern int rtc_td_hack;
-extern int usb_enabled;
-extern int smp_cpus;
-extern int max_cpus;
-extern int graphic_rotate;
-extern int semihosting_enabled;
-extern int old_param;
-extern int boot_menu;
-extern QEMUClock *rtc_clock;
-
-#define MAX_NODES 64
-extern int nb_numa_nodes;
-extern uint64_t node_mem[MAX_NODES];
-extern uint64_t node_cpumask[MAX_NODES];
-
-#define MAX_OPTION_ROMS 16
-typedef struct QEMUOptionRom {
-    const char *name;
-    int32_t bootindex;
-} QEMUOptionRom;
-extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
-extern int nb_option_roms;
-
-#define MAX_PROM_ENVS 128
-extern const char *prom_envs[MAX_PROM_ENVS];
-extern unsigned int nb_prom_envs;
-
-/* pci-hotplug */
-void pci_device_hot_add(Monitor *mon, const QDict *qdict);
-void drive_hot_add(Monitor *mon, const QDict *qdict);
-void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
-
-/* pcie aer error injection */
-void pcie_aer_inject_error_print(Monitor *mon, const QObject *data);
-int do_pcie_aer_inejct_error(Monitor *mon,
-                             const QDict *qdict, QObject **ret_data);
-
-/* serial ports */
-
-#define MAX_SERIAL_PORTS 4
-
-extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
-
-/* parallel ports */
-
-#define MAX_PARALLEL_PORTS 3
-
-extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
-
-void rtc_change_mon_event(struct tm *tm);
-
-void register_devices(void);
-
-void add_boot_device_path(int32_t bootindex, DeviceState *dev,
-                          const char *suffix);
-char *get_boot_devices_list(uint32_t *size);
 #endif
diff --git a/target-i386/helper.c b/target-i386/helper.c
index d15fca5..1b0868f 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -28,8 +28,8 @@ 
 #include "qemu-common.h"
 #include "kvm.h"
 #ifndef CONFIG_USER_ONLY
-#include "sysemu.h"
 #include "monitor.h"
+#include "machine-state.h"
 #endif
 
 //#define DEBUG_MMU
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 75ff202..de70ad1 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -20,7 +20,6 @@ 
 #include <linux/kvm.h>
 
 #include "qemu-common.h"
-#include "sysemu.h"
 #include "kvm.h"
 #include "cpu.h"
 #include "gdbstub.h"
@@ -29,6 +28,7 @@ 
 #include "hw/apic.h"
 #include "ioport.h"
 #include "vm-state.h"
+#include "machine-state.h"
 
 #ifdef CONFIG_KVM_PARA
 #include <linux/kvm_para.h>
diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c
index 854f168..5f18acd 100644
--- a/target-sparc/op_helper.c
+++ b/target-sparc/op_helper.c
@@ -1,7 +1,7 @@ 
 #include "exec.h"
 #include "host-utils.h"
 #include "helper.h"
-#include "sysemu.h"
+#include "machine-state.h"
 
 //#define DEBUG_MMU
 //#define DEBUG_MXCC
diff --git a/ui/sdl.c b/ui/sdl.c
index 0545915..b0976be 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -39,6 +39,7 @@ 
 #include "sdl_zoom.h"
 #include "host-state.h"
 #include "vm-state.h"
+#include "machine-state.h"
 
 static DisplayChangeListener *dcl;
 static SDL_Surface *real_screen;
diff --git a/vl.c b/vl.c
index 71a7616..52e121a 100644
--- a/vl.c
+++ b/vl.c
@@ -162,6 +162,7 @@  int main(int argc, char **argv)
 #include "arch_init.h"
 #include "host-state.h"
 #include "vm-state.h"
+#include "machine-state.h"
 
 #include "ui/qemu-spice.h"
 
-- 
1.7.2.5