diff --git a/arch_init.c b/arch_init.c
index f6aba02..e3bb1b3 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -31,6 +31,7 @@
 #include "qemu/error-report.h"
 #include "qmp-commands.h"
 #include "hw/acpi/acpi.h"
+#include "qemu/help_option.h"
 
 #ifdef TARGET_SPARC
 int graphic_width = 1024;
diff --git a/audio/audio.c b/audio/audio.c
index e841532..b64df3f 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -27,6 +27,8 @@
 #include "monitor/monitor.h"
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 
 #define AUDIO_CAP "audio"
 #include "audio_int.h"
diff --git a/block.c b/block.c
index ba24b8e..72fa5b2 100644
--- a/block.c
+++ b/block.c
@@ -22,7 +22,6 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "trace.h"
 #include "block/block_int.h"
 #include "block/blockjob.h"
@@ -40,6 +39,8 @@
 #include "qemu/timer.h"
 #include "qapi-event.h"
 #include "block/throttle-groups.h"
+#include "qemu/cutils.h"
+#include "qemu/id.h"
 
 #ifdef CONFIG_BSD
 #include <sys/ioctl.h>
diff --git a/block/archipelago.c b/block/archipelago.c
index 0507589..b9f5e69 100644
--- a/block/archipelago.c
+++ b/block/archipelago.c
@@ -51,7 +51,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "block/block_int.h"
 #include "qemu/error-report.h"
 #include "qemu/thread.h"
diff --git a/block/blkdebug.c b/block/blkdebug.c
index f85c54b..301a12a 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -23,7 +23,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "qemu/config-file.h"
 #include "block/block_int.h"
 #include "qemu/module.h"
diff --git a/block/blkverify.c b/block/blkverify.c
index 2a885cc..8ba3217 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -12,6 +12,7 @@
 #include "block/block_int.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qstring.h"
