diff mbox series

[RESEND,v6,08/36] multi-process: Add stub functions to facilitate build of multi-process

Message ID 647fa5bf70dbea7d2b4e47d2084dea3a66385433.1587614626.git.elena.ufimtseva@oracle.com (mailing list archive)
State New, archived
Headers show
Series [RESEND,v6,01/36] memory: alloc RAM from file at offset | expand

Commit Message

Elena Ufimtseva April 23, 2020, 4:13 a.m. UTC
From: Jagannathan Raman <jag.raman@oracle.com>

Add stub functions that are needed during compile time but not in
runtime.
To avoid duplicate symbol while linking for monitor_get_fd, put in
a separate file.

Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
---
 MAINTAINERS            |  3 ++
 accel/stubs/kvm-stub.c |  5 +++
 accel/stubs/tcg-stub.c | 98 ++++++++++++++++++++++++++++++++++++++++++
 stubs/Makefile.objs    |  1 +
 stubs/audio.c          | 12 ++++++
 stubs/get-fd.c         | 10 +++++
 stubs/monitor.c        | 53 +++++++++++++++++++++--
 stubs/net-stub.c       | 31 +++++++++++++
 stubs/replay.c         | 14 ++++++
 stubs/vl-stub.c        | 79 ++++++++++++++++++++++++++++++++++
 stubs/vmstate.c        | 19 ++++++++
 stubs/xen-mapcache.c   | 22 ++++++++++
 12 files changed, 344 insertions(+), 3 deletions(-)
 create mode 100644 stubs/audio.c
 create mode 100644 stubs/get-fd.c
 create mode 100644 stubs/net-stub.c
 create mode 100644 stubs/vl-stub.c
 create mode 100644 stubs/xen-mapcache.c

Comments

Stefan Hajnoczi April 24, 2020, 1:12 p.m. UTC | #1
On Wed, Apr 22, 2020 at 09:13:43PM -0700, elena.ufimtseva@oracle.com wrote:
> diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
> index f884bb6180..f74c7e927b 100644
> --- a/stubs/Makefile.objs
> +++ b/stubs/Makefile.objs
> @@ -20,6 +20,7 @@ stub-obj-y += migr-blocker.o
>  stub-obj-y += change-state-handler.o
>  stub-obj-y += monitor.o
>  stub-obj-y += monitor-core.o
> +stub-obj-y += get-fd.o
>  stub-obj-y += notify-event.o
>  stub-obj-y += qtest.o
>  stub-obj-y += replay.o

audio.c, vl-stub.c, and xen-mapcache.c are added by this patch but not
added to Makefile.objs?  Can they be removed?

This entire patch requires justification.  Stubs exist so that common
code can be linked without optional features.

For example, common code may call into kvm but that callback isn't
relevant when building with kvm accelerator support (e.g. say qemu-nbd).
That's where the stub function comes in.  It fulfills the dependency
without dragging in the actual kvm accelerator code.

Adding lots of stubs suggests you are building QEMU in a new way that
wasn't done before (this is true and expected for this patch series).  I
would like to understand the reason for these stubs though.  For
example, why do you need to stub audio?

Without a reason for each of these stubs we have no way of knowing if
they are actually used/needed.  Maybe an earlier version of the code
needed it but the latest version of the patch no longer does...

Stefan
Jag Raman April 24, 2020, 1:47 p.m. UTC | #2
> On Apr 24, 2020, at 9:12 AM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> 
> On Wed, Apr 22, 2020 at 09:13:43PM -0700, elena.ufimtseva@oracle.com wrote:
>> diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
>> index f884bb6180..f74c7e927b 100644
>> --- a/stubs/Makefile.objs
>> +++ b/stubs/Makefile.objs
>> @@ -20,6 +20,7 @@ stub-obj-y += migr-blocker.o
>> stub-obj-y += change-state-handler.o
>> stub-obj-y += monitor.o
>> stub-obj-y += monitor-core.o
>> +stub-obj-y += get-fd.o
>> stub-obj-y += notify-event.o
>> stub-obj-y += qtest.o
>> stub-obj-y += replay.o
> 
> audio.c, vl-stub.c, and xen-mapcache.c are added by this patch but not
> added to Makefile.objs?  Can they be removed?

