diff --git a/stubs/arch-query-cpu-def.c b/stubs/arch-query-cpu-def.c
index a975ab4..cefe4be 100644
--- a/stubs/arch-query-cpu-def.c
+++ b/stubs/arch-query-cpu-def.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "sysemu/arch_init.h"
 #include "qapi/qmp/qerror.h"
diff --git a/stubs/bdrv-commit-all.c b/stubs/bdrv-commit-all.c
index a8e0a95..bf84a1d 100644
--- a/stubs/bdrv-commit-all.c
+++ b/stubs/bdrv-commit-all.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "block/block.h"
 
diff --git a/stubs/clock-warp.c b/stubs/clock-warp.c
index 5565118..5ae32b9 100644
--- a/stubs/clock-warp.c
+++ b/stubs/clock-warp.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu/timer.h"
 
diff --git a/stubs/cpu-get-clock.c b/stubs/cpu-get-clock.c
index 5b34c97..1d07523 100644
--- a/stubs/cpu-get-clock.c
+++ b/stubs/cpu-get-clock.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu/timer.h"
 
diff --git a/stubs/cpu-get-icount.c b/stubs/cpu-get-icount.c
index d685859..3a6f2ab 100644
--- a/stubs/cpu-get-icount.c
+++ b/stubs/cpu-get-icount.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu/timer.h"
 
diff --git a/stubs/cpus.c b/stubs/cpus.c
index 8e6f06b..e192722 100644
--- a/stubs/cpus.c
+++ b/stubs/cpus.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qom/cpu.h"
 
diff --git a/stubs/dump.c b/stubs/dump.c
index 8c24eda..d9ee23f 100644
--- a/stubs/dump.c
+++ b/stubs/dump.c
@@ -11,6 +11,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "sysemu/dump-arch.h"
 #include "qmp-commands.h"
diff --git a/stubs/fd-register.c b/stubs/fd-register.c
index d0c34fd..f91aa34 100644
--- a/stubs/fd-register.c
+++ b/stubs/fd-register.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu/main-loop.h"
 
diff --git a/stubs/fdset-add-fd.c b/stubs/fdset-add-fd.c
index ee16437..bf9e60a 100644
--- a/stubs/fdset-add-fd.c
+++ b/stubs/fdset-add-fd.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "monitor/monitor.h"
 
diff --git a/stubs/fdset-find-fd.c b/stubs/fdset-find-fd.c
index 4f18344..1d9caf3 100644
--- a/stubs/fdset-find-fd.c
+++ b/stubs/fdset-find-fd.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "monitor/monitor.h"
 
diff --git a/stubs/fdset-get-fd.c b/stubs/fdset-get-fd.c
index 7112c15..5325044 100644
--- a/stubs/fdset-get-fd.c
+++ b/stubs/fdset-get-fd.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "monitor/monitor.h"
 
diff --git a/stubs/fdset-remove-fd.c b/stubs/fdset-remove-fd.c
index 7f6d61e..47ea297 100644
--- a/stubs/fdset-remove-fd.c
+++ b/stubs/fdset-remove-fd.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "monitor/monitor.h"
 
diff --git a/stubs/gdbstub.c b/stubs/gdbstub.c
index f6a4553..359c289 100644
--- a/stubs/gdbstub.c
+++ b/stubs/gdbstub.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "stdbool.h"            /* bool (in exec/gdbstub.h) */
 #include "stddef.h"             /* NULL */
 #include "exec/gdbstub.h"       /* xml_builtin */
diff --git a/stubs/get-fd.c b/stubs/get-fd.c
index 9f2c65c..85881fb 100644
--- a/stubs/get-fd.c
+++ b/stubs/get-fd.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "monitor/monitor.h"
 
diff --git a/stubs/get-next-serial.c b/stubs/get-next-serial.c
index 40c56d1..6ff6a6d 100644
--- a/stubs/get-next-serial.c
+++ b/stubs/get-next-serial.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 
 CharDriverState *serial_hds[0];
diff --git a/stubs/get-vm-name.c b/stubs/get-vm-name.c
index e5f619f..fa99013 100644
--- a/stubs/get-vm-name.c
+++ b/stubs/get-vm-name.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 
 const char *qemu_get_vm_name(void)
diff --git a/stubs/iothread-lock.c b/stubs/iothread-lock.c
index dda6f6b..9b6db2e 100644
--- a/stubs/iothread-lock.c
+++ b/stubs/iothread-lock.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu/main-loop.h"
 
diff --git a/stubs/is-daemonized.c b/stubs/is-daemonized.c
index c0ee917..d5cd1dc 100644
--- a/stubs/is-daemonized.c
+++ b/stubs/is-daemonized.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 
 /* Win32 has its own inline stub */
diff --git a/stubs/kvm.c b/stubs/kvm.c
index 828b824..ddd6204 100644
--- a/stubs/kvm.c
+++ b/stubs/kvm.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "sysemu/kvm.h"
 
diff --git a/stubs/machine-init-done.c b/stubs/machine-init-done.c
index 28a9255..9a0d625 100644
--- a/stubs/machine-init-done.c
+++ b/stubs/machine-init-done.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "sysemu/sysemu.h"
 
diff --git a/stubs/migr-blocker.c b/stubs/migr-blocker.c
index 300df6e..8ab3604 100644
--- a/stubs/migr-blocker.c
+++ b/stubs/migr-blocker.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "migration/migration.h"
 
