diff --git a/Makefile.objs b/Makefile.objs
index 3538789808af..5d4585c8e2f5 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -5,6 +5,12 @@ util-obj-y = util/ qobject/ qapi/
 
 chardev-obj-y = chardev/
 
+qom-obj-y = qom/
+
+crypto-obj-y = crypto/
+crypto-aes-obj-y = crypto/
+
+ifneq ($(CONFIG_USER_ONLY),y)
 #######################################################################
 # authz-obj-y is code used by both qemu system emulation and qemu-img
 
@@ -21,21 +27,11 @@ block-obj-$(CONFIG_REPLICATION) += replication.o
 
 block-obj-m = block/
 
-#######################################################################
-# crypto-obj-y is code used by both qemu system emulation and qemu-img
-
-crypto-obj-y = crypto/
-crypto-aes-obj-y = crypto/
-
-#######################################################################
-# qom-obj-y is code used by both qemu system emulation and qemu-img
-
-qom-obj-y = qom/
-
 #######################################################################
 # io-obj-y is code used by both qemu system emulation and qemu-img
 
 io-obj-y = io/
+endif
 
 ######################################################################
 # Target independent part of system emulation. The long term path is to
@@ -132,10 +128,18 @@ rdmacm-mux-obj-y = contrib/rdmacm-mux/
 trace-events-subdirs =
 trace-events-subdirs += accel/kvm
 trace-events-subdirs += accel/tcg
+ifeq ($(CONFIG_USER_ONLY),y)
+trace-events-subdirs += linux-user
+else
 trace-events-subdirs += authz
+trace-events-subdirs += nbd
 trace-events-subdirs += block
-trace-events-subdirs += chardev
+trace-events-subdirs += scsi
+trace-events-subdirs += io
+trace-events-subdirs += hw/display # needed by qemu-edid
+endif
 trace-events-subdirs += crypto
+trace-events-subdirs += chardev
 ifeq ($(CONFIG_SOFTMMU),y)
 trace-events-subdirs += audio
 trace-events-subdirs += hw/9pfs
@@ -146,7 +150,6 @@ trace-events-subdirs += hw/audio
 trace-events-subdirs += hw/block
 trace-events-subdirs += hw/block/dataplane
 trace-events-subdirs += hw/char
-trace-events-subdirs += hw/display
 trace-events-subdirs += hw/dma
 trace-events-subdirs += hw/hppa
 trace-events-subdirs += hw/i2c
@@ -183,12 +186,8 @@ trace-events-subdirs += migration
 trace-events-subdirs += net
 trace-events-subdirs += ui
 endif
-trace-events-subdirs += io
-trace-events-subdirs += linux-user
-trace-events-subdirs += nbd
 trace-events-subdirs += qapi
 trace-events-subdirs += qom