Hey Stefan,

Sorry it’s not clear. but these files are referenced in Makefile.target.

> 
> This entire patch requires justification.  Stubs exist so that common
> code can be linked without optional features.
> 
> For example, common code may call into kvm but that callback isn't
> relevant when building with kvm accelerator support (e.g. say qemu-nbd).
> That's where the stub function comes in.  It fulfills the dependency
> without dragging in the actual kvm accelerator code.
> 
> Adding lots of stubs suggests you are building QEMU in a new way that
> wasn't done before (this is true and expected for this patch series).  I
> would like to understand the reason for these stubs though.  For
> example, why do you need to stub audio?

These stub functions are only used by the remote process, and not by
QEMU itself.

Our goal is to ensure that the remote process is building the smallest
set of files necessary and these stub functions are necessary to meet
that goal.

For example, the remote process needs to build some of the functions
defined in “hw/core/qdev-properties-system.c”. However, this file
depends on audio.c (references audio_state_by_name()), which is not
needed for the remote process. The alternative to stub functions would
be to compile audio.c into the remote process, but that was not necessary
in our judgement. When the project started out, we spent a lot of time
figuring out which functions/files are necessary for the remote process, and
we stubbed out the ones which are needed to resolve dependency during
compilation, but not needed for functionality.

audio.c is just an example of tens of other places where we needed to
make similar judgements.

Would you prefer if we moved these stub functions into a separate
library (instead of stub-obj-y) which is only linked by the remote process?

--
Jag

> 
> Without a reason for each of these stubs we have no way of knowing if
> they are actually used/needed.  Maybe an earlier version of the code
> needed it but the latest version of the patch no longer does...
> 
> Stefan
Stefan Hajnoczi April 28, 2020, 4:29 p.m. UTC | #3
On Fri, Apr 24, 2020 at 09:47:56AM -0400, Jag Raman wrote:
> > On Apr 24, 2020, at 9:12 AM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> > On Wed, Apr 22, 2020 at 09:13:43PM -0700, elena.ufimtseva@oracle.com wrote:
> >> diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
> >> index f884bb6180..f74c7e927b 100644
> >> --- a/stubs/Makefile.objs
> >> +++ b/stubs/Makefile.objs
> >> @@ -20,6 +20,7 @@ stub-obj-y += migr-blocker.o
> >> stub-obj-y += change-state-handler.o
> >> stub-obj-y += monitor.o
> >> stub-obj-y += monitor-core.o
> >> +stub-obj-y += get-fd.o
> >> stub-obj-y += notify-event.o
> >> stub-obj-y += qtest.o
> >> stub-obj-y += replay.o
> > 
> > audio.c, vl-stub.c, and xen-mapcache.c are added by this patch but not
> > added to Makefile.objs?  Can they be removed?
> 
> Hey Stefan,
> 
> Sorry it’s not clear. but these files are referenced in Makefile.target.

Why is the Makefile.target change not in this patch?

Please structure patch series as logical changes that can be reviewed
sequentially.  Not only is it hard for reviewers to understand what is
going on but it probably also breaks bisectability if patches contain
incomplete changes.

