diff --git a/Makefile b/Makefile
index d6b9dc1..f56dcaa 100644
--- a/Makefile
+++ b/Makefile
@@ -44,6 +44,13 @@ ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
 endif
 endif
 
+GENERATED_BLOCK_HEADERS = block/qapi-generated/qmp-commands.h
+GENERATED_BLOCK_HEADERS += block/qapi-generated/qapi-types.h
+GENERATED_BLOCK_HEADERS += block/qapi-generated/qapi-visit.h
+GENERATED_BLOCK_SOURCES = block/qapi-generated/qmp-marshal.c
+GENERATED_BLOCK_SOURCES += block/qapi-generated/qapi-types.c
+GENERATED_BLOCK_SOURCES += block/qapi-generated/qapi-visit.c
+
 GENERATED_HEADERS = config-host.h qemu-options.def
 GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h
 GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c
@@ -136,6 +143,7 @@ dummy := $(call unnest-vars,, \
                 qga-vss-dll-obj-y \
                 block-obj-y \
                 block-obj-m \
+                qapi-block-obj-y \
                 common-obj-y \
                 common-obj-m)
 
@@ -212,7 +220,8 @@ util/module.o-cflags = -D'CONFIG_BLOCK_MODULES=$(block-modules)'
 qemu-img.o: qemu-img-cmds.h
 
 qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a
-qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a
+qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) $(qapi-block-obj-y) libqemustub.a
+qemu-nbd$(EXESUF): QEMU_CFLAGS += -DBLOCK_COMMAND_MONITOR
 qemu-io$(EXESUF): qemu-io.o $(block-obj-y) libqemuutil.a libqemustub.a
 
 qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
@@ -271,6 +280,22 @@ $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
 		$(gen-out-type) -o "." -m -i $<, \
 		"  GEN   $@")
 
+block/qapi-generated/qapi-types.c block/qapi-generated/qapi-types.h :\
+$(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
+	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
+		$(gen-out-type) -o block/qapi-generated -b -i $<, \
+		"  GEN   $@")
+block/qapi-generated/qapi-visit.c block/qapi-generated/qapi-visit.h :\
+$(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
+	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
+		$(gen-out-type) -o  block/qapi-generated -b -i $<, \
+		"  GEN   $@")
+block/qapi-generated/qmp-commands.h block/qapi-generated/qmp-marshal.c :\
+$(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
+	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
+		$(gen-out-type) -o  block/qapi-generated -m -i $<, \
+		"  GEN   $@")
+
 QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
 $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
 
@@ -291,8 +316,11 @@ clean:
 	rm -f trace/generated-tracers-dtrace.h*
 	rm -f $(foreach f,$(GENERATED_HEADERS),$(f) $(f)-timestamp)
 	rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp)
+	rm -f $(foreach f,$(GENERATED_BLOCK_HEADERS),$(f) $(f)-timestamp)
+	rm -f $(foreach f,$(GENERATED_BLOCK_SOURCES),$(f) $(f)-timestamp)
 	rm -rf qapi-generated
 	rm -rf qga/qapi-generated
+	rm -rf block/qapi-generated
 	for d in $(ALL_SUBDIRS); do \
 	if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
 	rm -f $$d/qemu-options.def; \
@@ -550,7 +578,8 @@ endif # CONFIG_WIN
 # Add a dependency on the generated files, so that they are always
 # rebuilt before other object files
 ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
-Makefile: $(GENERATED_HEADERS)
+Makefile: $(GENERATED_HEADERS) $(GENERATED_BLOCK_HEADERS)\
+	$(GENERATED_BLOCK_SOURCES)
 endif
 
 # Include automatically generated dependency files
diff --git a/Makefile.objs b/Makefile.objs
index 0f0f298..6fe81e9 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -21,6 +21,16 @@ block-obj-y += coroutine-$(CONFIG_COROUTINE_BACKEND).o
 
 block-obj-m = block/
 
+qapi-block-obj-y = block/qapi-generated/qmp-marshal.o blockdev.o qmp.o
+qapi-block-obj-y += monitor.o
+qapi-block-obj-y += qemu-char.o
+qapi-block-obj-y += qemu-log.o
+qapi-block-obj-y += qom/
+qapi-block-obj-y += util/
+qapi-block-obj-y += qobject/
+qapi-block-obj-y += block/
+qapi-block-obj-y += qapi/
+qapi-block-obj-y += stubs/
 
 ######################################################################
 # smartcard