-trace-events-subdirs += scsi
 trace-events-subdirs += target/arm
 trace-events-subdirs += target/hppa
 trace-events-subdirs += target/i386
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 852f17b8c79c..c147182fb052 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -45,7 +45,6 @@ SYSEMU_TARGET_LIST := $(subst -softmmu.mak,,$(notdir \
 
 check-unit-y += tests/check-qdict$(EXESUF)
 check-unit-y += tests/check-block-qdict$(EXESUF)
-check-unit-y += tests/test-char$(EXESUF)
 check-unit-y += tests/check-qnum$(EXESUF)
 check-unit-y += tests/check-qstring$(EXESUF)
 check-unit-y += tests/check-qlist$(EXESUF)
@@ -61,9 +60,12 @@ check-unit-y += tests/test-string-input-visitor$(EXESUF)
 check-unit-y += tests/test-string-output-visitor$(EXESUF)
 check-unit-y += tests/test-qmp-event$(EXESUF)
 check-unit-y += tests/test-opts-visitor$(EXESUF)
-check-unit-y += tests/test-coroutine$(EXESUF)
 check-unit-y += tests/test-visitor-serialization$(EXESUF)
 check-unit-y += tests/test-iov$(EXESUF)
+check-unit-y += tests/test-x86-cpuid$(EXESUF)
+ifneq ($(CONFIG_USER_ONLY),y)
+check-unit-y += tests/test-char$(EXESUF)
+check-unit-y += tests/test-coroutine$(EXESUF)
 check-unit-y += tests/test-aio$(EXESUF)
 check-unit-y += tests/test-aio-multithread$(EXESUF)
 check-unit-y += tests/test-throttle$(EXESUF)
@@ -76,7 +78,7 @@ check-unit-y += tests/test-blockjob-txn$(EXESUF)
 check-unit-y += tests/test-block-backend$(EXESUF)
 check-unit-y += tests/test-block-iothread$(EXESUF)
 check-unit-y += tests/test-image-locking$(EXESUF)
-check-unit-y += tests/test-x86-cpuid$(EXESUF)
+endif
 # all code tested by test-x86-cpuid is inside topology.h
 ifeq ($(CONFIG_SOFTMMU),y)
 check-unit-y += tests/test-xbzrle$(EXESUF)
@@ -101,6 +103,14 @@ check-unit-y += tests/check-qom-interface$(EXESUF)
 check-unit-y += tests/check-qom-proplist$(EXESUF)
 check-unit-y += tests/test-qemu-opts$(EXESUF)
 check-unit-y += tests/test-keyval$(EXESUF)
+ifneq (,$(findstring qemu-ga,$(TOOLS)))
+check-unit-$(call land,$(CONFIG_LINUX),$(CONFIG_VIRTIO_SERIAL)) += tests/test-qga$(EXESUF)
+endif
+check-unit-y += tests/test-timed-average$(EXESUF)
+check-unit-$(CONFIG_INOTIFY1) += tests/test-util-filemonitor$(EXESUF)
+check-unit-y += tests/test-util-sockets$(EXESUF)
+check-unit-y += tests/test-base64$(EXESUF)
+ifneq ($(CONFIG_USER_ONLY),y)
 check-unit-y += tests/test-write-threshold$(EXESUF)
 check-unit-y += tests/test-crypto-hash$(EXESUF)
 check-speed-y += tests/benchmark-crypto-hash$(EXESUF)
@@ -111,12 +121,6 @@ check-speed-y += tests/benchmark-crypto-cipher$(EXESUF)
 check-unit-y += tests/test-crypto-secret$(EXESUF)
 check-unit-$(CONFIG_GNUTLS) += tests/test-crypto-tlscredsx509$(EXESUF)
 check-unit-$(CONFIG_GNUTLS) += tests/test-crypto-tlssession$(EXESUF)
-ifneq (,$(findstring qemu-ga,$(TOOLS)))
-check-unit-$(call land,$(CONFIG_LINUX),$(CONFIG_VIRTIO_SERIAL)) += tests/test-qga$(EXESUF)
-endif
-check-unit-y += tests/test-timed-average$(EXESUF)
-check-unit-$(CONFIG_INOTIFY1) += tests/test-util-filemonitor$(EXESUF)
-check-unit-y += tests/test-util-sockets$(EXESUF)
 check-unit-y += tests/test-authz-simple$(EXESUF)
 check-unit-y += tests/test-authz-list$(EXESUF)
 check-unit-y += tests/test-authz-listfile$(EXESUF)
@@ -127,14 +131,14 @@ check-unit-y += tests/test-io-channel-file$(EXESUF)
 check-unit-$(CONFIG_GNUTLS) += tests/test-io-channel-tls$(EXESUF)
 check-unit-y += tests/test-io-channel-command$(EXESUF)
 check-unit-y += tests/test-io-channel-buffer$(EXESUF)
-check-unit-y += tests/test-base64$(EXESUF)
 check-unit-$(if $(CONFIG_NETTLE),y,$(CONFIG_GCRYPT)) += tests/test-crypto-pbkdf$(EXESUF)
 check-unit-y += tests/test-crypto-ivgen$(EXESUF)
 check-unit-y += tests/test-crypto-afsplit$(EXESUF)
 check-unit-y += tests/test-crypto-xts$(EXESUF)
 check-unit-y += tests/test-crypto-block$(EXESUF)
-check-unit-y += tests/test-logging$(EXESUF)
 check-unit-$(CONFIG_REPLICATION) += tests/test-replication$(EXESUF)
+endif
+check-unit-y += tests/test-logging$(EXESUF)
 check-unit-y += tests/test-bufferiszero$(EXESUF)
 check-unit-y += tests/test-uuid$(EXESUF)
 check-unit-y += tests/ptimer-test$(EXESUF)