> > 
> > This entire patch requires justification.  Stubs exist so that common
> > code can be linked without optional features.
> > 
> > For example, common code may call into kvm but that callback isn't
> > relevant when building with kvm accelerator support (e.g. say qemu-nbd).
> > That's where the stub function comes in.  It fulfills the dependency
> > without dragging in the actual kvm accelerator code.
> > 
> > Adding lots of stubs suggests you are building QEMU in a new way that
> > wasn't done before (this is true and expected for this patch series).  I
> > would like to understand the reason for these stubs though.  For
> > example, why do you need to stub audio?
> 
> These stub functions are only used by the remote process, and not by
> QEMU itself.
> 
> Our goal is to ensure that the remote process is building the smallest
> set of files necessary and these stub functions are necessary to meet
> that goal.
> 
> For example, the remote process needs to build some of the functions
> defined in “hw/core/qdev-properties-system.c”. However, this file
> depends on audio.c (references audio_state_by_name()), which is not
> needed for the remote process. The alternative to stub functions would
> be to compile audio.c into the remote process, but that was not necessary
> in our judgement. When the project started out, we spent a lot of time
> figuring out which functions/files are necessary for the remote process, and
> we stubbed out the ones which are needed to resolve dependency during
> compilation, but not needed for functionality.
> 
> audio.c is just an example of tens of other places where we needed to
> make similar judgements.
> 
> Would you prefer if we moved these stub functions into a separate
> library (instead of stub-obj-y) which is only linked by the remote process?

It's too bad that none of these judgements were documented.  As a
reviewer I have no idea what the justification for each individual stub
was.

Some stubs are unavoidable but they also indicate that the code is
tightly coupled where maybe it can be split up.  The
qdev-properties-system.c example you mentioned sounds like something
that should be broken up into multiple files.  Then stubs wouldn't be
necessary.

That said, adding stubs doesn't place a great burden on anyone and I
think they can be merged.
Jag Raman April 28, 2020, 6:58 p.m. UTC | #4
> On Apr 28, 2020, at 12:29 PM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> 
> On Fri, Apr 24, 2020 at 09:47:56AM -0400, Jag Raman wrote:
>>> On Apr 24, 2020, at 9:12 AM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
>>> On Wed, Apr 22, 2020 at 09:13:43PM -0700, elena.ufimtseva@oracle.com wrote:
>>>> diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
>>>> index f884bb6180..f74c7e927b 100644
>>>> --- a/stubs/Makefile.objs
>>>> +++ b/stubs/Makefile.objs
>>>> @@ -20,6 +20,7 @@ stub-obj-y += migr-blocker.o
>>>> stub-obj-y += change-state-handler.o
>>>> stub-obj-y += monitor.o
>>>> stub-obj-y += monitor-core.o
>>>> +stub-obj-y += get-fd.o
>>>> stub-obj-y += notify-event.o
>>>> stub-obj-y += qtest.o
>>>> stub-obj-y += replay.o
>>> 
>>> audio.c, vl-stub.c, and xen-mapcache.c are added by this patch but not
>>> added to Makefile.objs?  Can they be removed?
>> 
>> Hey Stefan,
>> 
>> Sorry it’s not clear. but these files are referenced in Makefile.target.
> 
> Why is the Makefile.target change not in this patch?
> 
> Please structure patch series as logical changes that can be reviewed
> sequentially.  Not only is it hard for reviewers to understand what is
> going on but it probably also breaks bisectability if patches contain
> incomplete changes.

Hi Stefan,

We grouped all the stubs into a separate patch for ease of review. If you’re finding
it hard to review this way, we’ll modify to ensure that the Makefile changes go along
with the stubs.

--
Jag