diff --git a/block/Makefile.objs b/block/Makefile.objs
index fd88c03..a368e98 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -20,10 +20,13 @@ block-obj-$(CONFIG_GLUSTERFS) += gluster.o
 block-obj-$(CONFIG_LIBSSH2) += ssh.o
 endif
 
-common-obj-y += stream.o
-common-obj-y += commit.o
-common-obj-y += mirror.o
-common-obj-y += backup.o
+block-job-obj-y = stream.o
+block-job-obj-y += commit.o
+block-job-obj-y += mirror.o
+block-job-obj-y += backup.o
+
+common-obj-y += $(block-job-obj-y)
+qapi-block-obj-y += $(block-job-obj-y)
 
 iscsi.o-cflags     := $(LIBISCSI_CFLAGS)
 iscsi.o-libs       := $(LIBISCSI_LIBS)
diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs
index d14b769..c67e110 100644
--- a/qapi/Makefile.objs
+++ b/qapi/Makefile.objs
@@ -4,3 +4,5 @@ util-obj-y += string-input-visitor.o string-output-visitor.o
 
 util-obj-y += opts-visitor.o
 util-obj-y += qmp-event.o
+
+qapi-block-obj-y += $(util-obj-y)
diff --git a/qobject/Makefile.objs b/qobject/Makefile.objs
index c9ff59c..96e652d 100644
--- a/qobject/Makefile.objs
+++ b/qobject/Makefile.objs
@@ -1,3 +1,5 @@
 util-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
 util-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
 util-obj-y += qerror.o
+
+qapi-block-obj-y += $(util-obj-y)
diff --git a/qom/Makefile.objs b/qom/Makefile.objs
index 985003b..f388fd3 100644
--- a/qom/Makefile.objs
+++ b/qom/Makefile.objs
@@ -1,3 +1,5 @@
-common-obj-y = object.o container.o qom-qobject.o
-common-obj-y += cpu.o
-common-obj-y += object_interfaces.o
+qom-obj-y = object.o container.o qom-qobject.o
+qom-obj-y += object_interfaces.o
+
+common-obj-y += $(qom-obj-y) cpu.o
+qapi-block-obj-y += $(qom-obj-y)
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 5e347d0..ce6454f 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -40,3 +40,18 @@ stub-obj-$(CONFIG_WIN32) += fd-register.o
 stub-obj-y += cpus.o
 stub-obj-y += kvm.o
 stub-obj-y += qmp_pc_dimm_device_list.o