+#include "qemu/cutils.h"
 
 typedef struct {
     BdrvChild *test_file;
diff --git a/block/block-backend.c b/block/block-backend.c
index ebdf78a..015aa2d 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -18,6 +18,7 @@
 #include "sysemu/blockdev.h"
 #include "sysemu/sysemu.h"
 #include "qapi-event.h"
+#include "qemu/id.h"
 
 /* Number of coroutines to reserve per attached device model */
 #define COROUTINE_POOL_RESERVATION 64
diff --git a/block/curl.c b/block/curl.c
index c70bfb4..57962dc 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -29,6 +29,7 @@
 #include "qapi/qmp/qstring.h"
 #include "crypto/secret.h"
 #include <curl/curl.h>
+#include "qemu/cutils.h"
 
 // #define DEBUG_CURL
 // #define DEBUG_VERBOSE
diff --git a/block/nbd.c b/block/nbd.c
index 9f333c9..7d67520 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -35,7 +35,7 @@
 #include "qapi/qmp/qjson.h"
 #include "qapi/qmp/qint.h"
 #include "qapi/qmp/qstring.h"
-
+#include "qemu/cutils.h"
 
 #define EN_OPTSTR ":exportname="
 
diff --git a/block/qapi.c b/block/qapi.c
index db2d3fb..87c5e0b 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -32,6 +32,7 @@
 #include "qapi/qmp-output-visitor.h"
 #include "qapi/qmp/types.h"
 #include "sysemu/block-backend.h"
+#include "qemu/cutils.h"
 
 BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs, Error **errp)
 {
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index 13f88d1..85cbc2b 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -23,10 +23,10 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "block/block_int.h"
 #include "block/qcow2.h"
 #include "qemu/error-report.h"
+#include "qemu/cutils.h"
 
 void qcow2_free_snapshots(BlockDriverState *bs)
 {
diff --git a/block/qcow2.c b/block/qcow2.c
index 8babecd..60feb7b 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -22,7 +22,6 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "block/block_int.h"
 #include "qemu/module.h"
 #include <zlib.h>
@@ -35,6 +34,7 @@
 #include "qapi-event.h"
 #include "trace.h"
 #include "qemu/option_int.h"
+#include "qemu/cutils.h"
 
 /*
   Differences with QCOW:
diff --git a/block/qed.h b/block/qed.h
index 615e676..22b3198 100644
--- a/block/qed.h
+++ b/block/qed.h
@@ -16,6 +16,7 @@
 #define BLOCK_QED_H
 
 #include "block/block_int.h"
+#include "qemu/cutils.h"
 
 /* The layout of a QED file is as follows:
  *
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 8866121..1a3d3f5 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -22,7 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
 #include "qemu/log.h"
diff --git a/block/raw-win32.c b/block/raw-win32.c
index 21a6cb8..9f8f199 100644
--- a/block/raw-win32.c
+++ b/block/raw-win32.c
@@ -22,7 +22,7 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "qemu/timer.h"
 #include "block/block_int.h"
 #include "qemu/module.h"
diff --git a/block/rbd.c b/block/rbd.c
index abfea61..f19b15f 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -13,10 +13,11 @@
 
 #include "qemu/osdep.h"
 
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "qemu/error-report.h"
 #include "block/block_int.h"
 #include "crypto/secret.h"
+#include "qemu/cutils.h"
 
 #include <rbd/librbd.h>
 
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 05677ed..ccd1f07 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -13,12 +13,12 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "qemu/uri.h"
 #include "qemu/error-report.h"
 #include "qemu/sockets.h"
 #include "block/block_int.h"
 #include "qemu/bitops.h"
+#include "qemu/cutils.h"
 
 #define SD_PROTO_VER 0x01
 
diff --git a/block/vdi.c b/block/vdi.c
index b403243..50055e1 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -50,11 +50,11 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "block/block_int.h"
 #include "qemu/module.h"
 #include "migration/migration.h"
 #include "qemu/coroutine.h"
+#include "qemu/cutils.h"
 
 #if defined(CONFIG_UUID)
 #include <uuid/uuid.h>
diff --git a/block/vmdk.c b/block/vmdk.c
index a8db5d9..c74c503 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -24,12 +24,12 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "block/block_int.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "qemu/module.h"
 #include "migration/migration.h"
+#include "qemu/cutils.h"
 #include <zlib.h>
 #include <glib.h>
 
diff --git a/block/vvfat.c b/block/vvfat.c
index b8d29e1..c1637d8 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -24,13 +24,14 @@
  */
 #include "qemu/osdep.h"
 #include <dirent.h>
-#include "qemu-common.h"
 #include "block/block_int.h"
 #include "qemu/module.h"
 #include "migration/migration.h"
 #include "qapi/qmp/qint.h"
 #include "qapi/qmp/qbool.h"
 #include "qapi/qmp/qstring.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 
 #ifndef S_IWGRP
 #define S_IWGRP 0
diff --git a/blockdev.c b/blockdev.c
index 0f20c65..94d4760 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -50,6 +50,8 @@
 #include "qmp-commands.h"
 #include "trace.h"
 #include "sysemu/arch_init.h"
+#include "qemu/cutils.h"
+#include "qemu/help_option.h"
 
 static QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =
     QTAILQ_HEAD_INITIALIZER(monitor_bdrv_states);
diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
index 0a6092b..898ee05 100644
--- a/bsd-user/elfload.c
+++ b/bsd-user/elfload.c
@@ -5,6 +5,7 @@
 
 #include "qemu.h"
 #include "disas/disas.h"
+#include "qemu/path.h"
 
 #ifdef _ARCH_PPC64
 #undef ARCH_DLINFO
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 287ec1d..27854c1 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -21,7 +21,8 @@
 #include <sys/mman.h>
 
 #include "qemu.h"
-#include "qemu-common.h"
+#include "qemu/path.h"
+#include "qemu/help_option.h"
 /* For tb_lock */
 #include "cpu.h"
 #include "tcg.h"
diff --git a/contrib/ivshmem-server/main.c b/contrib/ivshmem-server/main.c
index cca1061..685c2ce 100644
--- a/contrib/ivshmem-server/main.c
+++ b/contrib/ivshmem-server/main.c
@@ -7,7 +7,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 
 #include "ivshmem-server.h"
 
diff --git a/disas/i386.c b/disas/i386.c
index d40b72a..894b0a1 100644
--- a/disas/i386.c
+++ b/disas/i386.c
@@ -33,6 +33,8 @@
 
 #include "qemu/osdep.h"
 #include "disas/bfd.h"
+#include "qemu/cutils.h"
+
 /* include/opcode/i386.h r1.78 */
 
 /* opcode/i386.h -- Intel 80386 opcode macros
diff --git a/dump.c b/dump.c
index 81d2d4f..cbd140f 100644
--- a/dump.c
+++ b/dump.c
@@ -12,7 +12,8 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 #include "elf.h"
 #include "cpu.h"
 #include "exec/cpu-all.h"
diff --git a/exec.c b/exec.c
index f09dd4e..857c971 100644
--- a/exec.c
+++ b/exec.c
@@ -21,7 +21,7 @@
 #include <sys/mman.h>
 #endif
 
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "cpu.h"
 #include "tcg.h"
 #include "hw/hw.h"
diff --git a/gdbstub.c b/gdbstub.c
index 61c12b1..69c50d8 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -17,7 +17,8 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 #ifdef CONFIG_USER_ONLY
 
 #include "qemu.h"
diff --git a/hmp.c b/hmp.c
index 5b6084a..cb92717 100644
--- a/hmp.c
+++ b/hmp.c
@@ -34,6 +34,7 @@
 #include "ui/console.h"
 #include "block/qapi.h"
 #include "qemu-io.h"
+#include "qemu/cutils.h"
 
 #ifdef CONFIG_SPICE
 #include <spice/enums.h>
diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c
index 0805c9c..1174cf7 100644
--- a/hw/9pfs/9p-proxy.c
+++ b/hw/9pfs/9p-proxy.c
@@ -16,6 +16,7 @@
 #include "qemu/error-report.h"
 #include "fsdev/qemu-fsdev.h"
 #include "9p-proxy.h"
+#include "qemu/path.h"
 
 typedef struct V9fsProxy {
     int sockfd;
diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
index 365623e..f1475df 100644
--- a/hw/9pfs/9p-synth.c
+++ b/hw/9pfs/9p-synth.c
@@ -20,6 +20,7 @@
 #include "9p-synth.h"
 #include "qemu/rcu.h"
 #include "qemu/rcu_queue.h"
+#include "qemu/cutils.h"
 
 /* Root node for synth file system */
 static V9fsSynthNode v9fs_synth_root = {
diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
index 7c5989b..54466b5 100644
--- a/hw/alpha/dp264.c
+++ b/hw/alpha/dp264.c
@@ -18,6 +18,7 @@
 #include "hw/ide.h"
 #include "hw/timer/i8254.h"
 #include "hw/char/serial.h"
+#include "qemu/cutils.h"
 
 #define MAX_IDE_BUS 2
 
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index d9e61f7..05d430c 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -19,7 +19,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "sysemu/sysemu.h"
 #include "hw/arm/omap.h"
 #include "hw/arm/arm.h"
diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
index 6f68130..e3c162e 100644
--- a/hw/arm/omap1.c
+++ b/hw/arm/omap1.c
@@ -28,6 +28,8 @@
 #include "sysemu/blockdev.h"
 #include "qemu/range.h"
 #include "hw/sysbus.h"
+#include "qemu/cutils.h"
+#include "qemu/bcd.h"
 
 /* Should signal the TCMI/GPMC */
 uint32_t omap_badwidth_read8(void *opaque, hwaddr addr)
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index ff6ac7a..fed1eeb 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -17,6 +17,7 @@
 #include "sysemu/char.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
+#include "qemu/cutils.h"
 
 static struct {
     hwaddr io_base;
diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c
index 3b17a21..3cef2a3 100644
--- a/hw/arm/strongarm.c
+++ b/hw/arm/strongarm.c
@@ -36,6 +36,7 @@
 #include "sysemu/char.h"
 #include "sysemu/sysemu.h"
 #include "hw/ssi/ssi.h"
+#include "qemu/cutils.h"
 
 //#define DEBUG
 
diff --git a/hw/block/nvme.h b/hw/block/nvme.h
index bf3a3cc..8fb0c10 100644
--- a/hw/block/nvme.h
+++ b/hw/block/nvme.h
@@ -1,5 +1,6 @@
 #ifndef HW_NVME_H
 #define HW_NVME_H
+#include "qemu/cutils.h"
 
 typedef struct NvmeBar {
     uint64_t    cap;
diff --git a/hw/bt/hci.c b/hw/bt/hci.c
index 8bc33b5..a26cc26 100644
--- a/hw/bt/hci.c
+++ b/hw/bt/hci.c
@@ -26,6 +26,7 @@
 #include "hw/bt.h"
 #include "qapi/qmp/qerror.h"
 #include "sysemu/replay.h"
+#include "qemu/cutils.h"
 
 struct bt_hci_s {
     uint8_t *(*evt_packet)(void *opaque);
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 8e8031c..a2f1341 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -53,6 +53,7 @@
 #include "exec/memory.h"
 #include "exec/address-spaces.h"
 #include "hw/boards.h"
+#include "qemu/cutils.h"
 
 #include <zlib.h>
 
diff --git a/hw/core/machine.c b/hw/core/machine.c
index a8c4680..6b9fc69 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -17,6 +17,7 @@
 #include "hw/sysbus.h"
 #include "sysemu/sysemu.h"
 #include "qemu/error-report.h"
+#include "qemu/cutils.h"
 
 static char *machine_get_accel(Object *obj, Error **errp)
 {
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index bc89800..5b9fff4 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -8,6 +8,7 @@
 #include "net/hub.h"
 #include "qapi/visitor.h"
 #include "sysemu/char.h"
+#include "qemu/path.h"
 
 void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
                                   Error **errp)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index db41aa1..902414d 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -36,6 +36,7 @@
 #include "hw/hotplug.h"
 #include "hw/boards.h"
 #include "qapi-event.h"
+#include "qemu/path.h"
 
 int qdev_hotplug = 0;
 static bool qdev_hot_added = false;
diff --git a/hw/cris/boot.c b/hw/cris/boot.c
index 42485a4..5eb27e2 100644
--- a/hw/cris/boot.c
+++ b/hw/cris/boot.c
@@ -27,6 +27,7 @@
 #include "hw/loader.h"
 #include "elf.h"
 #include "boot.h"
+#include "qemu/cutils.h"
 
 static void main_cpu_reset(void *opaque)
 {
diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c
index 37ea7e4..0bd5bab 100644
--- a/hw/dma/pl330.c
+++ b/hw/dma/pl330.c
@@ -18,6 +18,7 @@
 #include "hw/sysbus.h"
 #include "qemu/timer.h"
 #include "sysemu/dma.h"
+#include "qemu/unicode.h"
 
 #ifndef PL330_ERR_DEBUG
 #define PL330_ERR_DEBUG 0
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 241e840..2a43a20 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -33,6 +33,7 @@
 #include "sysemu/dma.h"
 #include "hw/block/block.h"
 #include "sysemu/block-backend.h"
+#include "qemu/cutils.h"
 
 #include <hw/ide/internal.h>
 
diff --git a/hw/lm32/lm32_hwsetup.h b/hw/lm32/lm32_hwsetup.h
index 838754d..b71e6ea 100644
--- a/hw/lm32/lm32_hwsetup.h
+++ b/hw/lm32/lm32_hwsetup.h
@@ -26,6 +26,7 @@
 #define QEMU_HW_LM32_HWSETUP_H
 
 #include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "hw/loader.h"
 
 typedef struct {
diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c
index f71492e..5f14c1f 100644
--- a/hw/lm32/milkymist.c
+++ b/hw/lm32/milkymist.c
@@ -31,6 +31,7 @@
 #include "milkymist-hw.h"
 #include "lm32.h"
 #include "exec/address-spaces.h"
+#include "qemu/cutils.h"
 
 #define BIOS_FILENAME    "mmone-bios.bin"
 #define BIOS_OFFSET      0x00860000
diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c
index c24014a..d0f6705 100644
--- a/hw/microblaze/boot.c
+++ b/hw/microblaze/boot.c
@@ -33,6 +33,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/loader.h"
 #include "elf.h"
+#include "qemu/cutils.h"
 
 #include "boot.h"
 
diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
index d6d8058..a6acbfa 100644
--- a/hw/mips/mips_jazz.c
+++ b/hw/mips/mips_jazz.c
@@ -45,6 +45,7 @@
 #include "exec/address-spaces.h"
 #include "sysemu/qtest.h"
 #include "qemu/error-report.h"
+#include "qemu/help_option.h"
 
 enum jazz_model_e
 {
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 1838bc8..8608d94 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -17,6 +17,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "hw/hw.h"
 #include "hw/i386/pc.h"
 #include "hw/pci/pci.h"
diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index 481abdb..e15bb1d 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -28,6 +28,7 @@
 #include "hw/input/adb.h"
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
+#include "qemu/cutils.h"
 
 /* XXX: implement all timer modes */
 
diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
index 1e35f7f..af13f51 100644
--- a/hw/net/fsl_etsec/etsec.c
+++ b/hw/net/fsl_etsec/etsec.c
@@ -33,6 +33,7 @@
 #include "hw/ptimer.h"
 #include "etsec.h"
 #include "registers.h"
+#include "qemu/unicode.h"
 
 /* #define HEX_DUMP */
 /* #define DEBUG_REGISTER */
diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c
index ed1de7d..a48afb5 100644
--- a/hw/net/fsl_etsec/rings.c
+++ b/hw/net/fsl_etsec/rings.c
@@ -23,6 +23,7 @@
  */
 #include "qemu/osdep.h"
 #include "net/checksum.h"
+#include "qemu/unicode.h"
 
 #include "etsec.h"
 #include "registers.h"
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 7866248..d96932f 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -31,6 +31,7 @@
 #include "trace.h"
 #include "qemu/error-report.h"
 #include "qemu/config-file.h"
+#include "qemu/cutils.h"
 
 #define FW_CFG_NAME "fw_cfg"
 #define FW_CFG_PATH "/machine/" FW_CFG_NAME
diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c
index 1671f46..24f6121 100644
--- a/hw/nvram/mac_nvram.c
+++ b/hw/nvram/mac_nvram.c
@@ -27,6 +27,7 @@
 #include "hw/nvram/openbios_firmware_abi.h"
 #include "sysemu/sysemu.h"
 #include "hw/ppc/mac.h"
+#include "qemu/cutils.h"
 #include <zlib.h>
 
 /* debug NVR */
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index e67664d..bb605ef 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -40,6 +40,7 @@
 #include "exec/address-spaces.h"
 #include "hw/hotplug.h"
 #include "hw/boards.h"
+#include "qemu/cutils.h"
 
 //#define DEBUG_PCI
 #ifdef DEBUG_PCI
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index f0a36b3..4b75ee9 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -70,6 +70,7 @@
 #include "sysemu/block-backend.h"
 #include "exec/address-spaces.h"
 #include "hw/sysbus.h"
+#include "qemu/cutils.h"
 
 #define MAX_IDE_BUS 2
 #define CFG_ADDR 0xf0000510
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index d952713..ab983c3 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -44,6 +44,7 @@
 #include "kvm_ppc.h"
 #include "sysemu/block-backend.h"
 #include "exec/address-spaces.h"
+#include "qemu/cutils.h"
 
 #define MAX_IDE_BUS 2
 #define CFG_ADDR 0xf0000510
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 793b9ed..3ffb85e 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -46,6 +46,7 @@
 #include "exec/address-spaces.h"
 #include "trace.h"
 #include "elf.h"
+#include "qemu/cutils.h"
 
 /* SMP is not enabled, for now */
 #define MAX_CPUS 1
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 64c4acc..56973b5 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -63,7 +63,7 @@
 #include "hw/nmi.h"
 
 #include "hw/compat.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 
 #include <libfdt.h>
 
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index ef063c0..a727ae6 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -11,6 +11,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "hw/ppc/spapr_drc.h"
 #include "qom/object.h"
 #include "hw/qdev.h"
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index 39f4682..37de7a0 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -36,7 +36,8 @@
 #include "hw/pci/pci.h"
 #include "hw/pci-host/spapr.h"
 #include "hw/ppc/spapr_drc.h"
-
+#include "qemu/help_option.h"
+#include "qemu/bcd.h"
 #include <libfdt.h>
 
 struct rtas_error_log {
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index b7c5ebd..2db2292 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -39,6 +39,7 @@
 
 #include <libfdt.h>
 #include "hw/ppc/spapr_drc.h"
+#include "qemu/cutils.h"
 
 /* #define DEBUG_SPAPR */
 
diff --git a/hw/ppc/spapr_rtc.c b/hw/ppc/spapr_rtc.c
index 02fa373..3a17ac4 100644
--- a/hw/ppc/spapr_rtc.c
+++ b/hw/ppc/spapr_rtc.c
@@ -31,6 +31,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/ppc/spapr.h"
 #include "qapi-event.h"
+#include "qemu/cutils.h"
 
 #define SPAPR_RTC(obj) \
     OBJECT_CHECK(sPAPRRTCState, (obj), TYPE_SPAPR_RTC)
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index a21752b..004aa8a 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -8,6 +8,7 @@
 #include "sysemu/blockdev.h"
 #include "trace.h"
 #include "sysemu/dma.h"
+#include "qemu/cutils.h"
 
 static char *scsibus_get_dev_path(DeviceState *dev);
 static char *scsibus_get_fw_dev_path(DeviceState *dev);
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 469aec2..157674b 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -29,7 +29,6 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0)
 #endif
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "qemu/error-report.h"
 #include "hw/scsi/scsi.h"
 #include "block/scsi.h"
@@ -38,6 +37,7 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0)
 #include "sysemu/blockdev.h"
 #include "hw/block/block.h"
 #include "sysemu/dma.h"
+#include "qemu/cutils.h"
 
 #ifdef __linux
 #include <scsi/sg.h>
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index c86622c..2d809e3 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -27,6 +27,7 @@
 #include "hw/virtio/virtio-access.h"
 #include "hw/fw-path-provider.h"
 #include "linux/vhost.h"
+#include "qemu/cutils.h"
 
 /* Features supported by host kernel. */
 static const int kernel_feature_bits[] = {
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index eebef37..850db7c 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -43,6 +43,7 @@
 #include "elf.h"
 #include "sysemu/block-backend.h"
 #include "trace.h"
+#include "qemu/cutils.h"
 
 /*
  * Sun4m architecture was used in the following machines:
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 0a6f453..41ea0e6 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -41,6 +41,7 @@
 #include "elf.h"
 #include "sysemu/block-backend.h"
 #include "exec/address-spaces.h"
+#include "qemu/cutils.h"
 
 //#define DEBUG_IRQ
 //#define DEBUG_EBUS
diff --git a/hw/timer/ds1338.c b/hw/timer/ds1338.c
index ff31561..cc1a778 100644
--- a/hw/timer/ds1338.c
+++ b/hw/timer/ds1338.c
@@ -12,6 +12,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/i2c/i2c.h"
+#include "qemu/bcd.h"
 
 /* Size of NVRAM including both the user-accessible area and the
  * secondary register area.
diff --git a/hw/timer/exynos4210_rtc.c b/hw/timer/exynos4210_rtc.c
index f21fb54..da4dd45 100644
--- a/hw/timer/exynos4210_rtc.c
+++ b/hw/timer/exynos4210_rtc.c
@@ -29,6 +29,7 @@
 #include "hw/sysbus.h"
 #include "qemu/timer.h"
 #include "qemu-common.h"
+#include "qemu/bcd.h"
 #include "hw/ptimer.h"
 
 #include "hw/hw.h"
diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c
index bbcfeb2..82e3e40 100644
--- a/hw/timer/m48t59.c
+++ b/hw/timer/m48t59.c
@@ -30,6 +30,7 @@
 #include "hw/sysbus.h"
 #include "hw/isa/isa.h"
 #include "exec/address-spaces.h"
+#include "qemu/bcd.h"
 
 //#define DEBUG_NVRAM
 
diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index eb0100a..266ebd7 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -22,6 +22,8 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
+#include "qemu/bcd.h"
 #include "hw/hw.h"
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c
index 3ccb2cb..1c8cdd9 100644
--- a/hw/timer/pl031.c
+++ b/hw/timer/pl031.c
@@ -15,6 +15,7 @@
 #include "hw/sysbus.h"
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
+#include "qemu/cutils.h"
 
 //#define DEBUG_PL031
 
diff --git a/hw/timer/twl92230.c b/hw/timer/twl92230.c
index 1c92438..7ba4e9a 100644
--- a/hw/timer/twl92230.c
+++ b/hw/timer/twl92230.c
@@ -25,6 +25,7 @@
 #include "hw/i2c/i2c.h"
 #include "sysemu/sysemu.h"
 #include "ui/console.h"
+#include "qemu/bcd.h"
 
 #define VERBOSE 1
 
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 4452bdb..a34a3c9 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -6,6 +6,7 @@
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
 #include "trace.h"
+#include "qemu/cutils.h"
 
 static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
 
diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index c6abd38..1a6e824 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -33,6 +33,7 @@
 #include "qemu/config-file.h"
 #include "sysemu/sysemu.h"
 #include "qemu/iov.h"
+#include "qemu/cutils.h"
 
 /*#define TRAFFIC_DEBUG*/
 /* Thanks to NetChip Technologies for donating this product ID.
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index afad1db..0859ae5 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -10,6 +10,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "qemu/error-report.h"
 #include "hw/usb.h"
 #include "hw/usb/desc.h"
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 5ae0424..ad44560 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -21,6 +21,7 @@
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
 #include "qapi/visitor.h"
+#include "qemu/cutils.h"
 
 //#define DEBUG_MSD
 
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 38a5393..3539a11 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -33,6 +33,7 @@
 #include "qemu/error-report.h"
 #include "qemu/iov.h"
 #include "sysemu/char.h"
+#include "qemu/path.h"
 
 #include <sys/ioctl.h>
 #include <usbredirparser.h>
diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index 194c9b4..bbf3646 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -20,7 +20,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "qemu/option.h"
 #include "qemu/config-file.h"
 #include "qemu/queue.h"
@@ -29,6 +28,7 @@
 #include "sysemu/watchdog.h"
 #include "qapi-event.h"
 #include "hw/nmi.h"
+#include "qemu/help_option.h"
 
 static int watchdog_action = WDT_RESET;
 static QLIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list;
diff --git a/hw/xen/xen-host-pci-device.c b/hw/xen/xen-host-pci-device.c
index 9666fff..b2524af 100644
--- a/hw/xen/xen-host-pci-device.c
+++ b/hw/xen/xen-host-pci-device.c
@@ -8,6 +8,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "xen-host-pci-device.h"
 
 #define XEN_HOST_PCI_MAX_EXT_CAP \
diff --git a/include/qemu-common.h b/include/qemu-common.h
index 887ca71..e6818fd 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -59,251 +59,6 @@ int qemu_main(int argc, char **argv, char **envp);
 void qemu_get_timedate(struct tm *tm, int offset);
 int qemu_timedate_diff(struct tm *tm);
 
-/**
- * is_help_option:
- * @s: string to test
- *
- * Check whether @s is one of the standard strings which indicate
- * that the user is asking for a list of the valid values for a
- * command option like -cpu or -M. The current accepted strings
- * are 'help' and '?'. '?' is deprecated (it is a shell wildcard
- * which makes it annoying to use in a reliable way) but provided
- * for backwards compatibility.
- *
- * Returns: true if @s is a request for a list.
- */
-static inline bool is_help_option(const char *s)
-{
-    return !strcmp(s, "?") || !strcmp(s, "help");
-}
-
-/* util/cutils.c */
-/**
- * pstrcpy:
- * @buf: buffer to copy string into
- * @buf_size: size of @buf in bytes
- * @str: string to copy
- *
- * Copy @str into @buf, including the trailing NUL, but do not
- * write more than @buf_size bytes. The resulting buffer is
- * always NUL terminated (even if the source string was too long).
- * If @buf_size is zero or negative then no bytes are copied.
- *
- * This function is similar to strncpy(), but avoids two of that
- * function's problems:
- *  * if @str fits in the buffer, pstrcpy() does not zero-fill the
- *    remaining space at the end of @buf
- *  * if @str is too long, pstrcpy() will copy the first @buf_size-1
- *    bytes and then add a NUL
- */
-void pstrcpy(char *buf, int buf_size, const char *str);
-/**
- * strpadcpy:
- * @buf: buffer to copy string into
- * @buf_size: size of @buf in bytes
- * @str: string to copy
- * @pad: character to pad the remainder of @buf with
- *
- * Copy @str into @buf (but *not* its trailing NUL!), and then pad the
- * rest of the buffer with the @pad character. If @str is too large
- * for the buffer then it is truncated, so that @buf contains the
- * first @buf_size characters of @str, with no terminator.
- */
-void strpadcpy(char *buf, int buf_size, const char *str, char pad);
-/**
- * pstrcat:
- * @buf: buffer containing existing string
- * @buf_size: size of @buf in bytes
- * @s: string to concatenate to @buf
- *
- * Append a copy of @s to the string already in @buf, but do not
- * allow the buffer to overflow. If the existing contents of @buf
- * plus @str would total more than @buf_size bytes, then write
- * as much of @str as will fit followed by a NUL terminator.
- *
- * @buf must already contain a NUL-terminated string, or the
- * behaviour is undefined.
- *
- * Returns: @buf.
- */
-char *pstrcat(char *buf, int buf_size, const char *s);
-/**
- * strstart:
- * @str: string to test
- * @val: prefix string to look for
- * @ptr: NULL, or pointer to be written to indicate start of
- *       the remainder of the string
- *
- * Test whether @str starts with the prefix @val.
- * If it does (including the degenerate case where @str and @val
- * are equal) then return true. If @ptr is not NULL then a
- * pointer to the first character following the prefix is written
- * to it. If @val is not a prefix of @str then return false (and
- * @ptr is not written to).
- *
- * Returns: true if @str starts with prefix @val, false otherwise.
- */
-int strstart(const char *str, const char *val, const char **ptr);
-/**
- * stristart:
- * @str: string to test
- * @val: prefix string to look for
- * @ptr: NULL, or pointer to be written to indicate start of
- *       the remainder of the string
- *
- * Test whether @str starts with the case-insensitive prefix @val.
- * This function behaves identically to strstart(), except that the
- * comparison is made after calling qemu_toupper() on each pair of
- * characters.
- *
- * Returns: true if @str starts with case-insensitive prefix @val,
- *          false otherwise.
- */
-int stristart(const char *str, const char *val, const char **ptr);
-/**
- * qemu_strnlen:
- * @s: string
- * @max_len: maximum number of bytes in @s to scan
- *
- * Return the length of the string @s, like strlen(), but do not
- * examine more than @max_len bytes of the memory pointed to by @s.
- * If no NUL terminator is found within @max_len bytes, then return
- * @max_len instead.
- *
- * This function has the same behaviour as the POSIX strnlen()
- * function.
- *
- * Returns: length of @s in bytes, or @max_len, whichever is smaller.
- */
-int qemu_strnlen(const char *s, int max_len);
-/**
- * qemu_strsep:
- * @input: pointer to string to parse
- * @delim: string containing delimiter characters to search for
- *
- * Locate the first occurrence of any character in @delim within
- * the string referenced by @input, and replace it with a NUL.
- * The location of the next character after the delimiter character
- * is stored into @input.
- * If the end of the string was reached without finding a delimiter
- * character, then NULL is stored into @input.
- * If @input points to a NULL pointer on entry, return NULL.
- * The return value is always the original value of *@input (and
- * so now points to a NUL-terminated string corresponding to the
- * part of the input up to the first delimiter).
- *
- * This function has the same behaviour as the BSD strsep() function.
- *
- * Returns: the pointer originally in @input.
- */
-char *qemu_strsep(char **input, const char *delim);
-time_t mktimegm(struct tm *tm);
-int qemu_fdatasync(int fd);
-int fcntl_setfl(int fd, int flag);
-int qemu_parse_fd(const char *param);
-int qemu_strtol(const char *nptr, const char **endptr, int base,
-                long *result);
-int qemu_strtoul(const char *nptr, const char **endptr, int base,
-                 unsigned long *result);
-int qemu_strtoll(const char *nptr, const char **endptr, int base,
-                 int64_t *result);
-int qemu_strtoull(const char *nptr, const char **endptr, int base,
-                  uint64_t *result);
-
-int parse_uint(const char *s, unsigned long long *value, char **endptr,
-               int base);
-int parse_uint_full(const char *s, unsigned long long *value, int base);
-
-/*
- * qemu_strtosz() suffixes used to specify the default treatment of an
- * argument passed to qemu_strtosz() without an explicit suffix.
- * These should be defined using upper case characters in the range
- * A-Z, as qemu_strtosz() will use qemu_toupper() on the given argument
- * prior to comparison.
- */
-#define QEMU_STRTOSZ_DEFSUFFIX_EB 'E'
-#define QEMU_STRTOSZ_DEFSUFFIX_PB 'P'
-#define QEMU_STRTOSZ_DEFSUFFIX_TB 'T'
-#define QEMU_STRTOSZ_DEFSUFFIX_GB 'G'
-#define QEMU_STRTOSZ_DEFSUFFIX_MB 'M'
-#define QEMU_STRTOSZ_DEFSUFFIX_KB 'K'
-#define QEMU_STRTOSZ_DEFSUFFIX_B 'B'
-int64_t qemu_strtosz(const char *nptr, char **end);
-int64_t qemu_strtosz_suffix(const char *nptr, char **end,
-                            const char default_suffix);
-int64_t qemu_strtosz_suffix_unit(const char *nptr, char **end,
-                            const char default_suffix, int64_t unit);
-#define K_BYTE     (1ULL << 10)
-#define M_BYTE     (1ULL << 20)
-#define G_BYTE     (1ULL << 30)
-#define T_BYTE     (1ULL << 40)
-#define P_BYTE     (1ULL << 50)
-#define E_BYTE     (1ULL << 60)
-
-/* used to print char* safely */
-#define STR_OR_NULL(str) ((str) ? (str) : "null")
-
-/* id.c */
-
-typedef enum IdSubSystems {
-    ID_QDEV,
-    ID_BLOCK,
-    ID_MAX      /* last element, used as array size */
-} IdSubSystems;
-
-char *id_generate(IdSubSystems id);
-bool id_wellformed(const char *id);
-
-/* path.c */
-void init_paths(const char *prefix);
-const char *path(const char *pathname);
-
-#define qemu_isalnum(c)		isalnum((unsigned char)(c))
-#define qemu_isalpha(c)		isalpha((unsigned char)(c))
-#define qemu_iscntrl(c)		iscntrl((unsigned char)(c))
-#define qemu_isdigit(c)		isdigit((unsigned char)(c))
-#define qemu_isgraph(c)		isgraph((unsigned char)(c))
-#define qemu_islower(c)		islower((unsigned char)(c))
-#define qemu_isprint(c)		isprint((unsigned char)(c))
-#define qemu_ispunct(c)		ispunct((unsigned char)(c))
-#define qemu_isspace(c)		isspace((unsigned char)(c))
-#define qemu_isupper(c)		isupper((unsigned char)(c))
-#define qemu_isxdigit(c)	isxdigit((unsigned char)(c))
-#define qemu_tolower(c)		tolower((unsigned char)(c))
-#define qemu_toupper(c)		toupper((unsigned char)(c))
-#define qemu_isascii(c)		isascii((unsigned char)(c))
-#define qemu_toascii(c)		toascii((unsigned char)(c))
-
-void *qemu_oom_check(void *ptr);
-
-ssize_t qemu_write_full(int fd, const void *buf, size_t count)
-    QEMU_WARN_UNUSED_RESULT;
-
-#ifndef _WIN32
-int qemu_pipe(int pipefd[2]);
-/* like openpty() but also makes it raw; return master fd */
-int qemu_openpty_raw(int *aslave, char *pty_name);
-#endif
-
-#ifdef _WIN32
-/* MinGW needs type casts for the 'buf' and 'optval' arguments. */
-#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
-    getsockopt(sockfd, level, optname, (void *)optval, optlen)
-#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
-    setsockopt(sockfd, level, optname, (const void *)optval, optlen)
-#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
-#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
-    sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
-#else
-#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
-    getsockopt(sockfd, level, optname, optval, optlen)
-#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
-    setsockopt(sockfd, level, optname, optval, optlen)
-#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
-#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
-    sendto(sockfd, buf, len, flags, destaddr, addrlen)
-#endif
-
 /* Error handling.  */
 
 void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
@@ -409,17 +164,6 @@ void os_setup_early_signal_handling(void);
 char *os_find_datadir(void);
 void os_parse_cmd_args(int index, const char *optarg);
 
-/* Convert a byte between binary and BCD.  */
-static inline uint8_t to_bcd(uint8_t val)
-{
-    return ((val / 10) << 4) | (val % 10);
-}
-
-static inline uint8_t from_bcd(uint8_t val)
-{
-    return ((val >> 4) * 10) + (val & 0x0f);
-}
-
 /* Round number down to multiple */
 #define QEMU_ALIGN_DOWN(n, m) ((n) / (m) * (m))
 
@@ -436,15 +180,6 @@ static inline uint8_t from_bcd(uint8_t val)
 int uleb128_encode_small(uint8_t *out, uint32_t n);
 int uleb128_decode_small(const uint8_t *in, uint32_t *n);
 
-/* unicode.c */
-int mod_utf8_codepoint(const char *s, size_t n, char **end);
-
-/*
- * Hexdump a buffer to a file. An optional string prefix is added to every line
- */
-
-void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size);
-
 /* vector definitions */
 #ifdef __ALTIVEC__
 #include <altivec.h>
diff --git a/include/qemu/bcd.h b/include/qemu/bcd.h
new file mode 100644
index 0000000..7e720c4
--- /dev/null
+++ b/include/qemu/bcd.h
@@ -0,0 +1,10 @@
+/* Convert a byte between binary and BCD.  */
+static inline uint8_t to_bcd(uint8_t val)
+{
+    return ((val / 10) << 4) | (val % 10);
+}
+
+static inline uint8_t from_bcd(uint8_t val)
+{
+    return ((val >> 4) * 10) + (val & 0x0f);
+}
diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
new file mode 100644
index 0000000..1c13532
--- /dev/null
+++ b/include/qemu/cutils.h
@@ -0,0 +1,167 @@
+#include "qemu/typedefs.h"
+#include "qemu/fprintf-fn.h"
+
+/**
+ * pstrcpy:
+ * @buf: buffer to copy string into
+ * @buf_size: size of @buf in bytes
+ * @str: string to copy
+ *
+ * Copy @str into @buf, including the trailing NUL, but do not
+ * write more than @buf_size bytes. The resulting buffer is
+ * always NUL terminated (even if the source string was too long).
+ * If @buf_size is zero or negative then no bytes are copied.
+ *
+ * This function is similar to strncpy(), but avoids two of that
+ * function's problems:
+ *  * if @str fits in the buffer, pstrcpy() does not zero-fill the
+ *    remaining space at the end of @buf
+ *  * if @str is too long, pstrcpy() will copy the first @buf_size-1
+ *    bytes and then add a NUL
+ */
+void pstrcpy(char *buf, int buf_size, const char *str);
+/**
+ * strpadcpy:
+ * @buf: buffer to copy string into
+ * @buf_size: size of @buf in bytes
+ * @str: string to copy
+ * @pad: character to pad the remainder of @buf with
+ *
+ * Copy @str into @buf (but *not* its trailing NUL!), and then pad the
+ * rest of the buffer with the @pad character. If @str is too large
+ * for the buffer then it is truncated, so that @buf contains the
+ * first @buf_size characters of @str, with no terminator.
+ */
+void strpadcpy(char *buf, int buf_size, const char *str, char pad);
+/**
+ * pstrcat:
+ * @buf: buffer containing existing string
+ * @buf_size: size of @buf in bytes
+ * @s: string to concatenate to @buf
+ *
+ * Append a copy of @s to the string already in @buf, but do not
+ * allow the buffer to overflow. If the existing contents of @buf
+ * plus @str would total more than @buf_size bytes, then write
+ * as much of @str as will fit followed by a NUL terminator.
+ *
+ * @buf must already contain a NUL-terminated string, or the
+ * behaviour is undefined.
+ *
+ * Returns: @buf.
+ */
+char *pstrcat(char *buf, int buf_size, const char *s);
+/**
+ * strstart:
+ * @str: string to test
+ * @val: prefix string to look for
+ * @ptr: NULL, or pointer to be written to indicate start of
+ *       the remainder of the string
+ *
+ * Test whether @str starts with the prefix @val.
+ * If it does (including the degenerate case where @str and @val
+ * are equal) then return true. If @ptr is not NULL then a
+ * pointer to the first character following the prefix is written
+ * to it. If @val is not a prefix of @str then return false (and
+ * @ptr is not written to).
+ *
+ * Returns: true if @str starts with prefix @val, false otherwise.
+ */
+int strstart(const char *str, const char *val, const char **ptr);
+/**
+ * stristart:
+ * @str: string to test
+ * @val: prefix string to look for
+ * @ptr: NULL, or pointer to be written to indicate start of
+ *       the remainder of the string
+ *
+ * Test whether @str starts with the case-insensitive prefix @val.
+ * This function behaves identically to strstart(), except that the
+ * comparison is made after calling qemu_toupper() on each pair of
+ * characters.
+ *
+ * Returns: true if @str starts with case-insensitive prefix @val,
+ *          false otherwise.
+ */
+int stristart(const char *str, const char *val, const char **ptr);
+/**
+ * qemu_strnlen:
+ * @s: string
+ * @max_len: maximum number of bytes in @s to scan
+ *
+ * Return the length of the string @s, like strlen(), but do not
+ * examine more than @max_len bytes of the memory pointed to by @s.
+ * If no NUL terminator is found within @max_len bytes, then return
+ * @max_len instead.
+ *
+ * This function has the same behaviour as the POSIX strnlen()
+ * function.
+ *
+ * Returns: length of @s in bytes, or @max_len, whichever is smaller.
+ */
+int qemu_strnlen(const char *s, int max_len);
+/**
+ * qemu_strsep:
+ * @input: pointer to string to parse
+ * @delim: string containing delimiter characters to search for
+ *
+ * Locate the first occurrence of any character in @delim within
+ * the string referenced by @input, and replace it with a NUL.
+ * The location of the next character after the delimiter character
+ * is stored into @input.
+ * If the end of the string was reached without finding a delimiter
+ * character, then NULL is stored into @input.
+ * If @input points to a NULL pointer on entry, return NULL.
+ * The return value is always the original value of *@input (and
+ * so now points to a NUL-terminated string corresponding to the
+ * part of the input up to the first delimiter).
+ *
+ * This function has the same behaviour as the BSD strsep() function.
+ *
+ * Returns: the pointer originally in @input.
+ */
+char *qemu_strsep(char **input, const char *delim);
+time_t mktimegm(struct tm *tm);
+int qemu_fdatasync(int fd);
+int fcntl_setfl(int fd, int flag);
+int qemu_parse_fd(const char *param);
+int qemu_strtol(const char *nptr, const char **endptr, int base,
+                long *result);
+int qemu_strtoul(const char *nptr, const char **endptr, int base,
+                 unsigned long *result);
+int qemu_strtoll(const char *nptr, const char **endptr, int base,
+                 int64_t *result);
+int qemu_strtoull(const char *nptr, const char **endptr, int base,
+                  uint64_t *result);
+
+int parse_uint(const char *s, unsigned long long *value, char **endptr,
+               int base);
+int parse_uint_full(const char *s, unsigned long long *value, int base);
+
+/*
+ * qemu_strtosz() suffixes used to specify the default treatment of an
+ * argument passed to qemu_strtosz() without an explicit suffix.
+ * These should be defined using upper case characters in the range
+ * A-Z, as qemu_strtosz() will use qemu_toupper() on the given argument
+ * prior to comparison.
+ */
+#define QEMU_STRTOSZ_DEFSUFFIX_EB 'E'
+#define QEMU_STRTOSZ_DEFSUFFIX_PB 'P'
+#define QEMU_STRTOSZ_DEFSUFFIX_TB 'T'
+#define QEMU_STRTOSZ_DEFSUFFIX_GB 'G'
+#define QEMU_STRTOSZ_DEFSUFFIX_MB 'M'
+#define QEMU_STRTOSZ_DEFSUFFIX_KB 'K'
+#define QEMU_STRTOSZ_DEFSUFFIX_B 'B'
+int64_t qemu_strtosz(const char *nptr, char **end);
+int64_t qemu_strtosz_suffix(const char *nptr, char **end,
+                            const char default_suffix);
+int64_t qemu_strtosz_suffix_unit(const char *nptr, char **end,
+                            const char default_suffix, int64_t unit);
+#define K_BYTE     (1ULL << 10)
+#define M_BYTE     (1ULL << 20)
+#define G_BYTE     (1ULL << 30)
+#define T_BYTE     (1ULL << 40)
+#define P_BYTE     (1ULL << 50)
+#define E_BYTE     (1ULL << 60)
+
+/* used to print char* safely */
+#define STR_OR_NULL(str) ((str) ? (str) : "null")
diff --git a/include/qemu/help_option.h b/include/qemu/help_option.h
new file mode 100644
index 0000000..a7a3177
--- /dev/null
+++ b/include/qemu/help_option.h
@@ -0,0 +1,17 @@
+/**
+ * is_help_option:
+ * @s: string to test
+ *
+ * Check whether @s is one of the standard strings which indicate
+ * that the user is asking for a list of the valid values for a
+ * command option like -cpu or -M. The current accepted strings
+ * are 'help' and '?'. '?' is deprecated (it is a shell wildcard
+ * which makes it annoying to use in a reliable way) but provided
+ * for backwards compatibility.
+ *
+ * Returns: true if @s is a request for a list.
+ */
+static inline bool is_help_option(const char *s)
+{
+    return !strcmp(s, "?") || !strcmp(s, "help");
+}
diff --git a/include/qemu/id.h b/include/qemu/id.h
new file mode 100644
index 0000000..3ed104e
--- /dev/null
+++ b/include/qemu/id.h
@@ -0,0 +1,8 @@
+typedef enum IdSubSystems {
+    ID_QDEV,
+    ID_BLOCK,
+    ID_MAX      /* last element, used as array size */
+} IdSubSystems;
+
+char *id_generate(IdSubSystems id);
+bool id_wellformed(const char *id);
diff --git a/include/qemu/path.h b/include/qemu/path.h
new file mode 100644
index 0000000..a776567
--- /dev/null
+++ b/include/qemu/path.h
@@ -0,0 +1,47 @@
+void init_paths(const char *prefix);
+const char *path(const char *pathname);
+#define qemu_isalnum(c)		isalnum((unsigned char)(c))
+#define qemu_isalpha(c)		isalpha((unsigned char)(c))
+#define qemu_iscntrl(c)		iscntrl((unsigned char)(c))
+#define qemu_isdigit(c)		isdigit((unsigned char)(c))
+#define qemu_isgraph(c)		isgraph((unsigned char)(c))
+#define qemu_islower(c)		islower((unsigned char)(c))
+#define qemu_isprint(c)		isprint((unsigned char)(c))
+#define qemu_ispunct(c)		ispunct((unsigned char)(c))
+#define qemu_isspace(c)		isspace((unsigned char)(c))
+#define qemu_isupper(c)		isupper((unsigned char)(c))
+#define qemu_isxdigit(c)	isxdigit((unsigned char)(c))
+#define qemu_tolower(c)		tolower((unsigned char)(c))
+#define qemu_toupper(c)		toupper((unsigned char)(c))
+#define qemu_isascii(c)		isascii((unsigned char)(c))
+#define qemu_toascii(c)		toascii((unsigned char)(c))
+
+void *qemu_oom_check(void *ptr);
+
+ssize_t qemu_write_full(int fd, const void *buf, size_t count)
+QEMU_WARN_UNUSED_RESULT;
+
+#ifndef _WIN32
+int qemu_pipe(int pipefd[2]);
+/* like openpty() but also makes it raw; return master fd */
+int qemu_openpty_raw(int *aslave, char *pty_name);
+#endif
+
+#ifdef _WIN32
+/* MinGW needs type casts for the 'buf' and 'optval' arguments. */
+#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
+    getsockopt(sockfd, level, optname, (void *)optval, optlen)
+#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
+    setsockopt(sockfd, level, optname, (const void *)optval, optlen)
+#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
+#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
+    sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
+#else
+#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
+    getsockopt(sockfd, level, optname, optval, optlen)
+#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
+    setsockopt(sockfd, level, optname, optval, optlen)
+#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
+#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
+    sendto(sockfd, buf, len, flags, destaddr, addrlen)
+#endif
diff --git a/include/qemu/unicode.h b/include/qemu/unicode.h
new file mode 100644
index 0000000..80dcd0d
--- /dev/null
+++ b/include/qemu/unicode.h
@@ -0,0 +1,5 @@
+int mod_utf8_codepoint(const char *s, size_t n, char **end);
+/*
+Hexdump a buffer to a file. An optional string prefix is added to every line
+*/
+void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size);
diff --git a/io/channel-socket.c b/io/channel-socket.c
index d005070..2d274ec 100644
--- a/io/channel-socket.c
+++ b/io/channel-socket.c
@@ -22,6 +22,7 @@
 #include "io/channel-socket.h"
 #include "io/channel-watch.h"
 #include "trace.h"
+#include "qemu/path.h"
 
 #define SOCKET_MAX_FDS 16
 
diff --git a/io/channel-util.c b/io/channel-util.c
index 0fb4bd0..b826397 100644
--- a/io/channel-util.c
+++ b/io/channel-util.c
@@ -22,7 +22,7 @@
 #include "io/channel-util.h"
 #include "io/channel-file.h"
 #include "io/channel-socket.h"
-
+#include "qemu/path.h"
 
 static bool fd_is_socket(int fd)
 {
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 19dc7f5..e47caff 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -7,6 +7,7 @@
 
 #include "qemu.h"
 #include "disas/disas.h"
+#include "qemu/path.h"
 
 #ifdef _ARCH_PPC64
 #undef ARCH_DLINFO
diff --git a/linux-user/main.c b/linux-user/main.c
index 2b1e755..b432bf2 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -22,7 +22,9 @@
 #include <sys/resource.h>
 
 #include "qemu.h"
-#include "qemu-common.h"
+#include "qemu/path.h"
+#include "qemu/cutils.h"
+#include "qemu/help_option.h"
 #include "cpu.h"
 #include "tcg.h"
 #include "qemu/timer.h"
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9517531..032d338 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -18,6 +18,8 @@
  */
 #define _ATFILE_SOURCE
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 #include <elf.h>
 #include <endian.h>
 #include <grp.h>
diff --git a/linux-user/uaccess.c b/linux-user/uaccess.c
index 75d890d..0a5c0b0 100644
--- a/linux-user/uaccess.c
+++ b/linux-user/uaccess.c
@@ -1,5 +1,6 @@
 /* User memory access */
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 
 #include "qemu.h"
 
diff --git a/main-loop.c b/main-loop.c
index 19beae7..f08a0f2 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -23,7 +23,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "qemu/timer.h"
 #include "qemu/sockets.h"	// struct in_addr needed for libslirp.h
 #include "sysemu/qtest.h"
diff --git a/migration/migration.c b/migration/migration.c
index 034a918..991313a 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -14,7 +14,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "migration/migration.h"
diff --git a/migration/qemu-file-unix.c b/migration/qemu-file-unix.c
index 4474e18..8af5648 100644
--- a/migration/qemu-file-unix.c
+++ b/migration/qemu-file-unix.c
@@ -22,13 +22,13 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "qemu/error-report.h"
 #include "qemu/iov.h"
 #include "qemu/sockets.h"
 #include "qemu/coroutine.h"
 #include "migration/qemu-file.h"
 #include "migration/qemu-file-internal.h"
+#include "qemu/path.h"
 
 typedef struct QEMUFileSocket {
     int fd;
diff --git a/migration/savevm.c b/migration/savevm.c
index 0a33c22..16ba443 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -27,7 +27,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "hw/boards.h"
 #include "hw/hw.h"
 #include "hw/qdev.h"
@@ -50,7 +49,7 @@
 #include "qemu/iov.h"
 #include "block/snapshot.h"
 #include "block/qapi.h"
-
+#include "qemu/cutils.h"
 
 #ifndef ETH_P_RARP
 #define ETH_P_RARP 0x8035
diff --git a/monitor.c b/monitor.c
index e99ca8c..7660927 100644
--- a/monitor.c
+++ b/monitor.c
@@ -76,6 +76,8 @@
 #include "qapi-event.h"
 #include "qmp-introspect.h"
 #include "sysemu/block-backend.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 
 /* for hmp_info_irq/pic */
 #if defined(TARGET_SPARC)
diff --git a/net/net.c b/net/net.c
index b0c832e..3a0542b 100644
--- a/net/net.c
+++ b/net/net.c
@@ -31,7 +31,8 @@
 #include "util.h"
 
 #include "monitor/monitor.h"
-#include "qemu-common.h"
+#include "qemu/path.h"
+#include "qemu/help_option.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "qemu/sockets.h"
diff --git a/net/netmap.c b/net/netmap.c
index 1b42728..f1e9b8b 100644
--- a/net/netmap.c
+++ b/net/netmap.c
@@ -37,6 +37,7 @@
 #include "sysemu/sysemu.h"
 #include "qemu/error-report.h"
 #include "qemu/iov.h"
+#include "qemu/cutils.h"
 
 typedef struct NetmapState {
     NetClientState      nc;
diff --git a/net/slirp.c b/net/slirp.c
index 6b51fbc..fa171a7 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -37,6 +37,7 @@
 #include "qemu/sockets.h"
 #include "slirp/libslirp.h"
 #include "sysemu/char.h"
+#include "qemu/cutils.h"
 
 static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
 {
diff --git a/net/socket.c b/net/socket.c
index 73dc49a..450ad3f 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -26,7 +26,7 @@
 #include "net/net.h"
 #include "clients.h"
 #include "monitor/monitor.h"
-#include "qemu-common.h"
+#include "qemu/path.h"
 #include "qemu/error-report.h"
 #include "qemu/option.h"
 #include "qemu/sockets.h"
diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index 83de19a..ff47033 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -24,7 +24,7 @@
 
 #include "qemu/osdep.h"
 #include "tap_int.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "sysemu/sysemu.h"
 #include "qemu/error-report.h"
 
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 0929cf7..494c834 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -32,8 +32,8 @@
 #include <sys/ioctl.h>
 
 #include "sysemu/sysemu.h"
-#include "qemu-common.h"
 #include "qemu/error-report.h"
+#include "qemu/cutils.h"
 
 #define PATH_NET_TUN "/dev/net/tun"
 
diff --git a/net/tap-solaris.c b/net/tap-solaris.c
index e3907a8..aef59c1 100644
--- a/net/tap-solaris.c
+++ b/net/tap-solaris.c
@@ -25,6 +25,7 @@
 #include "qemu/osdep.h"
 #include "tap_int.h"
 #include "sysemu/sysemu.h"
+#include "qemu/cutils.h"
 
 #include <sys/ethernet.h>
 #include <sys/sockio.h>
diff --git a/net/tap.c b/net/tap.c
index cd7a7fc..9ff068d 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -37,6 +37,7 @@
 #include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
 #include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "qemu/error-report.h"
 
 #include "net/tap.h"
diff --git a/os-posix.c b/os-posix.c
index 92fa3ba..107fde3 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -38,6 +38,7 @@
 #include "qemu/rcu.h"
 #include "qemu/error-report.h"
 #include "qemu/log.h"
+#include "qemu/cutils.h"
 
 #ifdef CONFIG_LINUX
 #include <sys/prctl.h>
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index 73e4ace..13cc8f0 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -11,7 +11,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/opts-visitor.h"
 #include "qemu/queue.h"
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 81e3ff3..46a5404 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -27,6 +27,7 @@
 #include "qapi/qmp/qerror.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
+#include "qemu/help_option.h"
 
 /*
  * Aliases were a bad idea from the start.  Let's keep them
diff --git a/qemu-char.c b/qemu-char.c
index 3bf30b5..95efb8c 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -22,7 +22,8 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 #include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
 #include "qemu/error-report.h"
diff --git a/qemu-img.c b/qemu-img.c
index 2edb139..2611ba9 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -26,7 +26,7 @@
 #include "qapi/qmp-output-visitor.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qjson.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "qemu/config-file.h"
 #include "qemu/option.h"
 #include "qemu/error-report.h"
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index e929d24..0346a71 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -18,6 +18,7 @@
 #include "qemu/main-loop.h"
 #include "qemu/timer.h"
 #include "sysemu/block-backend.h"
+#include "qemu/cutils.h"
 
 #define CMD_NOFILE_OK   0x01
 
diff --git a/qemu-nbd.c b/qemu-nbd.c
index a5c1d95..713d46d 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -17,7 +17,8 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 #include "sysemu/block-backend.h"
 #include "block/block_int.h"
 #include "block/nbd.h"
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 9f51fae..ca1a8de 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -23,6 +23,8 @@
 #include "qemu/host-utils.h"
 #include "qemu/sockets.h"
 #include "qemu/base64.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 
 #ifndef CONFIG_HAS_ENVIRON
 #ifdef __APPLE__
diff --git a/qga/commands.c b/qga/commands.c
index e091ee1..95d8b04 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -16,6 +16,7 @@
 #include "qga-qmp-commands.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/base64.h"
+#include "qemu/cutils.h"
 
 /* Maximum captured guest-exec out_data/err_data - 16MB */
 #define GUEST_EXEC_MAX_OUTPUT (16*1024*1024)
diff --git a/qga/main.c b/qga/main.c
index 0a168e2..053e08c 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -29,6 +29,7 @@
 #include "qapi/qmp/dispatch.h"
 #include "qga/channel.h"
 #include "qemu/bswap.h"
+#include "qemu/help_option.h"
 #ifdef _WIN32
 #include "qga/service-win32.h"
 #include "qga/vss-win32.h"
diff --git a/qmp.c b/qmp.c
index 3f16a77..9d0953b 100644
--- a/qmp.c
+++ b/qmp.c
@@ -14,7 +14,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
 #include "qmp-commands.h"
diff --git a/qobject/json-parser.c b/qobject/json-parser.c
index 6c05f6c..31b9c7c 100644
--- a/qobject/json-parser.c
+++ b/qobject/json-parser.c
@@ -13,7 +13,7 @@
 
 #include "qemu/osdep.h"
 
-#include "qemu-common.h"
+#include "qemu/path.h"
 #include "qapi/qmp/qstring.h"
 #include "qapi/qmp/qint.h"
 #include "qapi/qmp/qdict.h"
diff --git a/qobject/qdict.c b/qobject/qdict.c
index 9833bd0..a128536 100644
--- a/qobject/qdict.c
+++ b/qobject/qdict.c
@@ -19,6 +19,7 @@
 #include "qapi/qmp/qobject.h"
 #include "qemu/queue.h"
 #include "qemu-common.h"
+#include "qemu/cutils.h"
 
 /**
  * qdict_new(): Create a new QDict
diff --git a/qobject/qjson.c b/qobject/qjson.c
index 06dc210..ef160d2 100644
--- a/qobject/qjson.c
+++ b/qobject/qjson.c
@@ -21,6 +21,7 @@
 #include "qapi/qmp/qbool.h"
 #include "qapi/qmp/qfloat.h"
 #include "qapi/qmp/qdict.h"
+#include "qemu/unicode.h"
 
 typedef struct JSONParsingState
 {
diff --git a/qom/object.c b/qom/object.c
index 844ae7a..5158862 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -13,7 +13,7 @@
 #include "qemu/osdep.h"
 #include "qom/object.h"
 #include "qom/object_interfaces.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "qapi/visitor.h"
 #include "qapi-visit.h"
 #include "qapi/string-input-visitor.h"
diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index ace3982..acc5c96 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -33,6 +33,7 @@
 #include "qemu/osdep.h"
 #include "slirp.h"
 #include "ip_icmp.h"
+#include "qemu/path.h"
 
 /* The message sent when emulating PING */
 /* Be nice and tell them it's just a pseudo-ping packet */
diff --git a/slirp/misc.c b/slirp/misc.c
index e2eea2e..bdb8929 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -12,6 +12,7 @@
 #include "monitor/monitor.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
+#include "qemu/path.h"
 
 #ifdef DEBUG
 int slirp_debug = DBG_CALL|DBG_MISC|DBG_ERROR;
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 0466d33..63d96c2 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -28,6 +28,7 @@
 #include "sysemu/char.h"
 #include "slirp.h"
 #include "hw/hw.h"
+#include "qemu/cutils.h"
 
 /* host loopback address */
 struct in_addr loopback_addr;
diff --git a/slirp/socket.c b/slirp/socket.c
index 2b5453e..0666bfe 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -6,7 +6,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/path.h"
 #include <slirp.h>
 #include "ip_icmp.h"
 #ifdef __sun__
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index b1aa1f2..92be294 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -40,6 +40,7 @@
 
 #include "qemu/osdep.h"
 #include <slirp.h>
+#include "qemu/path.h"
 
 /* patchable/settable parameters for tcp */
 /* Don't do rfc1323 performance enhancements */
diff --git a/slirp/tftp.c b/slirp/tftp.c
index abb0106..e01369b 100644
--- a/slirp/tftp.c
+++ b/slirp/tftp.c
@@ -25,6 +25,7 @@
 #include "qemu/osdep.h"
 #include <slirp.h>
 #include "qemu-common.h"
+#include "qemu/cutils.h"
 
 static inline int tftp_session_in_use(struct tftp_session *spt)
 {
diff --git a/target-arm/arm-semi.c b/target-arm/arm-semi.c
index 76c33b9..8be0645 100644
--- a/target-arm/arm-semi.c
+++ b/target-arm/arm-semi.c
@@ -30,6 +30,7 @@
 #include "qemu-common.h"
 #include "exec/gdbstub.h"
 #include "hw/arm/arm.h"
+#include "qemu/cutils.h"
 #endif
 
 #define TARGET_SYS_OPEN        0x01
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 0f38d1e..08dc88c 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -17,6 +17,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 
 #include "cpu.h"
 #include "sysemu/kvm.h"
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index d67c169..5caa5dd 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -42,6 +42,7 @@
 #include "exec/gdbstub.h"
 #include "exec/memattrs.h"
 #include "sysemu/hostmem.h"
+#include "qemu/cutils.h"
 
 //#define DEBUG_KVM
 
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index bd0cffc..0714b0e 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -31,6 +31,7 @@
 #include "qemu/error-report.h"
 #include "qapi/visitor.h"
 #include "hw/qdev-properties.h"
+#include "qemu/path.h"
 
 //#define PPC_DUMP_CPU
 //#define PPC_DEBUG_SPR
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 1cbf703..d66d7b1 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -26,6 +26,7 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "qemu/timer.h"
 #include "qemu/error-report.h"
 #include "hw/hw.h"
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 550671b..4c8c2d2 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -36,7 +36,7 @@
 #define NDEBUG
 #endif
 
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "qemu/host-utils.h"
 #include "qemu/timer.h"
 
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 0a80ddf..f1e2336 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -13,7 +13,7 @@
 #include "qemu/osdep.h"
 #include <glib.h>
 #include <glib/gstdio.h>
-#include "qemu-common.h"
+#include "qemu/path.h"
 #include "libqtest.h"
 #include "hw/acpi/acpi-defs.h"
 #include "hw/smbios/smbios.h"
diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c
index e184c67..253556e 100644
--- a/tests/ivshmem-test.c
+++ b/tests/ivshmem-test.c
@@ -16,6 +16,7 @@
 #include "libqos/pci-pc.h"
 #include "libqtest.h"
 #include "qemu-common.h"
+#include "qemu/path.h"
 
 #define TMPSHMSIZE (1 << 20)
 static char *tmpshm;
diff --git a/tests/qom-test.c b/tests/qom-test.c
index 3c6cfca..bd5cdde 100644
--- a/tests/qom-test.c
+++ b/tests/qom-test.c
@@ -11,6 +11,7 @@
 #include <glib.h>
 
 #include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "libqtest.h"
 #include "qapi/qmp/types.h"
 
diff --git a/tests/tcg/linux-test.c b/tests/tcg/linux-test.c
index 1c6c013..5070d31 100644
--- a/tests/tcg/linux-test.c
+++ b/tests/tcg/linux-test.c
@@ -39,6 +39,7 @@
 #include <dirent.h>
 #include <setjmp.h>
 #include <sys/shm.h>
+#include "qemu/cutils.h"
 
 #define TESTPATH "/tmp/linux-test.tmp"
 #define TESTPORT 7654
diff --git a/tests/test-cutils.c b/tests/test-cutils.c
index 398700d..fb8f5b5 100644
--- a/tests/test-cutils.c
+++ b/tests/test-cutils.c
@@ -28,8 +28,7 @@
 #include "qemu/osdep.h"
 #include <glib.h>
 
-#include "qemu-common.h"
-
+#include "qemu/cutils.h"
 
 static void test_parse_uint_null(void)
 {
diff --git a/tests/test-rfifolock.c b/tests/test-rfifolock.c
index 9a3cb24..c8d5553 100644
--- a/tests/test-rfifolock.c
+++ b/tests/test-rfifolock.c
@@ -13,6 +13,7 @@
 #include "qemu/osdep.h"
 #include <glib.h>
 #include "qemu-common.h"
+#include "qemu/path.h"
 #include "qemu/rfifolock.h"
 
 static void test_nesting(void)
diff --git a/trace/control.c b/trace/control.c
index 20d3370..ccddda5 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -9,6 +9,7 @@
 
 #include "qemu/osdep.h"
 #include "trace/control.h"
+#include "qemu/help_option.h"
 #ifdef CONFIG_TRACE_SIMPLE
 #include "trace/simple.h"
 #endif
diff --git a/ui/gtk.c b/ui/gtk.c
index 38ef3fd..f372a6d 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -36,6 +36,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "qemu/cutils.h"
 
 #include "ui/console.h"
 #include "ui/gtk.h"
diff --git a/ui/keymaps.c b/ui/keymaps.c
index 8899a0b..8b03ac1 100644
--- a/ui/keymaps.c
+++ b/ui/keymaps.c
@@ -25,6 +25,7 @@
 #include "qemu/osdep.h"
 #include "keymaps.h"
 #include "sysemu/sysemu.h"
+#include "qemu/path.h"
 
 static int get_keysym(const name2keysym_t *table,
                       const char *name)
diff --git a/ui/sdl.c b/ui/sdl.c
index abeef33..d8cf5bc 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -30,6 +30,7 @@
 #include <SDL_syswm.h>
 
 #include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "ui/console.h"
 #include "ui/input.h"
 #include "sysemu/sysemu.h"
diff --git a/ui/vnc.c b/ui/vnc.c
index 729f630..e06d39c 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -44,6 +44,7 @@
 #include "crypto/tlscredsanon.h"
 #include "crypto/tlscredsx509.h"
 #include "qom/object_interfaces.h"
+#include "qemu/cutils.h"
 
 #define VNC_REFRESH_INTERVAL_BASE GUI_REFRESH_INTERVAL_DEFAULT
 #define VNC_REFRESH_INTERVAL_INC  50
diff --git a/util/cutils.c b/util/cutils.c
index c3dd534..7e70931 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -22,13 +22,14 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "qemu/host-utils.h"
 #include <math.h>
 
 #include "qemu/sockets.h"
 #include "qemu/iov.h"
 #include "net/net.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 
 void strpadcpy(char *buf, int buf_size, const char *str, char pad)
 {
diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c
index 2e30e74..836532e 100644
--- a/util/event_notifier-posix.c
+++ b/util/event_notifier-posix.c
@@ -11,7 +11,8 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 #include "qemu/event_notifier.h"
 #include "sysemu/char.h"
 #include "qemu/main-loop.h"
diff --git a/util/hexdump.c b/util/hexdump.c
index 1d9c129..65ac909 100644
--- a/util/hexdump.c
+++ b/util/hexdump.c
@@ -14,7 +14,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/unicode.h"
 
 void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size)
 {
diff --git a/util/id.c b/util/id.c
index bbbadcc..5d29e32 100644
--- a/util/id.c
+++ b/util/id.c
@@ -11,7 +11,8 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/id.h"
+#include "qemu/path.h"
 
 bool id_wellformed(const char *id)
 {
diff --git a/util/iov.c b/util/iov.c
index 062f4e5..5641e2e 100644
--- a/util/iov.c
+++ b/util/iov.c
@@ -19,6 +19,7 @@
 #include "qemu/osdep.h"
 #include "qemu/iov.h"
 #include "qemu/sockets.h"
+#include "qemu/unicode.h"
 
 size_t iov_from_buf_full(const struct iovec *iov, unsigned int iov_cnt,
                          size_t offset, const void *buf, size_t bytes)
diff --git a/util/osdep.c b/util/osdep.c
index 8356bdd..44d22f8 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -36,7 +36,8 @@
 extern int madvise(caddr_t, size_t, int);
 #endif
 
-#include "qemu-common.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 #include "qemu/sockets.h"
 #include "qemu/error-report.h"
 #include "monitor/monitor.h"
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 7615be4..048a5c7 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -51,6 +51,8 @@
 #include <libgen.h>
 #include <setjmp.h>
 #include <sys/signal.h>
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 
 #ifdef CONFIG_LINUX
 #include <sys/syscall.h>
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index a3f0664..e67e31e 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -36,6 +36,7 @@
 #include "qemu/main-loop.h"
 #include "trace.h"
 #include "qemu/sockets.h"
+#include "qemu/cutils.h"
 
 /* this must come after including "trace.h" */
 #include <shlobj.h>
diff --git a/util/path.c b/util/path.c
index d09e8c5..7f9fc27 100644
--- a/util/path.c
+++ b/util/path.c
@@ -6,7 +6,8 @@
 #include "qemu/osdep.h"
 #include <sys/param.h>
 #include <dirent.h>
-#include "qemu-common.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 
 struct pathelem
 {
diff --git a/util/qemu-openpty.c b/util/qemu-openpty.c
index 2e8b43b..8c9c4a9 100644
--- a/util/qemu-openpty.c
+++ b/util/qemu-openpty.c
@@ -34,6 +34,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "qemu/path.h"
 
 #if defined(__GLIBC__)
 # include <pty.h>
diff --git a/util/qemu-option.c b/util/qemu-option.c
index e7aa43f..1d23934 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -30,6 +30,9 @@
 #include "qapi/qmp/types.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/option_int.h"
+#include "qemu/cutils.h"
+#include "qemu/id.h"
+#include "qemu/help_option.h"
 
 /*
  * Extracts the name of an option from the parameter string (p points at the
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index fd37ac2..8ea2a15 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -23,6 +23,8 @@
 #include "qapi/qmp-input-visitor.h"
 #include "qapi/qmp-output-visitor.h"
 #include "qapi-visit.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 
 #ifndef AI_ADDRCONFIG
 # define AI_ADDRCONFIG 0
diff --git a/util/readline.c b/util/readline.c
index e94c975..a97fe0d 100644
--- a/util/readline.c
+++ b/util/readline.c
@@ -23,8 +23,9 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "qemu/readline.h"
+#include "qemu/cutils.h"
+#include "qemu/path.h"
 
 #define IS_NORM 0
 #define IS_ESC  1
diff --git a/util/unicode.c b/util/unicode.c
index 524dca8..a812a35 100644
--- a/util/unicode.c
+++ b/util/unicode.c
@@ -11,7 +11,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/unicode.h"
 
 /**
  * mod_utf8_codepoint:
diff --git a/vl.c b/vl.c
index 7a28982..2a42e1b 100644
--- a/vl.c
+++ b/vl.c
@@ -22,7 +22,8 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-
+#include "qemu/cutils.h"
+#include "qemu/help_option.h"
 
 #ifdef CONFIG_SECCOMP
 #include "sysemu/seccomp.h"