> 
>>> 
>>> This entire patch requires justification.  Stubs exist so that common
>>> code can be linked without optional features.
>>> 
>>> For example, common code may call into kvm but that callback isn't
>>> relevant when building with kvm accelerator support (e.g. say qemu-nbd).
>>> That's where the stub function comes in.  It fulfills the dependency
>>> without dragging in the actual kvm accelerator code.
>>> 
>>> Adding lots of stubs suggests you are building QEMU in a new way that
>>> wasn't done before (this is true and expected for this patch series).  I
>>> would like to understand the reason for these stubs though.  For
>>> example, why do you need to stub audio?
>> 
>> These stub functions are only used by the remote process, and not by
>> QEMU itself.
>> 
>> Our goal is to ensure that the remote process is building the smallest
>> set of files necessary and these stub functions are necessary to meet
>> that goal.
>> 
>> For example, the remote process needs to build some of the functions
>> defined in “hw/core/qdev-properties-system.c”. However, this file
>> depends on audio.c (references audio_state_by_name()), which is not
>> needed for the remote process. The alternative to stub functions would
>> be to compile audio.c into the remote process, but that was not necessary
>> in our judgement. When the project started out, we spent a lot of time
>> figuring out which functions/files are necessary for the remote process, and
>> we stubbed out the ones which are needed to resolve dependency during
>> compilation, but not needed for functionality.
>> 
>> audio.c is just an example of tens of other places where we needed to
>> make similar judgements.
>> 
>> Would you prefer if we moved these stub functions into a separate
>> library (instead of stub-obj-y) which is only linked by the remote process?
> 
> It's too bad that none of these judgements were documented.  As a
> reviewer I have no idea what the justification for each individual stub
> was.
> 
> Some stubs are unavoidable but they also indicate that the code is
> tightly coupled where maybe it can be split up.  The
> qdev-properties-system.c example you mentioned sounds like something
> that should be broken up into multiple files.  Then stubs wouldn't be
> necessary.
> 
> That said, adding stubs doesn't place a great burden on anyone and I
> think they can be merged.
Stefan Hajnoczi April 29, 2020, 9:41 a.m. UTC | #5
On Tue, Apr 28, 2020 at 02:58:21PM -0400, Jag Raman wrote:
> > On Apr 28, 2020, at 12:29 PM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> > On Fri, Apr 24, 2020 at 09:47:56AM -0400, Jag Raman wrote:
> >>> On Apr 24, 2020, at 9:12 AM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> >>> On Wed, Apr 22, 2020 at 09:13:43PM -0700, elena.ufimtseva@oracle.com wrote:
> >>>> diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
> >>>> index f884bb6180..f74c7e927b 100644
> >>>> --- a/stubs/Makefile.objs
> >>>> +++ b/stubs/Makefile.objs
> >>>> @@ -20,6 +20,7 @@ stub-obj-y += migr-blocker.o
> >>>> stub-obj-y += change-state-handler.o
> >>>> stub-obj-y += monitor.o
> >>>> stub-obj-y += monitor-core.o
> >>>> +stub-obj-y += get-fd.o
> >>>> stub-obj-y += notify-event.o
> >>>> stub-obj-y += qtest.o
> >>>> stub-obj-y += replay.o
> >>> 
> >>> audio.c, vl-stub.c, and xen-mapcache.c are added by this patch but not
> >>> added to Makefile.objs?  Can they be removed?
> >> 
> >> Hey Stefan,
> >> 
> >> Sorry it’s not clear. but these files are referenced in Makefile.target.
> > 
> > Why is the Makefile.target change not in this patch?
> > 
> > Please structure patch series as logical changes that can be reviewed
> > sequentially.  Not only is it hard for reviewers to understand what is
> > going on but it probably also breaks bisectability if patches contain
> > incomplete changes.
> 
> Hi Stefan,
> 
> We grouped all the stubs into a separate patch for ease of review. If you’re finding
> it hard to review this way, we’ll modify to ensure that the Makefile changes go along
> with the stubs.

Grouping all the stubs into a single patch isn't a problem.

The issue is that some of the new .c files are not referenced by any
makefile rules.  They aren't being compiled and may contain syntax
errors.

There is also no justification for these stubs so reviewers don't know
why exactly they are needed.  I would have liked to know what required
the creation of each stub.  If you don't remember the details anymore
then let's not worry about it, but sometimes there are cleaner ways of
resolving dependencies than adding stubs.

Stefan
diff mbox series

Patch

diff --git a/MAINTAINERS b/MAINTAINERS
index 2e700e6e64..c5fba124e4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -450,6 +450,7 @@  F: hw/pci-host/xen_igd_pt.c
 F: include/hw/block/dataplane/xen*
 F: include/hw/xen/
 F: include/sysemu/xen-mapcache.h
+F: stubs/xen-mapcache.c
 
 Guest CPU Cores (HAXM)
 ---------------------
@@ -1927,6 +1928,7 @@  F: include/hw/audio/
 F: tests/qtest/ac97-test.c
 F: tests/qtest/es1370-test.c
 F: tests/qtest/intel-hda-test.c