+
+qapi-block-obj-y += arch-type.o
+qapi-block-obj-y += autostart.o
+qapi-block-obj-y += kvm-allowed.o
+qapi-block-obj-y += cpus-list.o
+qapi-block-obj-y += serial-hds.o
+qapi-block-obj-y += qemu-chr-open-msmouse.o
+qapi-block-obj-y += runstate-is-running.o
+qapi-block-obj-y += kvm-cpu-synchronize-state.o
+qapi-block-obj-y += kvm-cpu-synchronize-post-init.o
+qapi-block-obj-y += qemu-add-machine-init-done-notifier.o
+qapi-block-obj-y += get-double.o
+qapi-block-obj-y += get-expr.o
+qapi-block-obj-y += vmstate-info-buffer.o
+qapi-block-obj-y += vmstate-info-uint32.o
diff --git a/stubs/arch-type.c b/stubs/arch-type.c
new file mode 100644
index 0000000..90b2e80
--- /dev/null
+++ b/stubs/arch-type.c
@@ -0,0 +1,3 @@
+#include <stdint.h>
+
+const uint32_t arch_type = -1;
diff --git a/stubs/autostart.c b/stubs/autostart.c
new file mode 100644
index 0000000..0746d71
--- /dev/null
+++ b/stubs/autostart.c
@@ -0,0 +1 @@
+int autostart;
diff --git a/stubs/cpus-list.c b/stubs/cpus-list.c
new file mode 100644
index 0000000..c1f0455
--- /dev/null
+++ b/stubs/cpus-list.c
@@ -0,0 +1,3 @@
+#include "sysemu/kvm.h"
+
+struct CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus);
diff --git a/stubs/get-double.c b/stubs/get-double.c
new file mode 100644
index 0000000..b365266
--- /dev/null
+++ b/stubs/get-double.c
@@ -0,0 +1,8 @@
+#include <stdint.h>
+#include "monitor/monitor-system.h"
+
+int get_double(Monitor *mon, double *pval, const char **pp)
+{
+    *pval = 0;
+    return 0;
+}
diff --git a/stubs/get-expr.c b/stubs/get-expr.c
new file mode 100644
index 0000000..e05ad5c
--- /dev/null
+++ b/stubs/get-expr.c
@@ -0,0 +1,8 @@
+#include <stdint.h>
+#include "monitor/monitor-system.h"
+
+int get_expr(Monitor *mon, int64_t *pval, const char **pp)
+{
+    *pval = 0;
+    return 0;
+}
diff --git a/stubs/kvm-allowed.c b/stubs/kvm-allowed.c
new file mode 100644
index 0000000..74a2fa9
--- /dev/null
+++ b/stubs/kvm-allowed.c
@@ -0,0 +1,3 @@
+#include <stdbool.h>
+
+bool kvm_allowed;
diff --git a/stubs/kvm-cpu-synchronize-post-init.c b/stubs/kvm-cpu-synchronize-post-init.c
new file mode 100644
index 0000000..f78faa7
--- /dev/null
+++ b/stubs/kvm-cpu-synchronize-post-init.c
@@ -0,0 +1,5 @@
+#include "sysemu/kvm.h"
+
+void kvm_cpu_synchronize_post_init(CPUState *cpu)
+{
+}
diff --git a/stubs/kvm-cpu-synchronize-state.c b/stubs/kvm-cpu-synchronize-state.c
new file mode 100644
index 0000000..53fd523
--- /dev/null
+++ b/stubs/kvm-cpu-synchronize-state.c
@@ -0,0 +1,5 @@
+#include "sysemu/kvm.h"
+
+void kvm_cpu_synchronize_state(CPUState *cpu)
+{
+}
diff --git a/stubs/qemu-add-machine-init-done-notifier.c b/stubs/qemu-add-machine-init-done-notifier.c
new file mode 100644
index 0000000..744a6a9
--- /dev/null
+++ b/stubs/qemu-add-machine-init-done-notifier.c
@@ -0,0 +1,5 @@
+#include "sysemu/sysemu.h"
+
+void qemu_add_machine_init_done_notifier(Notifier *notify)
+{
+}
diff --git a/stubs/qemu-chr-open-msmouse.c b/stubs/qemu-chr-open-msmouse.c
new file mode 100644
index 0000000..459f10b
--- /dev/null
+++ b/stubs/qemu-chr-open-msmouse.c
@@ -0,0 +1,7 @@
+#include "sysemu/char.h"
+#include "ui/console.h"
+
+CharDriverState *qemu_chr_open_msmouse(void)
+{
+    return NULL;
+}
diff --git a/stubs/runstate-is-running.c b/stubs/runstate-is-running.c
new file mode 100644
index 0000000..f7e6fc2
--- /dev/null
+++ b/stubs/runstate-is-running.c
@@ -0,0 +1,6 @@
+#include "sysemu/sysemu.h"
+
+int runstate_is_running(void)
+{
+    return 1;
+}
diff --git a/stubs/serial-hds.c b/stubs/serial-hds.c
new file mode 100644
index 0000000..81d539c
--- /dev/null
+++ b/stubs/serial-hds.c
@@ -0,0 +1,3 @@
+#include "sysemu/sysemu.h"
+
+CharDriverState *serial_hds[MAX_SERIAL_PORTS];
diff --git a/stubs/vmstate-info-buffer.c b/stubs/vmstate-info-buffer.c
new file mode 100644
index 0000000..29fcaa0
--- /dev/null
+++ b/stubs/vmstate-info-buffer.c
@@ -0,0 +1,8 @@
+#include <qemu-common.h>
+#include "migration/vmstate.h"
+
+const VMStateInfo vmstate_info_buffer = {
+    .name = "buffer",
+    .get  = NULL,
+    .put  = NULL,
+};
diff --git a/stubs/vmstate-info-uint32.c b/stubs/vmstate-info-uint32.c
new file mode 100644
index 0000000..1d11233
--- /dev/null
+++ b/stubs/vmstate-info-uint32.c
@@ -0,0 +1,8 @@
+#include <qemu-common.h>
+#include "migration/vmstate.h"
+
+const VMStateInfo vmstate_info_uint32 = {
+    .name = "uint32",
+    .get  = NULL,
+    .put  = NULL,
+};
diff --git a/util/Makefile.objs b/util/Makefile.objs
index 6b3c83b..20d65c0 100644
--- a/util/Makefile.objs
+++ b/util/Makefile.objs
@@ -15,3 +15,5 @@ util-obj-y += throttle.o
 util-obj-y += getauxval.o
 util-obj-y += readline.o
 util-obj-y += rfifolock.o
+
+qapi-block-obj-y += $(util-obj-y)