diff --git a/stubs/mon-is-qmp.c b/stubs/mon-is-qmp.c
index dd26f19..a8344ce 100644
--- a/stubs/mon-is-qmp.c
+++ b/stubs/mon-is-qmp.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "monitor/monitor.h"
 
diff --git a/stubs/mon-printf.c b/stubs/mon-printf.c
index 0ce2ca6..e7c1e0c 100644
--- a/stubs/mon-printf.c
+++ b/stubs/mon-printf.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "monitor/monitor.h"
 
diff --git a/stubs/monitor-init.c b/stubs/monitor-init.c
index 563902b..de1bc7c 100644
--- a/stubs/monitor-init.c
+++ b/stubs/monitor-init.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "monitor/monitor.h"
 
diff --git a/stubs/notify-event.c b/stubs/notify-event.c
index 32f7289..14e5226 100644
--- a/stubs/notify-event.c
+++ b/stubs/notify-event.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu/main-loop.h"
 
diff --git a/stubs/qmp_pc_dimm_device_list.c b/stubs/qmp_pc_dimm_device_list.c
index b584bd8..a4af7fe 100644
--- a/stubs/qmp_pc_dimm_device_list.c
+++ b/stubs/qmp_pc_dimm_device_list.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qom/object.h"
 #include "hw/mem/pc-dimm.h"
 
diff --git a/stubs/qtest.c b/stubs/qtest.c
index 4dfde61..891eb95 100644
--- a/stubs/qtest.c
+++ b/stubs/qtest.c
@@ -8,6 +8,7 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/osdep.h"
 #include "sysemu/qtest.h"
 
 /* Needed for qtest_allowed() */
diff --git a/stubs/replay-user.c b/stubs/replay-user.c
index cf33072..b29e7eb 100644
--- a/stubs/replay-user.c
+++ b/stubs/replay-user.c
@@ -9,6 +9,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include "sysemu/replay.h"
 
 bool replay_exception(void)
diff --git a/stubs/replay.c b/stubs/replay.c
index 8f98790..00ca01f 100644
--- a/stubs/replay.c
+++ b/stubs/replay.c
@@ -1,5 +1,5 @@
+#include "qemu/osdep.h"
 #include "sysemu/replay.h"
-#include <stdlib.h>
 #include "sysemu/sysemu.h"
 
 ReplayMode replay_mode;
diff --git a/stubs/reset.c b/stubs/reset.c
index ad28725..5d47711 100644
--- a/stubs/reset.c
+++ b/stubs/reset.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "hw/hw.h"
 
 /* Stub functions for binaries that never call qemu_devices_reset(),
diff --git a/stubs/runstate-check.c b/stubs/runstate-check.c
index bd2e375..7c5227e 100644
--- a/stubs/runstate-check.c
+++ b/stubs/runstate-check.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "sysemu/sysemu.h"
 
 bool runstate_check(RunState state)
diff --git a/stubs/set-fd-handler.c b/stubs/set-fd-handler.c
index a8481bc..26965de 100644
--- a/stubs/set-fd-handler.c
+++ b/stubs/set-fd-handler.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu/main-loop.h"
 
diff --git a/stubs/slirp.c b/stubs/slirp.c
index bd0ac7f..dcae51f 100644
--- a/stubs/slirp.c
+++ b/stubs/slirp.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "slirp/slirp.h"
 
diff --git a/stubs/sysbus.c b/stubs/sysbus.c
index e134965..d8da90c 100644
--- a/stubs/sysbus.c
+++ b/stubs/sysbus.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "hw/qdev-core.h"
 
 BusState *sysbus_get_default(void)
diff --git a/stubs/target-get-monitor-def.c b/stubs/target-get-monitor-def.c
index 711a9ae..013e657 100644
--- a/stubs/target-get-monitor-def.c
+++ b/stubs/target-get-monitor-def.c
@@ -19,6 +19,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu/osdep.h"
 #include "stdint.h"
 
 typedef struct CPUState CPUState;
diff --git a/stubs/target-monitor-defs.c b/stubs/target-monitor-defs.c
index 7d8d182..203ebb0 100644
--- a/stubs/target-monitor-defs.c
+++ b/stubs/target-monitor-defs.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "stddef.h"
 #include "qemu/typedefs.h"
 
diff --git a/stubs/uuid.c b/stubs/uuid.c
index ffc0ed4..92ad717 100644
--- a/stubs/uuid.c
+++ b/stubs/uuid.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "sysemu/sysemu.h"
 #include "qmp-commands.h"
diff --git a/stubs/vhost.c b/stubs/vhost.c
index d346b85..2d76cde 100644
--- a/stubs/vhost.c
+++ b/stubs/vhost.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "hw/virtio/vhost.h"
 
 bool vhost_has_free_slot(void)
diff --git a/stubs/vm-stop.c b/stubs/vm-stop.c
index 69fd86b..8271cad 100644
--- a/stubs/vm-stop.c
+++ b/stubs/vm-stop.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "sysemu/sysemu.h"
 
diff --git a/stubs/vmstate.c b/stubs/vmstate.c
index 778bc3f..6590627 100644
--- a/stubs/vmstate.c
+++ b/stubs/vmstate.c
@@ -1,3 +1,4 @@
+#include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "migration/vmstate.h"
 