+F: stubs/audio.c
 
 Block layer core
 M: Kevin Wolf <kwolf@redhat.com>
@@ -2159,6 +2161,7 @@  F: include/net/
 F: qemu-bridge-helper.c
 T: git https://github.com/jasowang/qemu.git net
 F: qapi/net.json
+F: stubs/net-stub.c
 
 Netmap network backend
 M: Luigi Rizzo <rizzo@iet.unipi.it>
diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c
index 82f118d2df..baa6b38da4 100644
--- a/accel/stubs/kvm-stub.c
+++ b/accel/stubs/kvm-stub.c
@@ -31,6 +31,7 @@  bool kvm_allowed;
 bool kvm_readonly_mem_allowed;
 bool kvm_ioeventfd_any_length_allowed;
 bool kvm_msi_use_devid;
+bool kvm_halt_in_kernel_allowed;
 
 int kvm_destroy_vcpu(CPUState *cpu)
 {
@@ -58,6 +59,10 @@  void kvm_cpu_synchronize_post_init(CPUState *cpu)
 {
 }
 
+void kvm_cpu_synchronize_pre_loadvm(CPUState *cpu)
+{
+}
+
 int kvm_cpu_exec(CPUState *cpu)
 {
     abort();
diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c
index 677191a69c..2e4e8741fb 100644
--- a/accel/stubs/tcg-stub.c
+++ b/accel/stubs/tcg-stub.c
@@ -11,14 +11,112 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qemu-common.h"
 #include "cpu.h"
 #include "tcg/tcg.h"
 #include "exec/exec-all.h"
+#include "translate-all.h"
+#include "exec/ram_addr.h"
+
+bool parallel_cpus;
 
 void tb_flush(CPUState *cpu)
 {
 }
 
+#ifdef CONFIG_MPQEMU
+void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr)
+{
+}
+
+void tb_invalidate_phys_range(ram_addr_t start, ram_addr_t end)
+{
+}
+
+void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end)
+{
+}
+
+void tb_invalidate_phys_page_fast(struct page_collection *pages,
+                                  tb_page_addr_t start, int len,
+                                  uintptr_t retaddr)
+{
+}
+
+void tlb_init(CPUState *cpu)
+{
+}
+
 void tlb_set_dirty(CPUState *cpu, target_ulong vaddr)
 {
 }
+
+void tlb_flush(CPUState *cpu)
+{
+}
+
+void tlb_flush_page(CPUState *cpu, target_ulong addr)
+{
+}
+
+void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length)
+{
+}
+
+void tcg_region_init(void)
+{
+}
+
+void tcg_register_thread(void)
+{
+}
+
+void tcg_flush_softmmu_tlb(CPUState *cs)
+{
+}
+
+void cpu_loop_exit_noexc(CPUState *cpu)
+{
+    cpu->exception_index = -1;
+    cpu_loop_exit(cpu);
+}
+
+void cpu_loop_exit(CPUState *cpu)
+{
+    cpu->can_do_io = 1;
+    siglongjmp(cpu->jmp_env, 1);
+}
+
+void cpu_reloading_memory_map(void)
+{
+}
+
+int cpu_exec(CPUState *cpu)
+{
+    return 0;
+}
+
+void cpu_exec_step_atomic(CPUState *cpu)
+{
+}
+
+bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit)
+{
+    return false;
+}
+
+void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc)
+{
+    cpu_loop_exit(cpu);
+}
+
+struct page_collection *
+page_collection_lock(tb_page_addr_t start, tb_page_addr_t end)
+{
+    return NULL;
+}
+
+void page_collection_unlock(struct page_collection *set)
+{
+}
+#endif
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index f884bb6180..f74c7e927b 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -20,6 +20,7 @@  stub-obj-y += migr-blocker.o
 stub-obj-y += change-state-handler.o
 stub-obj-y += monitor.o
 stub-obj-y += monitor-core.o
+stub-obj-y += get-fd.o
 stub-obj-y += notify-event.o
 stub-obj-y += qtest.o
 stub-obj-y += replay.o
diff --git a/stubs/audio.c b/stubs/audio.c
new file mode 100644
index 0000000000..8ae3b0f568
--- /dev/null
+++ b/stubs/audio.c
@@ -0,0 +1,12 @@ 
+#include "qemu/osdep.h"
+#include "audio/audio.h"
+
+AudioState *audio_state_by_name(const char *name)
+{
+    return NULL;
+}
+
+const char *audio_get_id(QEMUSoundCard *card)
+{
+    return NULL;
+}
diff --git a/stubs/get-fd.c b/stubs/get-fd.c
new file mode 100644
index 0000000000..6800dbe6d4
--- /dev/null
+++ b/stubs/get-fd.c
@@ -0,0 +1,10 @@ 
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "monitor/monitor.h"
+#include "../monitor/monitor-internal.h"
+
+int monitor_get_fd(Monitor *mon, const char *name, Error **errp)
+{
+    error_setg(errp, "only QEMU supports file descriptor passing");
+    return -1;
+}
diff --git a/stubs/monitor.c b/stubs/monitor.c
index 20786ac4ff..4613bc23e0 100644
--- a/stubs/monitor.c
+++ b/stubs/monitor.c
@@ -2,11 +2,27 @@ 
 #include "qapi/error.h"
 #include "monitor/monitor.h"
 #include "../monitor/monitor-internal.h"
+#include "qapi/qapi-types-misc.h"
+#include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-types-qom.h"
+#include "qapi/qapi-commands-qdev.h"
+#include "hw/qdev-core.h"
+#include "sysemu/sysemu.h"
+#include "sysemu/runstate.h"
+#include "monitor/hmp.h"
 
-int monitor_get_fd(Monitor *mon, const char *name, Error **errp)
+#pragma weak hmp_handle_error
+#pragma weak cur_mon
+#pragma weak monitor_vprintf
+#pragma weak monitor_printf
+#pragma weak monitor_cur_is_qmp
+#pragma weak qmp_device_list_properties
+
+__thread Monitor *cur_mon;
+
+int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
 {
-    error_setg(errp, "only QEMU supports file descriptor passing");
-    return -1;
+    abort();
 }
 
 void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp)
@@ -16,3 +32,34 @@  void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp)
 void monitor_fdsets_cleanup(void)
 {
 }
+
+int monitor_get_cpu_index(void)
+{
+    return -ENOSYS;
+}
+int monitor_printf(Monitor *mon, const char *fmt, ...)
+{
+    return -ENOSYS;
+}
+
+bool monitor_cur_is_qmp(void)
+{
+    return false;
+}
+
+ObjectPropertyInfoList *qmp_device_list_properties(const char *typename,
+                                                   Error **errp)
+{
+    return NULL;
+}
+
+VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev,
+                                                     VMChangeStateHandler *cb,
+                                                     void *opaque)
+{
+    return NULL;
+}
+
+void hmp_handle_error(Monitor *mon, Error *err)
+{
+}
diff --git a/stubs/net-stub.c b/stubs/net-stub.c
new file mode 100644
index 0000000000..cb2274ba40
--- /dev/null
+++ b/stubs/net-stub.c
@@ -0,0 +1,31 @@ 
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "net/net.h"
+
+int qemu_find_net_clients_except(const char *id, NetClientState **ncs,
+                                 NetClientDriver type, int max)
+{
+    return -ENOSYS;
+}
+
+NetClientState *net_hub_port_find(int hub_id)
+{
+    return NULL;
+}
+
+int net_hub_id_for_client(NetClientState *nc, int *id)
+{
+    return -ENOSYS;
+}
+
+int qemu_show_nic_models(const char *arg, const char *const *models)
+{
+    return -ENOSYS;
+}
+
+int qemu_find_nic_model(NICInfo *nd, const char * const *models,
+                        const char *default_model)
+{
+    return -ENOSYS;
+}
+
diff --git a/stubs/replay.c b/stubs/replay.c
index 5974ec1f50..2e3feee6a9 100644
--- a/stubs/replay.c
+++ b/stubs/replay.c
@@ -88,3 +88,17 @@  int replay_read_random(void *buf, size_t len)
 {
     return 0;
 }
+
+bool replay_has_checkpoint(void)
+{
+    return false;
+}
+
+int replay_get_instructions(void)
+{
+    return 0;
+}
+
+void replay_account_executed_instructions(void)
+{
+}
diff --git a/stubs/vl-stub.c b/stubs/vl-stub.c
new file mode 100644
index 0000000000..fff72be201
--- /dev/null
+++ b/stubs/vl-stub.c
@@ -0,0 +1,79 @@ 
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "qemu/uuid.h"
+#include "sysemu/sysemu.h"
+#include "exec/cpu-common.h"
+#include "exec/gdbstub.h"
+#include "sysemu/replay.h"
+#include "disas/disas.h"
+#include "sysemu/runstate.h"
+
+bool tcg_allowed;
+bool xen_allowed;
+bool boot_strict;
+bool qemu_uuid_set;
+
+int mem_prealloc;
+int smp_cpus;
+int vga_interface_type = VGA_NONE;
+int smp_cores = 1;
+int smp_threads = 1;
+int icount_align_option;
+int boot_menu;
+
+unsigned int max_cpus;
+const uint32_t arch_type;
+const char *mem_path;
+uint8_t qemu_extra_params_fw[2];
+uint8_t *boot_splash_filedata;
+size_t boot_splash_filedata_size;
+struct syminfo *syminfos;
+
+ram_addr_t ram_size;
+MachineState *current_machine;
+QemuUUID qemu_uuid;
+
+int runstate_is_running(void)
+{
+    return 0;
+}
+
+void runstate_set(RunState new_state)
+{
+}
+
+void vm_state_notify(int running, RunState state)
+{
+}
+
+bool qemu_vmstop_requested(RunState *r)
+{
+    return false;
+}
+
+void qemu_system_debug_request(void)
+{
+}
+
+char *qemu_find_file(int type, const char *name)
+{
+    return NULL;
+}
+
+void gdb_set_stop_cpu(CPUState *cpu)
+{
+}
+
+void replay_enable_events(void)
+{
+}
+
+void replay_disable_events(void)
+{
+}
+
+#ifdef TARGET_I386
+void x86_cpu_list(void)
+{
+}
+#endif
diff --git a/stubs/vmstate.c b/stubs/vmstate.c
index cc4fe41dfc..c7c015ac58 100644
--- a/stubs/vmstate.c
+++ b/stubs/vmstate.c
@@ -1,7 +1,9 @@ 
 #include "qemu/osdep.h"
 #include "migration/vmstate.h"
+#include "migration/misc.h"
 
 const VMStateDescription vmstate_dummy = {};
+const VMStateInfo vmstate_info_timer;
 
 int vmstate_register_with_alias_id(VMStateIf *obj,
                                    uint32_t instance_id,
@@ -23,3 +25,20 @@  bool vmstate_check_only_migratable(const VMStateDescription *vmsd)
 {
     return true;
 }
+
+void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev)
+{
+}
+
+void vmstate_unregister_ram(MemoryRegion *mr, DeviceState *dev)
+{
+}
+
+void vmstate_register_ram_global(MemoryRegion *mr)
+{
+}
+
+bool migration_is_idle(void)
+{
+    return true;
+}
diff --git a/stubs/xen-mapcache.c b/stubs/xen-mapcache.c
new file mode 100644
index 0000000000..af5c031727
--- /dev/null
+++ b/stubs/xen-mapcache.c
@@ -0,0 +1,22 @@ 
+#include "qemu/osdep.h"
+#include "exec/hwaddr.h"
+#include "exec/cpu-common.h"
+#include "sysemu/xen-mapcache.h"
+
+#ifdef CONFIG_XEN
+
+void xen_invalidate_map_cache_entry(uint8_t *buffer)
+{
+}
+
+uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size, uint8_t lock, bool dma)
+{
+    return NULL;
+}
+
+ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
+{
+    return 0;
+}
+
+#endif